Пример #1
0
 public ErrorList GenerateSet(Context ctx, int localIndex)
 {
     return GenerateSet(
         ctx,
         c => c.Sink.FastEmitLoadLocal(
             localIndex));
 }
Пример #2
0
 public ErrorList GenerateSet(Context ctx, Action<Context> exp)
 {
     Ctx = ctx;
     Errors.Clear();
     var errors = new ErrorList();
     if (T.Type == 0)
     {
         var error = (CommonErrorNode) T;
         errors.ErrorParse(error);
         return Errors;
     }
     var child = (CommonTree) T.Children[0];
     switch (child.Type)
     {
         case 0:
         {
             var error = (CommonErrorNode) child;
             errors.ErrorParse(error);
             break;
         }
         case TemplateLexer.MStart:
         case TemplateLexer.EStart:
         {
             EmitSet(child, exp);
             //pop off voidtype from final function in chain
             break;
         }
         default:
         {
             break;
         }
     }
     return Errors;
 }
Пример #3
0
 public ErrorList Generate(Context ctx)
 {
     _context = ctx;
     OnGenerate();
     return Errors;
 }
Пример #4
0
        private ErrorList InternalCompile(ICharStream stream)
        {
            var errors = new ErrorList();
            var lexer = TemplateLexer.Create(stream);
            var tStream = new CommonTokenStream(lexer);
            var parser = new TemplateParser(tStream) {Errors = errors};
            var docResult = parser.document();

            _template = new DynamicMethod(
                string.Format("__template_{0}", Name),
                typeof (void),
                new[] {typeof (VirtualTemplate)},
                typeof (VirtualTemplate),
                true);

            var emit = _template.GetILGenerator();
            var ctx = new Context(emit) {OptimizeLevel = OptimizeLevel};
            var doc = new Document(docResult.Tree);

            try
            {
                var e = doc.Generate(ctx);
                errors.AddRange(e);
                _image = (RunTemplate) _template.CreateDelegate(typeof (RunTemplate));
                Assembly = ctx.Sink.Build();
            }
            catch (Exception e)
            {
                errors.ErrorUnhandledCompileError(e);
            }

            stream.Seek(0);
            Source = stream.ToString();

            return errors;
        }
Пример #5
0
 public ErrorList GenerateSet(Context ctx, Expression exp)
 {
     return GenerateSet(ctx, c => Errors.AddRange(exp.Generate(c)));
 }