Example #1
0
 /**
  * Die Methode führt die Kontextanalyse für diesen Ausdruck durch. Diese Methode wird auch für
  * Ausdrücke aufgerufen, die rechts vom Objekt-Zugriffsoperator stehen.
  *
  * @param declarations Die an dieser Stelle gültigen Deklarationen.
  * @param caller Die Klasse des Anfragenden.
  * @throws CompileException Während der Kontextanylyse wurde ein Fehler gefunden.
  */
 void contextAnalysisForMember(Declarations declarations, ClassDeclaration caller)
     throws CompileException {
   declarations.resolveVarOrMethod(identifier, caller);
   /** END Bonus Aufgabe 5 */
   if (identifier.declaration instanceof VarDeclaration) {
     type = (ClassDeclaration) ((VarDeclaration) identifier.declaration).type.declaration;
     lValue = true;
     /** BEGIN Aufgabe (i): Vererbung */
     // SELF und BASE sind R-Werte
     if (identifier.name.equals("_self") || identifier.name.equals("_base")) {
       lValue = false;
     }
     /** END Aufgabe (i) */
   } else if (identifier.declaration instanceof MethodDeclaration) {
     // type = ClassDeclaration.voidType;
     /** BEGIN Aufgabe (g): return */
     type = (ClassDeclaration) ((MethodDeclaration) identifier.declaration).returnType.declaration;
     /** END Aufgabe (g) */
   } else {
     assert false;
   }
 }
 public void visitDeclarations(Declarations declarations) {
   visitDeclaration(declarations);
   visit(declarations.getDeclarations());
 }
Example #3
0
 /**
  * Die Methode führt die Kontextanalyse für diesen Ausdruck durch.
  *
  * @param declarations Die an dieser Stelle gültigen Deklarationen.
  * @return Dieser Ausdruck.
  * @throws CompileException Während der Kontextanylyse wurde ein Fehler gefunden.
  */
 Expression contextAnalysis(Declarations declarations) throws CompileException {
   declarations.resolveType(newType);
   type = (ClassDeclaration) newType.declaration;
   return this;
 }