Esempio n. 1
0
def compile_action_def(a, sig):
    sig = sig.copy()
    if not hasattr(a.args[1], 'lineno'):
        print a
    assert hasattr(a.args[1], 'lineno')
    with sig:
        params = a.args[0].args
        pformals = [v.to_const('prm:') for v in params]
        if params:
            subst = dict((x.rep, y) for x, y in zip(params, pformals))
            a = ivy_ast.substitute_ast(a, subst)
            assert hasattr(a.args[1], 'lineno')


#            a = ivy_ast.subst_prefix_atoms_ast(a,subst,None,None)
#            print "after: %s" % (a)
# convert object paramaters to arguments (object-orientation!)
        formals = [compile_const(v, sig) for v in pformals + a.formal_params]
        returns = [compile_const(v, sig) for v in a.formal_returns]
        #        print returns
        res = sortify(a.args[1])
        assert hasattr(res, 'lineno'), res
        res.formal_params = formals
        res.formal_returns = returns
        res.label = a.args[0].relname
        return res
Esempio n. 2
0
def compile_action_def(a,sig):
    sig = sig.copy()
    if not hasattr(a.args[1],'lineno'):
        print a
    assert hasattr(a.args[1],'lineno')
    with sig:
        with ASTContext(a.args[1]):
            params = a.args[0].args
            pformals = [v.to_const('prm:') for v in params] 
            if params:
                subst = dict((x.rep,y) for x,y in zip(params,pformals))
                a = ivy_ast.substitute_ast(a,subst)
                assert hasattr(a.args[1],'lineno')
    #            a = ivy_ast.subst_prefix_atoms_ast(a,subst,None,None)
    #            print "after: %s" % (a)
            # convert object paramaters to arguments (object-orientation!)
            formals =  [compile_const(v,sig) for v in pformals + a.formal_params]
            returns = [compile_const(v,sig) for v in a.formal_returns]
    #        print returns
            res = sortify(a.args[1])
            assert hasattr(res,'lineno'), res
            for suba in res.iter_subactions():
                if isinstance(suba,CallAction):
                    if any(lu.used_variables_ast(a) for a in suba.args[0].args):
                        iu.dbg('a.args[0]')
                        iu.dbg('a.formal_params')
                        iu.dbg('suba.lineno')
                        iu.dbg('suba')
                        raise iu.IvyError(suba,"call may not have free variables")
            res.formal_params = formals
            res.formal_returns = returns
            res.label = a.args[0].relname
            return res
Esempio n. 3
0
def compile_action_def(a,sig):
    sig = sig.copy()
    with sig:
        params = a.args[0].args
        pformals = [v.to_const('prm:') for v in params] 
        if params:
            subst = dict((x.rep,y) for x,y in zip(params,pformals))
#            print subst
            a = ivy_ast.substitute_ast(a,subst)
#            a = ivy_ast.subst_prefix_atoms_ast(a,subst,None,None)
#            print "after: %s" % (a)
        # convert object paramaters to arguments (object-orientation!)
        formals =  [compile_const(v,sig) for v in pformals + a.formal_params]
        returns = [compile_const(v,sig) for v in a.formal_returns]
#        print returns
        res = sortify(a.args[1])
        res.formal_params = formals
        res.formal_returns = returns
        return res
Esempio n. 4
0
def compile_action_def(a, sig):
    sig = sig.copy()
    if not hasattr(a.args[1], 'lineno'):
        print a
    assert hasattr(a.args[1], 'lineno')
    with sig:
        with ASTContext(a.args[1]):
            params = a.args[0].args
            pformals = [v.to_const('prm:') for v in params]
            if params:
                subst = dict((x.rep, y) for x, y in zip(params, pformals))
                a = ivy_ast.substitute_ast(a, subst)
                assert hasattr(a.args[1], 'lineno')
    #            a = ivy_ast.subst_prefix_atoms_ast(a,subst,None,None)
    #            print "after: %s" % (a)
    # convert object paramaters to arguments (object-orientation!)
            formals = [
                compile_const(v, sig) for v in pformals + a.formal_params
            ]
            returns = [compile_const(v, sig) for v in a.formal_returns]
            #        print returns
            res = sortify(a.args[1])
            assert hasattr(res, 'lineno'), res
            for suba in res.iter_subactions():
                if isinstance(suba, CallAction):
                    if any(
                            lu.used_variables_ast(a)
                            for a in suba.args[0].args):
                        iu.dbg('a.args[0]')
                        iu.dbg('a.formal_params')
                        iu.dbg('suba.lineno')
                        iu.dbg('suba')
                        raise iu.IvyError(suba,
                                          "call may not have free variables")
            res.formal_params = formals
            res.formal_returns = returns
            res.label = a.args[0].relname
            return res