X-Git-Url: https://code.kerkeslager.com/?p=fur;a=blobdiff_plain;f=normalization.py;h=4a16a3dcefbf364f9107281708058316f12d1503;hp=618e5d9a7d1d6e59eb8a32ed8680780963d0afc6;hb=3da330f045ed7fcb66ee9d9447de320680263699;hpb=204200cd277191bd0a272528b2a811cbdb7990a0 diff --git a/normalization.py b/normalization.py index 618e5d9..4a16a3d 100644 --- a/normalization.py +++ b/normalization.py @@ -141,11 +141,14 @@ def normalize_string_literal_expression(counter, expression): ) def normalize_symbol_expression(counter, expression): - # TODO Store this in a C variable + variable = '${}'.format(counter) return ( - counter, - (), - NormalSymbolExpression(symbol=expression.symbol), + counter + 1, + (NormalVariableInitializationStatement( + variable=variable, + expression=NormalSymbolExpression(symbol=expression.symbol), + ),), + NormalVariableExpression(variable=variable), ) def normalize_function_call_expression(counter, expression): @@ -358,6 +361,10 @@ def normalize_expression(counter, expression): }[type(expression)](counter, expression) def normalize_expression_statement(counter, statement): + # TODO Normalized will be a NormalVariableExpression, which will go unused + # for expression statements in every case except when it's a return + # statement. This cases warnings on C compilation. We should only generate + # this variable when it will be used on return. counter, prestatements, normalized = normalize_expression(counter, statement.expression) return ( @@ -406,7 +413,6 @@ def normalize_statement_list(statement_list): yield normalized def normalize(program): - return NormalProgram( statement_list=normalize_statement_list(program.statement_list), )