public ReflexValue processLine(String line) { line = line.trim(); if (line.endsWith("\\")) { currentLine.append(line.substring(0, line.length() - 1)); currentLine.append("\n"); return new ReflexValue(">"); } else if (!line.endsWith(";") && !line.endsWith("end") && !line.endsWith("}")) { line = line + ";"; } currentLine.append(line); try { ReflexTreeWalker walker = ReflexExecutor.getWalkerForProgramWithRegistry( savedRegistry, currentLine.toString(), handler); if (handler != null) { walker.setReflexHandler(handler); } ReflexNode returned = walker.walk(); ReflexValue val = returned.evaluate(debugger, scope); savedRegistry = walker.languageRegistry; return val; } catch (Exception e) { e.printStackTrace(); return new ReflexValue(e.getMessage()); } finally { currentLine.setLength(0); } }
@Override public ReflexValue evaluate(IReflexDebugger debugger, Scope scope) { debugger.stepStart(this, scope); ReflexValue value = expression.evaluate(debugger, scope); debugger.recordMessage("Sleeping "); if (value.isNumber()) { try { Thread.sleep(value.asLong()); } catch (InterruptedException e) { } } debugger.stepEnd(this, new ReflexVoidValue(lineNumber), scope); return new ReflexVoidValue(lineNumber); }
@Override public ReflexValue evaluate(IReflexDebugger debugger, Scope scope) { debugger.stepStart(this, scope); String channel = null; if (expression != null) { ReflexValue value = expression.evaluate(debugger, scope); channel = value.asString(); } String value = handler.getInputHandler().read(channel); ReflexValue retValue; if (value == null) { retValue = new ReflexNullValue(lineNumber); } else { retValue = new ReflexValue(lineNumber, value); } debugger.stepEnd(this, retValue, scope); return retValue; }