mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 18:50:08 +00:00
fixed a bug in the Slang b2s word...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0743ead8ef
commit
b14dae9bdf
@ -59,6 +59,11 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.word[builtin=yes] {
|
||||||
|
font-style: italic;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
#stack {
|
#stack {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
@ -69,6 +74,9 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
function stringifySlangCode(code){
|
function stringifySlangCode(code){
|
||||||
|
if(code == null){
|
||||||
|
return code
|
||||||
|
}
|
||||||
if(typeof(code) == typeof('str') && /\s/.test(code)){
|
if(typeof(code) == typeof('str') && /\s/.test(code)){
|
||||||
return '\''+code+'\''
|
return '\''+code+'\''
|
||||||
} else if(code.constructor.name == 'Array'){
|
} else if(code.constructor.name == 'Array'){
|
||||||
@ -163,10 +171,13 @@ function showAvailableWords(){
|
|||||||
})
|
})
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
var code = NAMESPACE[e]
|
var code = NAMESPACE[e]
|
||||||
|
var builtin = 'no'
|
||||||
if(code.constructor.name == 'Array'){
|
if(code.constructor.name == 'Array'){
|
||||||
code = stringifySlangCode(code)
|
code = stringifySlangCode(code)
|
||||||
|
} else if(typeof(code) == typeof(function(){})){
|
||||||
|
builtin = 'yes'
|
||||||
}
|
}
|
||||||
return '<span title="'+code+'">'+e+'</span>'
|
return '<span class="word" builtin="'+builtin+'" title="'+code+'">'+e+'</span>'
|
||||||
})
|
})
|
||||||
.join(', ')
|
.join(', ')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,6 +151,7 @@ var NAMESPACE = {
|
|||||||
// ... [ ... ] -- ... ...
|
// ... [ ... ] -- ... ...
|
||||||
'b2s': function(context){
|
'b2s': function(context){
|
||||||
var c = context.stack.pop()
|
var c = context.stack.pop()
|
||||||
|
c = c === undefined ? [] : c
|
||||||
context.stack.splice.apply(context.stack, [context.stack.length, 0].concat(c))
|
context.stack.splice.apply(context.stack, [context.stack.length, 0].concat(c))
|
||||||
},
|
},
|
||||||
'print': function(context){
|
'print': function(context){
|
||||||
@ -294,6 +295,11 @@ var NAMESPACE = {
|
|||||||
'dup': function(context){
|
'dup': function(context){
|
||||||
return context.stack[context.stack.length-1]
|
return context.stack[context.stack.length-1]
|
||||||
},
|
},
|
||||||
|
// x -- x'
|
||||||
|
// NOTE: this will do a deep copy...
|
||||||
|
'clone': function(context){
|
||||||
|
return JSON.parse(JSON.stringify(context.stack.pop()))
|
||||||
|
},
|
||||||
// x --
|
// x --
|
||||||
'drop': function(context){
|
'drop': function(context){
|
||||||
context.stack.pop()
|
context.stack.pop()
|
||||||
@ -497,6 +503,9 @@ var BOOTSTRAP = [
|
|||||||
'--',
|
'--',
|
||||||
'-- With that out of the way, let\'s start with the bootstrap...',
|
'-- With that out of the way, let\'s start with the bootstrap...',
|
||||||
'--',
|
'--',
|
||||||
|
'-- make a new block instance shorthand...',
|
||||||
|
':: [] [ [ ] clone ]',
|
||||||
|
'',
|
||||||
':: _swap ( x | y -- y | x ) [ 1 1 _swapN ]',
|
':: _swap ( x | y -- y | x ) [ 1 1 _swapN ]',
|
||||||
':: _push ( x | -- | x ) [ 0 _swapN ]',
|
':: _push ( x | -- | x ) [ 0 _swapN ]',
|
||||||
':: _pull ( | x -- x | ) [ 0 swap _swapN ]',
|
':: _pull ( | x -- x | ) [ 0 swap _swapN ]',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user