.NAME No exit

.DESCRIPTION
No exit instructions are allowed

.SEVERITY Advisory

.COMMAND tcl

.CODE

proc compute {standardName tree} {
	
	set formalism [::logiscope::treeFormalism $tree]

	set opList {}
	::logiscope::forobj op $formalism formalismOperator {
		lappend opList [::logiscope::opName $op]
	}
	# find the operators in the tree that are exit operators
	filterTree $tree [list opNameIs exit_statement]
}

#------------------------------------------------------------------
# opNameIs adds a rule violation if the operator of tree is opName
#------------------------------------------------------------------
proc opNameIs {opName tree} {
	set op [::logiscope::treeOperator $tree]
	if {[string equal [::logiscope::opName $op] $opName]} {
		# the operator has been identified: add a violation
		::logiscope::addViolation $tree
		return 0
	}
	return 1
}

#------------------------------------------------------------------
# filterTree applies callback to tree, and recurs on tree's sons
#------------------------------------------------------------------
proc filterTree {tree callback} {
	if {[eval $callback [list $tree]]} {
		::logiscope::forobj son $tree treeChild {
			filterTree $son $callback
    		}
	}
}

