Example #1
0
        private void CompileCil(ILProcessor body, IAstElement element, CilCompilationContext context)
        {
            var compiler = this.cilCompilers.SingleOrDefault(c => c.CanCompile(body, element));
            if (compiler == null)
                throw new NotImplementedException("LightCompiler: No CilCompiler for " + element);

            compiler.Compile(body, element, context);
        }
Example #2
0
        private void CompileMethod(MethodDefinition method, AstMethodDefinitionBase methodAst, DefinitionBuildingContext parentContext)
        {
            var body = method.Body.GetILProcessor();
            var context = new CilCompilationContext(method, methodAst, (e, c) => CompileCil(body, e, c), parentContext);

            foreach (var element in methodAst.Body) {
                CompileCil(body, element, context);
            }
        }
Example #3
0
        public override void Compile(ILProcessor processor, AstNewExpression @new, CilCompilationContext context)
        {
            if (@new.Constructor == null)
            {
                throw new NotImplementedException("NewCompiler: Constructor on " + @new + " is null.");
            }

            foreach (var argument in @new.Arguments)
            {
                context.Compile(argument);
            }
            processor.Emit(OpCodes.Newobj, context.ConvertReference(@new.Constructor));
        }
Example #4
0
 public abstract void Compile(ILProcessor processor, TAstElement element, CilCompilationContext context);
Example #5
0
 void ICilCompiler.Compile(ILProcessor processor, IAstElement element, CilCompilationContext context)
 {
     this.Compile(processor, (TAstElement)element, context);
 }
Example #6
0
        public override void Compile(ILProcessor processor, AstReturnStatement element, CilCompilationContext context)
        {
            if (element.Result != null)
            {
                context.Compile(element.Result);
            }

            processor.Emit(OpCodes.Ret);
        }