Refactor jseval words.
This commit is contained in:
@ -16,6 +16,11 @@ vocabulary web web definitions
|
|||||||
|
|
||||||
: jseval! ( a n index -- ) 0 call ;
|
: jseval! ( a n index -- ) 0 call ;
|
||||||
|
|
||||||
|
1 value jsslot
|
||||||
|
: JSWORD ( "name" )
|
||||||
|
create jsslot jseval! jsslot , 1 +to jsslot
|
||||||
|
does> @ call ;
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
var n = i32[sp>>2]; sp -= 4;
|
var n = i32[sp>>2]; sp -= 4;
|
||||||
@ -24,8 +29,7 @@ r|
|
|||||||
eval(text);
|
eval(text);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 1 jseval!
|
| JSWORD jseval ( a n -- )
|
||||||
: jseval ( a n -- ) 1 call ;
|
|
||||||
|
|
||||||
r~
|
r~
|
||||||
globalObj.ueforth = context;
|
globalObj.ueforth = context;
|
||||||
@ -509,8 +513,8 @@ r|
|
|||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 2 jseval!
|
| JSWORD web-type-raw ( a n -- yield? )
|
||||||
: web-type ( a n -- ) 2 call if yield then ;
|
: web-type ( a n -- ) web-type-raw if yield then ;
|
||||||
' web-type is type
|
' web-type is type
|
||||||
|
|
||||||
r|
|
r|
|
||||||
@ -530,8 +534,8 @@ r|
|
|||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 3 jseval!
|
| JSWORD web-key-raw ( -- n )
|
||||||
: web-key ( -- n ) begin yield 3 call dup if exit then drop again ;
|
: web-key ( -- n ) begin yield web-key-raw dup if exit then drop again ;
|
||||||
' web-key is key
|
' web-key is key
|
||||||
|
|
||||||
r|
|
r|
|
||||||
@ -544,8 +548,8 @@ r|
|
|||||||
sp += 4; i32[sp>>2] = context.inbuffer.length ? -1 : 0;
|
sp += 4; i32[sp>>2] = context.inbuffer.length ? -1 : 0;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 4 jseval!
|
| JSWORD web-key?-raw ( -- f )
|
||||||
: web-key? ( -- f ) yield 4 call ;
|
: web-key? ( -- f ) yield web-key?-raw ;
|
||||||
' web-key? is key?
|
' web-key? is key?
|
||||||
|
|
||||||
r|
|
r|
|
||||||
@ -558,8 +562,7 @@ r|
|
|||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 5 jseval!
|
| JSWORD terminate ( n -- )
|
||||||
: terminate ( n -- ) 5 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -570,8 +573,7 @@ r|
|
|||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 6 jseval!
|
| JSWORD shouldEcho? ( -- f )
|
||||||
: shouldEcho? 6 call ;
|
|
||||||
shouldEcho? echo !
|
shouldEcho? echo !
|
||||||
|
|
||||||
r|
|
r|
|
||||||
@ -583,8 +585,7 @@ r|
|
|||||||
context.setMode(mode);
|
context.setMode(mode);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 7 jseval!
|
| JSWORD grmode ( mode -- )
|
||||||
: grmode ( mode -- ) 7 call ;
|
|
||||||
: gr 1 grmode ;
|
: gr 1 grmode ;
|
||||||
: text 0 grmode ;
|
: text 0 grmode ;
|
||||||
|
|
||||||
@ -607,8 +608,7 @@ r|
|
|||||||
context.ctx.fillRect(x, y, w, h);
|
context.ctx.fillRect(x, y, w, h);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 8 jseval!
|
| JSWORD rawbox ( x y w h col -- )
|
||||||
: rawbox ( x y w h col -- ) 8 call ;
|
|
||||||
$ffffff value color
|
$ffffff value color
|
||||||
: box ( x y w h -- ) color rawbox ;
|
: box ( x y w h -- ) color rawbox ;
|
||||||
|
|
||||||
@ -623,8 +623,7 @@ r|
|
|||||||
context.canvas.height = h;
|
context.canvas.height = h;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 9 jseval!
|
| JSWORD window ( w h -- )
|
||||||
: window ( w h -- ) 9 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -637,8 +636,7 @@ r|
|
|||||||
sp += 4; i32[sp>>2] = context.height;
|
sp += 4; i32[sp>>2] = context.height;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 10 jseval!
|
| JSWORD viewport@ ( -- w h )
|
||||||
: viewport@ ( -- w h ) 10 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -652,24 +650,21 @@ r|
|
|||||||
context.Resize();
|
context.Resize();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 11 jseval!
|
| JSWORD textRatios ( tf mp -- )
|
||||||
: textRatios ( tf mp -- ) ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
sp += 4; i32[sp>>2] = context.mobile;
|
sp += 4; i32[sp>>2] = context.mobile;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 12 jseval!
|
| JSWORD mobile ( -- f )
|
||||||
: mobile ( -- f ) 12 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
sp += 4; i32[sp>>2] = context.KEYBOARD_HEIGHT;
|
sp += 4; i32[sp>>2] = context.KEYBOARD_HEIGHT;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 13 jseval!
|
| JSWORD keys-height ( -- n )
|
||||||
: keys-height ( -- n ) 13 call ;
|
|
||||||
|
|
||||||
: show-text ( f -- )
|
: show-text ( f -- )
|
||||||
if
|
if
|
||||||
@ -688,8 +683,7 @@ r|
|
|||||||
context.ctx.translate(x, y);
|
context.ctx.translate(x, y);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 14 jseval!
|
| JSWORD translate ( x y )
|
||||||
: translate ( x y ) 14 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -702,8 +696,7 @@ r|
|
|||||||
context.ctx.scale(x / d, y / d);
|
context.ctx.scale(x / d, y / d);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 15 jseval!
|
| JSWORD scale ( x y div )
|
||||||
: scale ( x y div ) 15 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -715,8 +708,7 @@ r|
|
|||||||
context.ctx.rotate(Math.PI * 2 * angle / d);
|
context.ctx.rotate(Math.PI * 2 * angle / d);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 16 jseval!
|
| JSWORD rotate ( angle div )
|
||||||
: rotate ( angle div ) 16 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -726,8 +718,7 @@ r|
|
|||||||
context.ctx.save();
|
context.ctx.save();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 17 jseval!
|
| JSWORD gpush
|
||||||
: gpush 17 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -737,8 +728,7 @@ r|
|
|||||||
context.ctx.restore();
|
context.ctx.restore();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 18 jseval!
|
| JSWORD gpop
|
||||||
: gpop 18 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -749,8 +739,7 @@ r|
|
|||||||
context.canvas.style.imageRendering = f ? '' : 'pixelated';
|
context.canvas.style.imageRendering = f ? '' : 'pixelated';
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 19 jseval!
|
| JSWORD smooth ( f -- )
|
||||||
: smooth ( f -- ) 19 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -771,8 +760,7 @@ r|
|
|||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 20 jseval!
|
| JSWORD setItem ( a n a n sess -- )
|
||||||
: setItem ( a n a n sess -- ) 20 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -799,8 +787,7 @@ r|
|
|||||||
sp += 4; i32[sp>>2] = data.length;
|
sp += 4; i32[sp>>2] = data.length;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 21 jseval!
|
| JSWORD getItem ( a n a n sess -- n )
|
||||||
: getItem ( a n a n sess -- n ) 21 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -827,8 +814,7 @@ r|
|
|||||||
sp += 4; i32[sp>>2] = data.length;
|
sp += 4; i32[sp>>2] = data.length;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 22 jseval!
|
| JSWORD getKey ( a n sess -- n )
|
||||||
: getKey ( a n sess -- n ) 22 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -845,8 +831,7 @@ r|
|
|||||||
sp += 4; i32[sp>>2] = len;
|
sp += 4; i32[sp>>2] = len;
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 23 jseval!
|
| JSWORD keyCount ( sess -- n )
|
||||||
: keyCount ( sess -- n ) 23 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -854,8 +839,7 @@ r|
|
|||||||
context.ReleaseHandle(handle);
|
context.ReleaseHandle(handle);
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 24 jseval!
|
| JSWORD release ( handle -- )
|
||||||
: release ( handle -- ) 24 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -864,8 +848,7 @@ r|
|
|||||||
context.handles[i] = new AudioContext();
|
context.handles[i] = new AudioContext();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 25 jseval!
|
| JSWORD newAudioContext ( -- h )
|
||||||
: newAudioContext ( -- h ) 25 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -875,8 +858,7 @@ r|
|
|||||||
context.handles[i] = context.handles[audio_ctx].createOscillator();
|
context.handles[i] = context.handles[audio_ctx].createOscillator();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 26 jseval!
|
| JSWORD createOscillator ( h -- h )
|
||||||
: createOscillator ( h -- h ) 26 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -886,8 +868,7 @@ r|
|
|||||||
context.handles[i] = context.handles[audio_ctx].createGain();
|
context.handles[i] = context.handles[audio_ctx].createGain();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 27 jseval!
|
| JSWORD createGain ( h -- h )
|
||||||
: createGain ( h -- h ) 27 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -897,8 +878,7 @@ r|
|
|||||||
context.handles[i] = context.handles[audio_ctx].createBiquadFilter();
|
context.handles[i] = context.handles[audio_ctx].createBiquadFilter();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 28 jseval!
|
| JSWORD createBiquadFilter ( h -- h )
|
||||||
: createBiquadFilter ( h -- h ) 28 call ;
|
|
||||||
|
|
||||||
r|
|
r|
|
||||||
(function(sp) {
|
(function(sp) {
|
||||||
@ -908,8 +888,7 @@ r|
|
|||||||
context.handles[i] = context.handles[audio_ctx].createBufferSource();
|
context.handles[i] = context.handles[audio_ctx].createBufferSource();
|
||||||
return sp;
|
return sp;
|
||||||
})
|
})
|
||||||
| 29 jseval!
|
| JSWORD createBufferSource ( h -- h )
|
||||||
: createBufferSource ( h -- h ) 29 call ;
|
|
||||||
|
|
||||||
forth definitions web
|
forth definitions web
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user