Remove list get expression
authorDavid Kerkeslager <kerkeslager@gmail.com>
Thu, 4 Jan 2018 21:34:50 +0000 (16:34 -0500)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Thu, 4 Jan 2018 21:34:50 +0000 (16:34 -0500)
generation.py
normalization.py
transformation.py

index b2e191e..348cb18 100644 (file)
@@ -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,
index 40e3afd..9fdabd9 100644 (file)
@@ -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 (
index 56b61f3..e5a1bd5 100644 (file)
@@ -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,