コード例 #1
0
        private object Evaluate(SimpleNode inlineNode, IInternalContextAdapter context)
        {
            if (inlineNode.ChildrenCount == 1)
            {
                INode child = inlineNode.GetChild(0);
                return(child.Value(context));
            }
            else
            {
                StringBuilder result = new StringBuilder();

                for (int i = 0; i < inlineNode.ChildrenCount; i++)
                {
                    INode child = inlineNode.GetChild(i);

                    if (child.Type == ParserTreeConstants.REFERENCE)
                    {
                        result.Append(child.Value(context));
                    }
                    else
                    {
                        result.Append(child.Literal);
                    }
                }

                return(result.ToString());
            }
        }
コード例 #2
0
		/// <summary>  does the housekeeping upon creating.  If a dynamic type
		/// it needs to make an AST for further get()/set() operations
		/// Anything else is constant.
		/// </summary>
		private void setup()
		{
			switch(type)
			{
				case ParserTreeConstants.INTEGER_RANGE:
				case ParserTreeConstants.REFERENCE:
				case ParserTreeConstants.OBJECT_ARRAY:
				case ParserTreeConstants.STRING_LITERAL:
				case ParserTreeConstants.TEXT:
					{
						/*
			*  dynamic types, just render
			*/

						constant = false;

						try
						{
							/*
			    *  fakie : wrap in  directive to get the parser to treat our args as args
			    *   it doesn't matter that #include() can't take all these types, because we 
			    *   just want the parser to consider our arg as a Directive/VM arg rather than
			    *   as if inline in schmoo
			    */

							String buff = string.Format("#include({0} ) ", callerReference);

							//ByteArrayInputStream inStream = new ByteArrayInputStream( buff.getBytes() );

							//UPGRADE_ISSUE: The equivalent of constructor 'java.io.BufferedReader.BufferedReader' is incompatible with the expected type in C#. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1109"'
							TextReader br = new StringReader(buff);

							nodeTree = runtimeServices.Parse(br, string.Format("VMProxyArg:{0}", callerReference), true);

							/*
			    *  now, our tree really is the first DirectiveArg(), and only one
			    */

							nodeTree = (SimpleNode) nodeTree.GetChild(0).GetChild(0);

							/*
			    * sanity check
			    */

							if (nodeTree != null && nodeTree.Type != type)
							{
								runtimeServices.Error("VMProxyArg.setup() : programmer error : type doesn't match node type.");
							}

							/*
			    *  init.  We can do this as they are only references
			    */

							nodeTree.Init(null, runtimeServices);
						}
						catch(System.Exception e)
						{
							runtimeServices.Error(string.Format("VMProxyArg.setup() : exception {0} : {1}", callerReference, e));
						}

						break;
					}

				case ParserTreeConstants.TRUE:
					{
						constant = true;
						staticObject = true;
						break;
					}

				case ParserTreeConstants.FALSE:
					{
						constant = true;
						staticObject = false;
						break;
					}

				case ParserTreeConstants.NUMBER_LITERAL:
					{
						constant = true;
						staticObject = Int32.Parse(callerReference);
						break;
					}

				case ParserTreeConstants.WORD:
					{
						/*
						*  this is technically an error...
						*/

						runtimeServices.Error(
							string.Format(
								"Unsupported arg type : {0}  You most likely intended to call a VM with a string literal, so enclose with ' or \" characters. (VMProxyArg.setup())",
								callerReference));
						constant = true;
						staticObject = new String(callerReference.ToCharArray());

						break;
					}

				default:
					{
						runtimeServices.Error(string.Format(" VMProxyArg.setup() : unsupported type : {0}", callerReference));
					}
					break;
			}
		}
コード例 #3
0
		private object Evaluate(SimpleNode inlineNode, IInternalContextAdapter context)
		{
			if (inlineNode.ChildrenCount == 1)
			{
				INode child = inlineNode.GetChild(0);
				return child.Value(context);
			}
			else
			{
				StringBuilder result = new StringBuilder();

				for(int i = 0; i < inlineNode.ChildrenCount; i++)
				{
					INode child = inlineNode.GetChild(i);

					if (child.Type == ParserTreeConstants.REFERENCE)
					{
						result.Append(child.Value(context));
					}
					else
					{
						result.Append(child.Literal);
					}
				}

				return result.ToString();
			}
		}