リビジョン | 055054c5d91a70dc8d16a1baf16d621141fda16a (tree) |
---|---|
日時 | 2018-11-29 03:42:26 |
作者 | Agustina Arzille <avarzille@rise...> |
コミッター | Agustina Arzille |
Add the 'macro-fct' interface
@@ -1497,6 +1497,18 @@ | ||
1497 | 1497 | } |
1498 | 1498 | } |
1499 | 1499 | |
1500 | +DEFBUILTIN (macro_fct) | |
1501 | +{ | |
1502 | + object sym = *argv; | |
1503 | + if (!symbol_p (sym)) | |
1504 | + interp->raise2 ("arg-error", "macro-fct: argument must be a symbol"); | |
1505 | + else if (!as_symbol(sym)->flagged_p (symbol::ctv_flag)) | |
1506 | + qp_return (NIL); | |
1507 | + | |
1508 | + sym = symval (sym); | |
1509 | + qp_return (fct_p (sym) ? sym : NIL); | |
1510 | +} | |
1511 | + | |
1500 | 1512 | // Names for the builtins. |
1501 | 1513 | static const char BUILTIN_NAMES[] = |
1502 | 1514 | "%make-exception\0" |
@@ -1560,6 +1572,7 @@ | ||
1560 | 1572 | "%gc\0" |
1561 | 1573 | "%iter\0" |
1562 | 1574 | "exit\0" |
1575 | + "macro-fct\0" | |
1563 | 1576 | ; |
1564 | 1577 | |
1565 | 1578 | // List of builtins. |
@@ -1640,7 +1653,8 @@ | ||
1640 | 1653 | { p_use_fct, 3, 3 }, |
1641 | 1654 | { p_gc, 0, -1 }, |
1642 | 1655 | { p_iter, 1, 3 }, |
1643 | - { exit_fct, 0, 1 } | |
1656 | + { exit_fct, 0, 1 }, | |
1657 | + { macro_fct, 1, 1 } | |
1644 | 1658 | }; |
1645 | 1659 | |
1646 | 1660 | static native_function global_builtins[QP_NELEM (BUILTINS)]; |