Minor cleanup and removal of unneeded whitespace

This commit is contained in:
Jeremiah Orians 2018-03-05 19:13:20 -05:00
parent 426a92ab09
commit 589217b3b6
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
6 changed files with 31 additions and 37 deletions

View File

@ -116,7 +116,7 @@ struct token_list* sym_get_value(char *s, struct token_list* out, struct token_l
if(NULL != a)
{
current_target = a->type;
out = emit(prepend_string("LOAD_EFFECTIVE_ADDRESS %", postpend_char(numerate_number(stack_index(a, function)), LF)), out);
out = emit(prepend_string("LOAD_EFFECTIVE_ADDRESS %", numerate_number(stack_index(a, function))), out);
if(!match("=", global_token->s)) out = emit("LOAD_INTEGER\x0A", out);
return out;
}
@ -125,7 +125,7 @@ struct token_list* sym_get_value(char *s, struct token_list* out, struct token_l
if(NULL != a)
{
current_target = a->type;
out = emit(prepend_string("LOAD_EFFECTIVE_ADDRESS %", postpend_char(numerate_number(stack_index(a, function)), LF)), out);
out = emit(prepend_string("LOAD_EFFECTIVE_ADDRESS %", numerate_number(stack_index(a, function))), out);
if(!match("=", global_token->s) && !match("argv", s)) out = emit("LOAD_INTEGER\x0A", out);
return out;
}

View File

@ -52,6 +52,7 @@ clean:
./test/test18/cleanup.sh
./test/test19/cleanup.sh
./test/test99/cleanup.sh
./test/test100/cleanup.sh
# Directories
bin:
@ -81,7 +82,8 @@ test: test00-binary \
test17-binary \
test18-binary \
test19-binary \
test99-binary | results
test99-binary \
test100-binary | results
sha256sum -c test/test.answers
test00-binary: M2-Planet | results
@ -147,6 +149,9 @@ test19-binary: M2-Planet | results
test99-binary: M2-Planet | results
test/test99/hello.sh
test100-binary: M2-Planet | results
test/test100/hello.sh
# Generate test answers
.PHONY: Generate-test-answers
Generate-test-answers:

View File

@ -17,48 +17,36 @@
#include<stdlib.h>
#define MAX_STRING 4096
char* copy_string(char* target, char* source)
{
while(0 != source[0])
{
target[0] = source[0];
target = target + 1;
source = source + 1;
}
return target;
}
char* postpend_char(char* s, char a)
{
int i = 0;
while(0 != s[i])
{
i = i + 1;
}
s[i] = a;
return s;
char* ret = calloc(MAX_STRING, sizeof(char));
char* hold = copy_string(ret, s);
hold[0] = a;
return ret;
}
char* prepend_char(char a, char* s)
{
int hold = a;
int prev;
int i = 0;
do
{
prev = hold;
hold = s[i];
s[i] = prev;
i = i + 1;
} while(0 != hold);
return s;
char* ret = calloc(MAX_STRING, sizeof(char));
ret[0] = a;
copy_string((ret+1), s);
return ret;
}
char* prepend_string(char* add, char* base)
{
char* ret = calloc(MAX_STRING, sizeof(char));
int i = 0;
while(0 != add[i])
{
ret[i] = add[i];
i = i + 1;
}
int j = 0;
while(0 != base[j])
{
ret[i] = base[j];
i = i + 1;
j = j + 1;
}
copy_string(copy_string(ret, add), base);
return ret;
}

View File

@ -9,6 +9,7 @@ d27eb315d694324650b11a421d6990eee60ac5921a5625bbccb43d806f09e156 test/results/t
8cc38294fb1261843cfc3956fad5a451c95bbc2ed687435d4e2d59df2c4a8567 test/results/test08-binary
cc8f252877a85c0d7832094ff574d7173ac33940917bc1591358b8970651a81c test/results/test09-binary
3857aee4183de41bd00b014d616a5d73f4bfc57aa60a6073bb4113d6ff2fb8d5 test/results/test10-binary
e9f2c016b3119069d808c113a7cfdd01d1d6d205c81e34fe16a659e700e48c34 test/results/test100-binary
dce2f0b35323cf6a2b01f74a9335100f2d8626028af545832dbdb503573db0e5 test/results/test11-binary
88602970fa07b5da7a42b4f2b2486fe03accc6796e05453c4ab934e986790bef test/results/test12-binary
c85a57b5b1d65288efd47a3b12c6fca1efade9e7ec91e65efda5531d2c40d293 test/results/test13-binary

View File

@ -52,7 +52,7 @@ then
out=$(sha256sum -c test/test100/proof.answer)
[ "$out" = "test/test100/proof: OK" ] || exit 5
cp test/results/test100-binary bin/M2-Planet
[ ! -e bin/M2-Planet ] && mv test/results/test100-binary bin/M2-Planet
else
cp bin/M2-Planet-gcc bin/M2-Planet
fi

View File

@ -1 +1 @@
380db88d937c29f6f177daf592df473b97ff2c1dcee4adf82e99cdfb825fbc3e test/test100/proof
7aa6bad31f78227761301b4f5fc26147c7ed22b6e4265c0cbca3641a54e459b5 test/test100/proof