Trying to get to the point where make format
works the same
on Linux and MacOS
This commit is contained in:
parent
93b84087ce
commit
d620542ee5
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -18,3 +18,5 @@ src/\.#*
|
|||
post-scarcity\.iml
|
||||
|
||||
doc/
|
||||
|
||||
log*
|
||||
|
|
10
Makefile
10
Makefile
|
@ -1,4 +1,3 @@
|
|||
|
||||
TARGET ?= target/psse
|
||||
SRC_DIRS ?= ./src
|
||||
|
||||
|
@ -11,7 +10,10 @@ TESTS := $(shell find unit-tests -name *.sh)
|
|||
|
||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
INDENT_FLAGS := -kr -br -brf -brs -ce -cdw -npsl -nut -prs -l79 -ts2
|
||||
|
||||
INDENT_FLAGS := -nbad -bap -nbc -br -brf -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 \
|
||||
-d0 -di1 -nfc1 -i4 -ip0 -l75 -lp -npcs \
|
||||
-npsl -nsc -nsob -nss -nut -prs -l79 -ts2
|
||||
|
||||
VERSION := "0.0.2"
|
||||
|
||||
|
@ -25,7 +27,11 @@ doc: $(SRCS) Makefile
|
|||
doxygen
|
||||
|
||||
format: $(SRCS) $(HDRS) Makefile
|
||||
ifeq ($(shell uname -s), Darwin)
|
||||
gindent $(INDENT_FLAGS) $(SRCS) $(HDRS)
|
||||
else
|
||||
indent $(INDENT_FLAGS) $(SRCS) $(HDRS)
|
||||
endif
|
||||
|
||||
test: $(OBJS) $(TESTS) Makefile
|
||||
bash ./unit-tests.sh
|
||||
|
|
|
@ -73,9 +73,11 @@ void make_cons_page( ) {
|
|||
strncpy( &cell->tag.bytes[0], TRUETAG, TAGLENGTH );
|
||||
cell->count = MAXREFERENCE;
|
||||
cell->payload.free.car = ( struct cons_pointer ) {
|
||||
0, 1};
|
||||
0, 1
|
||||
};
|
||||
cell->payload.free.cdr = ( struct cons_pointer ) {
|
||||
0, 1};
|
||||
0, 1
|
||||
};
|
||||
fwprintf( stderr, L"Allocated special cell T\n" );
|
||||
break;
|
||||
case 2:
|
||||
|
@ -120,7 +122,8 @@ void dump_pages( FILE * output ) {
|
|||
|
||||
for ( int j = 0; j < CONSPAGESIZE; j++ ) {
|
||||
dump_object( output, ( struct cons_pointer ) {
|
||||
i, j} );
|
||||
i, j
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,29 @@ void dec_ref( struct cons_pointer pointer ) {
|
|||
}
|
||||
}
|
||||
|
||||
void dump_string_cell( FILE * output, wchar_t *prefix,
|
||||
struct cons_pointer pointer ) {
|
||||
struct cons_space_object cell = pointer2cell( pointer );
|
||||
if ( cell.payload.string.character == 0 ) {
|
||||
fwprintf( output,
|
||||
L"\t\t%ls cell: termination; next at page %d offset %d, count %u\n",
|
||||
prefix,
|
||||
cell.payload.string.cdr.page, cell.payload.string.cdr.offset,
|
||||
cell.count );
|
||||
} else {
|
||||
fwprintf( output,
|
||||
L"\t\t%ls cell: character '%lc' (%d) next at page %d offset %d, count %u\n",
|
||||
prefix,
|
||||
( wint_t ) cell.payload.string.character,
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.cdr.page,
|
||||
cell.payload.string.cdr.offset, cell.count );
|
||||
fwprintf( output, L"\t\t value: " );
|
||||
print( output, pointer );
|
||||
fwprintf( output, L"\n" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dump the object at this cons_pointer to this output stream.
|
||||
*/
|
||||
|
@ -91,8 +114,7 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
|||
fwprintf( output, L"\n" );
|
||||
/* TODO: dump the stack trace */
|
||||
for ( struct stack_frame * frame = cell.payload.exception.frame;
|
||||
frame != NULL;
|
||||
frame = frame->previous){
|
||||
frame != NULL; frame = frame->previous ) {
|
||||
dump_frame( output, frame );
|
||||
}
|
||||
break;
|
||||
|
@ -112,33 +134,10 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
|||
cell.payload.real.value, cell.count );
|
||||
break;
|
||||
case STRINGTV:
|
||||
if (cell.payload.string.character == 0) {
|
||||
fwprintf( output,
|
||||
L"\t\tString cell: termination; next at page %d offset %d, count %u\n",
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.cdr.page,
|
||||
cell.payload.string.cdr.offset, cell.count );
|
||||
}else {
|
||||
fwprintf( output,
|
||||
L"\t\tString cell: character '%lc' (%d) next at page %d offset %d, count %u\n",
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.cdr.page,
|
||||
cell.payload.string.cdr.offset, cell.count );
|
||||
fwprintf( output, L"\t\t value: " );
|
||||
print( output, pointer );
|
||||
fwprintf( output, L"\n" );}
|
||||
dump_string_cell( output, L"String", pointer );
|
||||
break;
|
||||
case SYMBOLTV:
|
||||
fwprintf( output,
|
||||
L"\t\tSymbol cell: character '%lc' (%d) next at page %d offset %d, count %u\n",
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.character,
|
||||
cell.payload.string.cdr.page,
|
||||
cell.payload.string.cdr.offset, cell.count );
|
||||
fwprintf( output, L"\t\t value:" );
|
||||
print( output, pointer );
|
||||
fwprintf( output, L"\n" );
|
||||
dump_string_cell( output, L"Symbol", pointer );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +167,8 @@ struct cons_pointer make_cons( struct cons_pointer car,
|
|||
* @param message should be a lisp string describing the problem, but actually any cons pointer will do;
|
||||
* @param frame should be the frame in which the exception occurred.
|
||||
*/
|
||||
struct cons_pointer make_exception( struct cons_pointer message, struct stack_frame * frame) {
|
||||
struct cons_pointer make_exception( struct cons_pointer message,
|
||||
struct stack_frame *frame ) {
|
||||
struct cons_pointer pointer = allocate_cell( EXCEPTIONTAG );
|
||||
struct cons_space_object *cell = &pointer2cell( pointer );
|
||||
|
||||
|
|
|
@ -461,7 +461,8 @@ struct cons_pointer make_cons( struct cons_pointer car,
|
|||
* @param message should be a lisp string describing the problem, but actually any cons pointer will do;
|
||||
* @param frame should be the frame in which the exception occurred.
|
||||
*/
|
||||
struct cons_pointer make_exception( struct cons_pointer message, struct stack_frame * frame);
|
||||
struct cons_pointer make_exception( struct cons_pointer message,
|
||||
struct stack_frame *frame );
|
||||
|
||||
/**
|
||||
* Construct a cell which points to an executable Lisp special form.
|
||||
|
|
|
@ -475,7 +475,8 @@ lisp_cond( struct stack_frame *frame, struct cons_pointer env ) {
|
|||
done = true;
|
||||
} else {
|
||||
result = lisp_throw( c_string_to_lisp_string
|
||||
( "Arguments to `cond` must be lists" ), frame );
|
||||
( "Arguments to `cond` must be lists" ),
|
||||
frame );
|
||||
}
|
||||
}
|
||||
/* TODO: if there are more than 8 clauses we need to continue into the
|
||||
|
|
|
@ -174,7 +174,9 @@ lisp_divide( struct stack_frame *frame, struct cons_pointer env ) {
|
|||
result = make_integer( arg0.payload.integer.value /
|
||||
arg1.payload.integer.value );
|
||||
} else if ( numberp( frame->arg[0] ) && numberp( frame->arg[1] ) ) {
|
||||
result = make_real( numeric_value(frame->arg[0]) / numeric_value(frame->arg[1]));
|
||||
result =
|
||||
make_real( numeric_value( frame->arg[0] ) /
|
||||
numeric_value( frame->arg[1] ) );
|
||||
} else {
|
||||
lisp_throw( c_string_to_lisp_string
|
||||
( "Cannot divide: not a number" ), frame );
|
||||
|
@ -182,6 +184,3 @@ lisp_divide( struct stack_frame *frame, struct cons_pointer env ) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
*/
|
||||
|
||||
struct cons_pointer read_number( FILE * input, wint_t initial );
|
||||
struct cons_pointer read_list( struct stack_frame *frame, FILE * input, wint_t initial );
|
||||
struct cons_pointer read_list( struct stack_frame *frame, FILE * input,
|
||||
wint_t initial );
|
||||
struct cons_pointer read_string( FILE * input, wint_t initial );
|
||||
struct cons_pointer read_symbol( FILE * input, wint_t initial );
|
||||
|
||||
|
@ -49,7 +50,8 @@ struct cons_pointer c_quote( struct cons_pointer arg ) {
|
|||
* treating this initial character as the first character of the object
|
||||
* representation.
|
||||
*/
|
||||
struct cons_pointer read_continuation(struct stack_frame *frame, FILE * input, wint_t initial ) {
|
||||
struct cons_pointer read_continuation( struct stack_frame *frame, FILE * input,
|
||||
wint_t initial ) {
|
||||
struct cons_pointer result = NIL;
|
||||
|
||||
wint_t c;
|
||||
|
@ -147,7 +149,8 @@ struct cons_pointer read_number( FILE * input, wint_t initial ) {
|
|||
* Read a list from this input stream, which no longer contains the opening
|
||||
* left parenthesis.
|
||||
*/
|
||||
struct cons_pointer read_list( struct stack_frame *frame, FILE * input, wint_t initial ) {
|
||||
struct cons_pointer read_list( struct stack_frame *frame, FILE * input,
|
||||
wint_t initial ) {
|
||||
struct cons_pointer result = NIL;
|
||||
|
||||
if ( initial != ')' ) {
|
||||
|
|
|
@ -56,7 +56,8 @@ struct cons_pointer repl_eval( struct cons_pointer input) {
|
|||
/**
|
||||
* Dummy up a Lisp print call with its own stack frame.
|
||||
*/
|
||||
struct cons_pointer repl_print( struct cons_pointer stream_pointer, struct cons_pointer value) {
|
||||
struct cons_pointer repl_print( struct cons_pointer stream_pointer,
|
||||
struct cons_pointer value ) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
|
||||
frame->arg[0] = value;
|
||||
|
@ -89,8 +90,7 @@ repl( FILE * in_stream, FILE * out_stream, FILE * error_stream,
|
|||
|
||||
/* suppress the 'end of stream' exception */
|
||||
if ( exceptionp( val ) &&
|
||||
!feof( pointer2cell( input_stream).payload.stream.stream ) )
|
||||
{
|
||||
!feof( pointer2cell( input_stream ).payload.stream.stream ) ) {
|
||||
repl_print( output_stream, val );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue