MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / SyntaxError

Class SyntaxError

src/main/java/wyil/lang/WyilFile.java:7275–7330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7273 // ============================================================
7274 public interface Attr {
7275 public static class SyntaxError extends AbstractItem implements Syntactic.Marker {
7276
7277 public SyntaxError(int errcode, Syntactic.Item target) {
7278 super(ATTR_error, BigInteger.valueOf(errcode).toByteArray(), target, new Tuple<>());
7279 }
7280
7281 public SyntaxError(int errcode, Syntactic.Item target, Tuple<Syntactic.Item> context) {
7282 super(ATTR_error, BigInteger.valueOf(errcode).toByteArray(), target, context);
7283 }
7284
7285 @Override
7286 public Syntactic.Item getTarget() {
7287 return operands[0];
7288 }
7289
7290 public Tuple<Syntactic.Item> getContext() {
7291 return (Tuple<Syntactic.Item>) operands[1];
7292 }
7293
7294 /**
7295 * Get the error code associated with this message
7296 *
7297 * @return
7298 */
7299 public int getErrorCode() {
7300 return new BigInteger(getData()).intValue();
7301 }
7302
7303 @Override
7304 public Syntactic.Item clone(Syntactic.Item[] operands) {
7305 return new SyntaxError(getErrorCode(), operands[0], (Tuple<Syntactic.Item>) operands[1]);
7306 }
7307
7308 @Override
7309 public String getMessage() {
7310 // Done
7311 return ErrorMessages.getErrorMessage(getErrorCode(), getContext());
7312 }
7313
7314 @Override
7315 public Trie getSource() {
7316 WyilFile bin = (WyilFile) getTarget().getHeap();
7317 Decl.Unit unit = getTarget().getAncestor(Decl.Unit.class);
7318 String nameStr = unit.getName().toString().replace("::", "/");
7319 return Trie.fromString(nameStr);
7320 }
7321
7322 public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.MANY, Data.TWO, "ATTR_error") {
7323 @SuppressWarnings("unchecked")
7324 @Override
7325 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
7326 int errcode = new BigInteger(data).intValue();
7327 return new SyntaxError(errcode, operands[0], (Tuple<Syntactic.Item>) operands[1]);
7328 }
7329 };
7330 }
7331
7332 public static class StackFrame extends AbstractItem {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected