Package com.oracle.truffle.r.runtime.RContext

Examples of com.oracle.truffle.r.runtime.RContext.ConsoleHandler


            return RNull.instance;
        }

        @SlowPath
        private static void doBrowser(MaterializedFrame frame) {
            ConsoleHandler ch = RContext.getInstance().getConsoleHandler();
            REnvironment callerEnv = REnvironment.frameToEnvironment(frame.materialize());
            ch.printf("Called from: %s%n", callerEnv == REnvironment.globalEnv() ? "top level" : RArguments.getFunction(frame).getTarget());
            String savedPrompt = ch.getPrompt();
            ch.setPrompt(browserPrompt());
            try {
                LW: while (true) {
                    String input = ch.readLine();
                    if (input.length() == 0) {
                        RLogicalVector browserNLdisabledVec = (RLogicalVector) ROptions.getValue("browserNLdisabled");
                        if (!RRuntime.fromLogical(browserNLdisabledVec.getDataAt(0))) {
                            break;
                        }
                    } else {
                        input = input.trim();
                    }
                    switch (input) {
                        case "c":
                        case "cont":
                            break LW;

                        case "s":
                        case "f":
                        case "n":
                            throw RError.nyi(null, notImplemented(input));

                        case "where": {
                            int ix = RArguments.getDepth(frame);
                            Frame stackFrame;
                            while (ix >= 0 && (stackFrame = Utils.getStackFrame(FrameAccess.READ_ONLY, ix)) != null) {
                                RFunction fun = RArguments.getFunction(stackFrame);
                                if (fun != null) {
                                    ch.printf("where %d: %s%n", ix, fun.getTarget());
                                }
                                ix--;
                            }
                            ch.println("");
                            break;
                        }

                        default:
                            RContext.getEngine().parseAndEval("<browser_input>", input, frame.materialize(), callerEnv, true, false);
                            break;
                    }
                }
            } finally {
                ch.setPrompt(savedPrompt);
            }
        }
View Full Code Here


            return null;
        } catch (RError e) {
            singleton.context.getConsoleHandler().println(e.getMessage());
            return null;
        } catch (UnsupportedSpecializationException use) {
            ConsoleHandler ch = singleton.context.getConsoleHandler();
            ch.println("Unsupported specialization in node " + use.getNode().getClass().getSimpleName() + " - supplied values: " +
                            Arrays.asList(use.getSuppliedValues()).stream().map(v -> v.getClass().getSimpleName()).collect(Collectors.toList()));
            return null;
        } catch (RecognitionException | RuntimeException e) {
            singleton.context.getConsoleHandler().println("Exception while parsing: " + e);
            e.printStackTrace();
View Full Code Here

    }

    @SlowPath
    private static void reportWarnings(boolean inAddition) {
        List<String> evalWarnings = singleton.context.extractEvalWarnings();
        ConsoleHandler consoleHandler = singleton.context.getConsoleHandler();
        // GnuR outputs warnings to the stderr, so we do too
        if (evalWarnings != null && evalWarnings.size() > 0) {
            if (inAddition) {
                consoleHandler.printError("In addition: ");
            }
            if (evalWarnings.size() == 1) {
                consoleHandler.printErrorln("Warning message:");
                consoleHandler.printErrorln(evalWarnings.get(0));
            } else {
                consoleHandler.printErrorln("Warning messages:");
                for (int i = 0; i < evalWarnings.size(); i++) {
                    consoleHandler.printErrorln((i + 1) + ":");
                    consoleHandler.printErrorln("  " + evalWarnings.get(i));
                }
            }
        }
    }
View Full Code Here

        }

        @Override
        @SlowPath
        public String[] readLinesInternal(int n) throws IOException {
            ConsoleHandler console = RContext.getInstance().getConsoleHandler();
            ArrayList<String> lines = new ArrayList<>();
            String line;
            while ((line = console.readLine()) != null) {
                lines.add(line);
                if (n > 0 && lines.size() == n) {
                    break;
                }
            }
View Full Code Here

TOP

Related Classes of com.oracle.truffle.r.runtime.RContext.ConsoleHandler

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.