コード例 #1
0
ファイル: ExpressionCompiler.cs プロジェクト: chenzuo/nquery
		public static RuntimeExpression CreateCompiled(ExpressionNode expressionNode)
		{
			string expressionSource = expressionNode.GenerateSource();
			ILEmitContext ilEmitContext = new ILEmitContext(expressionSource);
			
			ILParameterRegisterer ilParameterRegisterer = new ILParameterRegisterer(ilEmitContext);
			ilParameterRegisterer.Visit(expressionNode);

			ILTranslator ilTranslator = new ILTranslator(ilEmitContext);
			ilTranslator.Visit(expressionNode);

			CompiledExpressionDelegate compiledExpressionDelegate = ilEmitContext.CreateDelegate();
			object[] arguments = ilEmitContext.GetArguments();

			return new CompiledRuntimeExpression(expressionSource, expressionNode.ExpressionType, compiledExpressionDelegate, arguments);
		}
コード例 #2
0
        public static RuntimeExpression CreateCompiled(ExpressionNode expressionNode)
        {
            string        expressionSource = expressionNode.GenerateSource();
            ILEmitContext ilEmitContext    = new ILEmitContext(expressionSource);

            ILParameterRegisterer ilParameterRegisterer = new ILParameterRegisterer(ilEmitContext);

            ilParameterRegisterer.Visit(expressionNode);

            ILTranslator ilTranslator = new ILTranslator(ilEmitContext);

            ilTranslator.Visit(expressionNode);

            CompiledExpressionDelegate compiledExpressionDelegate = ilEmitContext.CreateDelegate();

            object[] arguments = ilEmitContext.GetArguments();

            return(new CompiledRuntimeExpression(expressionSource, expressionNode.ExpressionType, compiledExpressionDelegate, arguments));
        }