def handle_in_check(self,lhs,rhs,active_event):
        '''
        Call has form:
            lhs in rhs
        
        rhs can have three basic types: it can be a list, a map, or a
        string.  That means that it can either be a WaldoMapVariable,
        a WaldoListVariable, a WaldoStringVariable, or a Python
        string.

        Instead of using static type inference at compile time to
        determine, for sake of development, just doing dynamic check
        to determine which type it is and do the in processing here.

        FIXME: it is faster to do the static checks with type
        inference, etc. at compile time rather than at run time.
        '''
        lhs_val = self.get_val_if_waldo(lhs,active_event)

        # handles Python string case
        if util.is_string(rhs):
            return lhs_val in rhs
        
        elif is_non_ext_text_var(rhs):
            return lhs_val in rhs.get_val(active_event)

        elif is_non_ext_map_var(rhs):
            return rhs.get_val(active_event).contains_key_called(active_event,lhs_val)
        
        elif is_non_ext_list_var(rhs):
            return rhs.get_val(active_event).contains_val_called(active_event,lhs_val)


        util.logger_assert(
            'Error when calling in: unknown right hand side of expression')
    def assign_on_key(self,lhs,key,rhs,active_event):
        '''
        For bracket statements + struct statements
        '''
        if not isinstance(lhs,WaldoLockedObj):
            return False

        raw_key = self.get_val_if_waldo(key,active_event)
        if is_non_ext_text_var(lhs):
            raw_rhs = self.get_val_if_waldo(rhs,active_event)            
            to_overwrite_string = lhs.get_val(active_event)
            to_overwrite_string[raw_key] = raw_rhs
            lhs.set_val(active_event,to_overwrite_string)

        elif isinstance(lhs,WaldoExternalTextVariable):
            raw_rhs = self.get_val_if_waldo(rhs,active_event)            
            to_overwrite_string = lhs.get_val(active_event).get_val(active_event)
            to_overwrite_string[raw_key] = raw_rhs
            lhs.get_val(active_event).set_val(active_event,to_overwrite_string)
        elif is_reference_container(lhs):
            # just write the value explicitly for now.  Later, will
            # need to check if we need to wrap it first.
            lhs.get_val(active_event).set_val_on_key(active_event,raw_key,rhs)
        else:
            # just write the value explicitly for now.  Later, will
            # need to check if we need to wrap it first.
            lhs.get_val(active_event).set_val_on_key(active_event,raw_key,rhs)

        return True
    def to_text(self,what_to_call_to_text_on,active_event):
        '''
        @returns {Python String}
        '''
        if not isinstance(what_to_call_to_text_on,WaldoLockedObj):
            return str(what_to_call_to_text_on)

        # strings for waldo variable value types
        if (is_non_ext_text_var(what_to_call_to_text_on) or
            is_non_ext_num_var(what_to_call_to_text_on) or
            is_non_ext_true_false_var(what_to_call_to_text_on)):
            return str(what_to_call_to_text_on.get_val(active_event))

        # strings for reference types
        # lists
        if is_non_ext_list_var(what_to_call_to_text_on):
            to_return_arg = ''
            waldo_internal_list = what_to_call_to_text_on.get_val(active_event)
            # get each element separately from the list and call
            # to_text on it.
            for i in range(0,waldo_internal_list.get_len(active_event)):
                list_val = waldo_internal_list.get_val_on_key(active_event,i)
                to_return_arg += self.to_text(list_val,active_event) + ', '
            
            return '[%s]' % to_return_arg

        # maps
        if is_non_ext_map_var(what_to_call_to_text_on):
            to_return_arg = ''
            waldo_internal_map = what_to_call_to_text_on.get_val(active_event)
            # get each element separately from the list and call
            # to_text on it.
            waldo_key_list = waldo_internal_map.get_keys(active_event)
            waldo_internal_key_list = waldo_key_list.get_val(active_event)
            
            for i in range(0,waldo_internal_key_list.get_len(active_event)):
                key_val = waldo_internal_key_list.get_val_on_key(active_event,i)

                # get item from map
                item_val = waldo_internal_map.get_val_on_key(active_event,key_val)

                
                to_return_arg += (
                    self.to_text(key_val,active_event) + ': ' +
                    self.to_text(item_val,active_event) + ', ')

            
            return '{%s}' % to_return_arg
    def get_for_iter(self,to_iter_over,active_event):
        '''
        When call for loop on Waldo variables, need to get item to
        iterate over
        '''

        if (isinstance(to_iter_over,dict) or
            isinstance(to_iter_over,list) or
            util.is_string(to_iter_over)):
            return iter(to_iter_over)

        if is_non_ext_text_var(to_iter_over):
            return iter(to_iter_over.get_val(active_event))

        if is_non_ext_map_var(to_iter_over):
            return iter(to_iter_over.get_val(active_event).get_keys(active_event))

        if is_non_ext_list_var(to_iter_over):
            # FIXME: This is an inefficient way of reading all values
            # over list.
            to_return = []
            internal_val = to_iter_over.get_val(active_event)
            for i in range(0, internal_val.get_len(active_event)):
                to_append = internal_val.get_val_on_key(active_event,i)

                # The reason that we do this here is that in a for
                # loop, the operation we perform in the compiled code
                # immediately following the actual for header is
                # assign to another Waldo variable the variable being
                # held by to_append.  (We do this through a set_val
                # call.  set_val must take in InternalMaps or
                # InternalLists.  Therefore, get_val on the
                # WaldoList/WaldoMap first.  Note this is unnecessary
                # for all other for iterations because none of the
                # others possibly return a WaldoObject to iterate over.
                if (is_non_ext_list_var(to_append) or
                    is_non_ext_map_var(to_append)):
                    to_append = to_append.get_val(active_event)
                
                to_return.append(to_append)

            return iter(to_return)

        util.logger_assert(
            'Calling get_for_iter on an object that does not support iteration')
    def get_val_on_key(self,to_get_from,key,active_event):
        raw_key = self.get_val_if_waldo(key,active_event)
        
        if not isinstance(to_get_from,WaldoLockedObj):
            return to_get_from[raw_key]

        # handle text + ext text
        if is_non_ext_text_var(lhs):
            return to_get_from.get_val(active_event)[raw_key]

        if isinstance(lhs,WaldoExternalTextVariable):
            return to_get_from.get_val(active_event).get_val(active_event)[raw_key]

        # handle internals containers
        if is_reference_container(lhs):
            return to_get_from.get_val_on_key(active_event,raw_key)

        # handle map, list, struct
        return to_get_from.get_val(active_event).get_val_on_key(active_event,raw_key)
    def handle_len(self,what_calling_len_on, active_event):
        '''
        Can support python lists, dicts, strings, or waldo lists, waldo maps,
        waldo texts.
        
        @returns {int}
        '''
        if (isinstance(what_calling_len_on, dict) or
            isinstance(what_calling_len_on, list) or
            util.is_string(what_calling_len_on)):
            return len(what_calling_len_on)

        if is_non_ext_text_var(what_calling_len_on):
            return len(what_calling_len_on.get_val(active_event))


        if (is_non_ext_list_var(what_calling_len_on) or
            is_non_ext_map_var(what_calling_len_on)):
            return what_calling_len_on.get_val(active_event).get_len(active_event)

        util.logger_assert(
            'Calling len on an object that does not support the function')