Mercurial > hg > Members > shinya > pyrect
changeset 104:f228eb779162
modify CbC-grep. avoid optimize (call->jmp) in matcher.
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Dec 2010 11:07:30 +0900 |
parents | abe36c207b23 |
children | 14faa199c3bf |
files | pyrect/translator/cbc_grep_translator.py |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/translator/cbc_grep_translator.py Tue Dec 14 04:09:46 2010 +0900 +++ b/pyrect/translator/cbc_grep_translator.py Tue Dec 14 11:07:30 2010 +0900 @@ -56,10 +56,11 @@ self.emit("typedef unsigned char *UCHARP;") self.emiti("typedef struct env_ {") self.emit( "void (*ret)();") + self.emit( "int count;") self.demit("} ENV;") self.emit("typedef ENV *ENVP;", 2) - self.emit("void matcher(UCHARP beg, UCHARP buf, UCHARP end);") + self.emit("int matcher(UCHARP beg, UCHARP buf, UCHARP end);") self.emit('__code entry(%s);' % self.interface, 2) self.emit('__code accept(%s);' % self.interface) @@ -221,16 +222,17 @@ self.demit("}", 2) def emit_driver(self): - self.emiti("void matcher(UCHARP beg, UCHARP buf, UCHARP end) {") + self.emiti("int matcher(UCHARP beg, UCHARP buf, UCHARP end) {") self.emit( "__label__ _return;") self.emiti( "void __return() {") self.emit( "goto _return;") self.demit( "}") - self.emit( "ENVP envp = malloc(sizeof(ENV));") - self.emit( "envp->ret = __return;") - self.emit( "goto entry(%s);" % self.args) + self.emit( "ENV env;") + self.emit( "env.ret = __return;") + self.emit( "env.count = 0;") + self.emit( "goto entry(beg, buf, end, &env);") self.demiti("_return:") - self.emit( "return;") + self.emit( "return env.count;") self.demit("}", 2) self.emiti("__code entry(%s) {" % self.interface)