934 }
935
936 /**
937 * Direct eval
938 *
939 * @param self The scope of eval passed as 'self'
940 * @param str Evaluated code
941 * @param callThis "this" to be passed to the evaluated code
942 * @param location location of the eval call
943 * @param strict is eval called a strict mode code?
944 *
945 * @return the return value of the eval
946 *
947 * This is directly invoked from generated when eval(code) is called in user code
948 */
949 public static Object directEval(final Object self, final Object str, final Object callThis, final Object location, final boolean strict) {
950 if (!(str instanceof String || str instanceof ConsString)) {
951 return str;
952 }
953 final Global global = Global.instanceFrom(self);
954 final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global;
955
956 return global.getContext().eval(scope, str.toString(), callThis, location, strict, true);
957 }
958
959 /**
960 * Global print implementation - Nashorn extension
961 *
962 * @param self scope
963 * @param objects arguments to print
964 *
965 * @return result of print (undefined)
966 */
967 public static Object print(final Object self, final Object... objects) {
968 return Global.instanceFrom(self).printImpl(false, objects);
969 }
970
971 /**
972 * Global println implementation - Nashorn extension
973 *
974 * @param self scope
|
934 }
935
936 /**
937 * Direct eval
938 *
939 * @param self The scope of eval passed as 'self'
940 * @param str Evaluated code
941 * @param callThis "this" to be passed to the evaluated code
942 * @param location location of the eval call
943 * @param strict is eval called a strict mode code?
944 *
945 * @return the return value of the eval
946 *
947 * This is directly invoked from generated when eval(code) is called in user code
948 */
949 public static Object directEval(final Object self, final Object str, final Object callThis, final Object location, final boolean strict) {
950 if (!(str instanceof String || str instanceof ConsString)) {
951 return str;
952 }
953 final Global global = Global.instanceFrom(self);
954 final ScriptObject scope = self instanceof ScriptObject && ((ScriptObject)self).isScope()? (ScriptObject)self : global;
955
956 return global.getContext().eval(scope, str.toString(), callThis, location, strict, true);
957 }
958
959 /**
960 * Global print implementation - Nashorn extension
961 *
962 * @param self scope
963 * @param objects arguments to print
964 *
965 * @return result of print (undefined)
966 */
967 public static Object print(final Object self, final Object... objects) {
968 return Global.instanceFrom(self).printImpl(false, objects);
969 }
970
971 /**
972 * Global println implementation - Nashorn extension
973 *
974 * @param self scope
|