F diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
include_directories(src/semantics/value)
include_directories(src/semantics/constraints)
include_directories(src/debug)
+ include_directories(src/debug/wobler)
include_directories(src/misc)
src/debug/debug_type.c
src/debug/debug_value.c
src/debug/debug_ast.c
- src/debug/wonky_assert.c
src/frontend/lex/automatas/chonky.c
src/frontend/lex/automatas/chonky_jr.c
src/frontend/lex/lexer.c
)
add_library(innards STATIC ${SOURCES})
+ add_library(wonky_assert STATIC src/debug/wonky_assert.c)
add_executable(wonky src/wonky.c)
- target_link_libraries(wonky innards)
+ target_link_libraries(wonky innards wonky_assert)
#TESTING PROGRAM PART
+ add_library(wobler_assert STATIC src/debug/wobler/wobler_assert.c)
add_executable(wobler EXCLUDE_FROM_ALL src/debug/wobler/wobler.c)
- target_link_libraries(wobler innards)
- add_custom_target(test DEPENDS wobler)
-
- add_custom_command(TARGET test POST_BUILD COMMAND wobler ARGS ${WOBLER_DUMP_LOG} WORKING_DIRECTORY ${TEST_DIR} VERBATIM)
+ target_link_libraries(wobler innards wobler_assert)
+ add_custom_target(test DEPENDS wobler wobler_assert)
+ add_custom_command(TARGET test POST_BUILD COMMAND wobler ARGS ${WOBLER_DUMP_LOG} WORKING_DIRECTORY ${TEST_DIR} VERBATIM)
F diff --git a/src/backend/print/print.c b/src/backend/print/print.c
--- a/src/backend/print/print.c
+++ b/src/backend/print/print.c
char *this_directory[]={"./",NULL};
char ret;
- assert(base_source_names!=NULL);
+ wonky_assert(base_source_names!=NULL);
if(*base_source_names==NULL)
{
fprintf(out,"ERROR!");return;
}
- assert(!"reached end of switch");
+ wonky_assert(!"reached end of switch");
}
void print_denoted(FILE *out,struct Denoted *denoted)
{
case LINKAGE_NONE:
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
fprintf(out,"denoted object ");
print_token(out,((struct Denoted_Object*)denoted)->id);
fprintf(out," an internally linked ");
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
print_type(out,((struct Denoted_Function*)denoted)->type,1);
return;
case DT_Prototype:
fprintf(out,"denotation prototyep");return;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
fprintf(out,"struct ");
break;
default:
- assert(1==0);
+ wonky_assert(1==0);
}
fprintf(out,"{");
print_list_of_denoted(out,struct_union->members);
fprintf(out," an internally linked ");
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
print_type(out,function->function->type,1);
print_compound_statement_tree(out,function->body);
fprintf(out,"void");
return;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
#undef TOK
F diff --git a/src/backend/print/print.h b/src/backend/print/print.h
--- a/src/backend/print/print.h
+++ b/src/backend/print/print.h
#define WONKY_PRINT_H WONKY_PRINT_H
#include<stdio.h>
- #include<assert.h>
+ #include<wonky_assert.h>
#include <wonky.h>
#include <common.h>
F diff --git a/src/debug/debug.h b/src/debug/debug.h
--- a/src/debug/debug.h
+++ b/src/debug/debug.h
#ifndef WONKY_DEBUG_H
#define WONKY_DEBUG_H WONKY_DEBUG_H
- #include <assert.h>
+ #include <wonky_assert.h>
#include <debug_ast.h>
#include <debug_denoted.h>
#include <debug_initialiser.h>
F diff --git a/src/debug/wobler/wobler.c b/src/debug/wobler/wobler.c
--- a/src/debug/wobler/wobler.c
+++ b/src/debug/wobler/wobler.c
- #include <wonky.h>
- #include <print.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <float.h>
+ #include <wobler.h>
- #define NUMBER_OF_ELEMENTS_IN_ARRAY(x) (sizeof(x)/sizeof(x[0]))
-
- char *log_dump_location="wobler.log";
-
- FILE *real_stderr;
- FILE *real_stdout;
-
- size_t current_test;
-
- void should_compile(char **filenames);
- void should_not_compile(char **filenames);
- void run_tests();
- void print_result_summary();
- void print_names(char **filenames);
- void dump_program(FILE *where,struct Program *program);
- void dump_program_messages(FILE *where,struct Program *program);
- void print_result(char *error_message,char **filenames,struct Program *program);
-
- void detect_abort();
- _Bool should_be_exiting_right_now;
-
- static struct test_entry
- {
- char *filenames[100];
- void (*test_function)(char**);
- double how_much_time_should_execution_take;
-
- }
- tests[]=
- {
- {
- .filenames={"test_generic.c"},
- .test_function=should_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_declaration.c"},
- .test_function=should_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_declaration2.c"},
- .test_function=should_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_declaration_error.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_bitfields.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_generic_error.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_linkage.c"},
- .test_function=should_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_linkage_error.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_linkage_error2.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_bitfield_error.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_bitfield_error2.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_bitfield_error3.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_function_definition_error.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_function_definition_error2.c"},
- .test_function=should_not_compile,
- .how_much_time_should_execution_take=0.01,
- },
- {
- .filenames={"test_function_definition.c"},
- .test_function=should_compile,
- .how_much_time_should_execution_take=0.01,
- },
-
- };
-
- static double test_times[NUMBER_OF_ELEMENTS_IN_ARRAY(tests)];
- static _Bool passes_test[NUMBER_OF_ELEMENTS_IN_ARRAY(tests)];
int main(int argc,char **argv)
{
- real_stdout=stdout;
- real_stderr=stderr;
-
if(argv[1]!=NULL)
{
log_dump_location=argv[1];
}
- stdout=fopen(log_dump_location,"w");
- stderr=stdout;
+ wobler_log=fopen(log_dump_location,"w");
+ if(wobler_log==NULL)
+ {
+ printf("Could not open log file - %s\n Redirecting to stderr",log_dump_location);
+ wobler_log=stderr;
+ }
- atexit(detect_abort);
- fprintf(real_stdout,"THE WOBLER HAS AWOKEN!!\n\n");
+ //atexit(detect_abort);
+ printf("THE WOBLER HAS AWOKEN!!\n\n");
run_tests();
print_result_summary();
- fprintf(real_stdout,"\n\nTHE WOBLER GOES BACK TO SLUMBER! WONKY HAS BEEN SPARED FROM DEATH!\n");
+ printf("\n\nTHE WOBLER GOES BACK TO SLUMBER! WONKY HAS BEEN SPARED FROM DEATH!\n");
return 0;
}
void run_tests()
{
for(current_test=0;current_test<NUMBER_OF_ELEMENTS_IN_ARRAY(tests);++current_test)
- tests[current_test].test_function(tests[current_test].filenames);
+ {
+ if(setjmp(wobler_mark)==0) /*if we don't return from a long jump invoked in an assert*/
+ {
+ tests[current_test].test_function(tests[current_test].filenames);
+ }
+ }
}
void should_compile(char **filenames)
{
}
void print_result_summary()
{
- fprintf(real_stdout,"\n\n\tFor more details check %s\n\n",log_dump_location);
+ printf("\n\n\tFor more details check %s\n\n",log_dump_location);
}
void dump_program(FILE *where,struct Program *program)
{
print_errors(where,program->errors);
fprintf(where,"\n----- MESSAGES DUMP END -----\n");
}
- void print_names(char **filenames)
+ void print_names()
{
size_t i;
+ char **filenames;
+ filenames=tests[current_test].filenames;
for(i=0;filenames[i]!=NULL && i<100;++i)
{
- fprintf(real_stdout,"%s ",filenames[i]);
printf("%s ",filenames[i]);
+ fprintf(wobler_log,"%s ",filenames[i]);
}
}
void print_result(char *error_message,char **filenames,struct Program *program)
{
- fprintf(real_stdout,"[ ");
printf("[ ");
+ fprintf(wobler_log,"[ ");
if(passes_test[current_test])
{
- fprintf(real_stdout,"OK ");
- printf("OK ");
+ fprintf(wobler_log,"OK ");
+ printf("OK ");
}else
{
- fprintf(real_stdout,"Error ");
- printf("Error ");
+ fprintf(wobler_log,"Error ");
+ printf("Error ");
}
if(test_times[current_test] > tests[current_test].how_much_time_should_execution_take)
{
- fprintf(real_stdout,"SLOW ");
- printf("SLOW took %f seconds ( baseline is %f ) ",
+ printf("SLOW ");
+ fprintf(wobler_log,"SLOW took %f seconds ( baseline is %f ) ",
test_times[current_test],
tests[current_test].how_much_time_should_execution_take
);
}
- fprintf(real_stdout,"]\t");
+ fprintf(wobler_log,"]\t");
printf("]\t");
- print_names(filenames);
+ print_names();
if(!passes_test[current_test])
{
- fprintf(real_stdout," -- %s",error_message);
+ fprintf(wobler_log," -- %s",error_message);
fprintf(stdout," -- %s",error_message);
}
if(program)
- dump_program(stdout,program);
+ dump_program(wobler_log,program);
- fprintf(real_stdout,"\n");
+ fprintf(wobler_log,"\n");
printf("\n");
}
if(!should_be_exiting_right_now)
{
printf("\n[ABORT ]\t");
- fprintf(real_stderr,"\n[ABORT ]\t");
- print_names(tests[current_test].filenames);
+ fprintf(wobler_log,"\n[ABORT ]\t");
+ print_names();
}
}
F diff --git a/src/debug/wobler/wobler.h b/src/debug/wobler/wobler.h
new file mode 100644
--- /dev/null
+++ b/src/debug/wobler/wobler.h
+ #ifndef WOBLER_H
+ #define WOBLER_H WOBLER_H
+ #include <wobler_declarations.h>
+
+ _Bool should_be_exiting_right_now;
+ jmp_buf wobler_mark;
+
+ char *log_dump_location="wobler.log";
+
+ FILE *wobler_log;
+
+ size_t current_test;
+
+ #include <wobler_tests.h>
+
+ #define NUMBER_OF_ELEMENTS_IN_ARRAY(x) (sizeof(x)/sizeof(x[0]))
+ double test_times[NUMBER_OF_ELEMENTS_IN_ARRAY(tests)];
+ _Bool passes_test[NUMBER_OF_ELEMENTS_IN_ARRAY(tests)];
+ #endif
F diff --git a/src/debug/wobler/wobler_assert.c b/src/debug/wobler/wobler_assert.c
new file mode 100644
--- /dev/null
+++ b/src/debug/wobler/wobler_assert.c
+ #include <wobler_declarations.h>
+
+ void wonky_assert_function(_Bool wonky_assertion,const char *what_is_asserted,const char *file_of_assertion,const char *function_name,int line,const char *date)
+ {
+ if(!wonky_assertion)
+ {
+ printf("[ ASSERT ]\t");
+ fprintf(wobler_log,"[ ASSERT ]\t");
+ print_names();
+ printf("\n\tAssertion failed %s - %s:%d in %s\n",what_is_asserted,file_of_assertion,line,function_name,date);
+ fprintf(wobler_log,"\n\tAssertion failed %s - %s:%d in %s [ %s ]\n",what_is_asserted,file_of_assertion,line,function_name,date);
+ longjmp(wobler_mark,1);
+ }
+
+ }
F diff --git a/src/debug/wobler/wobler_declarations.h b/src/debug/wobler/wobler_declarations.h
new file mode 100644
--- /dev/null
+++ b/src/debug/wobler/wobler_declarations.h
+ #ifndef WOBLER_DECLARATIONS_H
+ #define WOBLER_DECLARATIONS_H WOBLER_DECLARATIONS_H
+ #include <wonky.h>
+ #include <print.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <time.h>
+ #include <float.h>
+ #include <setjmp.h>
+
+ void should_compile(char **filenames);
+ void should_not_compile(char **filenames);
+ void run_tests();
+ void print_result_summary();
+ void print_names();
+ void dump_program(FILE *where,struct Program *program);
+ void dump_program_messages(FILE *where,struct Program *program);
+ void print_result(char *error_message,char **filenames,struct Program *program);
+ void detect_abort();
+
+
+
+ extern _Bool should_be_exiting_right_now;
+ extern jmp_buf wobler_mark;
+ extern char *log_dump_location;
+ extern FILE *wobler_log;
+ extern size_t current_test;
+ #endif
F diff --git a/src/debug/wobler/wobler_tests.h b/src/debug/wobler/wobler_tests.h
new file mode 100644
--- /dev/null
+++ b/src/debug/wobler/wobler_tests.h
+ #ifndef WOBLER_TESTS_H
+ #define WOBLER_TESTS_H WOBLER_TESTS_H
+
+ struct test_entry
+ {
+ char *filenames[100];
+ void (*test_function)(char**);
+ double how_much_time_should_execution_take;
+
+ }
+ tests[]=
+ {
+ {
+ .filenames={"test_generic.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_declaration.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_declaration2.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_declaration_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_bitfields.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_generic_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_linkage.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_linkage_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_linkage_error2.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_bitfield_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_bitfield_error2.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_bitfield_error3.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_function_definition_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_function_definition_error2.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_function_definition.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+
+ };
+
+
+ #endif
F diff --git a/src/debug/wonky_assert.c b/src/debug/wonky_assert.c
--- a/src/debug/wonky_assert.c
+++ b/src/debug/wonky_assert.c
#include <wonky_assert.h>
- void wonky_assert_function(_Bool assertion)
+ void wonky_assert_function(_Bool wonky_assertion,const char *what_is_asserted,const char *file_of_assertion,const char *function_name,int line,const char *date)
{
- if(!assertion)
+ if(!wonky_assertion)
{
- printf("Assertion failed %s\n",__func__);
+ printf("Assertion failed %s - %s:%d in %s [ %s ]\n",what_is_asserted,file_of_assertion,line,function_name,date);
exit(1);
}
F diff --git a/src/debug/wonky_assert.h b/src/debug/wonky_assert.h
--- a/src/debug/wonky_assert.h
+++ b/src/debug/wonky_assert.h
- #if (!defined(WONKY_ASSERT_H) && !defined(NDEBUG)) || (!defined(WONKY_ASSERT_H) && defined(WONKY_ASSERT_C))
+ #ifndef WONKY_ASSERT_H
#define WONKY_ASSERT_H WONKY_ASSERT_H
#include <stdlib.h>
#include <stdio.h>
- #define wonky_assert(assertion) wonky_assert_function(assertion)
+ void wonky_assert_function(_Bool wonky_assertion,const char *what_is_asserted,const char *file_of_assertion,const char *function_name,int line,const char *date);
- /*this is a hack to make the wobler work better*/
- void wonky_assert_function(_Bool assertion);
+ #ifdef NDEBUG
- #elif !defined(WONKY_DEBUG)
+ # define wonky_assert(wonky_assertion) ((void)0)
- #define wonky_assert(assertion) ((void)0)
+ #else /*ifndef NDEBUG*/
- #endif
+ # define wonky_assert(wonky_assertion) wonky_assert_function(wonky_assertion,#wonky_assertion,__FILE__,__func__,__LINE__,__DATE__)
+
+ #endif /*ifdef NDEBUG*/
+
+
+
+
+
+ #endif /*header guard*/
F diff --git a/src/frontend/lex/preprocessing.c b/src/frontend/lex/preprocessing.c
--- a/src/frontend/lex/preprocessing.c
+++ b/src/frontend/lex/preprocessing.c
{
if(number_of_arguments==0)
{
- assert(args==NULL);
+ wonky_assert(args==NULL);
return;
}
flush_macro_arguments(number_of_arguments,args);
hold_token->line=src->which_row;
hold_token->column=src->which_column;
- assert(is_valid_token(hold_token));
+ wonky_assert(is_valid_token(hold_token));
Queue_Push(translation_data->tokens,hold_token);
}
}else
{
/*this isn't a macro, so we just push it to the token queue*/
- assert(is_valid_token(macro_name));
+ wonky_assert(is_valid_token(macro_name));
Queue_Push(translation_data->tokens,macro_name);
}
}
F diff --git a/src/frontend/parse/parse_declaration.c b/src/frontend/parse/parse_declaration.c
--- a/src/frontend/parse/parse_declaration.c
+++ b/src/frontend/parse/parse_declaration.c
break;
}
- assert(is_valid_denoted(hold));
+ wonky_assert(is_valid_denoted(hold));
Scope_Push(scope,hold,translation_data);
parse_function_definitions=0;
function_type->function_prototype_scope->parent=(struct Scope*)function->function_scope;
- assert(is_valid_denoted_function(function) && is_valid_type((struct Type*)function_type));
+ wonky_assert(is_valid_denoted_function(function) && is_valid_type((struct Type*)function_type));
function_body
=
}
);
- assert(is_valid_compound_statement(function_body));
+ wonky_assert(is_valid_compound_statement(function_body));
Queue_Push(where_to_push,get_function_definition_tree(scope,function,function_body,translation_data));
}
if(get_and_check(translation_data,KW_EQ))
{
initializer=parse_initialiser(translation_data,scope,object->object->type);
- assert(is_valid_initialiser(initializer));
+ wonky_assert(is_valid_initialiser(initializer));
}
Queue_Push(where_to_push,get_object_declaration_tree(object,initializer));
else if(ret->constraint==TC_SHORT)
push_translation_error("long and short constraints contradict",translation_data);
else
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
return (struct Denotation_Prototype*)get_denoted_error((struct Denoted*)ret);
}
}
break;
default:
/*should not be able to enter here*/
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
return (struct Denotation_Prototype*)get_denoted_error((struct Denoted*)ret);
}
push_translation_error("only one storage class allowed >:|",translation_data);
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
return (struct Denotation_Prototype*)get_denoted_error((struct Denoted*)ret);
push_translation_error("only one storage class allowed >:|",translation_data);
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
return (struct Denotation_Prototype*)get_denoted_error((struct Denoted*)ret);
}
push_translation_error("only one storage class allowed >:|",translation_data);
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
return (struct Denotation_Prototype*)get_denoted_error((struct Denoted*)ret);
}
F diff --git a/src/frontend/parse/parse_declaration.h b/src/frontend/parse/parse_declaration.h
--- a/src/frontend/parse/parse_declaration.h
+++ b/src/frontend/parse/parse_declaration.h
#include <queue.h>
#include <map.h>
#include <lexer.h>
- #include <assert.h>
+ #include <wonky_assert.h>
#include <linkage.h>
#include <common.h>
#include <debug.h>
F diff --git a/src/frontend/parse/parse_expression.c b/src/frontend/parse/parse_expression.c
--- a/src/frontend/parse/parse_expression.c
+++ b/src/frontend/parse/parse_expression.c
}
/*just in case*/
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
return (struct AST_Expression*)get_error_tree(NULL);
}
}while(get_and_check(translation_data,KW_COMMA));
ret=get_function_expression_tree(id,&arg_list,translation_data);
- assert(arg_list.size==0);
+ wonky_assert(arg_list.size==0);
if(get_and_check(translation_data,KW_CLOSE_NORMAL))
{
- assert(is_valid_function_expression(ret));
+ wonky_assert(is_valid_function_expression(ret));
return ret;
}else
{
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_postfix_expression));
+ wonky_assert(is_valid_ast_expression(hold_postfix_expression));
switch(kw_get(translation_data))
{
default:
return parse_postfix_expression(translation_data,scope);
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
/*shouldn't reach here - the default of the switch returns*/
}
/*
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
switch(kw_get(translation_data))
{
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
switch(kw_get(translation_data))
{
case KW_PLUS:
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
switch(kw_get(translation_data))
{
case KW_SHIFT_LEFT:
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
switch(kw_get(translation_data))
{
case KW_LESS:
while(translation_data->tokens->size!=0)
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
switch(kw_get(translation_data))
{
case KW_EQEQ:
while(get_and_check(translation_data,KW_AND))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_equality_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_bitwise_expression_tree(hold_left_expression,hold_right_expression,OP_BITWISE_AND,translation_data);
}
while(get_and_check(translation_data,KW_HAT))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_and_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_bitwise_expression_tree(hold_left_expression,hold_right_expression,OP_BITWISE_XOR,translation_data);
}
while(get_and_check(translation_data,KW_PIPE))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_exclusive_or_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_bitwise_expression_tree(hold_left_expression,hold_right_expression,OP_BITWISE_OR,translation_data);
while(get_and_check(translation_data,KW_AND_AND))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_inclusive_or_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_logical_expression_tree(hold_left_expression,hold_right_expression,OP_LOGICAL_AND,translation_data);
while(get_and_check(translation_data,KW_PIPE_PIPE))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_logical_and_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_logical_expression_tree(hold_left_expression,hold_right_expression,OP_LOGICAL_OR,translation_data);
hold_left_expression=parse_logical_or_expression(translation_data,scope);
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
if(get_and_check(translation_data,KW_QUESTION))
{
hold_left_expression=parse_conditional_expression(translation_data,scope);
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
if(translation_data->tokens->size==0)
return hold_left_expression;
chomp(translation_data);
hold_right_expression=parse_assignment_expression(translation_data,scope);
- assert(is_valid_ast_expression(hold_right_expression));
+ wonky_assert(is_valid_ast_expression(hold_right_expression));
if(operation_type==OP_ASSIGN)
return (struct AST_Expression*)get_simple_assignment_expression_tree(hold_left_expression,hold_right_expression,translation_data);
while(get_and_check(translation_data,KW_COMMA))
{
- assert(is_valid_ast_expression(hold_left_expression));
+ wonky_assert(is_valid_ast_expression(hold_left_expression));
hold_right_expression=parse_assignment_expression(translation_data,scope);
hold_left_expression=(struct AST_Expression*)get_comma_expression_tree(hold_left_expression,hold_right_expression,translation_data);
F diff --git a/src/frontend/parse/parse_statement.c b/src/frontend/parse/parse_statement.c
--- a/src/frontend/parse/parse_statement.c
+++ b/src/frontend/parse/parse_statement.c
chase_next_semicolumn(translation_data);
}
- assert(is_valid_compound_statement(hold));
+ wonky_assert(is_valid_compound_statement(hold));
return (struct AST*)hold;
}
/*
return (struct AST*)get_error_tree((struct AST*)hold);
}
- assert(is_valid_if_statement(hold));
+ wonky_assert(is_valid_if_statement(hold));
return (struct AST*)hold;
}
/*
hold=get_switch_statement_tree(hold_control_expression,hold_body_statement);
- assert(is_valid_switch_statement(hold));
+ wonky_assert(is_valid_switch_statement(hold));
return (struct AST*)hold;
}else
{
return (struct AST*)get_error_tree((struct AST*)NULL);
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*
( expression ) statement
}
);
- assert(is_valid_while_statement(hold));
+ wonky_assert(is_valid_while_statement(hold));
return (struct AST*)hold;
}else
{
return (struct AST*)get_error_tree((struct AST*)hold);
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*
if(get_and_check(translation_data,KW_CLOSE_NORMAL) && get_and_check(translation_data,KW_SEMI_COLUMN))
{
- assert(is_valid_do_while_statement(hold));
+ wonky_assert(is_valid_do_while_statement(hold));
return (struct AST*)hold;
}else
{
}
);
- assert(is_valid_for_statement(hold));
+ wonky_assert(is_valid_for_statement(hold));
return (struct AST*)hold;
}
/*
ret=get_goto_statement_tree(Queue_Pop(translation_data->tokens),scope,translation_data);
if(get_and_check(translation_data,KW_SEMI_COLUMN))
{
- assert(is_valid_goto_statement(ret));
+ wonky_assert(is_valid_goto_statement(ret));
return (struct AST*)ret;
}else
{
{
hold=get_break_continue_statement_tree(parse_data->continue_statement_owner,translation_data,ST_CONTINUE);
- assert(is_valid_break_continue_statement(hold));
+ wonky_assert(is_valid_break_continue_statement(hold));
return (struct AST*)hold;
}else
{
{
hold=get_break_continue_statement_tree(parse_data->break_statement_owner,translation_data,ST_BREAK);
- assert(is_valid_break_continue_statement(hold));
+ wonky_assert(is_valid_break_continue_statement(hold));
return (struct AST*)hold;
}else
{
hold=get_labeled_statement_tree(hold_id,hold_statement,ST_LABEL,translation_data,scope);
- assert(is_valid_labeled_statement(hold));
+ wonky_assert(is_valid_labeled_statement(hold));
return (struct AST*)hold;
}
hold_statement=parse_statement(translation_data,scope,parse_data);
hold=get_case_statement_tree(hold_statement,hold_expression,parse_data->current_switch_statement,translation_data);
- assert(is_valid_case_statement(hold));
+ wonky_assert(is_valid_case_statement(hold));
return (struct AST*)hold;
}else
{
push_translation_error(" ':' expected after expression in case statement",translation_data);
return (struct AST*)get_error_tree((struct AST*)hold_expression);
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*
:
hold=get_default_statement_tree(statement,translation_data);
- assert(is_valid_default_statement(hold));
+ wonky_assert(is_valid_default_statement(hold));
return (struct AST*)hold;
}else
{
{
hold=get_return_statement_tree(get_nop_tree(),translation_data,scope);
- assert(is_valid_return_statement(hold));
+ wonky_assert(is_valid_return_statement(hold));
return (struct AST*)hold;
}
hold=get_return_statement_tree(parse_expression(translation_data,scope),translation_data,scope);
if(get_and_check(translation_data,KW_SEMI_COLUMN))
{
- assert(is_valid_return_statement(hold));
+ wonky_assert(is_valid_return_statement(hold));
return (struct AST*)hold;
}else
{
}
if(get_and_check(translation_data,KW_SEMI_COLUMN))
{
- assert(is_valid_ast(hold));
+ wonky_assert(is_valid_ast(hold));
return hold;
}else
{
F diff --git a/src/frontend/parse/parse_translation_unit.c b/src/frontend/parse/parse_translation_unit.c
--- a/src/frontend/parse/parse_translation_unit.c
+++ b/src/frontend/parse/parse_translation_unit.c
}
}
- assert(is_valid_translation_unit(hold));
+ wonky_assert(is_valid_translation_unit(hold));
return (struct AST*)hold;
F diff --git a/src/misc/gcc_string.c b/src/misc/gcc_string.c
--- a/src/misc/gcc_string.c
+++ b/src/misc/gcc_string.c
ptrdiff_t diff;
size_t i;
- assert(first!=NULL && last!=NULL);
+ wonky_assert(first!=NULL && last!=NULL);
diff=last-first;
return ret;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
char* gstr_to_heap(const char *literal)
{
F diff --git a/src/misc/gcc_string.h b/src/misc/gcc_string.h
--- a/src/misc/gcc_string.h
+++ b/src/misc/gcc_string.h
#define GSTRING_H GSTRING_H
#include <stdlib.h>
#include <stddef.h>
- #include <assert.h>
+ #include <wonky_assert.h>
#include <common.h>
F diff --git a/src/misc/map.c b/src/misc/map.c
--- a/src/misc/map.c
+++ b/src/misc/map.c
if(temp == size)
{
- assert(tree->ID==NULL);
+ wonky_assert(tree->ID==NULL);
tree->ID=id;
tree->is_final=1;
return;
F diff --git a/src/misc/queue.c b/src/misc/queue.c
--- a/src/misc/queue.c
+++ b/src/misc/queue.c
}
void Queue_Append(struct Queue *lead,struct Queue *follower)
{
- assert(lead!=NULL);
- assert(follower!=NULL);
+ wonky_assert(lead!=NULL);
+ wonky_assert(follower!=NULL);
if(lead->last==NULL)
{
lead->last=follower->last;
*/
struct Queue Queue_Fit(struct Queue *q,size_t offset)
{
- assert(q->size>offset && offset>0);
+ wonky_assert(q->size>offset && offset>0);
struct Queue ret;
size_t i;
for(i=0,it=q->first; i<where ; ++i,it=it->prev)
{
- assert(it!=NULL);
+ wonky_assert(it!=NULL);
}
return it->data;
}
F diff --git a/src/misc/queue.h b/src/misc/queue.h
--- a/src/misc/queue.h
+++ b/src/misc/queue.h
#ifndef GQUEUE_H
#define GQUEUE_H GQUEUE_H
#include<stdlib.h>//malloc free
- #include<assert.h>
+ #include<wonky_assert.h>
#include <common.h>
typedef struct Queue Queue;
F diff --git a/src/program/gcc_error.c b/src/program/gcc_error.c
--- a/src/program/gcc_error.c
+++ b/src/program/gcc_error.c
}
void push_lexing_error(const char *error_message,struct Source_File *src,struct Translation_Data *translation_data, ...)
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
void push_lexing_note(const char *error_message,struct Source_File *src,struct Translation_Data *translation_data, ...)
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
void push_raw_translation_error(const char *error_message,size_t line,size_t column,const char *filename,struct Translation_Data *translation_data)
{
case TS_FUNC: /*TODO*/
goto hack;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
hack:
F diff --git a/src/program/program.c b/src/program/program.c
--- a/src/program/program.c
+++ b/src/program/program.c
struct Source_Name *name;
struct Source_File *file;
- assert(where_to_search!=NULL);
- assert(*where_to_search!=NULL);
+ wonky_assert(where_to_search!=NULL);
+ wonky_assert(*where_to_search!=NULL);
do
{
temp_name=gstr_append(*where_to_search,filename);
struct Translation_Data *hold_translation_data;
char *this_directory[]={"./","",NULL};
- assert(base_source_names!=NULL);
+ wonky_assert(base_source_names!=NULL);
if(*base_source_names==NULL)
{
}
void delete_translation_data(struct Translation_Data *translation_data)
{
- assert(translation_data->tokens->size==0 &&
+ wonky_assert(translation_data->tokens->size==0 &&
translation_data->errors->size==0 &&
translation_data->source_files->size==0);
free(translation_data->tokens);
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c
--- a/src/semantics/ast.c
+++ b/src/semantics/ast.c
array_type=(struct Type_Array*)expression_type;
expression_type=get_pointer_type(array_type->is_array_of,1,0);
- assert(expression_type!=NULL);
+ wonky_assert(expression_type!=NULL);
return get_cast_expression_tree(expression,expression_type,translation_data);
}else
left_type=(struct Type_Struct_Union*)extract_expresion_value_type(left->value,translation_data);
- assert(left_type->specifier==TS_STRUCT || left_type->specifier==TS_UNION);
+ wonky_assert(left_type->specifier==TS_STRUCT || left_type->specifier==TS_UNION);
ret=malloc(sizeof(struct AST_Binary_Expression));
ret->type=OP_MEMBER;
for(i=0;i<ret->number_of_arguments;++i)
{
- assert(arg_list->size>0);
+ wonky_assert(arg_list->size>0);
ret->arg_list[i]=(struct AST_Expression*)Queue_Pop(arg_list);
}
- assert(arg_list->size==0);
+ wonky_assert(arg_list->size==0);
if(constraint_check_function_expression(ret,translation_data) && id->type!=ERROR && id_type->specifier!=TS_ERROR)
{
delete_ast_declaration_error((struct AST_Declaration_Error*)ast);
break;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
void delete_ast_error(struct AST_Error *error)
F diff --git a/src/semantics/constraints/expression_constraints.c b/src/semantics/constraints/expression_constraints.c
--- a/src/semantics/constraints/expression_constraints.c
+++ b/src/semantics/constraints/expression_constraints.c
return 0;
}
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*for addition both operands shall have arithmetic type, or one operand shall be of pointer type and the other of integer type.
* for subtraction one of the following shall hold
return 0;
- assert(operation==OP_SUBTRACTION || operation==OP_ADDITION);
+ wonky_assert(operation==OP_SUBTRACTION || operation==OP_ADDITION);
left_type=extract_expresion_value_type(left->value,translation_data);
push_translation_error("constraint check violation in compound assignment expression",translation_data);
return 0;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
case OP_MULTIPLY_ASSIGN:
case OP_DIV_ASSIGN:
case OP_REMAINDER_ASSIGN:
case OP_PIPE_ASSIGN:
return constraint_check_bitwise_expression(left,right,operation,translation_data);
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
/*
F diff --git a/src/semantics/constraints/linkage_constraints.c b/src/semantics/constraints/linkage_constraints.c
--- a/src/semantics/constraints/linkage_constraints.c
+++ b/src/semantics/constraints/linkage_constraints.c
struct Linkage *linkage;
struct Denoted_Object *hold_object;
- assert(current->type!=FUNCTION_SCOPE);
+ wonky_assert(current->type!=FUNCTION_SCOPE);
if(previous_denoted_with_same_id==NULL) /*NOTE*/
return 1;
}
}else
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
struct Linkage *linkage;
struct Denoted_Function *hold_function;
- assert(current->type!=FUNCTION_SCOPE);
+ wonky_assert(current->type!=FUNCTION_SCOPE);
if(previous_denoted_with_same_id==NULL)
return 1;
}
}else
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
#endif
F diff --git a/src/semantics/constraints/statement_constraints.c b/src/semantics/constraints/statement_constraints.c
--- a/src/semantics/constraints/statement_constraints.c
+++ b/src/semantics/constraints/statement_constraints.c
push_translation_error("case statement used outside of a switch",translation_data);
return 0;
}
- assert(case_statement->control!=NULL);
+ wonky_assert(case_statement->control!=NULL);
/*
if(!ast_is_a_constant_expression((struct AST*)case_statement->control,translation_data))
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
_Bool constraint_check_function_definition(struct AST_Function_Definition *function,struct Translation_Data *translation_data)
F diff --git a/src/semantics/identifiers/denoted.c b/src/semantics/identifiers/denoted.c
--- a/src/semantics/identifiers/denoted.c
+++ b/src/semantics/identifiers/denoted.c
ret->id=NULL;
ret->type=prototype->type;
- assert(is_valid_denoted_base(ret));
+ wonky_assert(is_valid_denoted_base(ret));
return ret;
}
struct Denoted* get_denoted_function(struct token *id,struct Type *type,enum Function_Specifier fs)
ret->function_specifier=fs;
ret->function_scope=NULL;
- assert(is_valid_denoted_function(ret));
+ wonky_assert(is_valid_denoted_function(ret));
return (struct Denoted*)ret;
}
struct Denoted* get_denoted_object(struct token *id, enum Storage_Class_Specifier sc,struct Type *type,struct AST *initializer)
ret->object=get_object(type,sc);
- assert(is_valid_denoted_object(ret));
+ wonky_assert(is_valid_denoted_object(ret));
return (struct Denoted*)ret;
}
ret->type=base->type;
ret->id=base->id;
- assert(is_valid_denoted_type(ret));
+ wonky_assert(is_valid_denoted_type(ret));
return (struct Denoted*)ret;
}
struct Denoted* get_denoted_enum_const_expr(struct token *id,struct Enum *parent,struct AST* expression,struct Translation_Data *translation_data)
ret->expression=expression;
ret->value=evaluate_const_expression_integer(expression,translation_data);
- assert(is_valid_denoted_enum_const(ret));
+ wonky_assert(is_valid_denoted_enum_const(ret));
return (struct Denoted*)ret;
}
ret->expression=NULL;
ret->value=value;
- assert(is_valid_denoted_enum_const(ret));
+ wonky_assert(is_valid_denoted_enum_const(ret));
return (struct Denoted*)ret;
}
struct Denoted* get_denoted_enum(struct Enum *enumerator)
ret->denotation=DT_Enum;
ret->enumeration=enumerator;
- assert(is_valid_denoted_enum(ret));
+ wonky_assert(is_valid_denoted_enum(ret));
return (struct Denoted*)ret;
}
struct Denoted* get_denoted_struct_union(struct Struct_Union *struct_union)
ret->denotation=DT_Struct_Union_Tag;
ret->struct_union=struct_union;
- assert(is_valid_denoted_struct_union(ret));
+ wonky_assert(is_valid_denoted_struct_union(ret));
return (struct Denoted*)ret;
}
struct Denoted* get_denotation_prototype(struct Map *types)
ret->size=0;
ret->is_const=ret->is_volatile=0;
- assert(is_valid_denoted_prototype(ret));
+ wonky_assert(is_valid_denoted_prototype(ret));
return (struct Denoted*)ret;
}
struct Denoted* extract_denoted(struct Denoted_Base *base,struct Denotation_Prototype *prototype,_Bool allow_abstract)
Queue_Init(ret->gotos_jumping_to_this_statement);
- assert(is_valid_denoted_statement(ret));
+ wonky_assert(is_valid_denoted_statement(ret));
return (struct Denoted*)ret;
}
void delete_denoted(struct Denoted *denoted)
break;
case DT_Prototype:
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
void delete_denoted_error(struct Denoted_Error *error)
F diff --git a/src/semantics/identifiers/linkage.c b/src/semantics/identifiers/linkage.c
--- a/src/semantics/identifiers/linkage.c
+++ b/src/semantics/identifiers/linkage.c
denoted_object->object->storage_class=SCS_STATIC;
}else
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}else if(scope->type==FUNCTION_PROTOTYPE_SCOPE)
{
account_for_upper_linkage_on_object(scope,translation_data,denoted_object);
}else
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*check if id is linked oppositely*/
}else
{
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/*check if id is linked oppositely*/
F diff --git a/src/semantics/identifiers/scope.c b/src/semantics/identifiers/scope.c
--- a/src/semantics/identifiers/scope.c
+++ b/src/semantics/identifiers/scope.c
{
struct Normal_Scope *ret;
- assert(type==BLOCK_SCOPE || type==FILE_SCOPE || type==FUNCTION_PROTOTYPE_SCOPE);
+ wonky_assert(type==BLOCK_SCOPE || type==FILE_SCOPE || type==FUNCTION_PROTOTYPE_SCOPE);
ret=malloc(sizeof(struct Normal_Scope));
ret->type=type;
- assert((type!=FILE_SCOPE) || parent==NULL);
+ wonky_assert((type!=FILE_SCOPE) || parent==NULL);
ret->parent=parent;
Map_Init(&ret->tags);
Queue_Init(ret->object_order);
- assert(is_valid_normal_scope(ret));
+ wonky_assert(is_valid_normal_scope(ret));
return (struct Scope*)ret;
}
struct Scope* get_function_scope(struct Scope *parent,struct Denoted_Function *function)
{
struct Function_Scope *ret;
- assert(parent!=NULL && parent->type==FILE_SCOPE);
+ wonky_assert(parent!=NULL && parent->type==FILE_SCOPE);
ret=malloc(sizeof(struct Function_Scope));
ret->type=FUNCTION_SCOPE;
ret->label_order=malloc(sizeof(struct Queue));
Queue_Init(ret->label_order);
- assert(is_valid_function_scope(ret));
+ wonky_assert(is_valid_function_scope(ret));
return (struct Scope*)ret;
}
case FUNCTION_SCOPE:
delete_function_scope((struct Function_Scope*)scope);
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
{
case DT_Statement:
/*perhaps lables should be denoted*/
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
case DT_Function:
push_function(scope,translation_data,AS_DENOTED_FUNCTION(declarator));
break;
push_denoted_enum_constant(scope,translation_data,AS_DENOTED_ENUM_CONST(declarator));
break;
case DT_Struct_Union_Member:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
break;
case DT_Enum:
push_denoted_enum_tag(scope,translation_data,AS_DENOTED_ENUM(declarator));
current=scope;
while(current->type!=FUNCTION_SCOPE && current!=NULL)
{
- assert(current->type!=FILE_SCOPE);
+ wonky_assert(current->type!=FILE_SCOPE);
current=current->parent;
}
return (struct Function_Scope*)current;
if(hold_statement!=NULL)
{
- assert(hold_statement->denotation==DT_Statement);
+ wonky_assert(hold_statement->denotation==DT_Statement);
if(hold_statement->statement!=NULL)
{
return get_denoted_error((struct Denoted*)hold_statement);
}else
{
- assert(hold_statement->label!=NULL);
- assert(hold_statement->gotos_jumping_to_this_statement->size>0);
- assert(hold_statement->previous_denoted_object==NULL);
+ wonky_assert(hold_statement->label!=NULL);
+ wonky_assert(hold_statement->gotos_jumping_to_this_statement->size>0);
+ wonky_assert(hold_statement->previous_denoted_object==NULL);
hold_statement->label=label;
hold_statement->statement=statement;
/*note the use of the current scope instead of the function scope*/
hold_statement->previous_denoted_object=get_last_known_denoted_object((struct Normal_Scope*)current);
- assert(hold_statement->previous_denoted_object==NULL || hold_statement->previous_denoted_object->denotation==DT_Object);
+ wonky_assert(hold_statement->previous_denoted_object==NULL || hold_statement->previous_denoted_object->denotation==DT_Object);
return (struct Denoted*)hold_statement;
}
return (struct Denoted*)hold_statement;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
{
struct Denoted *hold_previous;
- assert(current->type!=FUNCTION_SCOPE);
+ wonky_assert(current->type!=FUNCTION_SCOPE);
{
struct Denoted *hold_previous;
- assert(current->type!=FUNCTION_SCOPE);
+ wonky_assert(current->type!=FUNCTION_SCOPE);
resolve_function_linkage(current,translation_data,denoted_function);
F diff --git a/src/semantics/memory/object.c b/src/semantics/memory/object.c
--- a/src/semantics/memory/object.c
+++ b/src/semantics/memory/object.c
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
F diff --git a/src/semantics/value/evaluation.c b/src/semantics/value/evaluation.c
--- a/src/semantics/value/evaluation.c
+++ b/src/semantics/value/evaluation.c
default:
return NULL;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
F diff --git a/src/semantics/value/initialiser.c b/src/semantics/value/initialiser.c
--- a/src/semantics/value/initialiser.c
+++ b/src/semantics/value/initialiser.c
if(constraint_check_denoted_initialiser(to_be_initialised,initialiser,translation_data))
{
- assert(is_valid_initialiser_denoted(ret));
+ wonky_assert(is_valid_initialiser_denoted(ret));
return (struct Initialiser*)ret;
}
else
if(constraint_check_indexed_initialiser_by_index(type,index,initialiser,translation_data))
{
- assert(is_valid_initialiser_indexed(ret));
+ wonky_assert(is_valid_initialiser_indexed(ret));
return (struct Initialiser*)ret;
}
else
if(constraint_check_expression_initialiser(expression,type_of_initialised,translation_data))
{
- assert(is_valid_initialiser_expression(ret));
+ wonky_assert(is_valid_initialiser_expression(ret));
return (struct Initialiser*)ret;
}
else
if(constraint_check_compound_initialiser(ret,translation_data))
{
- assert(is_valid_initialiser_compound(ret));
+ wonky_assert(is_valid_initialiser_compound(ret));
return (struct Initialiser*)ret;
}else
{
ret->kind=INITIALISER_ERROR;
ret->error=error;
- assert(is_valid_initialiser_error(ret));
+ wonky_assert(is_valid_initialiser_error(ret));
return (struct Initialiser*)ret;
}
F diff --git a/src/semantics/value/type.c b/src/semantics/value/type.c
--- a/src/semantics/value/type.c
+++ b/src/semantics/value/type.c
{
free(type);
- assert(is_valid_type((struct Type*)hold_node->ID));
+ wonky_assert(is_valid_type((struct Type*)hold_node->ID));
return (struct Type*)hold_node->ID;
}
}
ret->error=type;
ret=(struct Type_Error*)type_check_and_push((struct Type*)ret,type->node,sizeof(struct Type_Error));
- assert(is_valid_type_error(ret));
+ wonky_assert(is_valid_type_error(ret));
return (struct Type*)ret;
}
{
struct Type_Struct_Union *ret;
- assert(prototype->denotation=DT_Prototype);
+ wonky_assert(prototype->denotation=DT_Prototype);
prototype->denotation=DT_Object;
ret=calloc(1,sizeof(struct Type_Struct_Union));
return get_type_error((struct Type*)ret);
}else
{
- assert(is_valid_type_struct(ret) || is_valid_type_union(ret));
+ wonky_assert(is_valid_type_struct(ret) || is_valid_type_union(ret));
return (struct Type*)ret;
}
}
ret->has_constant_member=0;
ret->id=id;
- assert(is_valid_struct_union(ret));
+ wonky_assert(is_valid_struct_union(ret));
return ret;
}
struct Enum *get_enum_base(struct token *id)
ret=calloc(1,sizeof(struct Type_Basic));
- assert(prototype->denotation=DT_Prototype);
+ wonky_assert(prototype->denotation=DT_Prototype);
prototype->denotation=DT_Object;
ret->size=prototype->size;
}
}
- assert(is_valid_type_basic(ret));
+ wonky_assert(is_valid_type_basic(ret));
return (struct Type*)ret;
}
ret=(struct Type_Pointer*)type_check_and_push((struct Type*)ret,points_to->node,sizeof(struct Type_Pointer));
- assert(is_valid_type_pointer(ret));
+ wonky_assert(is_valid_type_pointer(ret));
return (struct Type*)ret;
}
ret->is_array_of=array_of;
ret=(struct Type_Array*)type_check_and_push((struct Type*)ret,array_of->node,sizeof(struct Type_Array));
- assert(is_valid_type_array(ret));
+ wonky_assert(is_valid_type_array(ret));
return (struct Type*)ret;
{
struct Type_Enum *ret;
- assert(prototype->denotation=DT_Prototype);
+ wonky_assert(prototype->denotation=DT_Prototype);
prototype->denotation=DT_Object;
ret=calloc(1,sizeof(struct Type_Enum));
return get_type_error((struct Type*)ret);
}
- assert(is_valid_type_enum(ret));
+ wonky_assert(is_valid_type_enum(ret));
return (struct Type*)ret;
}
free(parameters);
ret=(struct Type_Function*)type_check_and_push((struct Type*)ret,return_type->node,sizeof(struct Type_Function));
- assert(is_valid_type_function(ret));
+ wonky_assert(is_valid_type_function(ret));
return (struct Type*)ret;
}
_Bool is_type(struct Translation_Data *translation_data,struct Scope *scope,size_t look_ahead)
ret=(struct Type_Basic*)type_check_and_push((struct Type*)ret,translation_data->types,sizeof(struct Type_Basic));
- assert(is_valid_type_basic(ret));
+ wonky_assert(is_valid_type_basic(ret));
return ret;
}
/*TODO !!!*/
default:
return 0;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
/* 6.2.7
return 1;
}
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
return 0;
}
_Bool types_of_pointers_are_compatible_unqualified(struct Type_Pointer *a,struct Type_Pointer *b)
case TC_SHORT:
return 1;
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
default:
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
}
_Bool type_is_pointer(struct Type *type)
F diff --git a/src/semantics/value/value.c b/src/semantics/value/value.c
--- a/src/semantics/value/value.c
+++ b/src/semantics/value/value.c
ret=malloc(sizeof(struct Expression_Value));
ret->type=VALUE_VOID;
- assert(is_valid_value(ret));
+ wonky_assert(is_valid_value(ret));
return ret;
}
struct Expression_Value* get_expression_value_lvalue(struct Object *object)
else
ret->is_modifiable=1;
- assert(is_valid_lvalue(ret));
+ wonky_assert(is_valid_lvalue(ret));
return (struct Expression_Value*)ret;
}
struct Expression_Value* get_expression_value_constant(struct Constant *constant)
ret->type=VALUE_CONSTANT;
ret->constant=constant;
- assert(is_valid_value_constant(ret));
+ wonky_assert(is_valid_value_constant(ret));
return (struct Expression_Value*)ret;
}
struct Expression_Value* get_expression_value_rvalue(struct Object *temp_object)
ret->type=VALUE_TEMP;
ret->temp_object=temp_object;
- assert(is_valid_rvalue(ret));
+ wonky_assert(is_valid_rvalue(ret));
return (struct Expression_Value*)ret;
}
struct Expression_Value* get_expression_value_function_designator(struct Denoted_Function *function)
ret->type=VALUE_FUNCTION_DESIGNATOR;
ret->function=function;
- assert(is_valid_value_function_designator(ret));
+ wonky_assert(is_valid_value_function_designator(ret));
return (struct Expression_Value*)ret;
}
case VALUE_VOID:
return (struct Type*)get_type_insecure(TS_VOID,TSIGN_NONE,TC_NONE,0,translation_data);
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
delete_expression_value_void(expression_value);
return;
}
- assert(SHOULD_NOT_REACH_HERE);
+ wonky_assert(SHOULD_NOT_REACH_HERE);
}
void delete_expression_value_void(struct Expression_Value *void_expression_value)
{
F diff --git a/tests/.gdb_history b/tests/.gdb_history
new file mode 100644
--- /dev/null
+++ b/tests/.gdb_history
+ r /tmp/kek.log
+ where
+ b wonky_assert.c:10
+ r
+ print __FILE__
+ n
+ r
+ n
+ s
+ r
+ n
+ where
+ r
+ r /tmp/wo.log
+ where