(func_ir, var)
return arg1 + arg2
Check if a variable can be inferred as a string constant, and return
    the constant value, or raise GuardException otherwise.
Check if a variable can be inferred as a string constant, and return
    the constant value, or raise GuardException otherwise.
Check if a variable can be inferred as a string constant and return the constant value or raise GuardException otherwise .
def find_str_const(func_ir, var):
    """Check if a variable can be inferred as a string constant, and return
    the constant value, or raise GuardException otherwise.
    """
    require(isinstance(var, ir.Var))
    var_def = get_definition(func_ir, var)
    if isinstance(var_def, ir.Const):
        val = var_def.value
        require(isinstance(val, str))
        return val

    # only add supported (s1+s2), TODO: extend to other expressions
    require(isinstance(var_def, ir.Expr) and var_def.op == 'binop'
            and var_def.fn == operator.add)
    arg1 = find_str_const(func_ir, var_def.lhs)
    arg2 = find_str_const(func_ir, var_def.rhs)
    return arg1 + arg2
def find_str_const ( func_ir , var ) : require ( isinstance ( var , ir . Var ) ) var_def = get_definition ( func_ir , var ) if isinstance ( var_def , ir . Const ) : val = var_def . value require ( isinstance ( val , str ) ) return val # only add supported (s1+s2), TODO: extend to other expressions require ( isinstance ( var_def , ir . Expr ) and var_def . op == 'binop' and var_def . fn == operator . add ) arg1 = find_str_const ( func_ir , var_def . lhs ) arg2 = find_str_const ( func_ir , var_def . rhs ) return arg1 + arg2