comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLAssertFalseBuiltin.java @ 17004:158c9ba66e45

SL: added support for guest language stack traces to SLException; added SLAssertionError.
author Christian Humer <christian.humer@gmail.com>
date Mon, 01 Sep 2014 20:08:18 +0200
parents 8fd42ea95f64
children
comparison
equal deleted inserted replaced
17003:8fd42ea95f64 17004:158c9ba66e45
24 24
25 import com.oracle.truffle.api.*; 25 import com.oracle.truffle.api.*;
26 import com.oracle.truffle.api.dsl.*; 26 import com.oracle.truffle.api.dsl.*;
27 import com.oracle.truffle.api.nodes.*; 27 import com.oracle.truffle.api.nodes.*;
28 import com.oracle.truffle.api.source.*; 28 import com.oracle.truffle.api.source.*;
29 import com.oracle.truffle.sl.*;
29 import com.oracle.truffle.sl.runtime.*; 30 import com.oracle.truffle.sl.runtime.*;
30 31
31 /** 32 /**
32 * Asserts a given value to be <code>false</code> and throws an {@link AssertionError} if the value 33 * Asserts a given value to be <code>false</code> and throws an {@link AssertionError} if the value
33 * was <code>true</code>. 34 * was <code>true</code>.
41 42
42 @Specialization 43 @Specialization
43 public boolean doAssert(boolean value, String message) { 44 public boolean doAssert(boolean value, String message) {
44 if (value) { 45 if (value) {
45 CompilerDirectives.transferToInterpreter(); 46 CompilerDirectives.transferToInterpreter();
46 if (message == null) { 47 throw new SLAssertionError(message == null ? "" : message);
47 throw new AssertionError();
48 } else {
49 throw new AssertionError(message);
50 }
51 } 48 }
52 return value; 49 return value;
53 } 50 }
54 51
55 @Specialization 52 @Specialization