@Signature public Memory getPosition(Environment env, Memory... args){ if (getClosureEntity() != null) return LongMemory.valueOf(getClosureEntity().getTrace().getStartPosition() + 1); return LongMemory.valueOf(getEntity().getTrace().getStartPosition() + 1); }
private static String evalErrorMessage(ErrorException e) { return e.getMessage() + ", eval()'s code on line " + (e.getTraceInfo().getStartLine() + 1) + ", position " + (e.getTraceInfo().getStartPosition() + 1); }
public String getDebugMessage(){ return getType().getTypeName() + ": " + getMessage() + " in '" + trace.trace.getFileName() + "'" + " on line " + (trace.trace.getStartLine() + 1) + " at pos " + (trace.trace.getStartPosition() + 1); }
last.getTrace().getStartLine(), trace.getEndLine(), last.getTrace().getStartPosition(), trace.getEndLine() ));
@Signature public Memory getPosition(Environment env, Memory... args) { if (entity.isInternal() || entity.getTrace().isUnknown()) return Memory.FALSE; return LongMemory.valueOf(entity.getTrace().getStartPosition() + 1); }
public void writeTrace(TraceInfo trace) throws IOException { writeBoolean(trace != null); if (trace != null){ writeInt(trace.getStartLine()); writeInt(trace.getStartPosition()); writeUTF(trace.getFileName()); } }
public TraceInfo getTraceAppliedSourceMap(TraceInfo trace) { if (trace == null) { return null; } if (trace.getFile() == null) { return trace; } if (trace instanceof SourceMappedTraceInfo) { return trace; } SourceMap sourceMap = sourceMaps.get(trace.getFileName()); if (sourceMap != null) { int sourceLine = sourceMap.getSourceLine(trace.getStartLine() + 1); if (sourceLine != trace.getStartLine() && sourceLine != -1) { trace = new SourceMappedTraceInfo( trace.getContext(), sourceLine - 1, trace.getEndLine(), trace.getStartPosition(), trace.getEndPosition() ); } } return trace; }
public void writeTickTrigger(TraceInfo trace) { if (compiler.getScope().isDebugMode() && method.getLocalVariable("~local") != null) { int line = trace.getStartLine(); if (method.registerTickTrigger(line)) { writePushEnv(); writePushTraceInfo(trace.getStartLine(), trace.getStartPosition()); writePushLocal(); writeSysDynamicCall(Environment.class, "__tick", void.class, TraceInfo.class, ArrayMemory.class); } } }
@Override public void setTraceInfo(Environment env, TraceInfo trace) { super.setTraceInfo(env, trace); Memory line = clazz.refOfProperty(props, "line"); Memory file = clazz.refOfProperty(props, "file"); if (!line.isNull() || !file.isNull()){ this.trace = new TraceInfo( file.isNull() ? trace.getFileName() : file.toString(), line.isNull() ? trace.getStartLine() : line.toInteger() - 1, trace.getStartPosition() ); } }
@Override public boolean onFatal(ErrorException error) { Environment.this.echo("\n"); Environment.this.echo(error.getType().getTypeName() + ": " + error.getMessage()); if (error.getTraceInfo() != null) { Environment.this.echo( " in " + error.getTraceInfo().getFileName() + " on line " + (error.getTraceInfo().getStartLine() + 1) + ", position " + (error.getTraceInfo().getStartPosition() + 1) ); } return false; } });
trace.getStartPosition() + 1 ); } else if (param.getTypeHintingChecker() != null) { trace.getStartPosition() + 1 ); } else { trace.getStartPosition() + 1 ); trace.getFileName(), trace.getStartLine() + 1, trace.getStartPosition() + 1 );
@Override public ArrayMemory getProperties() { if (!init){ init = true; if (trace != null) { Memory m; m = clazz.refOfProperty(props, "file"); if (m.isNull()) { m.assign(trace.getFileName()); } m = clazz.refOfProperty(props, "line"); if (m.isNull()) { m.assign(trace.getStartLine() + 1); } m = clazz.refOfProperty(props, "position"); if (m.isNull()) { m.assign(trace.getStartPosition() + 1); } ArrayMemory backTrace = new ArrayMemory(); for(CallStackItem el : callStack) { backTrace.add(el.toArray()); } clazz.refOfProperty(props, "trace").assign(backTrace); } } return props; }
expressionCompiler.writePushDup(); expressionCompiler.writePushSmallInt(i); expressionCompiler.writePushCreateTraceInfo(traceInfo.getStartLine(), traceInfo.getStartPosition());
public static Memory error_get_last(Environment env) { SystemMessage err = env.getLastMessage(); if (err == null) return Memory.NULL; ArrayMemory result = new ArrayMemory(); result.refOfIndex("type").assign(err.getType().value); result.refOfIndex("message").assign(err.getMessage()); if (err.getTrace() != null && err.getTrace().trace != null) { result.refOfIndex("file").assign(err.getTrace().trace.getFileName()); result.refOfIndex("line").assign(err.getTrace().trace.getStartLine() + 1); result.refOfIndex("position").assign(err.getTrace().trace.getStartPosition() + 1); } return result.toConstant(); }
public ArrayMemory toArray(boolean provideObject, boolean ignoreArgs){ ArrayMemory el = new ArrayMemory(); if (trace != null) { if (trace.getFile() != null) el.refOfIndex("file").assign(trace.getFileName()); el.refOfIndex("line").assign(trace.getStartLine() + 1); } el.refOfIndex("function").assign(function); if (clazz != null) { el.refOfIndex("class").assign(clazz); el.refOfIndex("type").assign("::"); } if (object != null){ if (provideObject){ el.refOfIndex("object").assign(new ObjectMemory(object)); } el.refOfIndex("type").assign("->"); } if (!ignoreArgs){ el.refOfIndex("args").assign(ArrayMemory.of(args)); } if (trace != null) el.refOfIndex("position").assign(trace.getStartPosition() + 1); return el; }
+ " line: " + (e.getTraceInfo().getStartLine() + test.getSectionLine("FILE") + 2) + ", pos: " + (e.getTraceInfo().getStartPosition() + 1), e.getTraceInfo());
@Test public void testParseError() throws IOException { Throwable ex = null; Tokenizer tokenizer = new Tokenizer(new Context( " 'foobar \n ")); try { tokenizer.nextToken(); } catch (Throwable e){ ex = e; } assertTrue(ex instanceof ParseException); TraceInfo traceInfo = ((ParseException) ex).getTraceInfo(); assertNotNull(traceInfo); assertNull(traceInfo.getContext().getFileName()); assertEquals(1, traceInfo.getStartLine()); assertEquals(1, traceInfo.getEndLine()); assertEquals(1, traceInfo.getStartPosition()); assertEquals(1, traceInfo.getEndPosition()); }