Example #1
0
        internal Expression MaybeImmediatelyResolve(PastelParser parser)
        {
            if (this.Root is CompileTimeFunctionReference)
            {
                CompileTimeFunctionReference constFunc = (CompileTimeFunctionReference)this.Root;
                InlineConstant argName = (InlineConstant)this.Args[0];
                switch (constFunc.NameToken.Value)
                {
                case "ext_boolean":
                    return(new InlineConstant(
                               PType.BOOL,
                               this.FirstToken,
                               parser.GetParseTimeBooleanConstant(argName.Value.ToString())));

                case "ext_integer":
                    return(new InlineConstant(
                               PType.INT,
                               this.FirstToken,
                               parser.GetParseTimeIntegerConstant(argName.Value.ToString())));

                default:
                    return(this);
                }
            }
            return(this);
        }
        internal Executable[] ImmediateResolveMaybe(PastelParser parser)
        {
            if (this.Expression is FunctionInvocation)
            {
                if (((FunctionInvocation)this.Expression).Root is CompileTimeFunctionReference)
                {
                    FunctionInvocation           functionInvocation  = (FunctionInvocation)this.Expression;
                    CompileTimeFunctionReference compileTimeFunction = (CompileTimeFunctionReference)functionInvocation.Root;
                    switch (compileTimeFunction.NameToken.Value)
                    {
                    case "import":
                        string path = ((InlineConstant)functionInvocation.Args[0]).Value.ToString();
                        return(parser.ParseImportedCode(path));

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
            return(null);
        }