Ejemplo n.º 1
0
        /// <summary> Internal Put method to select between local and global scope.
        ///
        /// </summary>
        /// <param name="key">name of item to set
        /// </param>
        /// <param name="value">object to set to key
        /// </param>
        /// <param name="forceLocal">True forces the object into the local scope.
        /// </param>
        /// <returns> old stored object
        /// </returns>
        protected internal virtual object Put(string key, object value, bool forceLocal)
        {
            INode astNode = (INode)vmproxyhash[key];

            if (astNode != null)
            {
                if (astNode.Type == ParserTreeConstants.JJTREFERENCE)
                {
                    ASTReference ref_Renamed = (ASTReference)astNode;

                    if (ref_Renamed.GetNumChildren() > 0)
                    {
                        ref_Renamed.SetValue(innerContext, value);
                        return(null);
                    }
                    else
                    {
                        return(innerContext.Put(ref_Renamed.RootString, value));
                    }
                }
            }

            object tempObject;

            tempObject        = localcontext[key];
            localcontext[key] = value;
            object old = tempObject;

            if (!forceLocal)
            {
                old = base.Put(key, value);
            }
            return(old);
        }
Ejemplo n.º 2
0
 protected override bool Visit(ASTReference node)
 {
     if (!Visit(node.Child))
     {
         return(false);
     }
     node.TypeInfo = Cache.GetPointer(node.TypeInfo);
     return(true);
 }
Ejemplo n.º 3
0
        public override object Visit(ASTReference node, object data)
        {
            string text = (string)this.argmap[node.Literal.Substring(1)];

            if (text != null)
            {
                node.SetLiteral(text);
            }
            data = node.ChildrenAccept(this, data);
            return(data);
        }
        /// <summary>
        /// Visitor method - if the literal is right, will
        /// set the literal in the ASTReference node
        /// </summary>
        /// <param name="node">ASTReference to work on</param>
        /// <param name="data">Object to pass down from caller</param>
        public override Object Visit(ASTReference node, Object data)
        {
            // see if there is an override value for this
            // reference
            String overrideVal = (String)argumentMap[node.Literal.Substring(1)];

            // if so, set in the node
            if (overrideVal != null)
            {
                node.SetLiteral(overrideVal);
            }

            // feed the children...
            data = node.ChildrenAccept(this, data);

            return(data);
        }
        /// <summary>
        /// Visitor method - if the literal is right, will
        /// set the literal in the ASTReference node
        /// </summary>
        /// <param name="node">ASTReference to work on</param>
        /// <param name="data">Object to pass down from caller</param>
        public override Object visit(ASTReference node, Object data)
        {
            /*
             *  see if there is an override value for this
             *  reference
             */
            String override_Renamed = (String)argmap[node.literal().Substring(1)];

            /*
             *  if so, set in the node
             */
            if (override_Renamed != null)
            {
                node.Literal = override_Renamed;
            }

            /*
             *  feed the children...
             */
            data = node.childrenAccept(this, data);

            return(data);
        }
Ejemplo n.º 6
0
 protected override bool Visit(ASTReference node) => EmitUnary <CReference>(node);
Ejemplo n.º 7
0
		public void Reference()
		{
			/*@bgen(jjtree) Reference */
			ASTReference jjtn000 = new ASTReference(this, ParserTreeConstants.REFERENCE);
			bool jjtc000 = true;
			nodeTree.OpenNodeScope(jjtn000);
			//UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to ' ' which has different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1100"'
			try
			{
				switch(GetCurrentTokenKind())
				{
					case ParserConstants.IDENTIFIER:
						ConsumeToken(ParserConstants.IDENTIFIER);
						while(true)
						{
							if (jj_2_5(2))
							{
								;
							}
							else
							{
								//UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1012"'
								goto label_7_brk;
							}
							ConsumeToken(ParserConstants.DOT);
							if (jj_2_6(3))
							{
								Method();
							}
							else
							{
								switch(GetCurrentTokenKind())
								{
									case ParserConstants.IDENTIFIER:
										Identifier();
										break;

									default:
										jj_la1[23] = jj_gen;
										ConsumeToken(-1);
										throw new ParseException();
								}
							}
						}
						//UPGRADE_NOTE: Label 'label_7_brk' was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1011"'
						label_7_brk:
						;

						break;

					case ParserConstants.LCURLY:
						ConsumeToken(ParserConstants.LCURLY);
						ConsumeToken(ParserConstants.IDENTIFIER);
						while(true)
						{
							if (!jj_2_7(2))
							{
								//UPGRADE_NOTE: Labeled break statement was changed to a goto statement. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1012"'
								goto label_8_brk;
							}
							ConsumeToken(ParserConstants.DOT);
							if (jj_2_8(3))
							{
								Method();
							}
							else
							{
								switch(GetCurrentTokenKind())
								{
									case ParserConstants.IDENTIFIER:
										Identifier();
										break;

									default:
										jj_la1[24] = jj_gen;
										ConsumeToken(-1);
										throw new ParseException();
								}
							}
						}
						//UPGRADE_NOTE: Label 'label_8_brk' was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1011"'
						label_8_brk:
						;

						ConsumeToken(ParserConstants.RCURLY);
						break;

					default:
						jj_la1[25] = jj_gen;
						ConsumeToken(-1);
						throw new ParseException();
				}
			}
			catch(Exception exception)
			{
				nodeTree.ClearNodeScope(jjtn000);
				jjtc000 = false;
				if (exception is SystemException)
				{
					throw;
				}
				if (exception is ParseException)
				{
					throw;
				}
				throw (ApplicationException) exception;
			}
			finally
			{
				if (jjtc000)
				{
					nodeTree.CloseNodeScope(jjtn000, true);
				}
			}
		}
Ejemplo n.º 8
0
 public virtual Object Visit(ASTReference node, Object data)
 {
     data = node.ChildrenAccept(this, data);
     return(data);
 }
Ejemplo n.º 9
0
 /// <summary>Display an ASTReference node
 /// </summary>
 public override Object Visit(ASTReference node, Object data)
 {
     return(ShowNode(node, data));
 }
Ejemplo n.º 10
0
        /// <summary> Implementation of the Context.Get() method.  First checks
        /// localcontext, then arguments, then global context.
        ///
        /// </summary>
        /// <param name="key">name of item to Get
        /// </param>
        /// <returns> stored object or null
        /// </returns>
        public override object Get(string key)
        {
            object o = localcontext[key];

            if (o != null)
            {
                return(o);
            }

            INode astNode = (INode)vmproxyhash[key];

            if (astNode != null)
            {
                int type = astNode.Type;

                // if the macro argument (astNode) is a reference, we need to Evaluate it
                // in case it is a multilevel node
                if (type == NVelocity.Runtime.Parser.ParserTreeConstants.JJTREFERENCE)
                {
                    ASTReference ref_Renamed = (ASTReference)astNode;

                    if (ref_Renamed.GetNumChildren() > 0)
                    {
                        return(ref_Renamed.Execute((object)null, innerContext));
                    }
                    else
                    {
                        object obj = innerContext.Get(ref_Renamed.RootString);
                        if (obj == null && ref_Renamed.strictRef)
                        {
                            if (!innerContext.ContainsKey(ref_Renamed.RootString))
                            {
                                throw new MethodInvocationException("Parameter '" + ref_Renamed.RootString + "' not defined", null, key, ref_Renamed.TemplateName, ref_Renamed.Line, ref_Renamed.Column);
                            }
                        }
                        return(obj);
                    }
                }
                else if (type == NVelocity.Runtime.Parser.ParserTreeConstants.JJTTEXT)
                {
                    // this really shouldn't happen. text is just a throwaway arg for #foreach()
                    try
                    {
                        System.IO.StringWriter writer = new System.IO.StringWriter();
                        astNode.Render(innerContext, writer);

                        return(writer.ToString());
                    }
                    catch (System.SystemException e)
                    {
                        throw e;
                    }
                    catch (System.Exception e)
                    {
                        string msg = "ProxyVMContext.Get() : error rendering reference";
                        rsvc.Log.Error(msg, e);
                        throw new VelocityException(msg, e);
                    }
                }
                else
                {
                    // use value method to render other dynamic nodes
                    return(astNode.Value(innerContext));
                }
            }

            return(base.Get(key));
        }
Ejemplo n.º 11
0
 /// <summary>Display an ASTReference node
 /// </summary>
 public override System.Object visit(ASTReference node, System.Object data)
 {
     return(showNode(node, data));
 }
Ejemplo n.º 12
0
 public virtual System.Object visit(ASTReference node, System.Object data)
 {
     data = node.childrenAccept(this, data);
     return(data);
 }
Ejemplo n.º 13
0
 public override object Visit(ASTReference node, object data)
 {
     return(this.ShowNode(node, data));
 }
Ejemplo n.º 14
0
 protected abstract bool Visit(ASTReference node);