Exemplo n.º 1
0
 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]])
Exemplo n.º 2
0
	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]])
Exemplo n.º 3
0
	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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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]])
Exemplo n.º 6
0
	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]])
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
	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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
	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)
Exemplo n.º 12
0
	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]])
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
	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)
Exemplo n.º 16
0
	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)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
	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)
Exemplo n.º 20
0
 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]
         ])
Exemplo n.º 21
0
	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)
Exemplo n.º 22
0
 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)
Exemplo n.º 23
0
	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)
Exemplo n.º 24
0
 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)
Exemplo n.º 25
0
	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)
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
	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)
Exemplo n.º 28
0
 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]])
Exemplo n.º 29
0
 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)
Exemplo n.º 30
0
	def int_check_term(self, ast_node, ctxt):
		t = tyVar()
		self.mark_for_infer(ast_node, t)
		return (True, t, [])
Exemplo n.º 31
0
	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)
Exemplo n.º 32
0
 def int_check_term(self, ast_node, ctxt):
     t = tyVar()
     self.mark_for_infer(ast_node, t)
     return (True, t, [])
Exemplo n.º 33
0
	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)
Exemplo n.º 34
0
	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]])
Exemplo n.º 35
0
	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)
Exemplo n.º 36
0
 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)