Пример #1
0
        public override void EnterArray_structVarDeclaration(NewDecafParser.Array_structVarDeclarationContext context)
        {
            FieldDeclaration FD = new FieldDeclaration();
            VarType currentTypeName = getNodeCommand(context.varType()) as VarType;
            FD.TypeName = currentTypeName;
            FD.FieldId = context.Id().GetText();
            FD.IsArray = true;

            (getNodeCommand(context.Parent) as StructDeclaration).addCommand(FD);

            setNodeCommand(context, FD);
        }
Пример #2
0
        public override void ExitArray_varDeclaration(NewDecafParser.Array_varDeclarationContext context)
        {
            FieldDeclaration FD = new FieldDeclaration();
            VarType currentTypeName = getNodeCommand(context.varType()) as VarType;

            FD.TypeName = currentTypeName;
            FD.FieldId = context.Id().GetText();
            FD.IsArray = true;

            mainClass.addCommand(FD);

            ArrayDeclaration AD = new ArrayDeclaration
            {
                Type = currentTypeName.getGenCode(),
                Name = FD.FieldId,
                ArraySize = Convert.ToInt32(context.Num().GetText())
            };

            mainClass.addCommand(AD);
        }
Пример #3
0
        public override void ExitSingle_varDeclaration(NewDecafParser.Single_varDeclarationContext context)
        {
            FieldDeclaration FD = new FieldDeclaration();
            VarType currentTypeName = getNodeCommand(context.varType()) as VarType;
            FD.TypeName = currentTypeName;
            FD.FieldId = context.Id().GetText();
            FD.IsArray = false;

            mainClass.addCommand(FD);

            setNodeCommand(context, FD);
        }
Пример #4
0
 public void addCommand(FieldDeclaration theCommand)
 {
     fieldDeclList.Add(theCommand);
 }