public override void Visit(ClassDeclNode node)
        {
            ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.className.name);

            if (node.extendsClass != null)
                node.extendsClass.Accept(this);
        }
        public override void Visit(ClassDeclNode node)
        {
            ClassType classType = new ClassType(node.className.name);
            ClassBeingVisited = Analysis.Environment.Classes.Add(node.className.name);
            ClassBeingVisited.ClassType = classType;

            if(node.extendsClass != null)
                node.extendsClass.Accept(this);
        }
Beispiel #3
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);
 }
        public override void Visit(ClassDeclNode node)
        {
            ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.className.name);

            if (node.variableDeclList != null)
                for (int x = 0; x < node.variableDeclList.variableDeclList.Count; x++)
                {
                    FieldDefinition fieldDefinition = ClassBeingVisited.Fields.Add(node.variableDeclList.VariableDeclAtIndex(x).identifier.name);
                    fieldDefinition.FieldType = node.variableDeclList.VariableDeclAtIndex(x).type.Type;
                    if (fieldDefinition.FieldType.GetType() == typeof(ClassType))
                        Analysis.Environment.Classes.Lookup(fieldDefinition.FieldType.Name);
                }
            if (node.methodDeclList != null)
                for (int x = 0; x < node.methodDeclList.methodDeclList.Count; x++)
                    node.methodDeclList.MethodDeclAtIndex(x).Accept(this);
        }
        public override void Visit(ClassDeclNode node)
        {
            ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.className.name);
            ClassBeingVisited.SizeInBytes = SizeOf(ClassBeingVisited);
            int Offset = 4;
            if(ClassBeingVisited.ClassType.BaseClassType != null)
                Offset += SizeOf(Analysis.Environment.Classes.Lookup(ClassBeingVisited.ClassType.BaseClassType.Name));
            for (int x = 0; x < ClassBeingVisited.Fields.Count; x++)
            {
                FieldDefinition field = ClassBeingVisited.Fields.ItemAt(x);
                field.SizeInBytes = 4;
                Offset += field.SizeInBytes;
                field.Location = Offset;
            }

            if (node.methodDeclList != null)
                for (int x = 0; x < node.methodDeclList.methodDeclList.Count; x++)
                    node.methodDeclList.MethodDeclAtIndex(x).Accept(this);
        }
        public override void Visit(ClassDeclNode node)
        {
            ClassBeingVisited = Analysis.Environment.Classes.Lookup(node.className.name);
            if (node.extendsClass != null)
                GenText(node.className.name + "$$ dd " + node.extendsClass.className.name + "$$");
            else
                GenText(node.className.name + "$$ dd 0");

            Dictionary<string, string> VTable = GenerateVTable(ClassBeingVisited);
            Dictionary<string, string>.Enumerator enumerator = VTable.GetEnumerator();
            int MethodOffset = 4;
            while (enumerator.MoveNext())
            {
                GenText("\tdd " + enumerator.Current.Value + "$" + enumerator.Current.Key);
                if (ClassBeingVisited.Methods.Contains(enumerator.Current.Key))
                    ClassBeingVisited.Methods.Lookup(enumerator.Current.Key).Location = MethodOffset;
                MethodOffset += 4;
            }
        }
Beispiel #7
0
 public void AddClassDecl(ClassDeclNode classDecl)
 {
     this.classDeclList.Add(classDecl);
 }
Beispiel #8
0
 public void AddClassDecl(ClassDeclNode classDecl)
 {
     this.classDeclList.Add(classDecl);
 }
 public override void Visit(ClassDeclNode node)
 {
     Console.WriteLine(this.indentation + "Class <Identifier: " + node.className.name + ">           ---- Class Declaration ----");
     indentation = indentation + "   ";
     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);
         }
     }
     indentation = indentation.Substring(0, indentation.Length - 3);
 }