Package org.jruby.ast

Examples of org.jruby.ast.RootNode


    public void compileRoot(Node node, ScriptCompiler context, ASTInspector inspector) {
        compileRoot(node, context, inspector, true, true);
    }

    public void compileRoot(Node node, ScriptCompiler context, ASTInspector inspector, boolean load, boolean main) {
        RootNode rootNode = (RootNode) node;

        context.startScript(rootNode.getStaticScope());

        // create method for toplevel of script
        BodyCompiler methodCompiler = context.startMethod("__file__", "__file__", null, rootNode.getStaticScope(), inspector);

        Node nextNode = rootNode.getBodyNode();
        if (nextNode != null) {
            if (nextNode.nodeId == NodeType.BLOCKNODE) {
                // it's a multiple-statement body, iterate over all elements in turn and chain if it get too long
                BlockNode blockNode = (BlockNode) nextNode;
View Full Code Here


        position = topOfAST != null ? topOfAST.getPosition() : position;

        if (result.getBeginNodes().size() == 0) {
            if (topOfAST == null) topOfAST = NilImplicitNode.NIL;
           
            return new RootNode(position, result.getScope(), topOfAST);
        }
       
        BlockNode newTopOfAST = new BlockNode(position);
        for (Node beginNode: result.getBeginNodes()) {
            appendToBlock(newTopOfAST, beginNode);
        }
       
        // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty])
        if (topOfAST != null) newTopOfAST.add(topOfAST);
       
        return new RootNode(position, result.getScope(), newTopOfAST);
    }
View Full Code Here

    public void compileRoot(Node node, ScriptCompiler context, ASTInspector inspector) {
        compileRoot(node, context, inspector, true, true);
    }

    public void compileRoot(Node node, ScriptCompiler context, ASTInspector inspector, boolean load, boolean main) {
        RootNode rootNode = (RootNode) node;
        StaticScope staticScope = rootNode.getStaticScope();

        context.startScript(staticScope);

        // force static scope to claim restarg at 0, so it only implements the [] version of __file__
        staticScope.setRestArg(-2);

        // create method for toplevel of script
        BodyCompiler methodCompiler = context.startFileMethod(null, staticScope, inspector);

        Node nextNode = rootNode.getBodyNode();
        if (nextNode != null) {
            if (nextNode.getNodeType() == NodeType.BLOCKNODE) {
                // it's a multiple-statement body, iterate over all elements in turn and chain if it get too long
                BlockNode blockNode = (BlockNode) nextNode;
View Full Code Here

        position = topOfAST != null ? topOfAST.getPosition() : position;

        if (result.getBeginNodes().isEmpty()) {
            if (topOfAST == null) topOfAST = NilImplicitNode.NIL;
           
            return new RootNode(position, result.getScope(), topOfAST);
        }
       
        BlockNode newTopOfAST = new BlockNode(position);
        for (Node beginNode: result.getBeginNodes()) {
            appendToBlock(newTopOfAST, beginNode);
        }
       
        // Add real top to new top (unless this top is empty [only begin/end nodes or truly empty])
        if (topOfAST != null) newTopOfAST.add(topOfAST);
       
        return new RootNode(position, result.getScope(), newTopOfAST);
    }
View Full Code Here

        if (fetchGlobalConstant("DATA") == null) {
            try {inputStream.close();} catch (IOException ioe) {}
        }
       
        if (parseResult instanceof RootNode) {
            RootNode scriptNode = (RootNode) parseResult;       

            ThreadContext context = getCurrentContext();

            String oldFile = context.getFile();
            int oldLine = context.getLine();
            try {
                context.setFileAndLine(scriptNode.getPosition());

                if (config.isAssumePrinting() || config.isAssumeLoop()) {
                    runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(),
                            config.isSplit());
                } else {
View Full Code Here

        // no binding, just eval in "current" frame (caller's frame)
        DynamicScope evalScope = context.getCurrentScope().getEvalScope(runtime);
        evalScope.getStaticScope().determineModule();

        RootNode node = (RootNode) runtime.parseEval(src.convertToString().getByteList(), file, evalScope, lineNumber);

        return interpretCommonEval(runtime, file, lineNumber, "(eval)", node, self, Block.NULL_BLOCK, evalType);
    }
View Full Code Here

        evalScope.getStaticScope().determineModule();

        Frame lastFrame = context.preEvalWithBinding(binding);
        try {
            // Binding provided for scope, use it
            RootNode node = (RootNode) runtime.parseEval(src.convertToString().getByteList(), binding.getFile(), evalScope, binding.getLine());
            Block block = binding.getFrame().getBlock();

            return interpretCommonEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block, EvalType.BINDING_EVAL);
        } finally {
            context.postEvalWithBinding(binding, lastFrame);
View Full Code Here

TOP

Related Classes of org.jruby.ast.RootNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.