Beispiel #1
0
def DirFun(unit: ir.Unit, operands: List):
    name, kind, output_types, input_types = operands
    if len(input_types) > o.MAX_PARAMETERS or len(
            output_types) > o.MAX_PARAMETERS:
        raise ParseError(f"parameter list too long {name}")
    fun = unit.GetFun(name)
    if fun is None:
        fun = ir.Fun(name, kind, output_types, input_types)
        unit.AddFun(fun)
    elif fun.forward_declared:
        unit.InitForwardDeclaredFun(fun, kind, output_types, input_types)
    else:
        raise ParseError(f"duplicate Fun {name}")
Beispiel #2
0
def DirFun(unit: ir.Unit, operands: List):
    name, kind, output_types, input_types = operands
    if len(input_types) > o.MAX_PARAMETERS or len(
            output_types) > o.MAX_PARAMETERS:
        raise ParseError(f"parameter list too long {name}")
    fun = unit.GetFun(name)
    if fun is None:
        fun = ir.Fun(name, kind, output_types, input_types)
        unit.AddFun(fun)
    elif fun.kind is o.FUN_KIND.INVALID:  # forward_declared
        unit.InitForwardDeclaredFun(fun, kind, output_types, input_types)
    elif fun.kind is o.FUN_KIND.EXTERN or kind is o.FUN_KIND.EXTERN:
        assert output_types == fun.output_types
        assert input_types == fun.input_types
        if kind is o.FUN_KIND.EXTERN:
            # we already have a proper function
            return
        # definition of a formerly extern functions
        fun.kind = kind
        # move fun to make it current
        unit.funs.remove(fun)
        unit.funs.append(fun)
    else:
        raise ParseError(f"duplicate Fun {name}")