Lines Matching defs:com

103 #define NEW_TREE(type)		CompileNewTree(com, type)
106 #define IN_TAGBODY() (com->block->type == LispBlockBody && \
107 com->level == com->tagbody)
108 #define FORM_ENTER() ++com->level
109 #define FORM_LEAVE() --com->level
113 longjmp(com->jmp, 1)
397 LispCom com;
409 memset(&com, 0, sizeof(LispCom));
410 com.toplevel = com.block = LispCalloc(1, sizeof(CodeBlock));
411 com.block->type = LispBlockClosure;
412 com.block->tag = name;
483 com.form = form;
484 com.plist = CONS(NIL, NIL);
485 GC_PROTECT(com.plist);
488 if (setjmp(com.jmp) == 0) {
490 lex = com.lex = lisp__data.env.lex;
491 base = ComCall(&com, alist, name, arguments, 1, 0, 1);
495 ComProgn(&com, CAR(form));
505 result = MakeBytecodeObject(&com, name,
510 if (com.warnings)
511 warnings_p = FIXNUM(com.warnings);
1196 LispCom com;
1202 memset(&com, 0, sizeof(LispCom));
1204 com.toplevel = com.block = LispCalloc(1, sizeof(CodeBlock));
1205 com.block->type = LispBlockNone;
1206 com.lex = lisp__data.env.lex;
1208 com.plist = CONS(NIL, NIL);
1209 GC_PROTECT(com.plist);
1212 if (setjmp(com.jmp) == 0) {
1214 com.form = form;
1215 ComEval(&com, CAR(form));
1221 return (failed ? NIL : MakeBytecodeObject(&com, NIL, NIL));
1234 MakeBytecodeObject(LispCom *com, LispObj *name, LispObj *plist)
1245 LinkBytecode(com);
1250 bytecode->code = com->bytecode;
1251 bytecode->length = com->length;
1281 for (i = 0; i < com->table.num_bytecodes; i++) {
1283 code = cons = prev = CONS(com->table.bytecodes[i], NIL);
1287 RPLACD(cons, CONS(com->table.bytecodes[i], NIL));
1294 CompileFreeState(com);
1353 CompileFreeState(LispCom *com)
1355 CompileFreeBlock(com->block);
1356 LispFree(com->table.constants);
1357 LispFree(com->table.symbols);
1358 LispFree(com->table.builtins);
1359 LispFree(com->table.bytecodes);
1365 CompileNewTree(LispCom *com, CodeTreeType type)
1371 tree->block = com->block;
1372 if (com->block->tree == NULL)
1373 com->block->tree = tree;
1375 com->block->tail->next = tree;
1376 com->block->tail = tree;
1382 CompileIniBlock(LispCom *com, LispBlockType type, LispObj *tag)
1391 block->prev = com->block;
1393 block->level = com->level;
1394 com->block = block;
1397 com->tagbody = com->level;
1401 CompileFiniBlock(LispCom *com)
1403 com->block = com->block->prev;
1404 if (com->block && com->block->type == LispBlockBody)
1405 com->tagbody = com->block->level;
1409 com_BytecodeChar(LispCom *com, LispByteOpcode code, char value)
1418 com_BytecodeShort(LispCom *com, LispByteOpcode code, short value)
1427 com_BytecodeAtom(LispCom *com, LispByteOpcode code, LispAtom *atom)
1436 com_BytecodeObject(LispCom *com, LispByteOpcode code, LispObj *object)
1445 com_BytecodeCons(LispCom *com, LispByteOpcode code, LispObj *car, LispObj *cdr)
1455 com_Bytecode(LispCom *com, LispByteOpcode code)
1463 com_Load(LispCom *com, short offset)
1465 com_BytecodeShort(com, XBC_LOAD, offset);
1469 com_LoadLet(LispCom *com, short offset, LispAtom *name)
1479 com_LoadPush(LispCom *com, short offset)
1481 com_BytecodeShort(com, XBC_LOAD_PUSH, offset);
1485 com_Let(LispCom *com, LispAtom *name)
1487 com_BytecodeAtom(com, XBC_LET, name);
1491 com_Bind(LispCom *com, short count)
1494 com_BytecodeShort(com, XBC_LETBIND, count);
1498 com_Unbind(LispCom *com, short count)
1501 com_BytecodeShort(com, XBC_UNLET, count);
1505 com_LoadSym(LispCom *com, LispAtom *atom)
1507 com_BytecodeAtom(com, XBC_LOADSYM, atom);
1511 com_LoadSymLet(LispCom *com, LispAtom *symbol, LispAtom *name)
1521 com_LoadSymPush(LispCom *com, LispAtom *name)
1523 com_BytecodeAtom(com, XBC_LOADSYM_PUSH, name);
1527 com_LoadCon(LispCom *com, LispObj *constant)
1530 com_Bytecode(com, XBC_NIL);
1532 com_Bytecode(com, XBC_T);
1537 com_BytecodeObject(com, XBC_LOADCON, constant);
1541 com_LoadConLet(LispCom *com, LispObj *constant, LispAtom *name)
1544 com_BytecodeAtom(com, XBC_LET_NIL, name);
1555 com_LoadConPush(LispCom *com, LispObj *constant)
1558 com_Bytecode(com, XBC_PUSH_NIL);
1560 com_Bytecode(com, XBC_PUSH_T);
1562 com_Bytecode(com, XBC_PUSH_UNSPEC);
1564 com_BytecodeObject(com, XBC_LOADCON_PUSH, constant);
1568 com_Set(LispCom *com, short offset)
1570 com_BytecodeShort(com, XBC_SET, offset);
1574 com_SetSym(LispCom *com, LispAtom *symbol)
1576 com_BytecodeAtom(com, XBC_SETSYM, symbol);
1580 com_Struct(LispCom *com, short offset, LispObj *definition)
1590 com_Structp(LispCom *com, LispObj *definition)
1592 com_BytecodeObject(com, XBC_STRUCTP, definition);
1596 com_Call(LispCom *com, unsigned char num_arguments, LispBuiltin *builtin)
1606 com_Bytecall(LispCom *com, unsigned char num_arguments, LispObj *code)
1616 com_Funcall(LispCom *com, LispObj *function, LispObj *arguments)
1618 com_BytecodeCons(com, XBC_FUNCALL, function, arguments);
1622 CompileStackEnter(LispCom *com, int count, int builtin)
1624 if (!com->macro) {
1626 com->stack.cbstack += count;
1627 if (com->stack.bstack < com->stack.cbstack)
1628 com->stack.bstack = com->stack.cbstack;
1631 com->stack.cstack += count;
1632 if (com->stack.stack < com->stack.cstack)
1633 com->stack.stack = com->stack.cstack;
1639 CompileStackLeave(LispCom *com, int count, int builtin)
1641 if (!com->macro) {
1643 com->stack.cbstack -= count;
1645 com->stack.cstack -= count;
1650 LinkWarnUnused(LispCom *com, CodeBlock *block)
1657 LinkWarnUnused(com, tree->data.block);
1662 ++com->warnings;
1671 LinkBuildOffsets(LispCom *com, CodeTree *tree, long offset)
1801 offset = LinkBuildOffsets(com, tree->data.block->tree, offset);
1810 LinkDoOptimize_0(LispCom *com, CodeBlock *block)
2081 LinkDoOptimize_0(com, tree->data.block);
2109 LinkOptimize_0(LispCom *com)
2112 LinkDoOptimize_0(com, com->block);
2116 LinkResolveLabels(LispCom *com, CodeBlock *block)
2123 LinkResolveLabels(com, tree->data.block);
2135 LinkResolveJumps(LispCom *com, CodeBlock *block)
2152 LinkResolveJumps(com, tree->data.block);
2234 LinkFixupOffsets(LispCom *com, CodeTree *tree, long adjust)
2270 adjust = LinkFixupOffsets(com, tree->data.block->tree, adjust);
2279 LinkSkipPadding(LispCom *com, CodeTree *tree)
2287 LinkSkipPadding(com, ptr->data.block->tree);
2338 LinkCalculateJump(LispCom *com, CodeTree *tree, LispByteOpcode code)
2356 LinkFixupJumps(LispCom *com, CodeTree *tree)
2366 LinkCalculateJump(com, tree, XBC_JUMPNIL);
2369 LinkCalculateJump(com, tree, XBC_JUMP);
2373 LinkCalculateJump(com, tree, tree->code);
2377 LinkCalculateJump(com, tree, XBC_JUMP);
2383 LinkCalculateJump(com, tree, XBC_JUMP);
2386 LinkFixupJumps(com, tree->data.block->tree);
2390 LinkCalculateJump(com, tree, tree->code);
2396 LinkBuildTableSymbol(LispCom *com, LispAtom *symbol)
2398 if (BuildTablePointer(symbol, (void***)&com->table.symbols,
2399 &com->table.num_symbols) > 0xff) {
2405 LinkBuildTableConstant(LispCom *com, LispObj *constant)
2407 if (BuildTablePointer(constant, (void***)&com->table.constants,
2408 &com->table.num_constants) > 0xff) {
2414 LinkBuildTableBuiltin(LispCom *com, LispBuiltin *builtin)
2416 if (BuildTablePointer(builtin, (void***)&com->table.builtins,
2417 &com->table.num_builtins) > 0xff) {
2423 LinkBuildTableBytecode(LispCom *com, LispObj *bytecode)
2425 if (BuildTablePointer(bytecode, (void***)&com->table.bytecodes,
2426 &com->table.num_bytecodes) > 0xff) {
2432 LinkBuildTables(LispCom *com, CodeBlock *block)
2447 LinkBuildTableSymbol(com, tree->data.atom);
2452 LinkBuildTableConstant(com, tree->data.object);
2455 LinkBuildTableConstant(com, tree->data.load_con_set.object);
2459 LinkBuildTableBuiltin(com, tree->data.builtin.builtin);
2462 LinkBuildTableBytecode(com, tree->data.bytecall.code);
2466 LinkBuildTableSymbol(com, tree->data.let.name);
2469 LinkBuildTableConstant(com, tree->data.struc.definition);
2473 LinkBuildTableSymbol(com, tree->data.let_sym.symbol);
2474 LinkBuildTableSymbol(com, tree->data.let_sym.name);
2478 LinkBuildTableConstant(com, tree->data.let_con.object);
2479 LinkBuildTableSymbol(com, tree->data.let_con.name);
2483 LinkBuildTableConstant(com, tree->data.cons.car);
2484 LinkBuildTableConstant(com, tree->data.cons.cdr);
2491 LinkBuildTables(com, tree->data.block);
2500 LinkEmmitBytecode(LispCom *com, CodeTree *tree,
2605 (void**)com->table.symbols,
2606 com->table.num_symbols);
2615 (void**)com->table.constants,
2616 com->table.num_constants);
2623 (void**)com->table.constants,
2624 com->table.num_constants);
2633 (void**)com->table.builtins,
2634 com->table.num_builtins);
2642 (void**)com->table.bytecodes,
2643 com->table.num_bytecodes);
2651 (void**)com->table.builtins,
2652 com->table.num_builtins);
2662 (void**)com->table.symbols,
2663 com->table.num_symbols);
2671 (void**)com->table.constants,
2672 com->table.num_constants);
2680 (void**)com->table.symbols,
2681 com->table.num_symbols);
2684 (void**)com->table.symbols,
2685 com->table.num_symbols);
2693 (void**)com->table.constants,
2694 com->table.num_constants);
2697 (void**)com->table.symbols,
2698 com->table.num_symbols);
2706 (void**)com->table.constants,
2707 com->table.num_constants);
2710 (void**)com->table.constants,
2711 com->table.num_constants);
2733 offset = LinkEmmitBytecode(com, tree->data.block->tree,
2743 LinkBytecode(LispCom *com)
2750 com_Bytecode(com, XBC_RETURN);
2757 LinkWarnUnused(com, com->block);
2760 LinkOptimize_0(com);
2763 LinkResolveLabels(com, com->block);
2766 LinkResolveJumps(com, com->block);
2769 LinkBuildOffsets(com, com->block->tree, 0);
2772 LinkFixupOffsets(com, com->block->tree, 0);
2777 LinkSkipPadding(com, com->block->tree);
2780 LinkFixupJumps(com, com->block->tree);
2783 LinkBuildTables(com, com->block);
2786 com->length = sizeof(short) * 3;
2788 com->length += sizeof(short) * 4;
2789 com->length += com->table.num_constants * sizeof(LispObj*);
2790 com->length += com->table.num_symbols * sizeof(LispAtom*);
2791 com->length += com->table.num_builtins * sizeof(LispBuiltin*);
2792 com->length += com->table.num_bytecodes * sizeof(unsigned char*);
2793 com->length += com->table.num_bytecodes * sizeof(LispObj*);
2796 com->length += com->block->tail->offset + 1;
2797 com->bytecode = LispMalloc(com->length);
2801 *(short*)(com->bytecode + offset) = com->stack.stack;
2803 *(short*)(com->bytecode + offset) = com->stack.bstack;
2805 *(short*)(com->bytecode + offset) = com->stack.pstack;
2808 *(short*)(com->bytecode + offset) = com->table.num_constants;
2810 *(short*)(com->bytecode + offset) = com->table.num_symbols;
2812 *(short*)(com->bytecode + offset) = com->table.num_builtins;
2814 *(short*)(com->bytecode + offset) = com->table.num_bytecodes;
2817 count = sizeof(LispObj*) * com->table.num_constants;
2818 memcpy(com->bytecode + offset, com->table.constants, count);
2820 count = sizeof(LispAtom*) * com->table.num_symbols;
2821 memcpy(com->bytecode + offset, com->table.symbols, count);
2823 count = sizeof(LispBuiltin*) * com->table.num_builtins;
2824 memcpy(com->bytecode + offset, com->table.builtins, count);
2828 for (count = 0, codes = (unsigned char**)(com->bytecode + offset);
2829 count < com->table.num_bytecodes; count++, codes++)
2830 *codes = com->table.bytecodes[count]->data.bytecode.bytecode->code;
2831 offset += com->table.num_bytecodes * sizeof(unsigned char*);
2836 for (count = 0, names = (LispObj**)(com->bytecode + offset);
2837 count < com->table.num_bytecodes; count++, names++)
2838 *names = com->table.bytecodes[count]->data.bytecode.name;
2839 offset += com->table.num_bytecodes * sizeof(LispObj*);
2842 LinkEmmitBytecode(com, com->block->tree, com->bytecode + offset, 0);