|
333 | 333 | (i32.eq ($TYPE ($MEM_VAL1_ptr $args))
|
334 | 334 | (global.get $VECTOR_T)))))
|
335 | 335 |
|
| 336 | + (func $seq (param $args i32) (result i32) |
| 337 | + (LET $mv ($MEM_VAL1_ptr $args) |
| 338 | + $type ($TYPE $mv) |
| 339 | + $res 0 |
| 340 | + $ret 0 |
| 341 | + $empty 0 |
| 342 | + $current 0 |
| 343 | + $i 0 |
| 344 | + $char 0) |
| 345 | + |
| 346 | + (if (i32.eq $type (global.get $NIL_T)) |
| 347 | + (then (return (global.get $NIL)))) |
| 348 | + |
| 349 | + (if (AND (i32.ne $type (global.get $LIST_T)) |
| 350 | + (i32.ne $type (global.get $VECTOR_T)) |
| 351 | + (i32.ne $type (global.get $STRING_T))) |
| 352 | + (then (return (global.get $NIL)))) |
| 353 | + |
| 354 | + (if (i32.eqz ($VAL0 $mv)) (then (return (global.get $NIL)))) |
| 355 | + |
| 356 | + (if (i32.eq $type (global.get $LIST_T)) |
| 357 | + (then (return ($FORCE_SEQ_TYPE (global.get $LIST_T) $mv)))) |
| 358 | + |
| 359 | + (if (i32.eq $type (global.get $VECTOR_T)) |
| 360 | + (then (return ($FORCE_SEQ_TYPE (global.get $LIST_T) $mv)))) |
| 361 | + |
| 362 | + (if (i32.eq $type (global.get $STRING_T)) |
| 363 | + (then |
| 364 | + (local.set $mv ($to_String $mv)) |
| 365 | + (if (i32.eqz ($strlen $mv)) (then (return (global.get $NIL)))) |
| 366 | + (local.set $res ($MAP_LOOP_START (global.get $LIST_T))) |
| 367 | + (local.set $empty $res) |
| 368 | + (local.set $current $res) |
| 369 | + (local.set $ret $res) |
| 370 | + (local.set $i 0) |
| 371 | + (block $done |
| 372 | + (loop $loop |
| 373 | + (local.set $char (i32.load8_u (i32.add $mv $i))) |
| 374 | + (br_if $done (i32.eq $char 0)) |
| 375 | + |
| 376 | + (i32.store8 (global.get $token_buf) $char) |
| 377 | + (i32.store8 (i32.add (global.get $token_buf) 1) 0) |
| 378 | + |
| 379 | + (local.set $res |
| 380 | + ($MAP_LOOP_UPDATE (global.get $LIST_T) |
| 381 | + $empty $current ($STRING (global.get $STRING_T) (global.get $token_buf)) 0)) |
| 382 | + (if (i32.le_u $current (global.get $EMPTY_LIST)) |
| 383 | + ;; if first element, set return to new element |
| 384 | + (local.set $ret $res)) |
| 385 | + |
| 386 | + (local.set $i (i32.add $i 1)) |
| 387 | + (local.set $current $res) |
| 388 | + (br $loop) |
| 389 | + ) |
| 390 | + ) |
| 391 | + (return $ret) |
| 392 | + ) |
| 393 | + ) |
| 394 | + (global.get $NIL) |
| 395 | + ) |
| 396 | + |
336 | 397 | (func $cons (param $args i32) (result i32)
|
337 | 398 | ($LIST ($MEM_VAL1_ptr ($MEM_VAL0_ptr $args)) ($MEM_VAL1_ptr $args)))
|
338 | 399 |
|
|
468 | 529 | (LET $f ($MEM_VAL1_ptr $args)
|
469 | 530 | $rest_args ($MEM_VAL1_ptr ($MEM_VAL0_ptr $args))
|
470 | 531 | $f_args 0
|
471 |
| - $res ($MAP_LOOP_START (global.get $LIST_T)) |
| 532 | + $res ($MAP_LOOP_START (global.get $LIST_T)) |
472 | 533 | ;; push MAP_LOOP stack
|
473 | 534 | $ret $res
|
474 | 535 | $current $res
|
|
641 | 702 | $apply
|
642 | 703 | $map
|
643 | 704 | $nop ;; $conj
|
644 |
| - $nop ;; $seq |
| 705 | + $seq |
645 | 706 |
|
646 | 707 | ;; 54
|
647 | 708 | $with_meta
|
|
0 commit comments