def double_absolute_value(x): x000 = trace.trace_function_body('ret00') trace.trace_let('x', x000) trace.trace_let('double_x', exp.UndefinedExp()) double_x = None trace.trace_let('return_value', exp.UndefinedExp()) return_value = None trace.trace_set('double_x', exp.BinaryOpExp('*', exp.NumberExp(2), exp.IdExp('x'))) double_x = 2 * x test = \ exp.BinaryOpExp('<', exp.IdExp('x'), exp.NumberExp(0)) if x < 0: trace.trace_if_true(test) trace.trace_set('return_value', exp.UnaryOpExp('-', exp.IdExp('double_x'))) return_value = -double_x else: trace.trace_if_false(test) trace.trace_set('return_value', exp.IdExp('double_x')) return_value = double_x trace.trace_break('ret00', exp.IdExp('return_value')) trace.exit_block() return return_value
def serverless_function(trace, args): def double_absolute_value(x): x000 = trace.trace_function_body('ret00') trace.trace_let('x', x000) trace.trace_let('double_x', exp.UndefinedExp()) double_x = None trace.trace_let('return_value', exp.UndefinedExp()) return_value = None trace.trace_set('double_x', exp.BinaryOpExp('*', exp.NumberExp(2), exp.IdExp('x'))) double_x = 2 * x test = \ exp.BinaryOpExp('<', exp.IdExp('x'), exp.NumberExp(0)) if x < 0: trace.trace_if_true(test) trace.trace_set('return_value', exp.UnaryOpExp('-', exp.IdExp('double_x'))) return_value = -double_x else: trace.trace_if_false(test) trace.trace_set('return_value', exp.IdExp('double_x')) return_value = double_x trace.trace_break('ret00', exp.IdExp('return_value')) trace.exit_block() return return_value trace.trace_function_call('result', [ exp.IdExp('double_absolute_value'), exp.IndexExp(exp.IdExp('args'), exp.NumberExp(0)) ]) result = double_absolute_value(args[0]) return result
def serverless_function(trace, args): def echo(arg): arg000 = trace.trace_function_body('ret00') trace.trace_let('arg', arg000) trace.trace_break('ret00', exp.IdExp('arg')) trace.exit_block() return arg trace.trace_function_call( 'result', [exp.IdExp('echo'), exp.IndexExp(exp.IdExp('args'), exp.NumberExp(0))]) result = echo(args[0]) return result
def arithmetic(): trace.trace_function_body('ret00') trace.trace_let('foo', exp.UndefinedExp()) foo = None trace.trace_let('bar', exp.UndefinedExp()) bar = None trace.trace_let('res', exp.UndefinedExp()) res = None trace.trace_set('foo', exp.NumberExp(2)) foo = 2 trace.trace_set('bar', exp.BinaryOpExp('+', exp.IdExp('foo'), exp.NumberExp(3))) bar = foo + 3 trace.trace_set('res', exp.BinaryOpExp('*', exp.IdExp('foo'), exp.IdExp('bar'))) res = foo * bar trace.trace_break('ret00', exp.IdExp('res')) trace.exit_block() return res
def foo(): trace.trace_function_body('ret00') trace.trace_let('ret_val', exp.UndefinedExp()) ret_val = None def bar(): trace.trace_function_body('ret00') trace.trace_break('ret00', exp.NumberExp(2)) trace.exit_block() return 2 trace.trace_function_call('ret_val', ['bar']) ret_val = bar() trace.trace_break('ret00', exp.IdExp('ret_val')) trace.exit_block() return ret_val
def serverless_function(trace, args): def foo(): trace.trace_function_body('ret00') trace.trace_let('ret_val', exp.UndefinedExp()) ret_val = None def bar(): trace.trace_function_body('ret00') trace.trace_break('ret00', exp.NumberExp(2)) trace.exit_block() return 2 trace.trace_function_call('ret_val', ['bar']) ret_val = bar() trace.trace_break('ret00', exp.IdExp('ret_val')) trace.exit_block() return ret_val trace.trace_function_call('result', [exp.IdExp('foo')]) result = foo() return result
def serverless_function(trace, args): def arithmetic(): trace.trace_function_body('ret00') trace.trace_let('foo', exp.UndefinedExp()) foo = None trace.trace_let('bar', exp.UndefinedExp()) bar = None trace.trace_let('res', exp.UndefinedExp()) res = None trace.trace_set('foo', exp.NumberExp(2)) foo = 2 trace.trace_set('bar', exp.BinaryOpExp('+', exp.IdExp('foo'), exp.NumberExp(3))) bar = foo + 3 trace.trace_set('res', exp.BinaryOpExp('*', exp.IdExp('foo'), exp.IdExp('bar'))) res = foo * bar trace.trace_break('ret00', exp.IdExp('res')) trace.exit_block() return res trace.trace_function_call('result', [exp.IdExp('arithmetic'), args]) result = arithmetic()
def echo(arg): arg000 = trace.trace_function_body('ret00') trace.trace_let('arg', arg000) trace.trace_break('ret00', exp.IdExp('arg')) trace.exit_block() return arg