def compile_app(self): args = [a.compile() for a in self.args] # handle action calls in rhs of assignment if expr_context and top_context and self.rep in top_context.actions: returns = top_context.actions[self.rep] if len(returns) != 1: raise IvyError(self, "wrong number of return values") # TODO: right now we can't do anything with multiple returns sorts = [find_sort(r.sort) for r in returns] ress = [] for sort in sorts: res = ivy_logic.Symbol( 'loc:' + str(len(expr_context.local_syms)), sort) expr_context.local_syms.append(res) ress.append(res()) expr_context.code.append( CallAction(*([ivy_ast.Atom(self.rep, args)] + ress))) return ivy_ast.Tuple(*ress) sort = find_sort(returns[0].sort) res = ivy_logic.Symbol('loc:' + str(len(expr_context.local_syms)), sort) expr_context.local_syms.append(res) expr_context.code.append(CallAction(ivy_ast.Atom(self.rep, args), res)) return res() return (ivy_logic.Equals if self.rep == '=' else ivy_logic.find_polymorphic_symbol(self.rep))(*args)
def compile_app(self): args = [a.compile() for a in self.args] # handle action calls in rhs of assignment if expr_context and top_context and self.rep in top_context.actions: params,returns = top_context.actions[self.rep] if len(returns) != 1: raise IvyError(self,"wrong number of return values") # TODO: right now we can't do anything with multiple returns sorts = [cmpl_sort(r.sort) for r in returns] ress = [] for sort in sorts: res = ivy_logic.Symbol('loc:'+str(len(expr_context.local_syms)),sort) expr_context.local_syms.append(res) ress.append(res()) expr_context.code.append(CallAction(*([ivy_ast.Atom(self.rep,args)]+ress))) return ivy_ast.Tuple(*ress) sort = cmpl_sort(returns[0].sort) res = ivy_logic.Symbol('loc:'+str(len(expr_context.local_syms)),sort) expr_context.local_syms.append(res) with ASTContext(self): if len(params) != len(args): raise iu.IvyError(self,"wrong number of input parameters (got {}, expecting {})".format(len(args),len(params))) args = [sort_infer(a,cmpl_sort(p.sort)) for a,p in zip(args,params)] expr_context.code.append(CallAction(ivy_ast.Atom(self.rep,args),res)) return res() return (ivy_logic.Equals if self.rep == '=' else ivy_logic.find_polymorphic_symbol(self.rep))(*args)
def compile_app(self): args = [a.compile() for a in self.args] # handle action calls in rhs of assignment if expr_context and top_context and self.rep in top_context.actions: params, returns = top_context.actions[self.rep] if len(returns) != 1: raise IvyError(self, "wrong number of return values") # TODO: right now we can't do anything with multiple returns sorts = [cmpl_sort(r.sort) for r in returns] ress = [] for sort in sorts: res = ivy_logic.Symbol( 'loc:' + str(len(expr_context.local_syms)), sort) expr_context.local_syms.append(res) ress.append(res()) expr_context.code.append( CallAction(*([ivy_ast.Atom(self.rep, args)] + ress))) return ivy_ast.Tuple(*ress) sort = cmpl_sort(returns[0].sort) res = ivy_logic.Symbol('loc:' + str(len(expr_context.local_syms)), sort) expr_context.local_syms.append(res) with ASTContext(self): if len(params) != len(args): raise iu.IvyError( self, "wrong number of input parameters (got {}, expecting {})". format(len(args), len(params))) args = [ sort_infer(a, cmpl_sort(p.sort)) for a, p in zip(args, params) ] expr_context.code.append(CallAction(ivy_ast.Atom(self.rep, args), res)) return res() return (ivy_logic.Equals if self.rep == '=' else ivy_logic.find_polymorphic_symbol(self.rep))(*args)
def compile_app(self): args = [a.compile() for a in self.args] # handle action calls in rhs of assignment if expr_context and top_context and self.rep in top_context.actions: return compile_inline_call(self, args) sym = ivy_logic.Equals if self.rep == '=' else ivy_logic.find_polymorphic_symbol( self.rep, throw=False) if sym is not None: return (sym)(*args) res = compile_field_reference(self.rep, args) return res
def compile_field_reference_rec(symbol_name, args, top=False): sym = ivy_logic.find_polymorphic_symbol(symbol_name, throw=False) if sym is None: parent_name, child_name = iu.parent_child_name(symbol_name) if parent_name == 'this': raise cfrfail(symbol_name) try: base = compile_field_reference_rec(parent_name, args) except cfrfail: raise cfrfail(symbol_name) sort = base.sort sort_parent, sort_child = iu.parent_child_name(sort.name) destr_name = iu.compose_names(sort_parent, child_name) if expr_context and top_context and destr_name in top_context.actions: args.insert(0, base) return field_reference_action(destr_name, args, top) sym = ivy_logic.find_polymorphic_symbol(destr_name) args.insert(0, base) if hasattr(sym.sort, 'dom') and len(sym.sort.dom) > 0: res = sym(*pull_args(args, len(sym.sort.dom), sym, top)) return res return sym
def compile_app(self): args = [a.compile() for a in self.args] # handle action calls in rhs of assignment if expr_context and top_context and self.rep in top_context.actions: returns = top_context.actions[self.rep] if len(returns) != 1: raise IvyError(self,"wrong number of return values") # TODO: right now we can't do anything with multiple returns sorts = [find_sort(r.sort) for r in returns] ress = [] for sort in sorts: res = ivy_logic.Symbol('loc:'+str(len(expr_context.local_syms)),sort) expr_context.local_syms.append(res) ress.append(res) expr_context.code.append(CallAction(*([ivy_ast.Atom(self.rep,args)]+ress))) return ivy_ast.Tuple(*ress) sort = find_sort(returns[0].sort) res = ivy_logic.Symbol('loc:'+str(len(expr_context.local_syms)),sort) expr_context.local_syms.append(res) expr_context.code.append(CallAction(ivy_ast.Atom(self.rep,args),res)) return res return (ivy_logic.Equals if self.rep == '=' else ivy_logic.find_polymorphic_symbol(self.rep))(*args)