コード例 #1
0
        /// <summary>  does the housekeeping upon creationg.  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.JJTINTEGERRANGE:
            case ParserTreeConstants.JJTREFERENCE:
            case ParserTreeConstants.JJTOBJECTARRAY:
            case ParserTreeConstants.JJTSTRINGLITERAL:
            case ParserTreeConstants.JJTTEXT:
            {
                /*
                 *  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 = "#include(" + 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 = rsvc.parse(br, "VMProxyArg:" + callerReference, true);

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

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

                    /*
                     * sanity check
                     */

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

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

                    nodeTree.init(null, rsvc);
                }
                catch (Exception e)
                {
                    rsvc.error("VMProxyArg.setup() : exception " + callerReference + " : " + StringUtils.stackTrace(e));
                }

                break;
            }


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


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


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


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

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

                break;
            }


            default:
            {
                rsvc.error(" VMProxyArg.setup() : unsupported type : " + callerReference);
            }
            break;
            }
        }