| | 1372 | |
| | 1373 | case KEY_CONTINUE: |
| | 1374 | rex= crl_runtime_eval_key_continue( context ); |
| | 1375 | break; |
| | 1376 | |
| | 1377 | case KEY_BREAK: |
| | 1378 | rex= crl_runtime_eval_key_break( context ); |
| | 1379 | break; |
| | 1380 | |
| | 1381 | case STRUCTURE_LOOP_FOR: |
| | 1382 | rex= crl_runtime_loop_for( sym, context ); |
| | 1383 | break; |
| | 1384 | |
| | 1385 | case STRUCTURE_LOOP_WHILE: |
| | 1386 | rex= crl_runtime_loop_while( sym, context ); |
| | 1387 | break; |
| | 1388 | |
| | 1389 | case STRUCTURE_FUNCTION_DEF: |
| | 1390 | if( !(crl_rr_context_push_function_def( sym, &context )) ) |
| | 1391 | crl_fatal("error pushing function defintion!\n"); |
| | 1392 | break; |
| | 1393 | */ |
| 1397 | | case KEY_CONTINUE: |
| 1398 | | rex= crl_runtime_eval_key_continue( context ); |
| 1399 | | break; |
| 1400 | | |
| 1401 | | case KEY_BREAK: |
| 1402 | | rex= crl_runtime_eval_key_break( context ); |
| | 1404 | default: |
| | 1405 | crl_error("unhandled symbol type '0x%X'\n", sym->type ); |
| | 1406 | retval= false; break; |
| | 1407 | } |
| | 1408 | } |
| | 1409 | |
| | 1410 | crl_debug("symbol pass fully executed!\n"); |
| | 1411 | sym= sym->next; |
| | 1412 | |
| | 1413 | if( rex != NULL ) |
| | 1414 | break; |
| | 1415 | } |
| | 1416 | crl_garbage_invoke_sweep( context ); |
| | 1417 | |
| | 1418 | return rex; |
| | 1419 | } |
| | 1420 | |
| | 1421 | bool crl_runtime_exec_toplevel( crl_symbol_obj *sym, |
| | 1422 | crl_context_table *context ) |
| | 1423 | { |
| | 1424 | bool retval= true; crl_symbol_obj* ex= NULL; |
| | 1425 | while ( sym != NULL ) |
| | 1426 | { |
| | 1427 | crl_debug("exec of pass symbol type: '0x%X'\n", sym->type ); |
| | 1428 | if( sym->exp == OP_EXPRESS ) |
| | 1429 | { |
| | 1430 | ex = crl_runtime_evaluate_expression( sym, context ); |
| | 1431 | if( ex ) |
| | 1432 | { |
| | 1433 | if( crl_interactive ) |
| | 1434 | crl_runtime_object_print( ex, context, crlout, true ); |
| | 1435 | ex->n_ref--; |
| | 1436 | } |
| | 1437 | else { retval = false; } |
| | 1438 | } |
| | 1439 | else |
| | 1440 | { |
| | 1441 | switch( sym->type ) |
| | 1442 | { |
| | 1443 | /* |
| | 1444 | case STRUCTURE_CONDIT_CTX: |
| | 1445 | crl_runtime_conditional_dispatch( sym, context ); |
| 1424 | | crl_debug("symbol pass fully executed!\n"); |
| 1425 | | sym= sym->next; |
| 1426 | | |
| 1427 | | if( rex != NULL ) |
| 1428 | | break; |
| 1429 | | } |
| 1430 | | crl_garbage_invoke_sweep( context ); |
| 1431 | | |
| 1432 | | return rex; |
| 1433 | | } |
| 1434 | | |
| 1435 | | bool crl_runtime_exec_toplevel( crl_symbol_obj *sym, |
| 1436 | | crl_context_table *context ) |
| 1437 | | { |
| 1438 | | bool retval= true; crl_symbol_obj* ex= NULL; |
| 1439 | | while ( sym != NULL ) |
| 1440 | | { |
| 1441 | | crl_debug("exec of pass symbol type: '0x%X'\n", sym->type ); |
| 1442 | | if( sym->exp == OP_EXPRESS ) |
| 1443 | | { |
| 1444 | | ex = crl_runtime_evaluate_expression( sym, context ); |
| 1445 | | if( ex ) |
| 1446 | | { |
| 1447 | | if( crl_interactive ) |
| 1448 | | crl_runtime_object_print( ex, context, crlout, true ); |
| 1449 | | ex->n_ref--; |
| 1450 | | } |
| 1451 | | else { retval = false; } |
| 1452 | | } |
| 1453 | | else |
| 1454 | | { |
| 1455 | | switch( sym->type ) |
| 1456 | | { |
| 1457 | | /* |
| 1458 | | case OP_CALL_GOTO: |
| 1459 | | ex= crl_runtime_call_dispatch( sym, context ); |
| 1460 | | if( ex ) |
| 1461 | | { |
| 1462 | | if( ex->op_a_t == TYPE_SYMBOL_NIL ) |
| 1463 | | { |
| 1464 | | crl_free(ex); |
| 1465 | | } |
| 1466 | | else |
| 1467 | | { |
| 1468 | | if( crl_interactive ) |
| 1469 | | crl_runtime_object_print( ex, context, crlout, true ); |
| 1470 | | // garbage symbol now! |
| 1471 | | crl_garbage_mark_obj( &ex ); |
| 1472 | | } |
| 1473 | | } |
| 1474 | | break; |
| 1475 | | |
| 1476 | | case STRUCTURE_CONDIT_CTX: |
| 1477 | | crl_runtime_conditional_dispatch( sym, context ); |
| 1478 | | break; |
| 1479 | | |
| 1480 | | case STRUCTURE_LOOP_FOR: |
| 1481 | | //ignore return address since there is no valid return |
| 1482 | | crl_runtime_loop_for( sym, context ); |
| 1483 | | break; |
| 1484 | | |
| 1485 | | case STRUCTURE_LOOP_WHILE: |
| 1486 | | //ignore return address since there is no valid return |
| 1487 | | crl_runtime_loop_while( sym, context ); |
| 1488 | | break; |
| 1489 | | |
| 1490 | | case STRUCTURE_FUNCTION_DEF: |
| 1491 | | if( !(crl_rr_context_push_function_def( sym, &context )) ) |
| 1492 | | crl_fatal("error pushing function defintion!\n"); |
| 1493 | | break; |
| 1494 | | |
| 1495 | | case STRUCTURE_OBJECT_DEF: |
| 1496 | | if( !(crl_rr_context_push_obj_def( sym, &context )) ) |
| 1497 | | crl_fatal("error pushing object defintion!\n"); |
| 1498 | | break; |
| 1499 | | */ |
| 1500 | | |
| 1501 | | case SYMBOL_REFERENCE: |
| 1502 | | if( crl_interactive ) |
| 1503 | | crl_runtime_object_print( sym, context, crlout, true ); |
| 1504 | | break; |
| 1505 | | |
| 1506 | | case SYMBOL_PRIMARY: |
| 1507 | | crl_runtime_object_print( sym, context, crlout, true ); |
| 1508 | | break; |
| 1509 | | |
| 1510 | | default: |
| 1511 | | crl_error("unhandled symbol type '0x%X'\n", sym->type ); |
| 1512 | | retval= false; break; |
| 1513 | | } |
| 1514 | | } |
| 1515 | | |