Commit 25da6ff0 authored by dbarbera's avatar dbarbera
Browse files

Refactor assign expression generation into its own rule

parent 4a2f82d5
......@@ -258,18 +258,12 @@ def _prim_path(primaryId):
@expression.register(ogAST.ExprDiv)
@expression.register(ogAST.ExprMod)
@expression.register(ogAST.ExprRem)
@expression.register(ogAST.ExprAssign)
def _basic_operators(expr):
''' Expressions with two sides '''
builder = LLVM['builder']
left = expression(expr.left)
right = expression(expr.right)
if expr.operand == ':=':
builder.store(right, left)
return left
# load the value of the expression if it is a pointer
if left.type.kind == core.TYPE_POINTER:
left = builder.load(left, 'lefttmp')
......@@ -290,6 +284,16 @@ def _basic_operators(expr):
pass
@expression.register(ogAST.ExprAssign)
def _assign(expr):
'''Assign expression'''
builder = LLVM['builder']
left = expression(expr.left)
right = expression(expr.right)
builder.store(right, left)
return left
@expression.register(ogAST.ExprOr)
@expression.register(ogAST.ExprAnd)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment