Example #1
0
 def get_program(self, condition):
     return ast.Program(
         [],  # No local variable
         [
             ast.If(
                 condition,
                 ast.TaggedNode(ON_TRUE_TAG,
                                ast.Return(ast.LitteralBoolean(True))),
                 ast.TaggedNode(ON_FALSE_TAG,
                                ast.Return(ast.LitteralBoolean(False))))
         ])
Example #2
0
    def get_program(self, param):
        temp_name = 'result'
        temp_usage = ast.VariableUsage(temp_name)

        return ast.Program([
            (temp_name, ast.BooleanType),
        ], [
            ast.Assign(temp_usage,
                       ast.Call(ast.VariableUsage('identity'), [param])),
            ast.Return(temp_usage),
        ])
Example #3
0
 def get_program(self, condition):
     return ast.Program([], [
         ast.Return(condition),
     ])