parameters: (self, symbol, value, source=None, sort=0)
docstring: Recursively bind a symbol, with side effects.
docstring_summary: Recursively bind a symbol, with side effects.
docstring_tokens: Recursively bind a symbol with side effects .
function: def __set_symbol_internal(self, symbol, value, source=None, sort=0):
          "Recursively bind a symbol, with side effects."
          self.debug_emit(2, "    %sset_symbol_internal(%s, %s, %s, %s)" % (' ' * self.cdepth, symbol.name, value, `source`, sort))
          self.cdepth += 1
          if not source:
              source = symbol
          # The "touched" property marks this symbol changed for freeze purposes.
          # It has to stay on until the next commit.
          self.touched.append(symbol)
          # If it already has the desired value, we're done.
          oldval = cml.evaluate(symbol, self.debug)
          self.debug_emit(2, self.lang["OLDVAL"] % (' '*self.cdepth, symbol.name, oldval))
          if oldval == value:
              self.debug_emit(1, self.lang["UNCHANGED"] % (' '*self.cdepth, symbol.name,))
              # However, mark it set anyway.  This is useful for
              # distinguishing value by default from value by user action.
              self.__bindmark(symbol)
              # If this was a user setting or a frozen symbol.
              # Not actually going through the motions for a frozen
              # symbol is a speed hack.  We know the symbol can't change
              # so there's no reason to keep its binding cache full...
              if symbol == source or symbol.frozen():
                  self.cdepth -= 1
                  return
          elif symbol.frozen():
              # It's a violation if someone tries to raise the value of a symbol.
              # Log the violation so sanecheck() will cause a rollback
              if value > oldval:
                  self.changes_to_frozen.append(  \
                     self.lang["SETFAILED"] % (' '*self.cdepth, symbol.name))
              self.cdepth -= 1
              return
          # Barf on attempt to change the value of a changed value --
          # but only if the attempt comes from a different source,
          # because ancestry forcing will often result in the same symbol
          # being changed multiple times in succession from the same source.
          if self.chilled.has_key(symbol) and self.chilled[symbol] != source:
              self.__bindsymbol(symbol, value, source)	# record for debugging
              raise "UNSATISFIABLE"
          # Membership in chilled means we should treat the binding as frozen for
          # simplification purposes.  It has to be turned off when the current
          # call to set_symbol is done; otherwise side effects from inclusion
          # sequences would collide with each other.
          self.chilled[symbol] = source
          # Here's where the value actually gets set
          self.__bindsymbol(symbol, value, source, sort)
          # Make the side-effects of this symbol's previous bindings
          # temporarily invisible while computing side effects.  This
          # is necessary because things like dependent suppressions
          # need to be calculated according to the effects they would
          # have when the old bindings are removed, as they will be
          # if this change is committed (whew!)
          self.__bindconceal(symbol)
          # If this symbol was in a choice group and is being set true,
          # note this in the menu state
          if symbol.menu and symbol.menu.type == "choices" and value:
              symbol.menu.visits += 1
              symbol.menu.menuvalue = symbol
          # Unset all siblings if we're setting one to a non-n value.
          if value:
              for sibling in symbol.choicegroup:
                  self.__set_symbol_internal(sibling, cml.n, source)
          # Other side effects...
          if self.trit_tie and symbol == self.trit_tie and value == cml.n:
              for entry in self.dictionary.values():
                  if entry.type == "trit" and not entry.is_derived() and entry.eval() == cml.m:
                      self.__set_symbol_internal(entry, cml.y, source)
          # Now propagate the value change through ancestry chains.
          # Checking the 'sort' argument prevents nasty recursions
          # by suppressing dependent setting if we're setting an
          # ancestor, and vice-versa.
          if symbol.is_logical():
              if value > cml.n and sort != -1:
                  for ancestor in symbol.ancestors + symbol.menu.ancestors:
                      self.__dep_force_ancestors(symbol, source, value, ancestor)
              if value < cml.y and sort != 1:
                  for dependent in symbol.dependents:
                      self.__dep_force_dependents(symbol,source,value,dependent)
          # Perhaps we can deduce other values through explicit constraints?
          # This is where we'd plug in a full SAT algorithm if we were going
          # to use one.
          if self.interactive and not self.suppressions and symbol.visibility:
              self.__constrain(symbol.visibility, source)
          # Now loop through the constraints associated with this
          # symbol, simplifying out assigned variables and trying to
          # freeze more variables each time.  The outer loop guarantees
          # that as long as the constraints imply at least one more
          # tentative setting, we'll keep going.
          while 1:
              cc = 0
              for wff in symbol.constraints:
                  cc += self.__constrain(wff, source)
              if not cc:
                  break;
          # OK, now make the old bindings of this symbol visible again
          # (the change we just made might get rolled back later).
          self.__bindreveal(symbol)
          self.cdepth -= 1
