comparison truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java @ 22196:364e3f024643

Java objects passed into globalSymbol should be converted into something that Truffle languages can understand - e.g. TruffleObject instances.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Fri, 25 Sep 2015 14:06:44 +0200
parents 7afb5e5cc3ca
children 7abcbeb12d08
comparison
equal deleted inserted replaced
22195:09d91119929f 22196:364e3f024643
291 * <code>TruffleObject</code> for mutual inter-operability 291 * <code>TruffleObject</code> for mutual inter-operability
292 * @return instance of this builder 292 * @return instance of this builder
293 * @see PolyglotEngine#findGlobalSymbol(java.lang.String) 293 * @see PolyglotEngine#findGlobalSymbol(java.lang.String)
294 */ 294 */
295 public Builder globalSymbol(String name, Object obj) { 295 public Builder globalSymbol(String name, Object obj) {
296 globals.put(name, obj); 296 final Object truffleReady;
297 if (obj instanceof Number || obj instanceof String || obj instanceof Character || obj instanceof Boolean) {
298 truffleReady = obj;
299 } else {
300 truffleReady = JavaInterop.asTruffleObject(obj);
301 }
302 globals.put(name, truffleReady);
297 return this; 303 return this;
298 } 304 }
299 305
300 /** 306 /**
301 * Provides own executor for running {@link PolyglotEngine} scripts. By default 307 * Provides own executor for running {@link PolyglotEngine} scripts. By default