diff --git a/lib/compiling/GScompiler.js b/lib/compiling/GScompiler.js index 96f43553..5b6634ae 100644 --- a/lib/compiling/GScompiler.js +++ b/lib/compiling/GScompiler.js @@ -633,6 +633,18 @@ where compile() was called, in untrusted/run.js. } } + start = 0 + const bindmethodpatt = new RegExp('(\\w+)\\.(\\w+)\\s*') + while (true) { // convert all classinstance.classmethod without parens to classinstance.classmethod.bind(classinstance) + m = line.slice(start).match(bindmethodpatt) + if (m === null) break + if (classinstances.indexOf(m[1]) >= 0 && classmethods.indexOf(m[2]) >= 0 && + (start+m.index+m[0].length >= line.length || line[start+m.index+m[0].length] != '(')) { + line = line.slice(0,start+m.index)+line.slice(start+m.index).replace(m[2], m[2]+'.bind('+m[1]+')') + start += m.index+m[0].length+m[1].length+7 + } else start += m.index+m[0].length + } + if (!declaration) { // not function declaration nor class declaration const leftpatt = new RegExp('^(\\w+)\\s*=\\s*') // find p = ..... var left = null, right = line