Ejemplo n.º 1
0
        public static ScriptSyntaxAttribute Get(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            ScriptSyntaxAttribute attribute = type.GetTypeInfo().GetCustomAttribute <ScriptSyntaxAttribute>() ?? new ScriptSyntaxAttribute(type.Name, "...");

            return(attribute);
        }
Ejemplo n.º 2
0
        public override object Evaluate(TemplateContext context)
        {
            // Check that the Target is actually a function
            var functionCall = Target as ScriptFunctionCall;

            if (functionCall == null)
            {
                var parameterLessFunction = context.Evaluate(Target, true);
                if (!(parameterLessFunction is IScriptCustomFunction))
                {
                    ScriptSyntaxAttribute targetPrettyname = ScriptSyntaxAttribute.Get(Target);
                    throw new ScriptRuntimeException(Target.Span, string.Format(RS.WrapEvalFailed, Target, targetPrettyname.Name));
                }

                context.BlockDelegates.Push(Body);
                return(ScriptFunctionCall.Call(context, this, parameterLessFunction, false));
            }
            else
            {
                context.BlockDelegates.Push(Body);
                return(context.Evaluate(functionCall));
            }
        }