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); }
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); }
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); }
public void addCommand(FieldDeclaration theCommand) { fieldDeclList.Add(theCommand); }