Exemple #1
0
		internal ForIn (AST parent, AST lhs, AST obj, AST body, Location location)
			: base (parent, location)
		{
			this.lhs = lhs;
			this.obj = obj;
			this.body = body;
		}
Exemple #2
0
		internal If (AST parent, AST condition, AST true_stm, AST false_stm, Location location)
			: base (parent, location)
		{
			this.cond = condition;
			this.true_stm = true_stm;
			this.false_stm = false_stm;
		}
 internal PostOrPrefixOperator(AST parent, AST operand, JSToken oper, bool prefix, Location location)
     : base(parent, location)
 {
     this.operand = operand;
     this.oper = oper;
     this.prefix = prefix;
 }
Exemple #4
0
		internal Try (AST guarded_block, ArrayList catch_block, AST finally_block, AST parent, Location location)
			: base (parent, location)
		{
			this.guarded_block = guarded_block;
			this.catch_blocks = catch_block;
			this.finally_block = finally_block;
		}		
Exemple #5
0
		internal FunctionExpression (AST parent, string name, 
					     FormalParameterList p,
					     string return_type, Block body, Location location)
			: base (parent, location)
		{
			func_obj = new FunctionObject (name, p, return_type, body, location);
		}
Exemple #6
0
		internal BinaryOp (AST parent, AST left, AST right, JSToken op, Location location)
			: base (parent, location)
		{
			operand1 = left;
			operand2 = right;
			operatorTok = op;
		}
Exemple #7
0
		internal VariableDeclaration (AST parent, string id, string t, AST init, Location location)
			: base (parent, location)
		{
			this.id = id;

			if (t == null)
				this.type = typeof (System.Object);
			else {
				this.type_annot = t;
				// FIXME: resolve the type annotations
				this.type = typeof (System.Object);
			}
			this.val = init;
		}
        internal FunctionObject(string name, FormalParameterList p, string ret_type, Block body, Location location)
        {
            this._prototype = ObjectConstructor.Ctr.ConstructObject ();
            //
            // FIXME
            // 1) Must collect the attributes given.
            // 2) Check if they are semantically correct.
            // 3) Assign those values to 'attr'.
            //
            this.attr = MethodAttributes.Public | MethodAttributes.Static;

            this.name = name;
            this.parameters = p;

            this.type_annot = ret_type;
            //
            // FIXME: Must check that return_type it's a valid type,
            // and assign that to 'return_type' field.
            //
            this.return_type = typeof (void);

            this.body = body;
            this.location = location;
        }
Exemple #9
0
 internal ObjectLiteral(ArrayList elems, Location location)
     : base(null, location)
 {
     this.elems = elems;
 }
Exemple #10
0
 internal LongConstant(AST parent, long v, Location location)
     : base(parent, location)
 {
     Value = v;
 }
Exemple #11
0
 internal NumericConstant(AST parent, Location location)
     : base(parent, location)
 {
 }
Exemple #12
0
 internal FloatConstant(AST parent, float v, Location location)
     : base(parent, location)
 {
     Value = v;
 }
Exemple #13
0
 internal IntConstant(AST parent, int v, Location location)
     : base(parent, location)
 {
     Value = v;
 }
Exemple #14
0
		internal void Init (AST parent, string name, AST stm, Location location)
		{
			this.parent = parent;
			this.name = name;
			this.stm = stm;
			this.location = location;
		}
Exemple #15
0
 internal DoubleConstant(AST parent, double v, Location location)
     : base(parent, location)
 {
     Value = v;
 }
Exemple #16
0
 internal RegExpLiteral(AST parent, string re, string flags, Location location)
     : base(parent, location)
 {
     this.re = re;
     this.flags = flags;
 }
Exemple #17
0
 internal ShortConstant(AST parent, short v, Location location)
     : base(parent, location)
 {
     Value = v;
 }
