# HG changeset patch # User Kaito Tokumori # Date 1424521186 -32400 # Node ID 37a10fd62ea9bcba0fa4d0c61573477dd10e0b9d # Parent e1e9a4eac42daf549586f6096996192a222155b3 add programs for prototype generation checking diff -r e1e9a4eac42d -r 37a10fd62ea9 protoGenCheck/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/protoGenCheck/Makefile Sat Feb 21 21:19:46 2015 +0900 @@ -0,0 +1,13 @@ +CC=/Users/e105711/prog/seminar/CbC/llvmInst/Debug+Asserts/bin/clang +TARGET=noProtoFibonacci fibonacci + +.SUFFIXES: .c .o + +.c.o: + $(CC) -o $< + +all: $(TARGET) + +clean: + rm -f $(TARGET) + rm -f *.o diff -r e1e9a4eac42d -r 37a10fd62ea9 protoGenCheck/fibonacci.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/protoGenCheck/fibonacci.c Sat Feb 21 21:19:46 2015 +0900 @@ -0,0 +1,35 @@ +/* + calculate fibonacci progression. + Author : Kaito Tokumori +*/ + +#include +#include + +__code fibonacci(int loop); +__code calcLoop(int before, int current, int loop); +__code print_answer(int answer); + +int main(int argc, char **argv) { + int i; + i = atoi(argv[1]); + + goto fibonacci(i); +} + +__code fibonacci(int loop) { + goto calcLoop(0, 1, loop); +} + +__code calcLoop(int before, int current, int loop) { + if ( loop > 1) { + goto calcLoop(current, before+current, loop-1); + }else{ + goto print_answer(current); + } +} + +__code print_answer(int answer) { + printf("factorial = %d\n",answer); + exit(0); +} diff -r e1e9a4eac42d -r 37a10fd62ea9 protoGenCheck/noProtoFibonacci.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/protoGenCheck/noProtoFibonacci.c Sat Feb 21 21:19:46 2015 +0900 @@ -0,0 +1,31 @@ +/* + Prototype generator check. CbC compiler should compile this code without errors and warnings. + Author : Kaito Tokumori +*/ + +#include +#include + +int main(int argc, char **argv) { + int i; + i = atoi(argv[1]); + + goto fibonacci(i); +} + +__code fibonacci(int loop) { + goto calcLoop(0, 1, loop); +} + +__code calcLoop(int before, int current, int loop) { + if ( loop > 1) { + goto calcLoop(current, before+current, loop-1); + }else{ + goto print_answer(current); + } +} + +__code print_answer(int answer) { + printf("factorial = %d\n",answer); + exit(0); +}