language

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 1e9622851c7963ef4a11565a46b0e770ced3a2ff
parent 9b1100a3cf7a0af9a0a9c19dc57263de6073160f
Author: Paul Longtine <paullongtine@gmail.com>
Date:   Mon Dec 14 10:42:37 2015

re-arraged to support multiple tests

Diffstat:
 src/vm/src/main.c        | 36 ------------------------------------
 src/vm/test              | Bin 14 -> 0 bytes
 src/vm/tests/bc/Makefile | 27 +++++++++++++++++++++++++++
 src/vm/tests/bc/bytecode | Bin 0 -> 14 bytes
 src/vm/tests/bc/test     | Bin 0 -> 13990 bytes
 src/vm/tests/bc/test.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 69 insertions(+), 36 deletions(-)

diff --git a/src/vm/src/main.c b/src/vm/src/main.c @@ -1,42 +1,6 @@ #include <stdio.h> -#include "fh.h" -#include "is.h" -#include "bc.h" - int main(int argc, char** argv) { - if (argc < 2) return -1; - init(); - - // start testing - bc_cont* bc = bc_read(argv[1]); - bc_cont* ptr; - - for (ptr = bc; ptr->next != NULL; ptr = ptr->next) - { - if (ptr->op == 1) - { - printf("%x:\n", ptr->op); - } - if (ptr->op == 2) - { - printf("%x: %x\n", ptr->op, ptr->args[0][0]); - } - if (ptr->op == 3) - { - printf("%x: %x, %x %x\n", ptr->op, ptr->args[0][0], ptr->args[1][0], ptr->args[1][1]); - } - if (ptr->op == 4) - { - printf("%x: ", ptr->op); - int len = sizeof(ptr->args[0]); - for (int i = 0; i < len; i++) printf("%x ", ptr->args[0][i]); - printf("\n"); - } - } - - bc_cont_del(bc); - // end testing return 0; } diff --git a/src/vm/test b/src/vm/test Binary files differ diff --git a/src/vm/tests/bc/Makefile b/src/vm/tests/bc/Makefile @@ -0,0 +1,27 @@ +SRC_DIR = ../../src +INC_DIR = ../../inc + +CC = gcc +CFLAGS = -std=c99 -Wall -I$(INC_DIR) + +DEPS = i$(INC_DIR)/is_mdata.h \ + fh.h \ + is.h \ + bc.h \ + +OBJ = test.o \ + $(SRC_DIR)/fh.o \ + $(SRC_DIR)/is.o \ + $(SRC_DIR)/bc.o + +OUT = test + +%.o: %.c $(DEPS) + $(CC) $(CFLAGS) -c -o $@ $< + +$(OUT): $(OBJ) + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm $(SRC_DIR)/*.o + rm $(OUT) diff --git a/src/vm/tests/bc/bytecode b/src/vm/tests/bc/bytecode Binary files differ diff --git a/src/vm/tests/bc/test b/src/vm/tests/bc/test Binary files differ diff --git a/src/vm/tests/bc/test.c b/src/vm/tests/bc/test.c @@ -0,0 +1,42 @@ +#include <stdio.h> + +#include "fh.h" +#include "is.h" +#include "bc.h" + +int main(int argc, char** argv) +{ + if (argc < 2) return -1; + init(); + + // start testing + bc_cont* bc = bc_read(argv[1]); + bc_cont* ptr; + + for (ptr = bc; ptr->next != NULL; ptr = ptr->next) + { + if (ptr->op == 1) + { + printf("%x:\n", ptr->op); + } + if (ptr->op == 2) + { + printf("%x: %x\n", ptr->op, ptr->args[0][0]); + } + if (ptr->op == 3) + { + printf("%x: %x, %x %x\n", ptr->op, ptr->args[0][0], ptr->args[1][0], ptr->args[1][1]); + } + if (ptr->op == 4) + { + printf("%x: ", ptr->op); + int len = sizeof(ptr->args[0]); + for (int i = 0; i < len; i++) printf("%x ", ptr->args[0][i]); + printf("\n"); + } + } + + bc_cont_del(bc); + // end testing + return 0; +}