Beispiel #1
0
 public ErrorList SetTargetObject(
     Interpreter terp,
     ITemplateType source)
 {
     Errors.Clear();
     Interpreter = terp;
     InternalSetTargetObject((CommonTree) T.Children[0], source);
     return Errors;
 }
Beispiel #2
0
 public ErrorList Eval(
     Context ctx,
     Interpreter interpreter,
     out ITemplateType o)
 {
     if (T == null || T.Type == 0)
     {
         Errors.ErrorParse((CommonErrorNode) T);
         o = null;
         return Errors;
     }
     Ctx = ctx;
     Interpreter = interpreter;
     Errors.Clear();
     OnEval(out o);
     return Errors;
 }
        protected override void OnEval(out ITemplateType o)
        {
            var c = (CommonTree) T.Children[0];
            switch (c.Type)
            {
                case 0:
                {
                    Errors.ErrorParse((CommonErrorNode) c);
                    o = null;
                    break;
                }
                case TemplateLexer.MPass:
                case TemplateLexer.EPass:
                {
                    o = EvalPassThrough(c);
                    if (c.Type == TemplateLexer.MPass)
                    {
                        string obj;
                        if (!o.TryConvert(out obj))
                        {
                            Errors.ErrorMacrosOnlyAcceptStrings(c.Text);
                            return;
                        }
                        var i = new Interpreter(obj);

                        var result = i.Apply(S);
                        Errors.AddRange(result.Errors);

                        o = Errors.ContainsError()
                            ? StringType.Empty()
                            : StringType.New(result.Output);
                    }
                    break;
                }
                default:
                {
                    o = StringType.Empty();
                    break;
                }
            }
        }