示例#1
0
        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;
                }
            }
        }
示例#2
0
 public static int UnwrapBooleanType(ITemplateType operand)
 {
     if (operand == null)
         return 0;
     bool flag;
     if (!operand.TryConvert(out flag))
     {
         return 0;
     }
     return flag ? 1 : 0;
 }
 private ITemplateType EvalMacro(ITemplateType source)
 {
     if (source == null) return StringType.Empty();
     string obj;
     if (!source.TryConvert(out obj))
     {
         _errors.ErrorMacrosOnlyAcceptStrings(source.UnderlyingType, string.Empty);
         return StringType.Empty();
     }
     var i = new Interpreter.Interpreter(obj, Cache);
     var result = i.Apply(_state);
     _errors.AddRange(result.Errors);
     return StringType.New(result.Output);
 }