/// <summary> /// Generates the code for a Declaration node. /// </summary> /// <param name="d">The Declaration node.</param> /// <returns>String containing C# code for Declaration d.</returns> private string GenerateDeclaration(Declaration d) { // return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); GlobalVar var; if (IsaGlobalVar) return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); if (GlobalVariables.TryGetValue(d.Id, out var)) return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); //Commented out because we can't handle the same var name in different if/else statements /*if (MethodVariables.TryGetValue(d.Id, out var)) { if (var.Type != d.Datatype) { Console.WriteLine("[CSCodeGenerator]: found var needing renamed!"); string NewVariableName = RandomString(10, true); VarRename r = new VarRename(); r.OldVarName = d.Id; r.HasBeenAssigned = false; r.NewVarName = NewVariableName; VariablesToRename.Add(d.Id, r); d.Id = NewVariableName; MethodVariables.Add(d.Id, new GlobalVar() { Type = d.Datatype, Value = "" }); return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); } else return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); } else { MethodVariables[d.Id] = new GlobalVar() { Type = d.Datatype, Value = "" }; return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); } * */ return Generate(String.Format("{0} {1}", d.Datatype, CheckName(d.Id)), d); }
public Statement(Parser yyp, Declaration d) : base((yyp)) { kids.Add(d); }
public ArgumentDeclarationList(Parser yyp, Declaration d) : base((yyp)) { kids.Add(d); }
public ArgumentDeclarationList(Parser yyp, ArgumentDeclarationList adl, Declaration d) : base((yyp)) { while (0 < adl.kids.Count) kids.Add(adl.kids.Pop()); kids.Add(d); }
public GlobalVariableDeclaration(Parser yyp, Declaration d) : base((yyp)) { kids.Add(d); }