public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node) { try { if (this.nodeTree != null) { if (!this.init) { this.nodeTree.Init(context, this.rsvc); this.init = true; } VMContext vMContext = new VMContext(context, this.rsvc); for (int i = 1; i < this.argArray.Length; i++) { VMProxyArg vmpa = (VMProxyArg)this.proxyArgHash[this.argArray[i]]; vMContext.AddVMProxyArg(vmpa); } this.nodeTree.Render(vMContext, writer); } else { this.rsvc.Error("VM error : " + this.macroName + ". Null AST"); } } catch (System.Exception ex) { if (ex is MethodInvocationException) { throw; } this.rsvc.Error("VelocimacroProxy.render() : exception VM = #" + this.macroName + "() : " + StringUtils.StackTrace(ex)); } return(true); }
/// <summary> Return name of this Velocimacro. /// </summary> /// <summary> Velocimacros are always LINE /// type directives. /// </summary> /// <summary> sets the directive name of this VM /// </summary> /// <summary> sets the array of arguments specified in the macro definition /// </summary> /// <summary> returns the number of ars needed for this VM /// </summary> /// <summary> Sets the orignal macro body. This is simply the cat of the macroArray, but the /// Macro object creates this once during parsing, and everyone shares it. /// Note : it must not be modified. /// </summary> /// <summary> Renders the macro using the context /// </summary> public override bool render(InternalContextAdapter context, System.IO.TextWriter writer, INode node) { try { /* * it's possible the tree hasn't been parsed yet, so get * the VMManager to parse and init it */ if (nodeTree != null) { if (!init_Renamed_Field) { nodeTree.init(context, rsvc); init_Renamed_Field = true; } /* * wrap the current context and add the VMProxyArg objects */ VMContext vmc = new VMContext(context, rsvc); for (int i = 1; i < argArray.Length; i++) { /* * we can do this as VMProxyArgs don't change state. They change * the context. */ VMProxyArg arg = (VMProxyArg)proxyArgHash[argArray[i]]; vmc.AddVMProxyArg(arg); } /* * now render the VM */ nodeTree.render(vmc, writer); } else { rsvc.error("VM error : " + macroName + ". Null AST"); } } catch (System.Exception e) { /* * if it's a MIE, it came from the render.... throw it... */ if (e is MethodInvocationException) { throw (MethodInvocationException)e; } rsvc.error("VelocimacroProxy.render() : exception VM = #" + macroName + "() : " + StringUtils.stackTrace(e)); } return(true); }
/// <summary> /// Renders the macro using the context /// </summary> public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node) { try { // it's possible the tree hasn't been parsed yet, so get // the VMManager to parse and init it if (nodeTree == null) { runtimeServices.Error(string.Format("VM error : {0}. Null AST", macroName)); } else { if (!init) { nodeTree.Init(context, runtimeServices); init = true; } // wrap the current context and add the VMProxyArg objects VMContext vmContext = new VMContext(context, runtimeServices); for (int i = 1; i < argArray.Length; i++) { // we can do this as VMProxyArgs don't change state. They change // the context. VMProxyArg arg = (VMProxyArg)proxyArgHash[argArray[i]]; vmContext.AddVMProxyArg(arg); } // now render the VM nodeTree.Render(vmContext, writer); } } catch (Exception e) { // if it's a MIE, it came from the render.... throw it... if (e is MethodInvocationException) { throw; } runtimeServices.Error(string.Format("VelocimacroProxy.render() : exception VM = #{0}() : {1}", macroName, e)); } return(true); }
/// <summary> /// Renders the macro using the context /// </summary> public override bool Render(IInternalContextAdapter context, TextWriter writer, INode node) { try { // it's possible the tree hasn't been parsed yet, so get // the VMManager to parse and init it if (nodeTree != null) { if (!init) { nodeTree.Init(context, rsvc); init = true; } // wrap the current context and add the VMProxyArg objects VMContext vmc = new VMContext(context, rsvc); for(int i = 1; i < argArray.Length; i++) { // we can do this as VMProxyArgs don't change state. They change // the context. VMProxyArg arg = (VMProxyArg) proxyArgHash[argArray[i]]; vmc.AddVMProxyArg(arg); } // now render the VM nodeTree.Render(vmc, writer); } else { rsvc.Error("VM error : " + macroName + ". Null AST"); } } catch(Exception e) { // if it's a MIE, it came from the render.... throw it... if (e is MethodInvocationException) throw; rsvc.Error("VelocimacroProxy.render() : exception VM = #" + macroName + "() : " + e); } return true; }