コード例 #1
0
        /// <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]);
        }
コード例 #2
0
ファイル: lsl.parser.cs プロジェクト: WordfromtheWise/Aurora
		public  GlobalVariableDeclaration (Parser yyp, Assignment  a ):base(((LSLSyntax
		                                                                     )yyp)){ kids . Add ( a );
		}
コード例 #3
0
ファイル: lsl.parser.cs プロジェクト: WordfromtheWise/Aurora
		public  Statement (Parser yyp, Assignment  a ):base(((LSLSyntax
		                                                     )yyp)){ kids . Add ( a );
		}
コード例 #4
0
        /// <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 = "";
            List<string> identifiers = new List<string>();

            bool marc = FuncCallsMarc();
            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 DumpFunc(marc) + retstr.ToString();
        }
コード例 #5
0
ファイル: CSCodeGenerator.cs プロジェクト: Gnu32/Silverfin
        /// <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 = "";
            List<string> identifiers = new List<string>();

            bool marc = FuncCallsMarc();
            checkForMultipleAssignments(identifiers, a);
            if (a.kids[a.kids.Count - 1] is ListConstant && isAdditionExpression) //Deal with the list memory hack
            {
                a.kids.Pop(); //Get rid of the first one
                foreach (SYMBOL kid in a.kids)
                    retstr += GenerateNode(kid);
                return retstr; //If it is a list, and we are in an addition expression, we drop the assignment
            }

            retstr += GenerateNode((SYMBOL) a.kids.Pop());
            retstr += Generate(String.Format(" {0} ", a.AssignmentType), a);
            foreach (SYMBOL kid in a.kids)
                retstr += GenerateNode(kid);
            //fCalls += ";";//Add a ; at the end.
            //lock (AfterFuncCalls)
            //    AfterFuncCalls.Add (fCalls);

            return DumpFunc(marc) + retstr + DumpAfterFunc(marc);
        }
コード例 #6
0
        /// <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)
        {
            StringBuilder retstr = new StringBuilder();

            List<string> identifiers = new List<string>();
            checkForMultipleAssignments(identifiers, a);

            retstr.Append(GenerateNode((SYMBOL) a.kids.Pop()));
            retstr.Append(Generate(String.Format(" {0} ", a.AssignmentType), a));
            foreach (SYMBOL kid in a.kids)
                retstr.Append(GenerateNode(kid));

            return retstr.ToString();
        }