コード例 #1
0
        List <System.Linq.Expressions.Expression> TransformInternal()
        {
            INameResolver resolver = null;
            Node          node     = Parent;

            while ((resolver = node as INameResolver) == null)
            {
                node = node.Parent;
            }
            System.Linq.Expressions.Expression exp;
            if (resolver == null)
            {
                throw new InvalidOperationException("変数を宣言できるスコープが見つかりません。");
            }
            List <System.Linq.Expressions.Expression> exps = new List <System.Linq.Expressions.Expression>();

            foreach (var initializer in Initializers)
            {
                if (initializer.Value != null)
                {
                    exp = resolver.DeclareVariable(initializer.Key, initializer.Value.TransformRead());
                }
                else
                {
                    exp = resolver.DeclareVariable(initializer.Key, System.Linq.Expressions.Expression.Constant(IronTjs.Builtins.Void.Value));
                }
                if (exp == null)
                {
                    throw new InvalidOperationException(string.Format("スコープに変数 \"{0}\" を宣言できません。", initializer.Key));
                }
                exps.Add(exp);
            }
            return(exps);
        }