示例#1
0
 public virtual void Visit(MainClassDeclNode node)
 {
     ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.classIdentifier.name);
     MethodBeingVisited = ClassBeingVisited.Methods.Lookup("main");
     node.classIdentifier.Accept(this);
     node.mainParameterIdentifier.Accept(this);
     node.statement.Accept(this);
 }
示例#2
0
 public virtual void Visit(ClassDeclNode node)
 {
     ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.className.name);
     if (node.extendsClass != null)
         node.extendsClass.Accept(this);
     if (node.variableDeclList != null)
         for (int x = 0; x < node.variableDeclList.variableDeclList.Count; x++)
             node.variableDeclList.VariableDeclAtIndex(x).Accept(this);
     if (node.methodDeclList != null)
         for (int x = 0; x < node.methodDeclList.methodDeclList.Count; x++)
             node.methodDeclList.MethodDeclAtIndex(x).Accept(this);
 }
示例#3
0
 public MethodDefinition LookupMethodInClass(string methodName, ClassDefinition classDefinition)
 {
     ClassDefinition currentClass = classDefinition;
     while (true)
     {
         if (currentClass.Methods.Contains(methodName))
             return currentClass.Methods.Lookup(methodName);
         if (currentClass.ClassType.BaseClassType == null)
         {
             //currentClass.Methods.Add(methodName).ReturnType = InvalidType.Instance;
             throw new Exception("Undeclared identifier: " + methodName);
         }
         currentClass = Classes.Lookup(currentClass.ClassType.BaseClassType.Name);
     }
 }
示例#4
0
 public FieldDefinition LookupFieldInClass(string fieldName, ClassDefinition classDefinition)
 {
     ClassDefinition currentClass = classDefinition;
     while (true)
     {
         if (currentClass.Fields.Contains(fieldName))
             return currentClass.Fields.Lookup(fieldName);
         if (currentClass.ClassType.BaseClassType == null)
         {
             currentClass.Fields.Add(fieldName).FieldType = InvalidType.Instance;
             throw new Exception("Undeclared identifier: " + fieldName);
         }
         currentClass = Classes.Lookup(currentClass.ClassType.BaseClassType.Name);
     }
 }