diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-03-01 18:05:08 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-03-01 18:05:08 +0100 |
commit | 8a3ba59193b0487fdffa4dc05abd4487b1ebf7fb (patch) | |
tree | 6aaf53c01f103b3727501d4ca5b8cb3a48eed2e2 | |
parent | 029f4e66a157a01f094c20d11569f4876379bcfb (diff) |
Fix jump parsing bug (and better debug logging)
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | world.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
@@ -76,7 +76,7 @@ Argument parseArgument(const string &str,const unordered_map<string,Location> &l } Location ref=labels.find(str.substr(1))->second; assert(ref.bank==ip.bank); - return {arg_t::number,false,ref.bank-ip.bank,{}}; + return {arg_t::number,false,ref.pos-ip.pos,{}}; } else if(str[0]=='$'){ return {arg_t::constant,false,0,str.substr(1)}; } else if(isdigit(str[0])){ @@ -29,7 +29,7 @@ WorldAction Robot::tick(World &world){ } uint16_t* Robot::resolveVar(const Argument &arg,World &world){ - cout<<"resolveVar("<<(int)arg.type<<","<<arg.remote<<","<<arg.num<<","<<arg.name<<")"<<endl; + // cout<<"resolveVar("<<(int)arg.type<<","<<arg.remote<<","<<arg.num<<","<<arg.name<<")"<<endl; if(arg.remote){ assert(arg.type==arg_t::name); assert(arg.name=="active"); @@ -48,7 +48,7 @@ uint16_t* Robot::resolveVar(const Argument &arg,World &world){ Instruction Robot::resolve(World &world){ Instruction ins=banks.at(ip.bank).at(ip.pos); - cout<<"Resolving "<<ins<<endl; + cout<<this<<" Resolving "<<ins<<endl; vector<bool> dstvar(ins.args.size(),false); if(ins.op==ins_t::set||ins.op==ins_t::add||ins.op==ins_t::sub||ins.op==ins_t::scan){ assert(dstvar.size()>0); @@ -112,7 +112,7 @@ int Robot::calcDuration(Instruction &ins){ } WorldAction Robot::execute(Instruction &ins,World &world){ - cout<<"Executing "<<ins<<endl; + cout<<this<<" Executing "<<ins<<endl; WorldAction action=WorldAction::none; switch(ins.op){ case ins_t::set:{ |