Exemplo n.º 1
0
        public static Expression GetValue(Instruction instruction, HTMLCompiler compiler)
        {
            if (instruction == null)
            {
                return(null);
            }

            var creator = new HTMLValues(compiler);

            instruction.VisitMe(creator);
            var expression = compiler.CompileBlock(creator._emitted);

            return(expression);
        }
Exemplo n.º 2
0
        public ResponseHandler Compile(string language, string source)
        {
            var toolChain = _toolChains[language];

            var emitter = new Emitter(WebHelpers);

            toolChain.EmitDelegate(source, emitter);
            if (emitter.HasError)
            {
                //TODO error handling

                var errorBytes = Encoding.UTF8.GetBytes(emitter.ErrorMessage);

                return((response) => response.Write(errorBytes));
            }

            var instructions = emitter.GetEmittedResult();

            return(HTMLCompiler.Compile(instructions, emitter.Parameters));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Run compilation of given instruction (All write instructions are sended to output in pure HTML)
        /// </summary>
        /// <param name="root">Instruction to be compiled</param>
        /// <returns>Compiled response handler</returns>
        public static ResponseHandler Compile(Instruction root, IEnumerable <ParamDeclaration> parameters)
        {
            var compiler = new HTMLCompiler(parameters);

            return(compiler.compile(root));
        }
Exemplo n.º 4
0
 private HTMLValues(HTMLCompiler compiler)
 {
     _compiler = compiler;
 }