protected static String getCurrentSourceFileName() { if (parserContext != null && parserContext.get() != null) { return parserContext.get().getSourceFile(); } return null; }
public void testDebuggerInvoke2() { count = 0; MVELRuntime.resetDebugger(); MVELRuntime.setThreadDebugger(new Debugger() { public int onBreak(Frame frame) { count++; return 0; } }); String src = "a1=7;\na2=8;\nSystem.out.println(\"h\");\nac=23;\nde=23;\nge=23;\ngef=34;"; ParserContext ctx = new ParserContext(); ctx.setSourceFile("mysource"); ctx.setDebugSymbols(true); ExpressionCompiler c = new ExpressionCompiler(src, ctx); CompiledExpression compexpr = c.compile(); System.out.println(decompile(compexpr)); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 1); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 2); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 3); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 4); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 5); VariableResolverFactory factory = new DefaultLocalVariableResolverFactory(); MVEL.executeDebugger(compexpr, null, factory); System.out.println(count); assertEquals(5, count); }
MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 1); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 3); MVELRuntime.registerBreakpoint(ctx.getSourceFile(), 7);
return new CompiledExpression(finalizePayload(astBuild, secondPassOptimization, pCtx), pCtx.getSourceFile(), returnType, pCtx.getParserConfiguration(), literalOnly == 1); } catch (RuntimeException e) { throw new CompileException(e.getMessage(), expr, st, e);
return new CompiledExpression(finalizePayload(astBuild, secondPassOptimization, pCtx), pCtx.getSourceFile(), returnType, pCtx.getParserConfiguration(), literalOnly == 1); } catch (RuntimeException e) { throw new CompileException(e.getMessage(), expr, st, e);
if (pCtx.getSourceFile() == null) { throw new CompileException("unable to produce debugging symbols: source name must be provided.", expr, st); if (!pCtx.isLineMapped(pCtx.getSourceFile())) { pCtx.initLineMapping(pCtx.getSourceFile(), expr); int line = pCtx.getLineFor(pCtx.getSourceFile(), cursor); if (!pCtx.isVisitedLine(pCtx.getSourceFile(), pCtx.setLineCount(line)) && !pCtx.isBlockSymbols()) { lastWasLineLabel = true; pCtx.visitLine(pCtx.getSourceFile(), line); return lastNode = pCtx.setLastLineLabel(new LineLabel(pCtx.getSourceFile(), line, pCtx));
if (pCtx.getSourceFile() == null) { throw new CompileException("unable to produce debugging symbols: source name must be provided.", expr, st); if (!pCtx.isLineMapped(pCtx.getSourceFile())) { pCtx.initLineMapping(pCtx.getSourceFile(), expr); int line = pCtx.getLineFor(pCtx.getSourceFile(), cursor); if (!pCtx.isVisitedLine(pCtx.getSourceFile(), pCtx.setLineCount(line)) && !pCtx.isBlockSymbols()) { lastWasLineLabel = true; pCtx.visitLine(pCtx.getSourceFile(), line); return lastNode = pCtx.setLastLineLabel(new LineLabel(pCtx.getSourceFile(), line, pCtx));
if (pCtx.getSourceFile() == null) { throw new CompileException("unable to produce debugging symbols: source name must be provided."); if (!pCtx.isKnownLine(pCtx.getSourceFile(), pCtx.setLineCount(line)) && !pCtx.isBlockSymbols()) { lastWasLineLabel = true; pCtx.setLineAndOffset(line, cursor); return lastNode = pCtx.setLastLineLabel(new LineLabel(pCtx.getSourceFile(), line));
return new CompiledExpression(finalizePayload(astBuild, secondPassOptimization, pCtx), pCtx.getSourceFile(), returnType, pCtx, literalOnly == 1);