コード例 #1
0
 public virtual void WriteStoreArgument(StoreArgument s, ExpressionUsage u)
 {
     Begin(u);
     Write(s.Parameter.Name + Assign);
     WriteExpression(s.Value);
     End(u);
 }
コード例 #2
0
ファイル: JsWriter.cs プロジェクト: kusma/uno
 public override void WriteStoreArgument(StoreArgument s, ExpressionUsage u)
 {
     if (s.Parameter.IsReference)
     {
         Write(s.Parameter.Name + "(");
         WriteExpression(s.Value);
         Write(")");
     }
     else
     {
         base.WriteStoreArgument(s, u);
     }
 }
コード例 #3
0
        public override void End(ref Expression e, ExpressionUsage u)
        {
            switch (e.ExpressionType)
            {
            case ExpressionType.Lambda:
            {
                if (e == _lambda)
                {
                    var lambda = (Lambda)e;
                    e = new NewDelegate(
                        e.Source,
                        (DelegateType)lambda.ReturnType,
                        _closureStack.Peek().Expression,
                        _lambdaMethod);

                    _lambda       = null;
                    _lambdaMethod = null;
                }
                break;
            }

            case ExpressionType.LoadLocal:
            {
                var load = (LoadLocal)e;

                if (_closureVars.Contains(load.Variable))
                {
                    e = _lambda == null
                            ? _closureStack.Peek().Load(load.Variable)
                            : _closureStack.Peek().LoadInside(load.Variable);
                }
                break;
            }

            case ExpressionType.LoadArgument:
            {
                var load = (LoadArgument)e;
                if (_closureVars.Contains(load.Parameter))
                {
                    e = _lambda == null
                            ? _closureStack.Peek().Load(load.Parameter)
                            : _closureStack.Peek().LoadInside(load.Parameter);
                }
                else if (load.Function.Match(_ => false, lam => lam == _lambda))
                {
                    e = new LoadArgument(load.Source, _lambdaMethod, load.Index);
                }
                break;
            }

            case ExpressionType.This:
            {
                if (_closureVars.This && _lambda != null)
                {
                    e = _closureStack.Peek().ThisInside();
                }
                break;
            }

            case ExpressionType.StoreLocal:
            {
                var store = (StoreLocal)e;
                if (_closureVars.Contains(store.Variable))
                {
                    e = _lambda == null
                            ? _closureStack.Peek().Store(store.Variable, store.Value)
                            : _closureStack.Peek().StoreInside(store.Variable, store.Value);
                }
                break;
            }

            case ExpressionType.StoreArgument:
            {
                var store = (StoreArgument)e;
                if (_closureVars.Contains(store.Parameter))
                {
                    e = _lambda == null
                            ? _closureStack.Peek().Store(store.Parameter, store.Value)
                            : _closureStack.Peek().StoreInside(store.Parameter, store.Value);
                }
                else if (store.Function.Match(_ => false, lam => lam == _lambda))
                {
                    e = new StoreArgument(store.Source, _lambdaMethod, store.Index, store.Value);
                }
                break;
            }

            case ExpressionType.StoreThis:
            {
                var store = (StoreThis)e;
                if (_closureVars.This)
                {
                    e = _lambda == null
                            ? _closureStack.Peek().StoreThis(store.Value)
                            : _closureStack.Peek().StoreThisInside(store.Value);
                }
                break;
            }
            }
        }