Ejemplo n.º 1
0
        private LambdaCompiler(
            AnalyzedTree tree,
            LambdaExpression lambda,
            TypeBuilder typeBuilder,
            MethodInfo method,
            ILGenerator ilg,
            IList <Type> paramTypes,
            bool dynamicMethod,
            bool emitDebugSymbols)
        {
            ContractUtils.Requires(dynamicMethod || method.IsStatic, "dynamicMethod");
            _tree          = tree;
            _lambda        = lambda;
            _typeBuilder   = typeBuilder;
            _method        = method;
            _paramTypes    = new ReadOnlyCollection <Type>(paramTypes);
            _dynamicMethod = dynamicMethod;

            // These are populated by AnalyzeTree/VariableBinder
            _scope          = tree.Scopes[lambda];
            _boundConstants = tree.Constants[lambda];

            if (!dynamicMethod && _boundConstants.Count > 0)
            {
                throw Error.RtConstRequiresBundDelegate();
            }

            _ilg = new ILGen(ilg);

            Debug.Assert(!emitDebugSymbols || _typeBuilder != null, "emitting debug symbols requires a TypeBuilder");
            _emitDebugSymbols = emitDebugSymbols;

            // See if we can find a return label, so we can emit better IL
            AddReturnLabel(_lambda.Body);

            _boundConstants.EmitCacheConstants(this);
        }
Ejemplo n.º 2
0
 private void InitializeMethod()
 {
     // See if we can find a return label, so we can emit better IL
     AddReturnLabel(_lambda);
     _boundConstants.EmitCacheConstants(this);
 }