Skip to content

Commit

Permalink
Update mp2c
Browse files Browse the repository at this point in the history
  • Loading branch information
xupingmao committed Oct 6, 2020
1 parent d72c182 commit b3ed1b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ tinypy-1.1/
tm2c/output/
*.plist
*.bz2
/参考项目/
/参考项目/
/build/*.c
3 changes: 3 additions & 0 deletions mp2c/mp2c.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef TM2C_C
#define TM2C_C

#define LEVEL_ERROR 0
#define LOG(level, msg, lineno, value) /* x */

Object tm_call(Object func, int args, ...) {
int i = 0;
va_list ap;
Expand Down
11 changes: 7 additions & 4 deletions mp2c/mp2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tm_pusharg = "tm_pusharg("
tm_call = "tm_call("
tm_num = "tm_number("
tm_str = "string_const"
tm_str = "string_static"
tm_get_glo = "tm_get_global"
tm_define = "def_func"
def_native_method = "def_native_method"
Expand Down Expand Up @@ -323,8 +323,8 @@ def process(self, lines):
lines = define_lines + lines

head = "#define TM_NO_BIN 1\n"
head += '#include "../../src/vm.c"\n'
head += '#include "../../src/tm2c.c"\n'
head += '#include "../src/vm.c"\n'
head += '#include "../mp2c/mp2c.c"\n'
head += "#define S string_new\n"
head += "#define N tm_number\n"
head += "/* DEFINE START */\n"
Expand Down Expand Up @@ -973,6 +973,9 @@ def get_opt(options):

mod = name.split(".")[0]
code = mp2c(name, text, opt)
save("build/" + mod + ".c", code)

target_file = "build/" + mod + ".c"
save(target_file, code)
print("saved to", target_file)
# save("bin/" + mod + ".c", code)

0 comments on commit b3ed1b1

Please sign in to comment.