def generate(c_program):
template = ENV.get_template('program.c')
return template.render(
- builtins=list(sorted(c_program.builtins)),
+ builtins=list(sorted(c_program.builtin_set)),
statements=[generate_statement(statement) for statement in c_program.statements],
standard_libraries=list(sorted(c_program.standard_libraries)),
symbol_list=c_program.symbol_list,
CProgram = collections.namedtuple(
'CProgram',
[
- 'builtins',
+ 'builtin_set',
'statements',
'standard_libraries',
'symbol_list',
def transform_function_call_expression(accumulators, function_call):
if function_call.function.value in BUILTINS.keys():
# TODO Check that the builtin is actually callable
- accumulators.builtins.add(function_call.function.value)
+ accumulators.builtin_set.add(function_call.function.value)
return CFunctionCallExpression(
name='builtin$' + function_call.function.value,
Accumulators = collections.namedtuple(
'Accumulators',
[
- 'builtins',
+ 'builtin_set',
'symbol_list',
],
)
def transform(program):
accumulators = Accumulators(
- builtins=set(),
+ builtin_set=set(),
symbol_list = [],
)
]
standard_libraries = set()
- for builtin in accumulators.builtins:
+ for builtin in accumulators.builtin_set:
for standard_library in BUILTINS[builtin]:
standard_libraries.add(standard_library)
return CProgram(
- builtins=accumulators.builtins,
+ builtin_set=accumulators.builtin_set,
statements=c_statements,
standard_libraries=standard_libraries,
symbol_list=accumulators.symbol_list,