-
Notifications
You must be signed in to change notification settings - Fork 0
/
badtest01.js
52 lines (45 loc) · 1.32 KB
/
badtest01.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* this may be misguided and thus should be dumped...
*
// a new more flexible version of "defMacro"
defTestMacro( intree, intree[ 0 ] && intree[ 0 ].value == 'defMacro' ) {
intree.shift(); // defMacro
var macroname = intree.shift();
var argparens = intree.shift();
var curlybody = intree.shift();
var stringname = JaM.it( '(string)', "'" + macroname.value + "'" );
var arglist = argparens[1];
var body = curlybody[1];
//console.log( "arglist: %o", JaM.strtree( arglist ) );
//console.log( "body after: %o", JaM.strtree( body ) );
var mtree = JaM.genSym();
var margparens = JaM.genSym();
var collectparams = [];
var argname;
for( var i = 0; i < arglist.length; ++i ) {
if( arglist[ i ][ 0 ].value == 'block' && arglist[ i ][ 1 ].value == ':' ) {
argname = arglist[ i ][ 2 ];
collectparams.push( {{
var #argname = (#mtree.shift())[ 1 ];
}} );
}
else {
argname = arglist[ i ][ 0 ];
collectparams.push( {{
var #argname = #margparens[1].shift();
}} );
}
}
intree.unshift( {{
defTestMacro( #mtree, #mtree[ 0 ] && #mtree[ 0 ].value == #stringname ) {
#mtree.shift(); // macroname
var #margparens = #mtree.shift();
#collectparams
#mtree.unshift(
(function(){
#body
})()
);
}
}} );
}
*/