示例#1
0
        // Soo, since I cannot be 100% sure where the start of a instance might be
        // ( could be an expresion, complex var, etc)
        // Its put somewhere in a block
        public bool PushEnviromentFix(IList <ILNode> body, ILBasicBlock head, int pos)
        {
            ILExpression expr;
            ILLabel      next;
            ILLabel      pushLabel;
            ILLabel      pushLabelNext;

            if (head.MatchLastAndBr(GMCode.Push, out expr, out next) &&
                //     labelGlobalRefCount[next] == 1 &&  // don't check this
                body.Contains(labelToBasicBlock[next]) &&
                labelToBasicBlock[next].MatchSingleAndBr(GMCode.Pushenv, out pushLabel, out pushLabelNext)
                )
            {
                ILBasicBlock pushBlock = labelToBasicBlock[next];
                head.Body.RemoveAt(head.Body.Count - 2);// hackery, but sure, block should be removed in a flatten
                if (expr.Code == GMCode.Constant)
                {
                    ILValue value = expr.Operand as ILValue;
                    if (value.Value is int)
                    {
                        value.ValueText = context.InstanceToString((int)value.Value);
                    }
                }
                (pushBlock.Body[pushBlock.Body.Count - 2] as ILExpression).Arguments.Add(expr);
                return(true);
            }
            return(false);
        }
示例#2
0
        void ProcessVar(ILVariable v, Stack <ILNode> stack)
        {
            if (v.isResolved)
            {
                return;               // nothing to do
            }
            ILValue value = v.Instance as ILValue;

            Debug.Assert(value.Value is int); // means the value is an int
            int instance = (int)value;

            Debug.Assert(instance == 0);  // it should be a stack value at this point
            if (v.isArray)
            {
                v.Index = stack.Pop(); // get the index first
            }
            v.Instance = stack.Pop();  // get the instance
            value      = v.Instance as ILValue;
            if (value != null && value.Value is int)
            {
                v.InstanceName = context.InstanceToString((int)value);
            }
            else
            {
                v.InstanceName = null;
            }
            v.isResolved = true;
        }