nendo 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/benchmark/benchmark.nnd +62 -3
- data/benchmark/nendo_benchmark_code.nnd +22 -0
- data/benchmark/ruby_benchmark_code.rb +9 -2
- data/lib/debug/syslog.nndc +6 -14
- data/lib/init.nnd +7 -5
- data/lib/init.nndc +6666 -13966
- data/lib/nendo.rb +144 -97
- data/lib/nendo/test.nndc +279 -511
- data/lib/rfc/json.nndc +79 -167
- data/lib/srfi-1.nndc +3004 -6516
- data/lib/srfi-2.nndc +314 -914
- data/lib/srfi-26.nndc +1094 -2742
- data/lib/text/html-lite.nndc +465 -897
- data/lib/text/tree.nndc +27 -67
- data/lib/util/combinations.nndc +1253 -3317
- data/lib/util/list.nnd +0 -4
- data/lib/util/list.nndc +1411 -3419
- data/lib/util/match.nndc +21344 -61648
- data/test/nendo-util-test.nnd +5 -13
- data/test/nendo_spec.rb +134 -13
- metadata +3 -3
data/lib/nendo.rb
CHANGED
@@ -229,14 +229,6 @@ module Nendo
|
|
229
229
|
@renamedSymbol
|
230
230
|
end
|
231
231
|
|
232
|
-
# def ==(other_sc)
|
233
|
-
# if other_sc.is_a? SyntacticClosure
|
234
|
-
# @renamedSymbol == other_sc.renamedSymbol
|
235
|
-
# else
|
236
|
-
# false
|
237
|
-
# end
|
238
|
-
# end
|
239
|
-
|
240
232
|
def sourcefile() "dynamic S-expression ( no source )" end
|
241
233
|
def lineno() 1 end
|
242
234
|
|
@@ -287,13 +279,13 @@ module Nendo
|
|
287
279
|
end
|
288
280
|
|
289
281
|
class DelayedCallPacket
|
290
|
-
def initialize(
|
291
|
-
@origname = _origname
|
282
|
+
def initialize( _rubysym, _origname, _pred, _args )
|
292
283
|
@rubysym = _rubysym
|
284
|
+
@origname = _origname
|
293
285
|
@pred = _pred
|
294
286
|
@args = _args
|
295
287
|
end
|
296
|
-
attr_reader :
|
288
|
+
attr_reader :rubysym, :origname, :pred, :args
|
297
289
|
end
|
298
290
|
|
299
291
|
class Token
|
@@ -892,7 +884,12 @@ module Nendo
|
|
892
884
|
(a === b)
|
893
885
|
end
|
894
886
|
end
|
895
|
-
|
887
|
+
|
888
|
+
def __PLMARK_ARGS0( ) 0 end
|
889
|
+
def __PLMARK_ARGS1( a ) a end
|
890
|
+
def __PLMARK_ARGS2( a, b ) a + b end
|
891
|
+
def __PLMARK_ARGS3( a, b, c ) a + b + c end
|
892
|
+
|
896
893
|
def __PLMARK( *args )
|
897
894
|
arr = args[0].to_arr
|
898
895
|
case args[0].length
|
@@ -900,7 +897,7 @@ module Nendo
|
|
900
897
|
0
|
901
898
|
else
|
902
899
|
__assertFlat( arr )
|
903
|
-
arr.each { |x|
|
900
|
+
arr.each { |x|
|
904
901
|
if not (_number_QUMARK(x) or _string_QUMARK(x))
|
905
902
|
##arr.each { |v| STDERR.printf( "__PLMARK: %s\n", v ) }
|
906
903
|
raise TypeError, sprintf( "Error: arg %s is [%s] type",x ,x.class )
|
@@ -914,7 +911,12 @@ module Nendo
|
|
914
911
|
end
|
915
912
|
end
|
916
913
|
end
|
917
|
-
|
914
|
+
|
915
|
+
def __ASMARK_ARGS0( ) 1 end
|
916
|
+
def __ASMARK_ARGS1( a ) a end
|
917
|
+
def __ASMARK_ARGS2( a, b ) a * b end
|
918
|
+
def __ASMARK_ARGS3( a, b, c ) a * b * c end
|
919
|
+
|
918
920
|
def __ASMARK( *args )
|
919
921
|
arr = args[0].to_arr
|
920
922
|
case args[0].length
|
@@ -935,7 +937,12 @@ module Nendo
|
|
935
937
|
end
|
936
938
|
end
|
937
939
|
end
|
938
|
-
|
940
|
+
|
941
|
+
def __MIMARK_ARGS0( ) 0 end
|
942
|
+
def __MIMARK_ARGS1( a ) -a end
|
943
|
+
def __MIMARK_ARGS2( a, b ) a - b end
|
944
|
+
def __MIMARK_ARGS3( a, b, c ) a - b - c end
|
945
|
+
|
939
946
|
def __MIMARK( first, *rest )
|
940
947
|
raise TypeError if not _number_QUMARK(first)
|
941
948
|
rest = rest[0].to_arr
|
@@ -946,22 +953,22 @@ module Nendo
|
|
946
953
|
rest.inject(first){|x,y| x-y}
|
947
954
|
end
|
948
955
|
end
|
949
|
-
|
956
|
+
|
950
957
|
def __SLMARK( first, *rest )
|
951
958
|
raise TypeError if not _number_QUMARK(first)
|
952
959
|
rest = rest[0].to_arr
|
953
960
|
__assertFlat( rest )
|
954
|
-
if 0 == rest.length
|
961
|
+
if 0 == rest.length
|
955
962
|
1 / first
|
956
963
|
else
|
957
964
|
rest.inject(first){|x,y| x/y}
|
958
965
|
end
|
959
966
|
end
|
960
|
-
|
967
|
+
|
961
968
|
def __PAMARK( first, *rest )
|
962
969
|
_modulo( first, *rest )
|
963
970
|
end
|
964
|
-
|
971
|
+
|
965
972
|
def _quotient( first, second )
|
966
973
|
raise TypeError if not _number_QUMARK(first)
|
967
974
|
raise TypeError if not _number_QUMARK(second)
|
@@ -973,23 +980,23 @@ module Nendo
|
|
973
980
|
raise TypeError if not _number_QUMARK(second)
|
974
981
|
first - _quotient( first, second ) * second
|
975
982
|
end
|
976
|
-
|
983
|
+
|
977
984
|
def _modulo( first, *rest )
|
978
985
|
raise TypeError if not _number_QUMARK(first)
|
979
986
|
rest = rest[0].to_arr
|
980
987
|
__assertFlat( rest )
|
981
|
-
if 0 == rest.length
|
988
|
+
if 0 == rest.length
|
982
989
|
1 % first
|
983
990
|
else
|
984
991
|
rest.inject(first){|x,y| x%y}
|
985
992
|
end
|
986
993
|
end
|
987
|
-
|
994
|
+
|
988
995
|
def _not( arg )
|
989
996
|
arg = false if Nil == arg.class
|
990
997
|
not arg
|
991
998
|
end
|
992
|
-
|
999
|
+
|
993
1000
|
def _cons( first, second )
|
994
1001
|
if first.is_a? Nil
|
995
1002
|
first = Cell.new
|
@@ -1036,19 +1043,19 @@ module Nendo
|
|
1036
1043
|
Kernel::exit(arr[0])
|
1037
1044
|
end
|
1038
1045
|
end
|
1039
|
-
|
1046
|
+
|
1040
1047
|
def _print( format, *rest )
|
1041
1048
|
print( format, *(rest[0].to_arr) )
|
1042
1049
|
end
|
1043
|
-
|
1050
|
+
|
1044
1051
|
def _printf( format, *rest )
|
1045
1052
|
Kernel::printf( format, *(rest[0].to_arr) )
|
1046
1053
|
end
|
1047
|
-
|
1054
|
+
|
1048
1055
|
def _sprintf( format, *rest )
|
1049
1056
|
Kernel::sprintf( format, *(rest[0].to_arr) )
|
1050
1057
|
end
|
1051
|
-
|
1058
|
+
|
1052
1059
|
def _null_QUMARK( arg )
|
1053
1060
|
if Nil == arg.class
|
1054
1061
|
true
|
@@ -1119,14 +1126,14 @@ module Nendo
|
|
1119
1126
|
nil
|
1120
1127
|
end
|
1121
1128
|
end
|
1122
|
-
def _pair_QUMARK( arg )
|
1129
|
+
def _pair_QUMARK( arg )
|
1123
1130
|
if _null_QUMARK( arg )
|
1124
1131
|
false
|
1125
1132
|
else
|
1126
1133
|
(Cell == arg.class)
|
1127
1134
|
end
|
1128
1135
|
end
|
1129
|
-
def __PAMARKlist_QUMARK( arg )
|
1136
|
+
def __PAMARKlist_QUMARK( arg )
|
1130
1137
|
if _pair_QUMARK( arg )
|
1131
1138
|
(not arg.lastAtom) and (1 <= arg.to_arr.size) # it means proper list?
|
1132
1139
|
else
|
@@ -1219,19 +1226,19 @@ module Nendo
|
|
1219
1226
|
end until s[2]
|
1220
1227
|
ret
|
1221
1228
|
end
|
1222
|
-
|
1229
|
+
|
1223
1230
|
def _apply1( first, arg )
|
1224
|
-
trampCall( callProcedure( "(apply1 genereate func)", first, arg.to_arr ))
|
1231
|
+
trampCall( callProcedure( nil, "(apply1 genereate func)", first, arg.to_arr ))
|
1225
1232
|
end
|
1226
|
-
|
1233
|
+
|
1227
1234
|
def _global_MIMARKvariables
|
1228
1235
|
self.instance_variables.select { |x|
|
1229
1236
|
x.match( /^[@]_[_a-zA-Z]/ )
|
1230
|
-
}.map{ |name|
|
1237
|
+
}.map{ |name|
|
1231
1238
|
self.toLispSymbol( name[1..-1] ).intern
|
1232
1239
|
}.to_list
|
1233
1240
|
end
|
1234
|
-
|
1241
|
+
|
1235
1242
|
def _make_MIMARKvalues( lst )
|
1236
1243
|
if _pair_QUMARK( lst )
|
1237
1244
|
LispValues.new( lst.to_arr )
|
@@ -1241,9 +1248,9 @@ module Nendo
|
|
1241
1248
|
raise ArgumentError, "Error: make-values expects a list argument."
|
1242
1249
|
end
|
1243
1250
|
end
|
1244
|
-
|
1251
|
+
|
1245
1252
|
def _values_QUMARK( arg ) arg.is_a? LispValues end
|
1246
|
-
|
1253
|
+
|
1247
1254
|
def _values_MIMARKvalues( arg )
|
1248
1255
|
if _values_QUMARK( arg )
|
1249
1256
|
arg.values.to_list
|
@@ -1251,7 +1258,7 @@ module Nendo
|
|
1251
1258
|
raise TypeError, "Error: values-values expects only LispValues object."
|
1252
1259
|
end
|
1253
1260
|
end
|
1254
|
-
|
1261
|
+
|
1255
1262
|
def _make_MIMARKkeyword( arg )
|
1256
1263
|
if _symbol_QUMARK( arg ) or _string_QUMARK( arg )
|
1257
1264
|
LispKeyword.new( arg.to_s )
|
@@ -1259,7 +1266,7 @@ module Nendo
|
|
1259
1266
|
raise TypeError, "Error: make-keyword expects symbol or string object."
|
1260
1267
|
end
|
1261
1268
|
end
|
1262
|
-
|
1269
|
+
|
1263
1270
|
def _keyword_MIMARK_GTMARKstring( arg )
|
1264
1271
|
if _keyword_QUMARK( arg )
|
1265
1272
|
arg.key.to_s
|
@@ -1267,7 +1274,7 @@ module Nendo
|
|
1267
1274
|
raise TypeError, "Error: keyword->string expects only keyword object."
|
1268
1275
|
end
|
1269
1276
|
end
|
1270
|
-
|
1277
|
+
|
1271
1278
|
def _hash_MIMARKtable_MIMARKget( h, key, *args )
|
1272
1279
|
if h.has_key?(key)
|
1273
1280
|
h[key]
|
@@ -1280,7 +1287,7 @@ module Nendo
|
|
1280
1287
|
end
|
1281
1288
|
end
|
1282
1289
|
end
|
1283
|
-
|
1290
|
+
|
1284
1291
|
def _hash_MIMARKtable_MIMARKput_EXMARK( h, key, value )
|
1285
1292
|
h[key] = value
|
1286
1293
|
end
|
@@ -1289,20 +1296,20 @@ module Nendo
|
|
1289
1296
|
# don't use h.has_key(k), because has_key method undefined on some database bindings. (e.g. KyotoCabinet)
|
1290
1297
|
h[key] ? true : false
|
1291
1298
|
end
|
1292
|
-
|
1299
|
+
|
1293
1300
|
# backtrace expects this format "filename:lineno: place message ". e.g. "init.nnd:10: in aaa macro.".
|
1294
1301
|
def _raise( exception, message, backtrace )
|
1295
1302
|
raise exception, message, [ backtrace ]
|
1296
1303
|
end
|
1297
|
-
|
1304
|
+
|
1298
1305
|
def __ASMARKLINE_ASMARK()
|
1299
1306
|
@lastLineno
|
1300
1307
|
end
|
1301
|
-
|
1308
|
+
|
1302
1309
|
def __ASMARKFILE_ASMARK()
|
1303
1310
|
@lastSourcefile
|
1304
1311
|
end
|
1305
|
-
|
1312
|
+
|
1306
1313
|
def _vector_MIMARKset_EXMARK( v, index, value )
|
1307
1314
|
if !(v.is_a? Array)
|
1308
1315
|
raise TypeError, "Error: vector-set! requires Array as argument v(Lisp's vector).\n"
|
@@ -1314,8 +1321,8 @@ module Nendo
|
|
1314
1321
|
end
|
1315
1322
|
|
1316
1323
|
end
|
1317
|
-
|
1318
|
-
|
1324
|
+
|
1325
|
+
|
1319
1326
|
# Translate S expression to Ruby expression and Evaluation
|
1320
1327
|
class Evaluator
|
1321
1328
|
include BuiltinFunctions
|
@@ -1331,6 +1338,7 @@ module Nendo
|
|
1331
1338
|
@trace_debug = false
|
1332
1339
|
@lexicalVars = []
|
1333
1340
|
@syntaxHash = {}
|
1341
|
+
@optimize_level = 2
|
1334
1342
|
@char_table_lisp_to_ruby = {
|
1335
1343
|
# list (! $ % & * + - . / : < = > ? @ ^ _ ~ ...)
|
1336
1344
|
'!' => '_EXMARK',
|
@@ -1395,9 +1403,6 @@ module Nendo
|
|
1395
1403
|
@call_depth = 0
|
1396
1404
|
@call_counters = Hash.new
|
1397
1405
|
|
1398
|
-
# init optimize level
|
1399
|
-
@optimize_level = 1
|
1400
|
-
|
1401
1406
|
# compiled ruby code
|
1402
1407
|
# { 'filename1' => [ 'code1' 'code2' ... ],
|
1403
1408
|
# 'filename2' => [ 'code1' 'code2' ... ], ... }
|
@@ -1444,7 +1449,7 @@ module Nendo
|
|
1444
1449
|
def defMethodStr( name, _log )
|
1445
1450
|
[ "def self." + name.to_s + "_METHOD( origname, pred, args ) ",
|
1446
1451
|
" lispMethodEntry( origname, " + _log.to_s + " ) ; ",
|
1447
|
-
" ret = callProcedure( origname, pred, args ) ;",
|
1452
|
+
" ret = callProcedure( '" + name.to_s + "', origname, pred, args ) ;",
|
1448
1453
|
" lispMethodExit( origname, " + _log.to_s + " ) ; ",
|
1449
1454
|
" return ret ",
|
1450
1455
|
"end " ].join
|
@@ -1517,23 +1522,27 @@ module Nendo
|
|
1517
1522
|
}
|
1518
1523
|
name
|
1519
1524
|
end
|
1520
|
-
|
1525
|
+
|
1526
|
+
def errorMessageOf_toRubyArgument( origname, no, req, got )
|
1527
|
+
sprintf( "Error: [%s] wrong number of arguments for closure `%s' (requires %d, but got %d)", no, origname, req, got )
|
1528
|
+
end
|
1529
|
+
|
1521
1530
|
def toRubyArgument( origname, pred, args )
|
1522
|
-
|
1531
|
+
len = args.length
|
1523
1532
|
num = pred.arity
|
1524
1533
|
if 0 == num
|
1525
|
-
raise ArgumentError,
|
1534
|
+
raise ArgumentError, errorMessageOf_toRubyArgument( origname, 1, num, len ) if 0 != len
|
1526
1535
|
[]
|
1527
1536
|
elsif 0 < num
|
1528
|
-
if 0 ==
|
1537
|
+
if 0 == len
|
1529
1538
|
[ Nil.new ]
|
1530
1539
|
else
|
1531
|
-
raise ArgumentError,
|
1540
|
+
raise ArgumentError, errorMessageOf_toRubyArgument( origname, 2, num, len ) if num != len
|
1532
1541
|
args
|
1533
1542
|
end
|
1534
1543
|
else
|
1535
1544
|
num = num.abs( )-1
|
1536
|
-
raise ArgumentError,
|
1545
|
+
raise ArgumentError, errorMessageOf_toRubyArgument( origname, 3, num, len ) if num > len
|
1537
1546
|
params = []
|
1538
1547
|
rest = []
|
1539
1548
|
args.each_with_index { |x,i|
|
@@ -1555,13 +1564,10 @@ module Nendo
|
|
1555
1564
|
result
|
1556
1565
|
end
|
1557
1566
|
end
|
1558
|
-
|
1567
|
+
|
1559
1568
|
def trampCall( result )
|
1560
|
-
while result.
|
1561
|
-
|
1562
|
-
@tmp_pred = result.pred
|
1563
|
-
@tmp_args = result.args
|
1564
|
-
result = eval( sprintf( "self.%s( @tmp_origname, @tmp_pred, @tmp_args )", result.rubysym + "_METHOD" ), @binding )
|
1569
|
+
while result.class == DelayedCallPacket
|
1570
|
+
result = __send__( result.rubysym + "_METHOD", result.origname, result.pred, result.args )
|
1565
1571
|
end
|
1566
1572
|
result
|
1567
1573
|
end
|
@@ -1570,36 +1576,35 @@ module Nendo
|
|
1570
1576
|
if @global_lisp_binding[name].is_a? Proc
|
1571
1577
|
@global_lisp_binding[name].call( args[0], args[1], args[2] )
|
1572
1578
|
else
|
1573
|
-
callProcedure( args[0], args[1], args[2] )
|
1579
|
+
callProcedure( name, args[0], args[1], args[2] )
|
1574
1580
|
end
|
1575
1581
|
end
|
1576
1582
|
|
1577
1583
|
def delayCall( rubysym, origname, pred, args )
|
1578
1584
|
case @optimize_level
|
1579
1585
|
when 0 # no optimize
|
1580
|
-
callProcedure( origname, pred, args )
|
1586
|
+
callProcedure( rubysym, origname, pred, args )
|
1581
1587
|
else # tail call optimization
|
1582
|
-
DelayedCallPacket.new(
|
1588
|
+
DelayedCallPacket.new( rubysym, origname, pred, args )
|
1583
1589
|
end
|
1584
1590
|
end
|
1585
|
-
|
1586
|
-
def callProcedure( origname, pred, args )
|
1591
|
+
|
1592
|
+
def callProcedure( rubysym, origname, pred, args )
|
1587
1593
|
if @call_counters.has_key?( origname )
|
1588
1594
|
@call_counters[ origname ] += 1
|
1589
1595
|
else
|
1590
1596
|
@call_counters[ origname ] = 1
|
1591
1597
|
end
|
1592
|
-
|
1593
1598
|
result = pred.call( *toRubyArgument( origname, pred, args ))
|
1594
1599
|
|
1595
1600
|
@call_counters[ origname ] -= 1
|
1596
1601
|
|
1597
1602
|
result
|
1598
1603
|
end
|
1599
|
-
|
1604
|
+
|
1600
1605
|
# for code generation of Ruby's argument values
|
1601
1606
|
# in case: str = ","
|
1602
|
-
# [1,"2",3] => [
|
1607
|
+
# [1,"2",3] => [
|
1603
1608
|
# [ 1, ","]
|
1604
1609
|
# ["2", ","]
|
1605
1610
|
# [ 3 ]
|
@@ -1616,6 +1621,37 @@ module Nendo
|
|
1616
1621
|
[ :define, :set!, :"define-syntax", @core_syntax_hash[ :define ], @core_syntax_hash[ :set! ], @core_syntax_hash[ :"define-syntax" ] ].include?( sym )
|
1617
1622
|
end
|
1618
1623
|
|
1624
|
+
def optimizedFunc( origname, rubysym, args )
|
1625
|
+
case origname
|
1626
|
+
when '+', '-', '*'
|
1627
|
+
case args.length
|
1628
|
+
when 0
|
1629
|
+
[ "#{rubysym}_ARGS0(", ")" ]
|
1630
|
+
when 1
|
1631
|
+
[ "#{rubysym}_ARGS1(", args[0], ")" ]
|
1632
|
+
when 2
|
1633
|
+
[ "#{rubysym}_ARGS2(", args[0], args[1], ")" ]
|
1634
|
+
when 3
|
1635
|
+
[ "#{rubysym}_ARGS3(", args[0], args[1], args[2], ")" ]
|
1636
|
+
else
|
1637
|
+
false
|
1638
|
+
end
|
1639
|
+
when 'car', 'cdr', 'not', 'length', 'null?', 'reverse', 'uniq',
|
1640
|
+
'write', 'write-to-string', 'display', 'print',
|
1641
|
+
'procedure?', 'macro?', 'symbol?', 'keyword?', 'syntax?', 'core-syntax?',
|
1642
|
+
'pair?', '%list?', 'integer?', 'number?', 'string?', 'macroexpand-1',
|
1643
|
+
'to-s', 'to-i', 'nil?', 'to-list', 'to-arr',
|
1644
|
+
'intern', 'string->symbol', 'symbol->string', 'read-from-string'
|
1645
|
+
raise ArgumentError, "Error: #{origname} requires 1 argument. " unless 1 == args.length
|
1646
|
+
[ "#{rubysym}(", args[0], ")" ]
|
1647
|
+
when 'cons', '=', ">", ">=", "<", "<=", "eq?", "equal?", 'set-car!', 'set-cdr!'
|
1648
|
+
raise ArgumentError, "Error: #{origname} requires 2 arguments. " unless 2 == args.length
|
1649
|
+
[ "#{rubysym}(", args[0], args[1], ")" ]
|
1650
|
+
else
|
1651
|
+
false
|
1652
|
+
end
|
1653
|
+
end
|
1654
|
+
|
1619
1655
|
def execFunc( funcname, args, sourcefile, lineno, locals, sourceInfo, execType )
|
1620
1656
|
if isDefines( funcname )
|
1621
1657
|
ar = args.cdr.map { |x| x.car }
|
@@ -1664,29 +1700,39 @@ module Nendo
|
|
1664
1700
|
else
|
1665
1701
|
# Nendo function
|
1666
1702
|
arr = separateWith( args.map { |x| x.car }, "," )
|
1703
|
+
origname = funcname.to_s
|
1704
|
+
sym = toRubySymbol( origname )
|
1667
1705
|
if EXEC_TYPE_ANONYMOUS == execType
|
1668
|
-
[sprintf( "trampCall( callProcedure( 'anonymouse', " ),
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1706
|
+
[sprintf( "trampCall( callProcedure( nil, 'anonymouse', " ),
|
1707
|
+
[ funcname ] + [ "," ],
|
1708
|
+
"[", arr, "]",
|
1709
|
+
" ))"]
|
1672
1710
|
else
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1711
|
+
result = false
|
1712
|
+
if (execType == EXEC_TYPE_NORMAL) and (not locals.flatten.include?( sym ))
|
1713
|
+
if 1 < @optimize_level
|
1714
|
+
result = optimizedFunc( origname, sym, arr )
|
1715
|
+
end
|
1716
|
+
end
|
1717
|
+
if result
|
1718
|
+
result
|
1719
|
+
else
|
1720
|
+
_call = case execType
|
1721
|
+
when EXEC_TYPE_NORMAL
|
1722
|
+
if locals.flatten.include?( sym )
|
1723
|
+
[ "trampCall( callProcedure( '" + sym + "', ", "))" ] # local function
|
1724
|
+
else
|
1725
|
+
[ sprintf( "trampCall( self.%s_METHOD( ", sym ), "))" ] # toplevel function
|
1726
|
+
end
|
1727
|
+
when EXEC_TYPE_TAILCALL
|
1728
|
+
[ sprintf( "delayCall( '%s', ", sym ), ")" ]
|
1682
1729
|
end
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
sprintf( " %s", _call[1] )]
|
1730
|
+
|
1731
|
+
[sprintf( "%s '%s',", _call[0], origname ),
|
1732
|
+
[lispSymbolReference( sym, locals, nil, sourcefile, lineno )] + [","],
|
1733
|
+
"[", arr, "]",
|
1734
|
+
sprintf( " %s", _call[1] )]
|
1735
|
+
end
|
1690
1736
|
end
|
1691
1737
|
end
|
1692
1738
|
end
|
@@ -2194,14 +2240,14 @@ module Nendo
|
|
2194
2240
|
sexp
|
2195
2241
|
elsif _symbol_QUMARK( car ) and eval( sprintf( "(defined? @%s and LispMacro == @%s.class)", sym,sym ), @binding )
|
2196
2242
|
eval( sprintf( "@__macro = @%s", sym ), @binding )
|
2197
|
-
newSexp = trampCall( callProcedure( sym, @__macro, sexp.cdr.to_arr ))
|
2243
|
+
newSexp = trampCall( callProcedure( nil, sym, @__macro, sexp.cdr.to_arr ))
|
2198
2244
|
elsif _symbol_QUMARK( car ) and eval( sprintf( "(defined? @%s and LispSyntax == @%s.class)", sym,sym ), @binding )
|
2199
2245
|
# expected input is
|
2200
2246
|
# (syntaxName arg1 arg2 ...)
|
2201
2247
|
# will be transformed
|
2202
2248
|
# (syntaxName (syntaxName arg1 arg2 ...) () (global-variables))
|
2203
2249
|
eval( sprintf( "@__syntax = @%s", sym ), @binding )
|
2204
|
-
newSexp = trampCall( callProcedure( sym, @__syntax, [ sexp, Cell.new(), _global_MIMARKvariables( ) ] ))
|
2250
|
+
newSexp = trampCall( callProcedure( nil, sym, @__syntax, [ sexp, Cell.new(), _global_MIMARKvariables( ) ] ))
|
2205
2251
|
elsif _symbol_QUMARK( car ) and syntaxArray.map {|arr| arr[0].intern}.include?( car.intern )
|
2206
2252
|
# lexical macro expandeding
|
2207
2253
|
symbol_and_syntaxObj = syntaxArray.reverse.find {|arr| car == arr[0]}
|
@@ -2212,7 +2258,7 @@ module Nendo
|
|
2212
2258
|
vars = symbol_and_syntaxObj[3].map { |arr| arr[0] }
|
2213
2259
|
lexvars = @syntaxHash[ symbol_and_syntaxObj[1] ][0]
|
2214
2260
|
lispSyntax = @syntaxHash[ symbol_and_syntaxObj[1] ][1]
|
2215
|
-
newSexp = trampCall( callProcedure( symbol_and_syntaxObj[0], lispSyntax, [
|
2261
|
+
newSexp = trampCall( callProcedure( nil, symbol_and_syntaxObj[0], lispSyntax, [
|
2216
2262
|
sexp,
|
2217
2263
|
Cell.new(),
|
2218
2264
|
(_global_MIMARKvariables( ).to_arr + keys + vars).to_list ] ))
|
@@ -2286,10 +2332,11 @@ module Nendo
|
|
2286
2332
|
end
|
2287
2333
|
|
2288
2334
|
# compiling phase written
|
2289
|
-
|
2335
|
+
origsym = "%compile-phase"
|
2336
|
+
sym = toRubySymbol( origsym )
|
2290
2337
|
if ( eval( sprintf( "(defined? @%s and Proc == @%s.class)", sym,sym ), @binding ))
|
2291
2338
|
eval( sprintf( "@___tmp = @%s", sym ), @binding )
|
2292
|
-
sexp = trampCall( callProcedure(
|
2339
|
+
sexp = trampCall( callProcedure( nil, origsym, @___tmp, [ sexp ]))
|
2293
2340
|
if @debug
|
2294
2341
|
printf( "\n compiled= <<< %s >>>\n", (Printer.new())._print(sexp))
|
2295
2342
|
end
|
@@ -2412,7 +2459,7 @@ module Nendo
|
|
2412
2459
|
|
2413
2460
|
argsStr = (1..(pred.arity)).map { |n| "arg" + n.to_s }.join( "," )
|
2414
2461
|
str = [ "def self." + origname + "(" + argsStr + ")",
|
2415
|
-
sprintf( " trampCall( callProcedure( '%s', @_%s, [ " + argsStr + " ] )) ",
|
2462
|
+
sprintf( " trampCall( callProcedure( nil, '%s', @_%s, [ " + argsStr + " ] )) ",
|
2416
2463
|
origname, origname ),
|
2417
2464
|
"end ;",
|
2418
2465
|
"def @core." + origname + "(" + argsStr + ")",
|
@@ -2610,7 +2657,7 @@ module Nendo
|
|
2610
2657
|
end
|
2611
2658
|
|
2612
2659
|
def self.version
|
2613
|
-
"0.5.
|
2660
|
+
"0.5.2" ##NENDO-VERSION
|
2614
2661
|
end
|
2615
2662
|
|
2616
2663
|
attr_reader :evaluator
|