MCPcopy Create free account
hub / github.com/boostorg/build / compile_to_function

Function compile_to_function

src/engine/function.c:1497–1541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1495}
1496
1497static JAM_FUNCTION * compile_to_function( compiler * c )
1498{
1499 JAM_FUNCTION * const result = BJAM_MALLOC( sizeof( JAM_FUNCTION ) );
1500 int i;
1501 result->base.type = FUNCTION_JAM;
1502 result->base.reference_count = 1;
1503 result->base.formal_arguments = 0;
1504 result->base.num_formal_arguments = 0;
1505
1506 result->base.rulename = 0;
1507
1508 result->code_size = c->code->size;
1509 result->code = BJAM_MALLOC( c->code->size * sizeof( instruction ) );
1510 memcpy( result->code, c->code->data, c->code->size * sizeof( instruction ) );
1511
1512 result->constants = BJAM_MALLOC( c->constants->size * sizeof( OBJECT * ) );
1513 memcpy( result->constants, c->constants->data, c->constants->size * sizeof(
1514 OBJECT * ) );
1515 result->num_constants = c->constants->size;
1516
1517 result->num_subfunctions = c->rules->size;
1518 result->functions = BJAM_MALLOC( c->rules->size * sizeof( SUBFUNCTION ) );
1519 for ( i = 0; i < c->rules->size; ++i )
1520 {
1521 struct stored_rule * const rule = &dynamic_array_at( struct stored_rule,
1522 c->rules, i );
1523 result->functions[ i ].name = rule->name;
1524 result->functions[ i ].code = function_compile( rule->parse );
1525 result->functions[ i ].code->num_formal_arguments = rule->num_arguments;
1526 result->functions[ i ].code->formal_arguments = rule->arguments;
1527 result->functions[ i ].local = rule->local;
1528 }
1529
1530 result->actions = BJAM_MALLOC( c->actions->size * sizeof( SUBACTION ) );
1531 memcpy( result->actions, c->actions->data, c->actions->size * sizeof(
1532 SUBACTION ) );
1533 result->num_subactions = c->actions->size;
1534
1535 result->generic = 0;
1536
1537 result->file = 0;
1538 result->line = -1;
1539
1540 return result;
1541}
1542
1543
1544/*

Callers 2

function_compileFunction · 0.85
function_compile_actionsFunction · 0.85

Calls 1

function_compileFunction · 0.85

Tested by

no test coverage detected