Exemple #1
0
def compile_call(self):
    assert top_context
    ctx = ExprContext(lineno=self.lineno)
    name = self.args[0].rep
    if name not in top_context.actions:
        raise iu.IvyError(self, "call to unknown action: {}".format(name))
    with ctx:
        args = [a.cmpl() for a in self.args[0].args]
    params, returns = top_context.actions[name]
    if len(returns) != len(self.args) - 1:
        raise iu.IvyError(
            self,
            "wrong number of output parameters (got {}, expecting {})".format(
                len(self.args) - 1, len(returns)))
    if len(params) != len(args):
        raise iu.IvyError(
            self,
            "wrong number of input parameters (got {}, expecting {})".format(
                len(args), len(params)))
    with ASTContext(self):
        mas = [sort_infer(a, cmpl_sort(p.sort)) for a, p in zip(args, params)]


#        print self.args
    res = CallAction(*([ivy_ast.Atom(name, mas)] +
                       [a.cmpl() for a in self.args[1:]]))
    res.lineno = self.lineno
    ctx.code.append(res)
    res = ctx.extract()
    #    print "compiled call action: {}".format(res)
    return res
Exemple #2
0
def compile_call(self):
    ctx = ExprContext(lineno = self.lineno)
    with ctx:
        mas = [a.cmpl() for a in self.args[0].args]
    n = self.args[0].rep
#        print self.args
    res = CallAction(*([ivy_ast.Atom(n,mas)] + [a.cmpl() for a in self.args[1:]]))
    res.lineno = self.lineno
    ctx.code.append(res)
    res = ctx.extract()
#    print "compiled call action: {}".format(res)
    return res
Exemple #3
0
def compile_call(self):
    ctx = ExprContext(lineno=self.lineno)
    with ctx:
        mas = [a.cmpl() for a in self.args[0].args]
    n = self.args[0].rep
    #        print self.args
    res = CallAction(*([ivy_ast.Atom(n, mas)] +
                       [a.cmpl() for a in self.args[1:]]))
    res.lineno = self.lineno
    ctx.code.append(res)
    res = ctx.extract()
    #    print "compiled call action: {}".format(res)
    return res
Exemple #4
0
def compile_call(self):
    assert top_context
    ctx = ExprContext(lineno = self.lineno)
    name = self.args[0].rep
    if name not in top_context.actions:
        raise iu.IvyError(self,"call to unknown action: {}".format(name))
    with ctx:
        args = [a.cmpl() for a in self.args[0].args]
    params,returns = top_context.actions[name]
    if len(returns) != len(self.args) - 1:
        raise iu.IvyError(self,"wrong number of output parameters (got {}, expecting {})".format(len(self.args) - 1,len(returns)))
    if len(params) != len(args):
        raise iu.IvyError(self,"wrong number of input parameters (got {}, expecting {})".format(len(args),len(params)))
    with ASTContext(self):
        mas = [sort_infer(a,cmpl_sort(p.sort)) for a,p in zip(args,params)]
#        print self.args
    res = CallAction(*([ivy_ast.Atom(name,mas)] + [a.cmpl() for a in self.args[1:]]))
    res.lineno = self.lineno
    ctx.code.append(res)
    res = ctx.extract()
#    print "compiled call action: {}".format(res)
    return res
Exemple #5
0
def p_action_call_callatom_assign_callatom(p):
    "action : CALL callatom ASSIGN callatom"
    p[0] = CallAction(p[4], p[2])
    p[0].lineno = get_lineno(p, 1)
Exemple #6
0
def p_action_call_callatom(p):
    "action : CALL callatom"
    p[0] = CallAction(p[2])
    p[0].lineno = get_lineno(p, 1)
Exemple #7
0
def p_action_termtuple_assign_fmla(p):
    "action : termtuple ASSIGN callatom"
    p[0] = CallAction(*([p[3]] + list(p[1].args)))
    p[0].lineno = get_lineno(p, 2)
Exemple #8
0
def p_action_call_callatom_assign_callatom(p):
    'action : CALL callatom ASSIGN callatom'
    p[0] = CallAction(p[4], p[2])
    p[0].lineno = get_lineno(p, 1)
Exemple #9
0
def p_action_call_callatom(p):
    'action : CALL callatom'
    p[0] = CallAction(p[2])
    p[0].lineno = get_lineno(p, 1)
Exemple #10
0
def p_action_termtuple_assign_fmla(p):
    'action : termtuple ASSIGN callatom'
    p[0] = CallAction(*([p[3]] + list(p[1].args)))
    p[0].lineno = get_lineno(p, 2)
Exemple #11
0
def p_action_call_callatom_assign_callatom(p):
    'action : CALL callatom ASSIGN callatom'
    p[0] = CallAction(p[4],p[2])
    p[0].lineno = p.lineno(1)
Exemple #12
0
def p_action_call_callatom(p):
    'action : CALL callatom'
    p[0] = CallAction(p[2])
    p[0].lineno = p.lineno(1)
Exemple #13
0
def p_action_termtuple_assign_fmla(p):
    'action : termtuple ASSIGN callatom'
    p[0] = CallAction(*([p[3]]+list(p[1].args)))
    p[0].lineno = p.lineno(2)