Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
19711:e9e99d8dca54 | 19712:2f5d4df2af90 |
---|---|
865 executeBuilder.string(frame.getLocalName()); | 865 executeBuilder.string(frame.getLocalName()); |
866 } | 866 } |
867 locals.addReferencesTo(executeBuilder); | 867 locals.addReferencesTo(executeBuilder); |
868 executeBuilder.end(); | 868 executeBuilder.end(); |
869 | 869 |
870 boolean hasExecutedUnexpected = executedType != null && !executedType.isGeneric() && !executedType.isVoid(); | |
871 | |
870 CodeTreeBuilder contentBuilder = builder.create(); | 872 CodeTreeBuilder contentBuilder = builder.create(); |
871 contentBuilder.startReturn(); | 873 contentBuilder.startReturn(); |
872 contentBuilder.tree(TypeSystemCodeGenerator.expect(executedType, returnType, executeBuilder.build())); | 874 if (!hasExecutedUnexpected) { |
875 if (executedType == null || executedType.needsCastTo(returnType)) { | |
876 contentBuilder.cast(returnType.getPrimitiveType(), executeBuilder.build()); | |
877 } else { | |
878 contentBuilder.tree(executeBuilder.build()); | |
879 } | |
880 } else { | |
881 contentBuilder.tree(TypeSystemCodeGenerator.expect(executedType, returnType, executeBuilder.build())); | |
882 } | |
873 contentBuilder.end(); | 883 contentBuilder.end(); |
874 // try catch assert if unexpected value is not expected | 884 // try catch assert if unexpected value is not expected |
875 CodeTree content = contentBuilder.build(); | 885 CodeTree content = contentBuilder.build(); |
876 if (!execType.hasUnexpectedValue(context) && !returnType.isGeneric() && !returnType.isVoid()) { | 886 if (!execType.hasUnexpectedValue(context) && hasExecutedUnexpected) { |
877 content = wrapTryCatchUnexpected(content); | 887 content = wrapTryCatchUnexpected(content); |
878 } | 888 } |
879 builder.tree(content); | 889 builder.tree(content); |
880 } | 890 } |
881 | |
882 return method; | 891 return method; |
883 } | 892 } |
884 | 893 |
885 private CodeTree wrapTryCatchUnexpected(CodeTree content) { | 894 private CodeTree wrapTryCatchUnexpected(CodeTree content) { |
886 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); | 895 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); |