MCPcopy Index your code
hub / github.com/antlr/codebuff / STRuntimeMessage

Class STRuntimeMessage

output/java8/1.4.17/STRuntimeMessage.java:36–107  ·  view source on GitHub ↗

Used to track errors that occur in the ST interpreter.

Source from the content-addressed store, hash-verified

34
35
36public class STRuntimeMessage extends STMessage {
37 /** Which interpreter was executing? If {@code null}, can be IO error or
38 * bad URL etc...
39 */
40 final Interpreter interp;
41 /** Where error occurred in bytecode memory. */
42 public final int ip;
43 public final InstanceScope scope;
44 //List<ST> enclosingStack;
45
46 public STRuntimeMessage(Interpreter interp, ErrorType error, int ip) {
47 this(interp, error, ip, null);
48 }
49 public STRuntimeMessage(Interpreter interp, ErrorType error, int ip, InstanceScope scope) {
50 this(interp, error, ip, scope, null);
51 }
52 public STRuntimeMessage(Interpreter interp, ErrorType error, int ip, InstanceScope scope, Object arg) {
53 this(interp, error, ip, scope, null, arg, null);
54 }
55 public STRuntimeMessage(Interpreter interp,
56 ErrorType error,
57 int ip,
58 InstanceScope scope,
59 Throwable e, Object arg) {
60 this(interp, error, ip, scope, e, arg, null);
61 }
62 public STRuntimeMessage(Interpreter interp,
63 ErrorType error,
64 int ip,
65 InstanceScope scope,
66 Throwable e,
67 Object arg, Object arg2) {
68 this(interp, error, ip, scope, e, arg, arg2, null);
69 }
70 public STRuntimeMessage(Interpreter interp, ErrorType error, int ip, InstanceScope scope, Throwable e, Object arg, Object arg2, Object arg3) {
71 super(error, scope!=null ? scope.st : null, e, arg, arg2, arg3);
72 this.interp = interp;
73 this.ip = ip;
74 this.scope = scope;
75 }
76
77 /** Given an IP (code location), get it's range in source template then
78 * return it's template line:col.
79 */
80
81 public String getSourceLocation() {
82 if ( ip <0 || self==null || self.impl==null ) return null;
83 Interval I = self.impl.sourceMap[ip];
84 if ( I==null ) return null;
85 // get left edge and get line/col
86 int i = I.a;
87 Coordinate loc = Misc.getLineCharPosition(self.impl.template, i);
88 return loc.toString();
89 }
90
91 @Override
92 public String toString() {
93 StringBuilder buf = new StringBuilder();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected