Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java @ 19712:2f5d4df2af90
Truffle-DSL: fixed implementation of execute methods without unexpected value for null values.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 09 Mar 2015 00:41:43 +0100 |
parents | e9e99d8dca54 |
children | d03352ba2efb |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java Mon Mar 09 00:41:42 2015 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java Mon Mar 09 00:41:43 2015 +0100 @@ -867,18 +867,27 @@ locals.addReferencesTo(executeBuilder); executeBuilder.end(); + boolean hasExecutedUnexpected = executedType != null && !executedType.isGeneric() && !executedType.isVoid(); + CodeTreeBuilder contentBuilder = builder.create(); contentBuilder.startReturn(); - contentBuilder.tree(TypeSystemCodeGenerator.expect(executedType, returnType, executeBuilder.build())); + if (!hasExecutedUnexpected) { + if (executedType == null || executedType.needsCastTo(returnType)) { + contentBuilder.cast(returnType.getPrimitiveType(), executeBuilder.build()); + } else { + contentBuilder.tree(executeBuilder.build()); + } + } else { + contentBuilder.tree(TypeSystemCodeGenerator.expect(executedType, returnType, executeBuilder.build())); + } contentBuilder.end(); // try catch assert if unexpected value is not expected CodeTree content = contentBuilder.build(); - if (!execType.hasUnexpectedValue(context) && !returnType.isGeneric() && !returnType.isVoid()) { + if (!execType.hasUnexpectedValue(context) && hasExecutedUnexpected) { content = wrapTryCatchUnexpected(content); } builder.tree(content); } - return method; }