function_tokens: def __set_symbol_internal ( self , symbol , value , source = None , sort = 0 ) : self . debug_emit ( 2 , "    %sset_symbol_internal(%s, %s, %s, %s)" % ( ' ' * self . cdepth , symbol . name , value , `source` , sort ) ) self . cdepth += 1 if not source : source = symbol # The "touched" property marks this symbol changed for freeze purposes. # It has to stay on until the next commit. self . touched . append ( symbol ) # If it already has the desired value, we're done. oldval = cml . evaluate ( symbol , self . debug ) self . debug_emit ( 2 , self . lang [ "OLDVAL" ] % ( ' ' * self . cdepth , symbol . name , oldval ) ) if oldval == value : self . debug_emit ( 1 , self . lang [ "UNCHANGED" ] % ( ' ' * self . cdepth , symbol . name , ) ) # However, mark it set anyway.  This is useful for # distinguishing value by default from value by user action. self . __bindmark ( symbol ) # If this was a user setting or a frozen symbol. # Not actually going through the motions for a frozen # symbol is a speed hack.  We know the symbol can't change # so there's no reason to keep its binding cache full... if symbol == source or symbol . frozen ( ) : self . cdepth -= 1 return elif symbol . frozen ( ) : # It's a violation if someone tries to raise the value of a symbol. # Log the violation so sanecheck() will cause a rollback if value > oldval : self . changes_to_frozen . append ( self . lang [ "SETFAILED" ] % ( ' ' * self . cdepth , symbol . name ) ) self . cdepth -= 1 return # Barf on attempt to change the value of a changed value -- # but only if the attempt comes from a different source, # because ancestry forcing will often result in the same symbol # being changed multiple times in succession from the same source. if self . chilled . has_key ( symbol ) and self . chilled [ symbol ] != source : self . __bindsymbol ( symbol , value , source ) # record for debugging raise "UNSATISFIABLE" # Membership in chilled means we should treat the binding as frozen for # simplification purposes.  It has to be turned off when the current # call to set_symbol is done; otherwise side effects from inclusion # sequences would collide with each other. self . chilled [ symbol ] = source # Here's where the value actually gets set self . __bindsymbol ( symbol , value , source , sort ) # Make the side-effects of this symbol's previous bindings # temporarily invisible while computing side effects.  This # is necessary because things like dependent suppressions # need to be calculated according to the effects they would # have when the old bindings are removed, as they will be # if this change is committed (whew!) self . __bindconceal ( symbol ) # If this symbol was in a choice group and is being set true, # note this in the menu state if symbol . menu and symbol . menu . type == "choices" and value : symbol . menu . visits += 1 symbol . menu . menuvalue = symbol # Unset all siblings if we're setting one to a non-n value. if value : for sibling in symbol . choicegroup : self . __set_symbol_internal ( sibling , cml . n , source ) # Other side effects... if self . trit_tie and symbol == self . trit_tie and value == cml . n : for entry in self . dictionary . values ( ) : if entry . type == "trit" and not entry . is_derived ( ) and entry . eval ( ) == cml . m : self . __set_symbol_internal ( entry , cml . y , source ) # Now propagate the value change through ancestry chains. # Checking the 'sort' argument prevents nasty recursions # by suppressing dependent setting if we're setting an # ancestor, and vice-versa. if symbol . is_logical ( ) : if value > cml . n and sort != - 1 : for ancestor in symbol . ancestors + symbol . menu . ancestors : self . __dep_force_ancestors ( symbol , source , value , ancestor ) if value < cml . y and sort != 1 : for dependent in symbol . dependents : self . __dep_force_dependents ( symbol , source , value , dependent ) # Perhaps we can deduce other values through explicit constraints? # This is where we'd plug in a full SAT algorithm if we were going # to use one. if self . interactive and not self . suppressions and symbol . visibility : self . __constrain ( symbol . visibility , source ) # Now loop through the constraints associated with this # symbol, simplifying out assigned variables and trying to # freeze more variables each time.  The outer loop guarantees # that as long as the constraints imply at least one more # tentative setting, we'll keep going. while 1 : cc = 0 for wff in symbol . constraints : cc += self . __constrain ( wff , source ) if not cc : break # OK, now make the old bindings of this symbol visible again # (the change we just made might get rolled back later). self . __bindreveal ( symbol ) self . cdepth -= 1