Skip to content

Commit

Permalink
Expose built-in objects defined in ECMAScript5
Browse files Browse the repository at this point in the history
  • Loading branch information
devast8a committed Jan 6, 2014
1 parent 7598281 commit 0c2c306
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/aether.coffee
Expand Up @@ -168,7 +168,30 @@ module.exports = class Aether
# Return a ready-to-execute, instrumented function from the purified code
# Because JS_WALA normalizes it to define a wrapper function on this, we need to run the wrapper to get our real function out.
wrapper = new Function ['_aether'], @pure
dummyContext = {Math: Math} # TODO: put real globals in
globals = [
# Other
'eval',

# Math related
'NaN', 'Infinity', 'undefined', 'parseInt', 'parseFloat', 'isNaN', 'isFinite',

# URI related
'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent',

# Built-in objects
'Object', 'Function', 'Array', 'String', 'Boolean', 'Number', 'Date', 'RegExp', 'Math', 'JSON',

# Error Objects
'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError'
]

dummyContext = {}

globalRef = global ? window

for name in globals
dummyContext[name] = globalRef[name]

wrapper.call dummyContext, @
dummyContext[@options.functionName or 'foo']

Expand Down

0 comments on commit 0c2c306

Please sign in to comment.