Ejemplo n.º 1
0
 def overload_print(var_type, fmt):
     with overload('print', var_type >> io(unit), 's'):
         fmt = codegen.string_lit(cs, fmt)
         printf_args = [ fmt, cs.load_var('s') ]
         cs.builder.call( printf, printf_args )
         cs.builder.ret_void()
Ejemplo n.º 2
0
            printf_args = [ fmt, cs.load_var('s') ]
            cs.builder.call( printf, printf_args )
            cs.builder.ret_void()
        

    overload_print(string, '%s')
    overload_print(integer, '%d')
    overload_print(real, '%f')


    
    

    # TODO define this one manually
    with overload('print', boolean >> io(unit), 'b'):
        fmt = codegen.string_lit(cs, '%s')
        
        true = codegen.string_lit(cs, 'true')
        false = codegen.string_lit(cs, 'false')

        with cs.builder.if_else(cs.load_var('b')) as (then, alt):
            with then:
                cs.builder.call( printf, [fmt, true] )
            with alt:
                cs.builder.call( printf, [fmt, false] )
        
        cs.builder.ret_void()
        


    def overload_eq(t, attr):