def int_check_type(self, ast_node, ctxt): tvar1 = tyVar() if ast_node.name in ctxt['type_vars']: tvar2 = ctxt['type_vars'][ast_node.name] else: tvar2 = tyVar() ctxt['type_vars'][ast_node.name] = tvar2 return (True, tvar1, [tvar1 | Eq | tvar2 | just | [ast_node]])
def int_check_type(self, ast_node, ctxt): tvar1 = tyVar() if ast_node.name in ctxt['type_vars']: tvar2 = ctxt['type_vars'][ast_node.name] else: tvar2 = tyVar() ctxt['type_vars'][ast_node.name] = tvar2 return (True, tvar1, [tvar1 |Eq| tvar2 |just| [ast_node]])
def int_check_term(self, ast_node, ctxt): (s0,t0,cs0) = self.int_check_term(ast_node.term1, ctxt) (s1,t1,cs1) = self.int_check_term(ast_node.term2, ctxt) t2 = tyVar() t3 = tyVar() cs2 = [t0 |Eq| tyArrow(t2,t3) |just| [ast_node], t1 |Eq| t2 |just| [ast_node]] self.mark_for_infer(ast_node, t3) return (s0 and s1, t3, cs2 + cs0 + cs1)
def int_check_type(self, ast_node, ctxt): (s1, t1, cons1) = self.int_check_type(ast_node.type1, ctxt) (s2, t2, cons2) = self.int_check_type(ast_node.type2, ctxt) t3 = tyVar() t4 = tyVar() return (s1 and s2, t4, [ t1 | Eq | tyArrow(t3, t4) | just | [ast_node], t2 | eq | t3 | just | [ast_node] ] + cons1 + cons2)
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() if ast_node.name in ctxt['vars']: tvar2 = ctxt['vars'][ast_node.name] else: tvar2 = tyVar() ctxt['vars'][ast_node.name] = tvar2 self.mark_for_infer(ast_node, tvar1) return (True, tvar1, [tvar1 | Eq | tvar2 | just | [ast_node]])
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() if ast_node.name in ctxt['vars']: tvar2 = ctxt['vars'][ast_node.name] else: tvar2 = tyVar() ctxt['vars'][ast_node.name] = tvar2 self.mark_for_infer(ast_node, tvar1) return (True, tvar1, [tvar1 |Eq| tvar2 |just| [ast_node]])
def int_check_term(self, ast_node, ctxt): (s0, t0, cs0) = self.int_check_term(ast_node.term1, ctxt) (s1, t1, cs1) = self.int_check_term(ast_node.term2, ctxt) t2 = tyVar() t3 = tyVar() cs2 = [ t0 | Eq | tyArrow(t2, t3) | just | [ast_node], t1 | Eq | t2 | just | [ast_node] ] self.mark_for_infer(ast_node, t3) return (s0 and s1, t3, cs2 + cs0 + cs1)
def int_check_term(self, ast_node, ctxt): (s0,t0,cs0) = self.int_check_term(ast_node.term1, ctxt) (s1,t1,cs1) = self.int_check_term(ast_node.term2, ctxt) t2 = tyVar() cs2 = [t1 |Eq| tyList(t0) |just| [ast_node], t2 |Eq| t1] self.mark_for_infer(ast_node, t2) return (s0 and s1, t2, cs2 + cs0 + cs1)
def int_check_term(self, ast_node, ctxt): (s0, t0, cs0) = self.int_check_term(ast_node.term1, ctxt) (s1, t1, cs1) = self.int_check_term(ast_node.term2, ctxt) t2 = tyVar() cs2 = [t1 | Eq | tyList(t0) | just | [ast_node], t2 | Eq | t1] self.mark_for_infer(ast_node, t2) return (s0 and s1, t2, cs2 + cs0 + cs1)
def int_check_term(self, ast_node, ctxt): (s0, t0, cs0) = self.int_check_term(ast_node.term, ctxt) t1 = tyVar() self.mark_for_infer(ast_node, t1) return (s0, t1, [ t1 | Eq | tyBool | just | [ast_node], t0 | Eq | tyBool | just | [ast_node] ] + cs0)
def int_check_term(self, ast_node, ctxt): (s0, ts, cs0) = self.int_check_term(ast_node.terms, ctxt) cs1 = [] t1 = tyVar() for t0 in ts: cs1.append(t1 |Eq| tyMSet(t0) |just| [ast_node]) self.mark_for_infer(ast_node, t1) return (s0, t1, cs1 + cs0)
def int_check_type(self, ast_node, ctxt): tvar = tyVar() if ast_node.name not in BASE_TYPES: error_idx = self.declare_error("Unknown data type \'%s\'" % ast_node.name) self.extend_error(error_idx,ast_node) return (False,tvar,[]) else: return (True,tvar,[tvar |Eq| smt_base_type(ast_node.name) |just| [ast_node]])
def int_check_term(self, ast_node, ctxt): (s0, ts, cs0) = self.int_check_term(ast_node.terms, ctxt) cs1 = [] t1 = tyVar() for t0 in ts: cs1.append(t1 | Eq | tyMSet(t0) | just | [ast_node]) self.mark_for_infer(ast_node, t1) return (s0, t1, cs1 + cs0)
def int_check_dec(self, ast_node, ctxt): local_ctxt = copy_ctxt(ctxt) tvar1 = tyVar() ctxt['pred'][ast_node.name] = tvar1 if ast_node.type == None: return (True, [tvar1 | Eq | tyUnit | just | [ast_node]]) else: (s, tvar2, cons) = self.int_check_type(ast_node.type, local_ctxt) return (s, [tvar1 | Eq | tvar2 | just | [ast_node]] + cons)
def int_check_dec(self, ast_node, ctxt): local_ctxt = copy_ctxt(ctxt) tvar1 = tyVar() ctxt['pred'][ast_node.name] = tvar1 if ast_node.type == None: return (True,[tvar1 |Eq| tyUnit |just| [ast_node]]) else: (s,tvar2,cons) = self.int_check_type(ast_node.type, local_ctxt) return (s,[tvar1 |Eq| tvar2 |just| [ast_node]] + cons)
def int_check_dec(self, ast_node, ctxt): s0 = True type_sig_cons = [] for ty_sig in ast_node.type_sigs: (s,t,cs) = self.int_check_type(ty_sig.type_sig, ctxt) s0 = s0 and s t0 = tyVar() type_sig_cons += [t0 |Eq| t |just| [ty_sig]] + cs ctxt['cons'][ty_sig.name] = t0 return (s0, type_sig_cons)
def int_check_term(self, ast_node, ctxt): (s0, ts, cs0) = self.int_check_term(ast_node.terms, ctxt) curr = len(ts) - 1 t1 = tyUnit while curr >= 0: t1 = tyTuple(ts[curr], t1) curr -= 1 t0 = tyVar() self.mark_for_infer(ast_node, t0) return (s0, t0, [t0 | Eq | t1 | just | [ast_node]] + cs0)
def int_check_dec(self, ast_node, ctxt): s0 = True type_sig_cons = [] for ty_sig in ast_node.type_sigs: (s, t, cs) = self.int_check_type(ty_sig.type_sig, ctxt) s0 = s0 and s t0 = tyVar() type_sig_cons += [t0 | Eq | t | just | [ty_sig]] + cs ctxt['cons'][ty_sig.name] = t0 return (s0, type_sig_cons)
def int_check_term(self, ast_node, ctxt): (s0, ts, cs0) = self.int_check_term(ast_node.terms, ctxt) curr = len(ts) - 1 t1 = tyUnit while curr >= 0: t1 = tyTuple(ts[curr],t1) curr -= 1 t0 = tyVar() self.mark_for_infer(ast_node, t0) return (s0, t0, [t0 |Eq| t1 |just| [ast_node]] + cs0)
def int_check_type(self, ast_node, ctxt): tvar = tyVar() if ast_node.name not in BASE_TYPES: error_idx = self.declare_error("Unknown data type \'%s\'" % ast_node.name) self.extend_error(error_idx, ast_node) return (False, tvar, []) else: return (True, tvar, [ tvar | Eq | smt_base_type(ast_node.name) | just | [ast_node] ])
def int_check_term(self, ast_node, ctxt): (s0,t0,cs0) = self.int_check_term(ast_node.term1, ctxt) (s1,t1,cs1) = self.int_check_term(ast_node.term2, ctxt) t3 = tyVar() if ast_node.op in BOOL_OPS_1: cs3 = [t0 |Eq| t1 |just| [ast_node], t3 |Eq| tyBool |just| [ast_node]] elif ast_node.op in BOOL_OPS_2: cs3 = [tyMSet(t0) |Eq| t1 |just| [ast_node], t3 |Eq| tyBool |just| [ast_node]] elif ast_node.op in NUM_OPS: cs3 = [t0 |Eq| t1 |just| [ast_node], t0 |Eq| t3 |just| [ast_node]] self.mark_for_infer(ast_node, t3) return (s0 and s1, t3, cs3 + cs0 + cs1)
def int_check_type(self, ast_node, ctxt): types = ast_node.types curr = len(types) - 1 all_cons = [] t1 = tyUnit s0 = True while curr >= 0: (s, t2, cons) = self.int_check_type(types[curr], ctxt) s0 = s0 and s all_cons += cons t1 = tyTuple(t2, t1) curr -= 1 t0 = tyVar() return (s0, t0, [t0 | Eq | t1 | just | [ast_node]] + all_cons)
def int_check_type(self, ast_node, ctxt): types = ast_node.types curr = len(types)-1 all_cons = [] t1 = tyUnit s0 = True while curr >= 0: (s,t2,cons) = self.int_check_type(types[curr], ctxt) s0 = s0 and s all_cons += cons t1 = tyTuple(t2,t1) curr -= 1 t0 = tyVar() return (s0,t0,[t0 |Eq| t1 |just| [ast_node]] + all_cons)
def int_check_term(self, ast_node, ctxt): local_ctxt = copy_ctxt(ctxt) s0 = True all_cons = [] for comp_range in ast_node.comp_ranges: (s, cs) = self.int_check_comp_range(comp_range, ctxt, local_ctxt) s0 = s0 and s all_cons += cs (s, t0, cs) = self.int_check_term(ast_node.term, local_ctxt) t1 = tyVar() s0 = s0 and s all_cons += [t1 | Eq | tyMSet(t0) | just | [ast_node]] + cs for guard in ast_node.guards: (s, tg, cs) = self.int_check_term(guard, local_ctxt) s0 = s0 and s all_cons += [tg | Eq | tyBool | just | [ast_node]] + cs self.mark_for_infer(ast_node, t1) return (s0, t1, all_cons)
def int_check_term(self, ast_node, ctxt): local_ctxt = copy_ctxt( ctxt ) s0 = True all_cons = [] for comp_range in ast_node.comp_ranges: (s,cs) = self.int_check_comp_range( comp_range, ctxt, local_ctxt ) s0 = s0 and s all_cons += cs (s,t0,cs) = self.int_check_term(ast_node.term, local_ctxt) t1 = tyVar() s0 = s0 and s all_cons += [t1 |Eq| tyMSet(t0) |just| [ast_node]] + cs for guard in ast_node.guards: (s,tg,cs) = self.int_check_term( guard, local_ctxt ) s0 = s0 and s all_cons += [tg |Eq| tyBool |just| [ast_node]] + cs self.mark_for_infer(ast_node, t1) return (s0, t1, all_cons)
def int_check_term(self, ast_node, ctxt): (s0, t0, cs0) = self.int_check_term(ast_node.term1, ctxt) (s1, t1, cs1) = self.int_check_term(ast_node.term2, ctxt) t3 = tyVar() if ast_node.op in BOOL_OPS_1: cs3 = [ t0 | Eq | t1 | just | [ast_node], t3 | Eq | tyBool | just | [ast_node] ] elif ast_node.op in BOOL_OPS_2: cs3 = [ tyMSet(t0) | Eq | t1 | just | [ast_node], t3 | Eq | tyBool | just | [ast_node] ] elif ast_node.op in NUM_OPS: cs3 = [ t0 | Eq | t1 | just | [ast_node], t0 | Eq | t3 | just | [ast_node] ] self.mark_for_infer(ast_node, t3) return (s0 and s1, t3, cs3 + cs0 + cs1)
def int_check_type(self, ast_node, ctxt): (s1,t1,cons1) = self.int_check_type(ast_node.type1, ctxt) (s2,t2,cons2) = self.int_check_type(ast_node.type2, ctxt) t3 = tyVar() return (s1 and s2,t3,[t3 |Eq| tyArrow(t1,t2) |just| [ast_node]] + cons1 + cons2)
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() tvar2 = ctxt['cons'][ast_node.name] self.mark_for_infer(ast_node, tvar1) return (True, tvar1, [tvar1 | Eq | tvar2 | just | [ast_node]])
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() (s, tvar2, cons) = self.int_check_type(ast_node.type, ctxt) # print map(lambda c: str(c),cons) self.mark_for_infer(ast_node, tvar1) return (s, tvar1, [tvar1 | Eq | tvar2 | just | [ast_node]] + cons)
def int_check_term(self, ast_node, ctxt): t = tyVar() self.mark_for_infer(ast_node, t) return (True, t, [])
def int_check_term(self, ast_node, ctxt): (s0,t0,cs0) = self.int_check_term(ast_node.term, ctxt) t1 = tyVar() self.mark_for_infer(ast_node, t1) return (s0, t1, [t1 |Eq| tyBool |just| [ast_node], t0 |Eq| tyBool |just| [ast_node]] + cs0)
def int_check_term(self, ast_node, ctxt): t = tyVar() self.mark_for_infer(ast_node, t) return (True, t, [])
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() (s,tvar2,cons) = self.int_check_type( ast_node.type, ctxt) # print map(lambda c: str(c),cons) self.mark_for_infer(ast_node, tvar1) return (s,tvar1,[tvar1 |Eq| tvar2 |just| [ast_node]] + cons)
def int_check_term(self, ast_node, ctxt): tvar1 = tyVar() tvar2 = ctxt['cons'][ast_node.name] self.mark_for_infer(ast_node, tvar1) return (True, tvar1, [tvar1 |Eq| tvar2 |just| [ast_node]])
def int_check_type(self, ast_node, ctxt): (s,t1,cons) = self.int_check_type(ast_node.type, ctxt) t0 = tyVar() return (s,t0,[t0 |Eq| tyList(t1) |just| [ast_node]] + cons)
def int_check_type(self, ast_node, ctxt): (s, t1, cons) = self.int_check_type(ast_node.type, ctxt) t0 = tyVar() return (s, t0, [t0 | Eq | tyList(t1) | just | [ast_node]] + cons)