use the new API for bytecode objects

master
Daniel Kolesa 2015-12-19 16:06:11 +01:00
parent cc1cfe1328
commit 1812c06bf6
1 changed files with 5 additions and 13 deletions

18
main.cc
View File

@ -237,20 +237,12 @@ struct ObState: CsState {
struct Rule { struct Rule {
String target; String target;
Vector<String> deps; Vector<String> deps;
Uint32 *func; cscript::Bytecode func;
bool action; bool action;
Rule(): target(), deps(), func(nullptr), action(false) {} Rule(): target(), deps(), func(), action(false) {}
Rule(const Rule &r): target(r.target), deps(r.deps), func(r.func), Rule(const Rule &r): target(r.target), deps(r.deps), func(r.func),
action(r.action) { action(r.action) {}
cscript::bcode_ref(func);
}
~Rule() { cscript::bcode_unref(func); }
void set_func(Uint32 *c) {
func = c;
cscript::bcode_ref(func);
}
}; };
Vector<Rule> rules; Vector<Rule> rules;
@ -453,7 +445,7 @@ struct ObState: CsState {
Rule &r = rules.push(); Rule &r = rules.push();
r.target = target; r.target = target;
r.action = action; r.action = action;
r.set_func(body); r.func = body;
r.deps = cscript::util::list_explode(dep); r.deps = cscript::util::list_explode(dep);
} }
} }
@ -467,9 +459,9 @@ struct ObState: CsState {
if (!oldr) if (!oldr)
return; return;
Rule &r = rules.push(); Rule &r = rules.push();
r.set_func(oldr->func);
r.target = tgt; r.target = tgt;
r.action = oldr->action; r.action = oldr->action;
r.func = oldr->func;
r.deps = inherit_deps ? oldr->deps : cscript::util::list_explode(dep); r.deps = inherit_deps ? oldr->deps : cscript::util::list_explode(dep);
} }