Simple calls
This commit is contained in:
parent
83b0b705ae
commit
9dbdb11732
@ -82,6 +82,13 @@ def expression(inp: ourlang.Expression) -> Statements:
|
|||||||
|
|
||||||
raise NotImplementedError(expression, inp.type, inp.operator)
|
raise NotImplementedError(expression, inp.type, inp.operator)
|
||||||
|
|
||||||
|
if isinstance(inp, ourlang.FunctionCall):
|
||||||
|
for arg in inp.arguments:
|
||||||
|
yield from expression(arg)
|
||||||
|
|
||||||
|
yield wasm.Statement('call', '${}'.format(inp.function.name))
|
||||||
|
return
|
||||||
|
|
||||||
raise NotImplementedError(expression, inp)
|
raise NotImplementedError(expression, inp)
|
||||||
|
|
||||||
def statement_return(inp: ourlang.StatementReturn) -> Statements:
|
def statement_return(inp: ourlang.StatementReturn) -> Statements:
|
||||||
|
|||||||
@ -225,6 +225,23 @@ def helper(left: i32, right: i32) -> i32:
|
|||||||
assert 7 == result.returned_value
|
assert 7 == result.returned_value
|
||||||
assert [] == result.log_int32_list
|
assert [] == result.log_int32_list
|
||||||
|
|
||||||
|
@pytest.mark.integration_test
|
||||||
|
@pytest.mark.parametrize('type_', ['i32', 'i64', 'f32', 'f64'])
|
||||||
|
def test_call_with_expression(type_):
|
||||||
|
code_py = f"""
|
||||||
|
@exported
|
||||||
|
def testEntry() -> {type_}:
|
||||||
|
return helper(10 + 20, 3 + 5)
|
||||||
|
|
||||||
|
def helper(left: {type_}, right: {type_}) -> {type_}:
|
||||||
|
return left - right
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = Suite(code_py, 'test_call').run_code()
|
||||||
|
|
||||||
|
assert 22 == result.returned_value
|
||||||
|
assert TYPE_MAP[type_] == type(result.returned_value)
|
||||||
|
|
||||||
@pytest.mark.integration_test
|
@pytest.mark.integration_test
|
||||||
@pytest.mark.skip('Not yet implemented')
|
@pytest.mark.skip('Not yet implemented')
|
||||||
def test_assign():
|
def test_assign():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user