예제 #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);
 }