/// <summary> /// Replaces an instance of the node at s.kids[didx] with an assignment /// node. The assignment node has the Declaration node on the left hand /// side and a default initializer on the right hand side /// </summary> /// <param name="s"> /// The node containing the Declaration node that needs replacing /// </param> /// <param name="didx">Index of the Declaration node to replace</param> private void AddImplicitInitialization(SYMBOL s, int didx) { // We take the kids for a while to play with them int sKidSize = s.kids.Count; object[] sKids = new object[sKidSize]; for (int i = 0; i < sKidSize; i++) sKids[i] = s.kids.Pop(); // The child to be changed Declaration currentDeclaration = (Declaration)sKids[didx]; // We need an assignment node Assignment newAssignment = new Assignment(currentDeclaration.yyps, currentDeclaration, GetZeroConstant(currentDeclaration.yyps, currentDeclaration.Datatype), "="); sKids[didx] = newAssignment; // Put the kids back where they belong for (int i = 0; i < sKidSize; i++) s.kids.Add(sKids[i]); }
public GlobalVariableDeclaration(Parser yyp, Assignment a) : base(((LSLSyntax )yyp)) { kids.Add(a); }
public Statement(Parser yyp, Assignment a) : base(((LSLSyntax )yyp)) { kids.Add(a); }
/// <summary> /// Generates the code for an Assignment node. /// </summary> /// <param name="a">The Assignment node.</param> /// <returns>String containing C# code for Assignment a.</returns> private string GenerateAssignment(Assignment a) { string retstr = String.Empty; List<string> identifiers = new List<string>(); checkForMultipleAssignments(identifiers, a); retstr += GenerateNode((SYMBOL)a.kids.Pop()); retstr += Generate(String.Format(" {0} ", a.AssignmentType), a); foreach (SYMBOL kid in a.kids) retstr += GenerateNode(kid); return retstr; }