Beispiel #1
0
        public void SetBaseClass(TypeRef tr)
        {
            baseclass = tr;

            // If we know we have a base class, we add a call to the base auto-constructor
            // in our own auto-constructor
            Expression func = new ChooseField(new Name("base"), "_Constructor_");
            FunCall    fc   = new FunCall(func, new ExpressionList());

            autoCtor.body.statements.Add(new ExpressionStatement(fc));
        }
Beispiel #2
0
        public static Expression CreatePostfixExpr(ParseNode x, ref int i)
        {
            int        old = i;
            Expression r   = CreatePrimaryExpr(x, ref i);

            Assure(x, r != null, "unable to create primary expression");

            while (i < x.GetNumChildren())
            {
                old = i;
                ParseNode tmp = x.GetChild(i);

                if (tmp.Label == "bracketedexpr")
                {
                    i++;
                    Assure(x, tmp.GetNumChildren() == 1, "brackets must contain only a single sub-expression");
                    r = new ReadAt(r, CreateExpr(tmp.GetChild(0)));
                }
                else if (tmp.Label == "paranexpr")
                {
                    i++;
                    r = new FunCall(r, CreateCompoundExpr(tmp));
                }
                else if (tmp.ToString() == ".")
                {
                    i++;
                    Assure(x, x.GetNumChildren() > i, "a '.' operator must be followed by a valid name expression");
                    tmp = x.GetChild(i);
                    Assure(x, tmp.Label == "name", "a '.' operator must be followed by a valid name expression");
                    string sName = tmp.ToString();
                    Assure(x, sName.Length > 0, "Name expression must have non-zero length");
                    i++;
                    r = new ChooseField(r, sName);
                }
                else if (tmp.ToString() == "++")
                {
                    // You can't have anything to the left of ++
                    i++;
                    return(new PostIncExpr(r));
                }
                else
                {
                    return(r);
                }
                Assure(x, i > 0, "internal error, failed to advance sub-expression index");
            }

            return(r);
        }