/*! * Build in initial \c linked_list_chunk and then do various list modifications. * Everything is destroyed in the end. */ int main ( void ) { chunk ch ; linked_list_chunk llc = linked_list_chunk_create () ; assert ( linked_list_chunk_is_empty ( llc ) ) ; test_llc_ch ( llc , value_error_create ( 0 ) ) ; test_llc_ch ( llc , value_error_create ( 1 ) ) ; test_llc_ch ( llc , value_error_create ( 2 ) ) ; test_llc_ch ( llc , value_error_create ( 3 ) ) ; test_llc_ch ( llc , value_error_create ( 4 ) ) ; test_llc_ch ( llc , value_error_create ( 5 ) ) ; linked_list_chunk llc_2 = linked_list_chunk_copy ( llc ) ; linked_list_chunk_destroy ( llc ); puts ( " copy" ) ; linked_list_chunk_print ( llc_2 , stdout ) ; linked_list_chunk llc_3 = linked_list_chunk_copy ( llc_2 ) ; while ( ! linked_list_chunk_is_empty ( llc_2 ) ) { chunk ch = linked_list_chunk_pop_front ( llc_2 ) ; fprintf ( stdout , "*** removing from front : \"" ) ; chunk_print ( ch , stdout ) ; fprintf ( stdout , "\" :\n" ) ; linked_list_chunk_print ( llc_2 , stdout ) ; chunk_destroy ( ch ) ; } linked_list_chunk_destroy ( llc_2 ); fprintf ( stdout , "*** Adding a copy of 3 first elements: \n" ) ; linked_list_chunk_add_self_copy_front ( llc_3 , 3 ) ; linked_list_chunk_print ( llc_3 , stdout ) ; linked_list_chunk_destroy ( llc_3 ); return 0 ; }
/*! * \file * \brief Operator \c def: add an entry into the \c dictionary. * * The entry is composed of a protected label on the top of the stack and the value under it. * Both values are removed from the stack. * Nothing else is modified. * * If the stack is not deep enough or the first one is not a \c value_protected_label, a \c basic_type_error is returned. * * assert is enforced. * * \author Jérôme DURAND-LOSE * \version 1 * \date 2015 * \copyright GNU Public License. */ static basic_type operator_def_evaluate ( chunk const ch , va_list va ) { interpretation_context ic = va_arg( va , interpretation_context); chunk ch1 = linked_list_chunk_pop_front(ic->stack); chunk ch2 = linked_list_chunk_pop_front(ic-> stack); if(!(ch1) || !(ch2)){ return basic_type_error; } if(value_is_protected_label(ch1)){ dictionary_set(ic->dic , basic_type_get_pointer(chunk_answer_message(ch1 , "value_get_value")) , ch2); chunk_destroy(ch1); chunk_destroy(ch2); return basic_type_void; } chunk_destroy(ch1); chunk_destroy(ch2); return basic_type_error; }