/* * CODE FOR ALTERNATE IMPL : please ignore. I will remove when comfortable with current. */ /// <summary> not used in current impl /// * /// Constructor for alternate impl where VelProxy class would make new /// VMProxyArg objects, and use this constructor to avoid re-parsing the /// reference args /// * /// that impl also had the VMProxyArg carry it's context /// </summary> public VMProxyArg(VMProxyArg model, IInternalContextAdapter c) { userContext = c; contextReference = model.ContextReference; callerReference = model.CallerReference; nodeTree = model.NodeTree; staticObject = model.StaticObject; type = model.Type; if (nodeTree != null) { numTreeChildren = nodeTree.ChildrenCount; } if (type == ParserTreeConstants.REFERENCE) { if (numTreeChildren == 0) { /* * use the reference node to do this... */ singleLevelRef = ((ASTReference)nodeTree).RootString; } } }
private void setupProxyArgs(String[] callArgs, int[] callArgTypes) { // for each of the args, make a ProxyArg for (int i = 1; i < argArray.Length; i++) { VMProxyArg arg = new VMProxyArg(runtimeServices, argArray[i], callArgs[i - 1], callArgTypes[i - 1]); proxyArgHash[argArray[i]] = arg; } }
/// <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 (System.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); }
/* * CODE FOR ALTERNATE IMPL : please ignore. I will remove when comfortable with current. */ /// <summary> not used in current impl /// * /// Constructor for alternate impl where VelProxy class would make new /// VMProxyArg objects, and use this constructor to avoid re-parsing the /// reference args /// * /// that impl also had the VMProxyArg carry it's context /// </summary> public VMProxyArg(VMProxyArg model, IInternalContextAdapter c) { userContext = c; contextReference = model.ContextReference; callerReference = model.CallerReference; nodeTree = model.NodeTree; staticObject = model.StaticObject; type = model.Type; if (nodeTree != null) { numTreeChildren = nodeTree.ChildrenCount; } if (type == ParserTreeConstants.REFERENCE) { if (numTreeChildren == 0) { /* * use the reference node to do this... */ singleLevelRef = ((ASTReference) nodeTree).RootString; } } }
private void setupProxyArgs(String[] callArgs, int[] callArgTypes) { // for each of the args, make a ProxyArg for(int i = 1; i < argArray.Length; i++) { VMProxyArg arg = new VMProxyArg(runtimeServices, argArray[i], callArgs[i - 1], callArgTypes[i - 1]); proxyArgHash[argArray[i]] = arg; } }
/// <summary> return the inner / user context /// </summary> /// <summary> Used to put VMProxyArgs into this context. It separates /// the VMProxyArgs into constant and non-constant types /// pulling out the value of the constant types so they can /// be modified w/o damaging the VMProxyArg, and leaving the /// dynamic ones, as they modify context rather than their own /// state /// </summary> /// <param name="vmpa">VMProxyArg to add /// /// </param> public void AddVMProxyArg(VMProxyArg vmpa) { /* * ask if it's a constant : if so, get the value and put into the * local context, otherwise, put the vmpa in our vmProxyHash */ String key = vmpa.ContextReference; if (vmpa.isConstant()) { localContext[key] = vmpa.getObject(wrappedContext); } else { vmProxyHash[key] = vmpa; } }