From 521bb843144e1c835f9eeff8172eea580ef02c4d Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Thu, 4 Jan 2018 16:34:50 -0500 Subject: [PATCH] Remove list get expression --- generation.py | 7 ------- normalization.py | 27 --------------------------- transformation.py | 16 ---------------- 3 files changed, 50 deletions(-) diff --git a/generation.py b/generation.py index b2e191e..348cb18 100644 --- a/generation.py +++ b/generation.py @@ -36,18 +36,11 @@ def generate_structure_literal_expression(expression): def generate_list_construct_expression(expression): return 'List_construct({})'.format(expression.allocate) -def generate_list_get_expression(expression): - return 'List_get(&{}, {})'.format( - generate_expression(expression.list_expression), - generate_expression(expression.index_expression), - ) - def generate_expression(expression): return { transformation.CFunctionCallExpression: generate_function_call, transformation.CIntegerLiteral: generate_integer_literal, transformation.CListConstructExpression: generate_list_construct_expression, - transformation.CListGetExpression: generate_list_get_expression, transformation.CStringLiteral: generate_string_literal, transformation.CStructureLiteralExpression: generate_structure_literal_expression, transformation.CSymbolExpression: generate_symbol_expression, diff --git a/normalization.py b/normalization.py index 40e3afd..9fdabd9 100644 --- a/normalization.py +++ b/normalization.py @@ -147,14 +147,6 @@ NormalListAppendStatement = collections.namedtuple( ], ) -NormalListGetExpression = collections.namedtuple( - 'NormalListGetExpression', - [ - 'list_expression', - 'index_expression', - ], -) - def normalize_list_literal_expression(counter, expression): list_variable = '${}'.format(counter) counter += 1 @@ -190,25 +182,6 @@ def normalize_list_literal_expression(counter, expression): list_expression, ) -def normalize_list_item_expression(counter, expression): - counter, list_prestatements, list_expression = normalize_expression(counter, expression.list_expression) - counter, index_prestatements, index_expression = normalize_expression(counter, expression.index_expression) - - result_variable = '${}'.format(counter) - result_prestatement = NormalVariableInitializationStatement( - variable=result_variable, - expression=NormalListGetExpression( - list_expression=list_expression, - index_expression=index_expression, - ), - ) - - return ( - counter + 1, - list_prestatements + index_prestatements + (result_prestatement,), - NormalVariableExpression(variable=result_variable), - ) - def normalize_string_literal_expression(counter, expression): variable = '${}'.format(counter) return ( diff --git a/transformation.py b/transformation.py index 56b61f3..e5a1bd5 100644 --- a/transformation.py +++ b/transformation.py @@ -1,7 +1,6 @@ import collections import conversion -import normalization CIntegerLiteral = collections.namedtuple( 'CIntegerLiteral', @@ -204,14 +203,6 @@ CListAppendStatement = collections.namedtuple( ], ) -CListGetExpression = collections.namedtuple( - 'CListGetExpression', - [ - 'list_expression', - 'index_expression', - ], -) - def transform_structure_literal_expression(accumulators, expression): return CStructureLiteralExpression( field_count=expression.field_count, @@ -222,12 +213,6 @@ def transform_structure_literal_expression(accumulators, expression): def transform_list_construct_expression(accumulators, expression): return CListConstructExpression(allocate=expression.allocate) -def transform_list_get_expression(accumulators, expression): - return CListGetExpression( - list_expression=transform_expression(accumulators, expression.list_expression), - index_expression=transform_expression(accumulators, expression.index_expression), - ) - def transform_list_append_statement(accumulators, expression): return CListAppendStatement( list_expression=transform_expression(accumulators, expression.list_expression), @@ -239,7 +224,6 @@ def transform_expression(accumulators, expression): conversion.CPSFunctionCallExpression: transform_function_call_expression, conversion.CPSIntegerLiteralExpression: transform_integer_literal_expression, conversion.CPSListConstructExpression: transform_list_construct_expression, - normalization.NormalListGetExpression: transform_list_get_expression, conversion.CPSStructureLiteralExpression: transform_structure_literal_expression, conversion.CPSStringLiteralExpression: transform_string_literal_expression, conversion.CPSSymbolExpression: transform_symbol_expression, -- 2.20.1