larsbrinkhoff / lbForth

Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
GNU General Public License v3.0
418 stars 112 forks source link

Add support for JavaScriptCore. #43

Closed larsbrinkhoff closed 7 years ago

larsbrinkhoff commented 7 years ago

Seems to work quite well, except for one thing: readline doesn't seem to detect EOF when reading from a pipe. So the tests just hang when they reach the end of the input file.

pipcet commented 7 years ago

Hmm. There appears to be no way to distinguish EOF from an empty line in jsc.cpp:

2336    EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
2337    {
2338        Vector<char, 256> line;
2339        int c;
2340        while ((c = getchar()) != EOF) {
2341            // FIXME: Should we also break on \r?
2342            if (c == '\n')
2343                break;
2344            line.append(c);
2345        }
2346        line.append('\0');
2347        return JSValue::encode(jsString(exec, line.data()));
2348    }
larsbrinkhoff commented 7 years ago

Merged without the tests.