Skip to content

Commit 890d0b3

Browse files
committed
Add get_dirname and fix toBoolean
1 parent 261c2a1 commit 890d0b3

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.DS_Store

10 KB
Binary file not shown.

bin/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if (process.argv[2] && process.argv[2].indexOf('.py') !== -1) {
9090
if (filename.startsWith(file + '.')) fs.copyFileSync(path.join(directory, filename), path.join(process.cwd(), filename));
9191
}
9292
try {
93-
fs.appendFileSync(path.join(process.cwd(), file + '.js' ), '\n' + deserialize_rpython_json.toString() + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;');
93+
fs.appendFileSync(path.join(process.cwd(), file + '.js' ), '\n' + deserialize_rpython_json.toString() + '\nModule.wasmMemory = wasmMemory;\nvar rpyGlobalArg = {"Module": Module, "deserialize_rpython_json": deserialize_rpython_json, "get_dirname": function () {return __dirname;}};\nrpyGlobalArg.global = rpyGlobalArg;\n if (typeof window !== "undefined") rpyGlobalArg.window = window;\n if (typeof require !== "undefined") rpyGlobalArg.require = require;\n if (typeof self !== "undefined") rpyGlobalArg.self = self;');
9494
if (source_flag) {
9595
var source_map = JSON.parse(require('fs').readFileSync(path.join(directory, file + '.wasm.map')));
9696
source_map.sources.forEach(function (filename, index) {

javascript/emscripten.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,12 @@ def toBoolean(self):
893893
self._update()
894894
if self.type == 'boolean':
895895
return True if 'true' == self.toString() else False
896-
return True if 'true' == get_boolean(self.variable) else False
896+
#return True if 'true' == get_boolean(self.variable) else False
897+
elif self.type in ['array', 'object']: return True
898+
elif self.type == 'string': return self['length'].toBoolean()
899+
elif self.type == 'number': return self.toInteger() != 0
900+
elif self.type in ['null', 'undefined']: return False
901+
return True
897902

898903
def toBool(self): return self.toBoolean()
899904

0 commit comments

Comments
 (0)