public Term getValue ( ) { Term result = this ; Term assignment = this . substitution ; // If the variable is assigned, loops down the chain of assignments until no more can be found. Whatever term // is found at the end of the chain of assignments is the value of this variable. while ( assignment != null ) { result = assignment ; if ( ! assignment . isVar ( ) ) { break ; } else { assignment = ( ( Variable ) assignment ) . substitution ; } } return result ; }
Gets the actual value of a term which is either the term itself or in the case of variables the value that is currently assigned to the variable . When the variable is free the variable term itself is returned .