Exemple #18
0
        AST PrimaryExpr(AST parent)
        {
            int tt;
            AST pn;

            ts.allow_reg_exp = true;
            tt = ts.GetToken ();
            ts.allow_reg_exp = false;

            if (tt == Token.FUNCTION) {
                return Function (parent, FunctionType.Expression);
            } else if (tt == Token.LB) {
                ASTList elems = new ASTList (parent, new Location (ts.SourceName, ts.LineNumber));
                int skip_count = 0;
                decompiler.AddToken (Token.LB);
                bool after_lb_or_comma = true;
                for (;;) {
                    ts.allow_reg_exp = true;
                    tt = ts.PeekToken ();
                    ts.allow_reg_exp = false;

                    if (tt == Token.COMMA) {
                        ts.GetToken ();
                        decompiler.AddToken (Token.COMMA);
                        if (!after_lb_or_comma)
                            after_lb_or_comma = true;
                        else {
                            elems.Add (null);
                            ++skip_count;
                        }
                    } else if (tt == Token.RB) {
                        ts.GetToken ();
                        decompiler.AddToken (Token.RB);
                        break;
                    } else {
                        if (!after_lb_or_comma)
                            ReportError ("msg.no.bracket.arg");
                        elems.Add (AssignExpr (parent, false));
                        after_lb_or_comma = false;
                    }
                }
                // FIXME: pass a real Context
                return new ArrayLiteral (null, elems, skip_count, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.LC) {
                Location location = new Location (ts.SourceName, ts.LineNumber);
                ArrayList elems = new ArrayList ();
                decompiler.AddToken (Token.LC);

                if (!ts.MatchToken (Token.RC)) {
                    bool first = true;

                    commaloop: {
                    do {
                        ObjectLiteralItem property;

                        if (!first)
                            decompiler.AddToken (Token.COMMA);
                        else
                            first = false;

                        tt = ts.GetToken ();

                        if (tt == Token.NAME || tt == Token.STRING) {
                            string s = ts.GetString;
                            if (tt == Token.NAME)
                                decompiler.AddName (s);
                            else
                                decompiler.AddString (s);
                            property = new ObjectLiteralItem (s);
                        } else if (tt == Token.NUMBER) {
                            double n = ts.GetNumber;
                            decompiler.AddNumber (n);
                            property = new ObjectLiteralItem (n);
                        } else if (tt == Token.RC) {
                            // trailing comma is OK
                            ts.UnGetToken (tt);
                            goto leave_commaloop;
                        } else {
                            ReportError ("msg.bad.prop");
                            goto leave_commaloop;
                        }
                        MustMatchToken (Token.COLON, "msg.no.colon.prop");
                        // OBJLIT is used as ':' in object literal for
                        // decompilation to solve spacing ambiguity.
                        decompiler.AddToken (Token.OBJECTLIT);
                        property.exp = AssignExpr (parent, false);
                        elems.Add (property);
                    } while (ts.MatchToken (Token.COMMA));
                    MustMatchToken (Token.RC, "msg.no.brace.prop");
                    }
                    leave_commaloop:
                    ;
                }
                return new ObjectLiteral (elems, location);
            } else if (tt == Token.LP) {
                decompiler.AddToken (Token.LP);
                pn = Expr (parent, false);
                decompiler.AddToken (Token.RP);
                MustMatchToken (Token.RP, "msg.no.paren");
                decompiler.AddToken (Token.RP);
                return pn;
            } else if (tt == Token.NAME) {
                string name = ts.GetString;
                decompiler.AddName (name);
                return new Identifier (parent, name, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.NUMBER) {
                double n = ts.GetNumber;
                decompiler.AddNumber (n);

                Location location = new Location (ts.SourceName, ts.LineNumber);

                if (HasNoDecimals (n)) {
                    if (InRangeOf (n, Byte.MinValue, Byte.MaxValue))
                        return new ByteConstant (parent, (byte) n, location);
                    else if (InRangeOf (n, Int16.MinValue, Int16.MaxValue))
                        return new ShortConstant (parent, (short) n, location);
                    else if (InRangeOf (n, Int32.MinValue, Int32.MaxValue))
                        return new IntConstant (parent, (int) n, location);
                    else if (InRangeOf (n, Int64.MinValue, Int64.MaxValue))
                        return new LongConstant (parent, (long) n, location);
                    else
                        return new DoubleConstant (parent, n, location);
                } else {
                    if (InRangeOf (n, Single.MinValue, Single.MaxValue))
                        return new FloatConstant (parent, (float) n, location);
                    else if (InRangeOf (n, Double.MinValue, Double.MaxValue))
                        return new DoubleConstant (parent, n, location);
                    else
                        return new DoubleConstant (parent, n, location);
                }
            } else if (tt == Token.STRING) {
                string s = ts.GetString;
                decompiler.AddString (s);
                return new StringLiteral (null, s, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.REGEXP) {
                string flags = ts.reg_exp_flags;
                ts.reg_exp_flags = null;
                string re = ts.GetString;
                decompiler.AddRegexp (re, flags);
                return new RegExpLiteral (parent, re, flags, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.NULL) {
                decompiler.AddToken (tt);
                // FIXME, build the null object;
                return null;
            } else if (tt ==  Token.THIS) {
                decompiler.AddToken (tt);
                return new This (parent, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.FALSE || tt == Token.TRUE) {
                decompiler.AddToken (tt);
                bool v;
                if (tt == Token.FALSE)
                    v = false;
                else
                    v = true;
                return new BooleanConstant (null, v, new Location (ts.SourceName, ts.LineNumber));
            } else if (tt == Token.RESERVED) {
                ReportError ("msg.reserved.id");
            } else if (tt == Token.ERROR) {
                /* the scanner or one of its subroutines reported the error. */
            } else
                ReportError ("msg.syntax");
            return null; // should never reach here
        }
Exemple #19
0
        Function CreateFunction(AST parent, FunctionType func_type, string name)
        {
            Function func;
            Location location = new Location (ts.SourceName, ts.LineNumber);

            if (func_type == FunctionType.Statement)
                func = new FunctionDeclaration (parent, name, location);
            else if (func_type == FunctionType.Expression)
                func = new FunctionExpression (parent, name, location);
            else if (func_type == FunctionType.ExpressionStatement)
                throw new NotImplementedException ();
            else
                throw new Exception ("Unknown FunctionType");
            return func;
        }
Exemple #20
0
		internal AST (AST parent, Location location)
		{
			this.parent = parent;
			this.location = location;
		}
Exemple #21
0
		internal Function (AST parent, Location location)
			: base (parent, location)
		{
		}
Exemple #22
0
		internal StrictEquality (AST parent, AST left, AST right, JSToken op, Location location)
			: base (parent, left, right, op, location)
		{
		}
Exemple #23
0
 internal BooleanConstant(AST parent, bool val, Location location)
     : base(parent, location)
 {
     this.Value = val;
 }
Exemple #24
0
		internal VariableStatement (AST parent, Location location)
			: base (parent, location)
		{
			var_decls = new ArrayList ();
		}
Exemple #25
0
 internal This(AST parent, Location location)
     : base(parent, location)
 {
 }
Exemple #26
0
		internal Labelled (AST parent, Location location)
			: base (parent, location)
		{
		}
 internal FunctionDeclaration(AST parent, string name, Location location)
     : this(parent, name, null, String.Empty, null, location)
 {
 }
Exemple #28
0
 internal Block(AST parent, Location location)
     : base(parent, location)
 {
     elems = new ArrayList ();
 }
Exemple #29
0
 internal With(AST parent, AST exp, AST stm, Location location)
     : base(parent, location)
 {
     this.exp = exp;
     this.stm = stm;
 }
Exemple #30
0
 internal ByteConstant(AST parent, byte v, Location location)
     : base(parent, location)
 {
     Value = v;
 }