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

Function compile_to_function

v2/engine/function.c:1446–1490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1444}
1445
1446static JAM_FUNCTION * compile_to_function( compiler * c )
1447{
1448 JAM_FUNCTION * const result = BJAM_MALLOC( sizeof( JAM_FUNCTION ) );
1449 int i;
1450 result->base.type = FUNCTION_JAM;
1451 result->base.reference_count = 1;
1452 result->base.formal_arguments = 0;
1453 result->base.num_formal_arguments = 0;
1454
1455 result->base.rulename = 0;
1456
1457 result->code_size = c->code->size;
1458 result->code = BJAM_MALLOC( c->code->size * sizeof( instruction ) );
1459 memcpy( result->code, c->code->data, c->code->size * sizeof( instruction ) );
1460
1461 result->constants = BJAM_MALLOC( c->constants->size * sizeof( OBJECT * ) );
1462 memcpy( result->constants, c->constants->data, c->constants->size * sizeof(
1463 OBJECT * ) );
1464 result->num_constants = c->constants->size;
1465
1466 result->num_subfunctions = c->rules->size;
1467 result->functions = BJAM_MALLOC( c->rules->size * sizeof( SUBFUNCTION ) );
1468 for ( i = 0; i < c->rules->size; ++i )
1469 {
1470 struct stored_rule * const rule = &dynamic_array_at( struct stored_rule,
1471 c->rules, i );
1472 result->functions[ i ].name = rule->name;
1473 result->functions[ i ].code = function_compile( rule->parse );
1474 result->functions[ i ].code->num_formal_arguments = rule->num_arguments;
1475 result->functions[ i ].code->formal_arguments = rule->arguments;
1476 result->functions[ i ].local = rule->local;
1477 }
1478
1479 result->actions = BJAM_MALLOC( c->actions->size * sizeof( SUBACTION ) );
1480 memcpy( result->actions, c->actions->data, c->actions->size * sizeof(
1481 SUBACTION ) );
1482 result->num_subactions = c->actions->size;
1483
1484 result->generic = 0;
1485
1486 result->file = 0;
1487 result->line = -1;
1488
1489 return result;
1490}
1491
1492
1493/*

Callers 2

function_compileFunction · 0.85
function_compile_actionsFunction · 0.85

Calls 1

function_compileFunction · 0.85

Tested by

no test coverage detected