Beispiel #1
0
	def visit_Assign(self, node):
		name = node.targets[0].id
		state = self.env[node.lineno]
		if name in self.symbolic_memory:
			state[name] = self.symbolic_memory[name]
		self.symbolic_memory[name] = eval_symbolic(node.value,state,self.symbolic_memory)
		
		self.generic_visit(node)
Beispiel #2
0
    def visit_Assign(self, node):
        name = node.targets[0].id
        state = self.env[node.lineno]
        if name in self.symbolic_memory:
            state[name] = self.symbolic_memory[name]
        self.symbolic_memory[name] = eval_symbolic(node.value, state,
                                                   self.symbolic_memory)

        self.generic_visit(node)
Beispiel #3
0
    def visit_While(self, node):
        test = node.test
        state = self.env[node.lineno]
        iter_num = 1

        loop = self.eval_if(test, state[iter_num])
        expr = eval_symbolic(test, state[iter_num], self.symbolic_memory)

        if not expr.is_const():
            if loop:
                self.path_constraints += [expr]
            else:
                self.path_constraints += [expr.negate()]

            self.compare_and_update_stack(loop, self.branchno)
            self.branchno += 1

        if loop:
            iter_num += 1
            self.generic_visit(node)
            while True:
                loop = iter_num in state

                if not expr.is_const():
                    self.compare_stack(loop, self.branchno)

                if not loop:
                    break

                if not expr.is_const():
                    self.update_stack(loop, self.branchno)
                expr = eval_symbolic(test, state[iter_num],
                                     self.symbolic_memory)
                if not expr.is_const():
                    self.path_constraints += [expr]
                    self.branchno += 1
                iter_num += 1

                self.generic_visit(node)
Beispiel #4
0
	def visit_While(self, node):
		test = node.test
		state = self.env[node.lineno]
		iter_num = 1

		loop = self.eval_if(test,state[iter_num])
		expr = eval_symbolic(test,state[iter_num],self.symbolic_memory)

		if not expr.is_const():
			if loop:
				self.path_constraints += [expr]
			else:
				self.path_constraints += [expr.negate()]

			self.compare_and_update_stack(loop,self.branchno)
			self.branchno += 1

		if loop:
			iter_num += 1
			self.generic_visit(node)
			while True:
				loop = iter_num in state
				
				if not expr.is_const():
					self.compare_stack(loop,self.branchno)

				if not loop:
					break
				
				if not expr.is_const():
					self.update_stack(loop,self.branchno)
				expr = eval_symbolic(test,state[iter_num],self.symbolic_memory)
				if not expr.is_const():
					self.path_constraints += [expr]
					self.branchno += 1
				iter_num += 1

				self.generic_visit(node)
Beispiel #5
0
	def visit_If(self, node):
		test = node.test
		state = self.env[node.lineno]
		then_branch = self.eval_if(test,state)
		expr = eval_symbolic(test,state,self.symbolic_memory)

		if then_branch:
			orelse,node.orelse = node.orelse,[]
			self.path_constraints += [expr]
		else:
			body,node.body = node.body,[]
			self.path_constraints += [expr.negate()]

		self.compare_and_update_stack(then_branch,self.branchno)
		self.branchno += 1

		self.generic_visit(node)
		
		if then_branch:
			node.orelse = orelse
		else:
			node.body = body
Beispiel #6
0
    def visit_If(self, node):
        test = node.test
        state = self.env[node.lineno]
        then_branch = self.eval_if(test, state)
        expr = eval_symbolic(test, state, self.symbolic_memory)

        if then_branch:
            orelse, node.orelse = node.orelse, []
            self.path_constraints += [expr]
        else:
            body, node.body = node.body, []
            self.path_constraints += [expr.negate()]

        self.compare_and_update_stack(then_branch, self.branchno)
        self.branchno += 1

        self.generic_visit(node)

        if then_branch:
            node.orelse = orelse
        else:
            node.body = body