예제 #1
0
 private void checkVariable(Tree.Term term, Node node) {
   if (isEffectivelyBaseMemberExpression(term)) { // Note: other cases handled in ExpressionVisitor
     Tree.StaticMemberOrTypeExpression mte = (Tree.StaticMemberOrTypeExpression) term;
     Declaration member = mte.getDeclaration();
     if (member == declaration) {
       if ((declaration.isFormal() || declaration.isDefault()) && !isForwardReferenceable()) {
         term.addError(
             "member is formal or default and may not be assigned here: '"
                 + member.getName()
                 + "'");
       } else if (!isVariable() && !isLate()) {
         if (member instanceof Value) {
           if (node instanceof Tree.AssignOp) {
             term.addError(
                 "value is not a variable and may not be assigned here: '"
                     + member.getName()
                     + "'",
                 803);
           } else {
             term.addError("value is not a variable: '" + member.getName() + "'", 800);
           }
         } else {
           term.addError("not a variable value: '" + member.getName() + "'");
         }
       }
     }
   }
 }
 private CollectionLiteralAnnotationTerm startCollection(Tree.Term t) {
   Unit unit = t.getUnit();
   // Continue the visit to collect the elements
   ProducedType iteratedType = unit.getIteratedType(parameter().getType());
   TypeDeclaration declaration = iteratedType.getDeclaration();
   LiteralAnnotationTerm factory;
   if (unit.getStringDeclaration().equals(declaration)) {
     factory = StringLiteralAnnotationTerm.FACTORY;
   } else if (unit.getIntegerDeclaration().equals(declaration)) {
     factory = IntegerLiteralAnnotationTerm.FACTORY;
   } else if (unit.getCharacterDeclaration().equals(declaration)) {
     factory = CharacterLiteralAnnotationTerm.FACTORY;
   } else if (unit.getBooleanDeclaration().equals(declaration)) {
     factory = BooleanLiteralAnnotationTerm.FACTORY;
   } else if (unit.getFloatDeclaration().equals(declaration)) {
     factory = FloatLiteralAnnotationTerm.FACTORY;
   } else if (Decl.isEnumeratedTypeWithAnonCases(iteratedType)) {
     factory = ObjectLiteralAnnotationTerm.FACTORY;
   } else if (Decl.isAnnotationClass(declaration)) {
     t.addError(
         "compiler bug: iterables of annotation classes or annotation constructors not supported as literal "
             + (checkingDefaults ? "defaulted parameters" : "arguments"));
     return null;
   } else if (iteratedType.isSubtypeOf(
       ((TypeDeclaration) unit.getLanguageModuleDeclarationDeclaration("Declaration"))
           .getType())) {
     factory = DeclarationLiteralAnnotationTerm.FACTORY;
   } else {
     throw new RuntimeException();
   }
   CollectionLiteralAnnotationTerm result = this.elements;
   this.elements = new CollectionLiteralAnnotationTerm(factory);
   return result;
 }
 @Override
 public void visit(Tree.Term term) {
   if (annotationConstructor != null && !checkingDefaults) {
     term.addError("compiler bug: unsupported term " + term.getClass().getSimpleName());
   }
 }