Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/compiling/GScompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down