def check_type_sat(self, cons): # print (map(lambda c: str(c),cons)) mus = min_unsat_subset(self.solver, cons) if len(mus) == 0: model = self.solver.solve(cons) for d in model: key = str(d) if key in self.infer_goals: smt_type = model[d] self.infer_goals[key].smt_type = smt_type self.infer_goals[key].type = coerce_type( smt_type ) print "%s -> %s::%s" % (self.infer_goals[key], type_to_data_sort( model[d] ), self.infer_goals[key].type ) del self.infer_goals[key] return True else: error_idx = self.declare_error("Type Error in the following sites") for error_site in foldl( map(lambda c: c.get_just(),mus), []): self.extend_error(error_idx, error_site) return False
def check_type_sat(self, cons): # print (map(lambda c: str(c),cons)) mus = min_unsat_subset(self.solver, cons) if len(mus) == 0: model = self.solver.solve(cons) for d in model: key = str(d) if key in self.infer_goals: smt_type = model[d] self.infer_goals[key].smt_type = smt_type self.infer_goals[key].type = coerce_type(smt_type) print "%s -> %s::%s" % (self.infer_goals[key], type_to_data_sort(model[d]), self.infer_goals[key].type) del self.infer_goals[key] return True else: error_idx = self.declare_error("Type Error in the following sites") for error_site in foldl(map(lambda c: c.get_just(), mus), []): self.extend_error(error_idx, error_site) return False
def get_base_facts(self, fact): return foldl(map(lambda f: self.get_base_facts(f), fact.facts), [])
def build_display_regions(self, ast_node): error_idxs = ast_node.error_idxs + foldl(map(lambda lf: self.build_display_regions(lf),ast_node.loc_facts),[]) self.extend_display_regions(error_idxs,[(ast_node.lex_start,ast_node.lex_end)]) return error_idxs
def build_display_regions(self, ast_node): error_idxs = ast_node.error_idxs + foldl(map(lambda v: self.build_display_regions(v),ast_node.exist_vars),[]) self.extend_display_regions(error_idxs,[(ast_node.lex_start,ast_node.lex_end)]) return error_idxs
def getVars(self, fact): return foldl(map(lambda f: self.getVars(f), fact), [])