tc39 / eshost

A uniform wrapper around a multitude of ECMAScript hosts. CLI: https://github.com/bterlson/eshost-cli
Other
142 stars 36 forks source link

runtime/jsc: update to use JavaScriptCore's built-in $/$262 #48

Closed rwaldron closed 6 years ago

rwaldron commented 6 years ago

See: https://github.com/WebKit/webkit/blob/aeed7ff2493053fb9ffcc06fedc7e75311bacc8a/Source/JavaScriptCore/jsc.cpp#L574-L604

This enables tests that require $262.agent.*

I'm using var jsc = this["\x24"]; instead of just writing var jsc = $;, or even just extending $ if it exists, because the contents of the files in runtimes/* are not executed exactly as they appear. Each file experiences some amount of "processing" that will change the actual text content that eventually gets prepended to the test262 test source code. The bare minimum change that's applied is replacing all occurrences of $ to $262 (or whatever the shortName property is set to). Unfortunately, that means we cannot rely on the existence of an Identifier $ (or $262) in that code.

bterlson commented 6 years ago

Looks great! Nice work on that "hack", too. Really appreciate the documentation :)

rwaldron commented 6 years ago

Thanks @bterlson!