fixed a bug in the Slang b2s word...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-12-30 06:06:45 +04:00
parent 0743ead8ef
commit b14dae9bdf
2 changed files with 21 additions and 1 deletions

View File

@ -59,6 +59,11 @@
font-family: monospace;
}
.word[builtin=yes] {
font-style: italic;
color: blue;
}
#stack {
opacity: 0.8;
}
@ -69,6 +74,9 @@
<script>
function stringifySlangCode(code){
if(code == null){
return code
}
if(typeof(code) == typeof('str') && /\s/.test(code)){
return '\''+code+'\''
} else if(code.constructor.name == 'Array'){
@ -163,10 +171,13 @@ function showAvailableWords(){
})
.map(function(e){
var code = NAMESPACE[e]
var builtin = 'no'
if(code.constructor.name == 'Array'){
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(', ')
}

View File

@ -151,6 +151,7 @@ var NAMESPACE = {
// ... [ ... ] -- ... ...
'b2s': function(context){
var c = context.stack.pop()
c = c === undefined ? [] : c
context.stack.splice.apply(context.stack, [context.stack.length, 0].concat(c))
},
'print': function(context){
@ -294,6 +295,11 @@ var NAMESPACE = {
'dup': function(context){
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 --
'drop': function(context){
context.stack.pop()
@ -497,6 +503,9 @@ var 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 ]',
':: _push ( x | -- | x ) [ 0 _swapN ]',
':: _pull ( | x -- x | ) [ 0 swap _swapN ]',