Exemplo n.º 1
1
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // thisblock.localsN.SetDynamic("vid", value);
            context.ldarg(0);
            context.ldfld(block.frameFields[depth - 1]);
            context.ldstr(Name);
            value.GenSimple(context);
            context.call(Runtime.Frame.SetDynamic);

            value.GenSimple(context);

            context.ReleaseLocal(value, created);
        }
Exemplo n.º 2
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // Gen right hand sides
            ListGen mrhs;
            if (rhs is ListGen && !(rhs is MultipleRHS))
                mrhs = (ListGen)rhs;
            else
                mrhs = new ARGS(null, null, rhs, null, location, true);

            bool created;
            ISimple list = mrhs.GenArgList(context, out created);
            list.GenSimple(context);
            context.callvirt(Runtime.ArgList.CheckSingleRHS);
            int array = context.StoreInTemp("mrhs", Runtime.ArgListRef, location);

            context.ReleaseLocal(list, created);

            // Gen assignments to left hand sides
            for (LVALUE l = elements; l != null; l = (LVALUE)l.nd_next)
            {
                l.Assign(context, new MultipleRHS(array, l.location));
                context.pop();
            }

            context.ldloc(array);
            context.callvirt(Runtime.ArgList.ToRubyArray);

            context.ReleaseLocal(array, true);
        }
Exemplo n.º 3
0
 internal OR(Node lhs, Node rhs, YYLTYPE location)
     : base(location)
 {
     Debug.Assert(lhs != null && rhs != null);
     this.lhs = lhs;
     this.rhs = rhs;
 }
Exemplo n.º 4
0
 internal ARGS(YYLTYPE location, bool parens): base(location)
 {
     this.parameters = null;
     this.hashlist = null;
     this.array = null;
     this.block = null;
     this.parens = parens;
 }
Exemplo n.º 5
0
 internal FORMALS(Node normal, Node optional, Node rest, Node block, YYLTYPE location)
     : base(location)
 {
     this.normal = (StaticLocalVar)normal;
     this.optional = (ASSIGNMENT)optional;
     this.rest = (StaticLocalVar)rest;
     this.block = (StaticLocalVar)block;
 }
Exemplo n.º 6
0
 internal ARGS(Node parameters, Node hashlist, Node array, Node block, YYLTYPE location, bool parens): base(location)
 {
     this.parameters = parameters;
     this.hashlist = hashlist;
     this.array = array;
     this.block = block;
     this.parens = parens;
 }
Exemplo n.º 7
0
        protected Node _else;        // optional

        internal COND(Node cond, Node body, Node _else, YYLTYPE location)
            : base(location)
        {
            Debug.Assert(cond != null);
            this.cond = cond;
            this.body = body;
            this._else = _else;
        }
Exemplo n.º 8
0
 internal ARRAY(Node args, YYLTYPE location)
     : base(location)
 {
     if (args is ARGS)
         this.args = (ARGS)args;
     else
         this.args = new ARGS(args, null, null, null, args.location, false);
 }
Exemplo n.º 9
0
 internal CALL(Node args, YYLTYPE location)
     : base(location)
 {
     if (args == null)
         this.args = null;
     else if (args is ListGen)
         this.args = (ListGen)args;
     else
         this.args = new ARGS(args, null, null, null, location, false);
 }
Exemplo n.º 10
0
        internal TRY_BLOCK(Scope parent_scope, Node body, Node rescue, Node _else, Node ensure, YYLTYPE location)
            : base(location)
        {
            this.parent_scope = parent_scope;
            this.body = body;
            this.rescue = (RESCUE_CLAUSE)rescue;
            this._else = _else;
            this.ensure = ensure;

        }
Exemplo n.º 11
0
        internal CONCAT(Node A, Node B, YYLTYPE location)
            : base(location)
        {
            if (A == null || A is VALUE && ((string)((VALUE)A).value) == "")
            {
                this.head = B;
                return;
            }

            Node headA, headB;
            if (A is CONCAT)
                headA = ((CONCAT)A).head;
            else
                headA = A;

            if (B is CONCAT)
                headB = ((CONCAT)B).head;
            else
                headB = B;

            this.head = Parser.append(headA, headB);
        }
Exemplo n.º 12
0
        internal ControlFlowNode(Scope parent_scope, ARGS return_val, YYLTYPE location)
            : base(location)
        {
            this.parent_scope = parent_scope;

            // no return value
            if (return_val == null)
                return;
 
            if (return_val.block != null)
                throw new System.Exception("block argument should not be given");

            // just a single value => return that value
            if (return_val.hashlist == null && return_val.array == null && return_val.parameters.nd_next == null)
            {
                this.return_val = return_val.parameters;
                return;
            }

            // just hash values => return a HASH
            if (return_val.parameters == null && return_val.array == null)
            {
                this.return_val = new HASH(return_val.hashlist, return_val.location);
                return;
            }

            // return *p => if p is an ARRAY then ... else ...
            if (return_val.parameters == null && return_val.hashlist == null)
            {
                this.array = return_val.array;
                this.return_val = new ProxyNode(ReturnArray, return_val.location);
            }
            else
            {
                this.args = return_val;
                this.return_val = new ProxyNode(ReturnRubyArray, return_val.location);
            }
        }
