Shows text is page.

This commit is contained in:
Brad Nelson
2022-07-14 15:15:14 -07:00
parent 9d79b26e9e
commit c07be3978a
2 changed files with 41 additions and 10 deletions

View File

@ -19,7 +19,43 @@ forth definitions internals
( Bring a forth to the top of the vocabulary. )
: ok ." uEforth" raw-ok ;
: web-type 0 call ; ' web-type is type
: jseval! ( a n index -- ) 0 call ;
r|
(function(sp) {
var n = i32[sp>>2]; sp -= 4;
var a = i32[sp>>2]; sp -= 4;
var text = GetString(a, n);
eval(text);
return sp;
})
| 2 jseval!
: jseval ( a n -- ) 2 call ;
r|
if (!globalObj['write']) {
var console = document.createElement('pre');
console.id = 'console';
document.body.appendChild(console);
}
| jseval
r|
(function(sp) {
var n = i32[sp>>2]; sp -= 4;
var a = i32[sp>>2]; sp -= 4;
var text = GetString(a, n);
if (globalObj['write']) {
write(text);
} else {
var console = document.getElementById('console');
console.innerText += text.replace(/[\r]/g, '');
}
return sp;
})
| 1 jseval!
: web-type 1 call ; ' web-type is type
: web-key yield 0 ; ' web-key is key
: web-key? yield 0 ; ' web-key? is key?

View File

@ -36,20 +36,15 @@ var u16 = new Uint16Array(heap);
var u8 = new Uint8Array(heap);
var builtins = [];
var opcodes = {};
var objects = [Type, Eval];
var objects = [SetEval];
{{sys}}
function Type(sp) {
function SetEval(sp) {
var index = i32[sp>>2]; sp -= 4;
var n = i32[sp>>2]; sp -= 4;
var a = i32[sp>>2]; sp -= 4;
console.log(GetString(a, n));
}
function Eval(sp) {
var n = i32[sp>>2]; sp -= 4;
var a = i32[sp>>2]; sp -= 4;
eval(GetString(a, n));
objects[index] = eval(GetString(a, n));
}
function Call(sp) {