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); }
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)); }
/// <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)); }
private HTMLValues(HTMLCompiler compiler) { _compiler = compiler; }