Exemplo n.º 13
0
 internal ARRAY_ACCESS(Node array, Node args, YYLTYPE location): base(location)
 {
     Debug.Assert(array != null);
     this.array = array;
     this.args = (ListGen)args;
 }
Exemplo n.º 14
0
 internal ATTRIBUTE(Node attr_scope, string vid, YYLTYPE location)
     : base(vid, location)
 {
     this.attr_scope = attr_scope;
 }
Exemplo n.º 15
0
 internal override void Assign(CodeGenContext context, Node rhs)
 {
     new METHOD_CALL(attr_scope, vid+"=", rhs, location).GenCode(context);
 }
Exemplo n.º 16
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // Fixme: make sure CurrentRubyClass is not a singleton (see cvar_cbase)

            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // Ruby.Variables.cvar_set(caller, ruby_cref, "vid", value);
            context.ldloc(0);
            context.ruby_cbase(parent_scope);
            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.call(Runtime.Variables.cvar_set);

            context.ReleaseLocal(value, created);
        }
Exemplo n.º 17
0
 internal override void Assign(CodeGenContext context, Node rhs)
 {
     rhs.GenCode(context);
 }
Exemplo n.º 18
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // locals.field = value
            context.ldloc(0);
            value.GenSimple(context);
            context.stfld(field);

            GenCode0(context);

            context.ReleaseLocal(value, created);
        }
Exemplo n.º 19
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            bool value_created;
            ISimple value;

            if (qualified) // Fixme: scope == null???
            {
                // object where = scope;
                bool where_created;
                ISimple where = context.PreCompute(scope, "scope", out where_created);
            
                // object value = rhs;
                value = context.PreCompute(rhs, "rhs", out value_created);

                context.ldloc(0);
                where.GenSimple(context);

                context.ReleaseLocal(where, where_created);
            }
            else
            {
                // object value = rhs;
                value = context.PreCompute(rhs, "rhs", out value_created);

                context.ldloc(0);
                context.ruby_cbase(parent_scope);
            }

            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.call(Runtime.Eval.set_const);

            context.ReleaseLocal(value, value_created);
        }
Exemplo n.º 20
0
 internal override void Init(YYLTYPE location, params object[] inputs)
 {
     this.location = location;
     this.receiver = (Node)inputs[0];
     this.formals = (FORMALS)inputs[1];
     this.body = (Node)inputs[2];
 }
Exemplo n.º 21
0
 internal override void Assign(CodeGenContext context, Node rhs)
 {
     this.rhs = rhs;
     // a.ASET(index++rhs); 
     new METHOD_CALL(array, ID.intern(Tokens.tASET), new ProxyList(ArgsPlusRHS, location), location).GenCode(context);
 }
Exemplo n.º 22
0
 internal Scope(Node body, YYLTYPE location)
     : base(location)
 {
     this.body = body;
 }
Exemplo n.º 23
0
 internal abstract void Assign(CodeGenContext context, Node rhs);
Exemplo n.º 24
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // thisblock.localsN.vid = value;
            context.ldarg(0);
            context.ldfld(block.frameFields[depth - 1]);
            value.GenSimple(context);
            context.stfld(field);

            value.GenSimple(context);

            context.ReleaseLocal(value, created);
        }
Exemplo n.º 25
0
        internal void AssignOp(CodeGenContext context, string op, Node rhs)
        {
            // object a = array;
            bool a_created;
            ISimple a = context.PreCompute(array, "array", out a_created);

            // ArgList index = args;
            bool index_created;
            index = args.GenArgList(context, out index_created);

            // access <=> a[index];
            ARRAY_ACCESS access = new ARRAY_ACCESS((Node)a, new ProxyList(Index, location), location);

            // access1 = (access2 op rhs);
            access.Assign(context, METHOD_CALL.Create(access, op, rhs, location));

            context.ReleaseLocal(a, a_created);
            context.ReleaseLocal(index, index_created);
        }
Exemplo n.º 26
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // Eval.ivar_set(caller, recv, "vid", rhs);
            context.ldloc(0);
            context.ldarg("recv");
            context.ldstr(vid);
            value.GenSimple(context);
            context.call(Runtime.Eval.ivar_set);

            context.ReleaseLocal(value, created);
        }
Exemplo n.º 27
0
        private Node body;        // optional

        internal begin(Node body, YYLTYPE location)
            : base(location)
        {
            this.body = body;
        }
Exemplo n.º 28
0
 internal CONST(Scope parent_scope, Node scope, string vid, YYLTYPE location) : base(vid, location) 
 { 
     this.scope = scope;
     this.parent_scope = parent_scope;
     qualified = true;
 }
Exemplo n.º 29
0
 internal virtual void Init(YYLTYPE location, params object[] inputs)
 {
     this.body = (Node)inputs[0];
     this.location = location;
 }
Exemplo n.º 30
0
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            //Ruby.Variables.gvar_set(vid, rhs, caller);
            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.ldloc(0);
            context.call(Runtime.Variables.gvar_set);

            context.ReleaseLocal(value, created);
        }