summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f226da0)
raw | patch | inline | side by side (parent: f226da0)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 18 Aug 2017 20:06:05 +0000 (23:06 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 18 Aug 2017 20:06:05 +0000 (23:06 +0300) |
31 files changed:
diff --git a/obn-compile.sh b/obn-compile.sh
index 85b71c5cd77a31745dd068269b2181989469303d..4ad5c3d6b261bc9f977b75efaf7957c00a217299 100755 (executable)
--- a/obn-compile.sh
+++ b/obn-compile.sh
rm -rf classes tmp
mkdir -p classes tmp
-./a.out -d tmp $1
+./a.out -d tmp $*
jasmin -d classes tmp/*.j
diff --git a/obn-run-tests.sh b/obn-run-tests.sh
index fa1d728f373bbc133344fd14886982b2cdb21fe1..faaf6eacd92a3c1e2a002f7b5f393b321c1253bf 100755 (executable)
--- a/obn-run-tests.sh
+++ b/obn-run-tests.sh
set -e
+TEST_DIR=tests
+
# Тест: компиляция и исполнение
maketest()
{
local OK=1
local LOG=""
- if ! LOG="$(./obn-compile.sh $1)"; then
+ if ! LOG="$(./obn-compile.sh -I $TEST_DIR $1)"; then
OK=0;
echo "=============================="
echo "Test fail: $1 compile-time $?:"
if [ $OK = 1 ]; then
if ! ./obn-run.sh $1; then
OK=0
- echo "=============================="
- echo "Test fail: $1 run-time $?:"
- echo "$LOG"
- echo "=============================="
- echo
fi
fi
if [ $OK = 1 ]; then
makecomp()
{
local LOG=""
- if ! LOG="$(./obn-compile.sh $1)"; then
+ if ! LOG="$(./obn-compile.sh -I $TEST_DIR $1)"; then
echo "=============================="
echo "Test fail: $1 compile-time $?:"
echo "$LOG"
makefail()
{
local LOG=""
- if ! LOG="$(./obn-compile.sh $1)"; then
+ if ! LOG="$(./obn-compile.sh -I $TEST_DIR $1)"; then
echo "Test ok: $1"
else
echo "=============================="
diff --git a/src/main.c b/src/main.c
index 994ae806747dc34788ee8c76e9b247e27dd8202b..754d90aa7f216863d6f6337c0c3d41bd3def2afc 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "../include/oberon.h"
+struct string_stack
+{
+ char * string;
+ struct string_stack * next;
+};
+
static oberon_context_t * ctx;
static oberon_module_t * mod;
static const char * module;
static const char * out_path;
+static struct string_stack * path_list;
+
+static void
+add_to_stack(struct string_stack ** stack, char * string)
+{
+ struct string_stack * p = malloc(sizeof *p);
+ p -> string = string;
+ p -> next = *stack;
+ *stack = p;
+}
+
+static FILE *
+open_file(struct string_stack * path, const char * ext, const char * name, const char * mode)
+{
+ FILE * fp = NULL;
+ while(fp == NULL && path != NULL)
+ {
+ char fname[256];
+ snprintf(fname, 256, "%s/%s.%s", path -> string, name, ext);
+ fp = fopen(fname, mode);
+ path = path -> next;
+ }
+ return fp;
+}
static const char *
import_module(const char * name)
{
- assert(name);
-
FILE * fp;
- char fname[256];
- snprintf(fname, 256, "%s.obn", name);
- fp = fopen(fname, "r");
+ fp = open_file(path_list, "obn", name, "r");
if(fp == NULL)
{
- printf("can't open file %s\n", fname);
- exit(1);
return NULL;
}
init(int argc, char ** argv)
{
int i = 1;
+ add_to_stack(&path_list, ".");
out_path = ".";
- if(argc > 2 && strcmp(argv[i], "-d") == 0)
+ while(argc > 2)
{
- out_path = argv[i + 1];
- argc -= 2;
- i += 2;
+ if(argc > 2 && strcmp(argv[i], "-d") == 0)
+ {
+ out_path = argv[i + 1];
+ argc -= 2;
+ i += 2;
+ }
+ else if(argc > 2 && strcmp(argv[i], "-I") == 0)
+ {
+ add_to_stack(&path_list, argv[i + 1]);
+ argc -= 2;
+ i += 2;
+ }
+ else
+ {
+ break;
+ }
}
if(argc != 2 || argv[i][0] == '-')
init(argc, argv);
code = import_module(module);
+ if(code == NULL)
+ {
+ printf("can't open module source %s\n", module);
+ return 0;
+ }
ctx = oberon_create_context(import_module);
oberon_set_out_directory(ctx, out_path);
diff --git a/Test1.obn b/tests/Test1.obn
diff --git a/Test10.obn b/tests/Test10.obn
diff --git a/Test11.obn b/tests/Test11.obn
diff --git a/Test12.obn b/tests/Test12.obn
diff --git a/Test13.obn b/tests/Test13.obn
diff --git a/Test14.obn b/tests/Test14.obn
diff --git a/Test15.obn b/tests/Test15.obn
diff --git a/Test16.obn b/tests/Test16.obn
diff --git a/Test17A.obn b/tests/Test17A.obn
diff --git a/Test17B.obn b/tests/Test17B.obn
diff --git a/Test17C.obn b/tests/Test17C.obn
diff --git a/Test17Common.obn b/tests/Test17Common.obn
diff --git a/Test17D.obn b/tests/Test17D.obn
diff --git a/Test17E.obn b/tests/Test17E.obn
diff --git a/Test17F.obn b/tests/Test17F.obn
diff --git a/Test18A.obn b/tests/Test18A.obn
diff --git a/Test18B.obn b/tests/Test18B.obn
diff --git a/Test18C.obn b/tests/Test18C.obn
diff --git a/Test19.obn b/tests/Test19.obn
similarity index 91%
rename from Test19.obn
rename to tests/Test19.obn
index 323d52829abcee47f89ae98fcde1b5c447a4e8c4..c5e684db354fe4ff4bcc90c0d81fc1315aca666a 100644 (file)
rename from Test19.obn
rename to tests/Test19.obn
index 323d52829abcee47f89ae98fcde1b5c447a4e8c4..c5e684db354fe4ff4bcc90c0d81fc1315aca666a 100644 (file)
--- a/Test19.obn
+++ b/tests/Test19.obn
x : POINTER TO ARRAY OF CHAR;
BEGIN
- f := Files.Old("Test19.obn");
+ f := Files.Old("tests/Test19.obn");
ASSERT(f # NIL);
Files.Set(r, f, 0);
diff --git a/Test2.obn b/tests/Test2.obn
diff --git a/Test20.obn b/tests/Test20.obn
diff --git a/Test3.obn b/tests/Test3.obn
diff --git a/Test4.obn b/tests/Test4.obn
diff --git a/Test5.obn b/tests/Test5.obn
diff --git a/Test6.obn b/tests/Test6.obn
diff --git a/Test7.obn b/tests/Test7.obn
diff --git a/Test8.obn b/tests/Test8.obn
diff --git a/Test9.obn b/tests/Test9.obn