Example #1
0
def _filter_rtn(args, keywords, starargs, context, dryrun, orig_args):
    assert not keywords
    assert not starargs
    assert len(args) == 2
    f = args[0]

    r = context.get_cached(_filter_rtn)
    if not r:
        r = InstanceType(ListClass, [Union.EMPTY])
        context.set_cached(_filter_rtn, r)

    rtn = []
    for t in args[1].types():
        elt_type = get_iter_type(Union(t), context)
        if f != Union(NONE):
            f.call([elt_type], {}, None, context, dryrun, orig_args)

        if t is STR:
            rtn.append(Union(STR))
        else:
            r.update(0, elt_type)
            rtn.append(Union(r))

    return Union.make_union(*rtn)
Example #2
0
def _filter_rtn(args, keywords, starargs, context, dryrun, orig_args):
    assert not keywords
    assert not starargs
    assert len(args) == 2
    f = args[0]

    r = context.get_cached(_filter_rtn)
    if not r:
        r = InstanceType(ListClass, [Union.EMPTY])
        context.set_cached(_filter_rtn, r)

    rtn = []
    for t in args[1].types():
        elt_type = get_iter_type(Union(t), context)
        if f != Union(NONE):
            f.call([elt_type], {}, None, context, dryrun, orig_args)

        if t is STR:
            rtn.append(Union(STR))
        else:
            r.update(0, elt_type)
            rtn.append(Union(r))

    return Union.make_union(*rtn)
Example #3
0
    lt = elt_u.getattr("__lt__", context)
    lt.call([elt_u], {}, None, context, False, None)
ListClass.setattr("sort", Union(FixedFunction([InstanceArg(ListClass, [Var(0)])], NONE, implicit_behavior_funcs=[sort_effects])))
ListClass.setattr("reverse", Union(FixedFunction([InstanceArg(ListClass, [Var(0)])], NONE)))
ListClass.setattr("index", Union(FixedFunction([InstanceArg(ListClass, [Var(0)]), Subtype(Var(0)), INT, INT], INT, ndefaults=2)))
ListClass.setattr("__mul__", Union(FixedFunction([InstanceArg(ListClass, [Var(0)]), INT], InstanceArg(ListClass, [Var(0)]))))



def _dict_kw(args, keywords, starargs, context, dryrun, orig_args):
    try:
        args, keywords, vararg = translate_call(args, keywords, starargs, ["self"], 0, None, context)
    except _FuncArgsError, e:
        context.log_error(e.message)
        return Union.EMPTY
    u = Union.make_union(*keywords.values())

    for t in args[0].types():
        if not isinstance(t, InstanceType) or t.cls != DictClass:
            print "WTF"
            continue
        if t.unions is None:
            t.unions = [Union.EMPTY, Union.EMPTY]

        t.update(0, Union(STR))
        t.update(1, u)
    return Union(NONE)


DictClass.setattr("__init__", Union(PolymorphicFunction(
    FixedFunction([InstanceArg(DictClass, [BOT, BOT], update=True)], NONE),
Example #4
0
            ndefaults=2)))
ListClass.setattr(
    "__mul__",
    Union(
        FixedFunction([InstanceArg(ListClass, [Var(0)]), INT],
                      InstanceArg(ListClass, [Var(0)]))))


def _dict_kw(args, keywords, starargs, context, dryrun, orig_args):
    try:
        args, keywords, vararg = translate_call(args, keywords, starargs,
                                                ["self"], 0, None, context)
    except _FuncArgsError, e:
        context.log_error(e.message)
        return Union.EMPTY
    u = Union.make_union(*keywords.values())

    for t in args[0].types():
        if not isinstance(t, InstanceType) or t.cls != DictClass:
            print "WTF"
            continue
        if t.unions is None:
            t.unions = [Union.EMPTY, Union.EMPTY]

        t.update(0, Union(STR))
        t.update(1, u)
    return Union(NONE)


DictClass.setattr(
    "__init__",