Using the jsc command-line tool, I have noticed there is no way to load a file other than to evaluate it as JavaScript. It is useful to be able to load a file as text or data, so I have created a patch to add a loadFile(path) function to jsc. The only change is to jsc.cpp, and simply adds the ability to load a file and turn its contents into a JSC string value.
Created attachment 157688 [details] Patch
Would shell functionality help? cat myfile.js | jsc
It wouldn't be relevant, at least not the example you present, since I don't want to eval or load JavaScript in any way. (Rather, it already does that, and I need something else.) I want to load a file and turn the contents of it into a *string* variable. That's what this patch does.
Comment on attachment 157688 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=157688&action=review > Source/JavaScriptCore/ChangeLog:8 > + Added a loadFile function to jsc for file input when testin libraries written in JS. Typo: testin -> testing
Created attachment 205152 [details] Patch
Sorry for the insane delay on this. I've corrected the commit message, this should hopefully be ready to go in.
Comment on attachment 205152 [details] Patch Attachment 205152 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/918471
Comment on attachment 205152 [details] Patch Attachment 205152 [details] did not pass efl-ews (efl): Output: http://webkit-queues.appspot.com/results/857774
Comment on attachment 205152 [details] Patch Attachment 205152 [details] did not pass efl-wk2-ews (efl-wk2): Output: http://webkit-queues.appspot.com/results/884437
Comment on attachment 205152 [details] Patch Attachment 205152 [details] did not pass qt-ews (qt): Output: http://webkit-queues.appspot.com/results/876611
Comment on attachment 205152 [details] Patch Attachment 205152 [details] did not pass qt-wk2-ews (qt-wk2): Output: http://webkit-queues.appspot.com/results/876610
Created attachment 205154 [details] Patch
Fixed a typo from an old data type identifier.
Comment on attachment 205154 [details] Patch Looks good. Please rebase this patch for the changes to throwing exceptions since the patch was originally posted and resubmit.
*** This bug has been marked as a duplicate of bug 125059 ***