상속: Tools.SYMBOL
        /// <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);
        }
예제 #2
0
 public Statement(Parser yyp, Declaration d) : base((yyp))
 {
     kids.Add(d);
 }
예제 #3
0
 public ArgumentDeclarationList(Parser yyp, Declaration d) : base((yyp))
 {
     kids.Add(d);
 }
예제 #4
0
 public ArgumentDeclarationList(Parser yyp, ArgumentDeclarationList adl, Declaration d) : base((yyp))
 {
     while (0 < adl.kids.Count) kids.Add(adl.kids.Pop());
     kids.Add(d);
 }
예제 #5
0
 public GlobalVariableDeclaration(Parser yyp, Declaration d) : base((yyp))
 {
     kids.Add(d);
 }