Skip to content

Commit

Permalink
Purged away all assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed May 27, 2010
1 parent dedcb6f commit 16ccc6f
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 121 deletions.
10 changes: 5 additions & 5 deletions abc_codesynt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void method_info::abstract_value(llvm::ExecutionEngine* ex, llvm::IRBuilder<>& b
e.first=builder.CreateCall(ex->FindFunctionNamed("abstract_b"),e.first);
break;
default:
assert("Unexpected object type to abstract"&& false);
throw RunTimeException("Unexpected object type to abstract");
}

}
Expand Down Expand Up @@ -563,7 +563,7 @@ inline void method_info::syncLocals(llvm::ExecutionEngine* ex,llvm::IRBuilder<>&
builder.CreateStore(v,t);
}
else
assert("Unexpected object type" && false);
throw RunTimeException("Unexpected object type");
}
}
}
Expand Down Expand Up @@ -1464,7 +1464,7 @@ void method_info::doAnalysis(std::map<unsigned int,block_info>& blocks, llvm::IR
cur.locals_start_obj[i]=Builder.CreateAlloca(bool_type);
break;
default:
assert("Unsupported object type" && false);
throw RunTimeException("Unsupported object type");
}
}
}
Expand Down Expand Up @@ -3183,7 +3183,7 @@ SyntheticFunction::synt_function method_info::synt_method()
LOG(LOG_TRACE, "synt astypelate" );
stack_entry v1=static_stack_pop(Builder,static_stack,dynamic_stack,dynamic_stack_index);
stack_entry v2=static_stack_pop(Builder,static_stack,dynamic_stack,dynamic_stack_index);
assert(v1.second==STACK_OBJECT && v2.second==STACK_OBJECT);
assert_and_throw(v1.second==STACK_OBJECT && v2.second==STACK_OBJECT);
value=Builder.CreateCall2(ex->FindFunctionNamed("asTypelate"),v1.first,v2.first);
static_stack_push(static_stack,stack_entry(value,STACK_OBJECT));
break;
Expand Down Expand Up @@ -3750,7 +3750,7 @@ SyntheticFunction::synt_function method_info::synt_method()
LOG(LOG_TRACE, "synt istypelate" );
stack_entry v1=static_stack_pop(Builder,static_stack,dynamic_stack,dynamic_stack_index);
stack_entry v2=static_stack_pop(Builder,static_stack,dynamic_stack,dynamic_stack_index);
assert(v1.second==STACK_OBJECT && v2.second==STACK_OBJECT);
assert_and_throw(v1.second==STACK_OBJECT && v2.second==STACK_OBJECT);
value=Builder.CreateCall2(ex->FindFunctionNamed("isTypelate"),v1.first,v2.first);
static_stack_push(static_stack,stack_entry(value,STACK_BOOLEAN));
break;
Expand Down
12 changes: 6 additions & 6 deletions abc_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
//kill
u30 t;
code >> t;
assert(context->locals[t]);
assert_and_throw(context->locals[t]);
context->locals[t]->decRef();
context->locals[t]=new Undefined;
break;
Expand Down Expand Up @@ -405,7 +405,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
}

ASObject* index_obj=context->runtime_stack_pop();
assert(index_obj->getObjectType()==T_INTEGER);
assert_and_throw(index_obj->getObjectType()==T_INTEGER);
unsigned int index=index_obj->toUInt();

int dest=defaultdest;
Expand Down Expand Up @@ -756,7 +756,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
//getlocal
u30 i;
code >> i;
assert(context->locals[i]);
assert_and_throw(context->locals[i]);
context->locals[i]->incRef();
LOG(LOG_CALLS, "getLocal " << i << ": " << context->locals[i]->toString(true) );
context->runtime_stack_push(context->locals[i]);
Expand All @@ -769,7 +769,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
code >> i;
LOG(LOG_CALLS, "setLocal " << i );
ASObject* obj=context->runtime_stack_pop();
assert(obj);
assert_and_throw(obj);
if(context->locals[i])
context->locals[i]->decRef();
context->locals[i]=obj;
Expand Down Expand Up @@ -1181,7 +1181,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
{
//getlocal_n
int i=opcode&3;
assert(context->locals[i]);
assert_and_throw(context->locals[i]);
LOG(LOG_CALLS, "getLocal " << i << ": " << context->locals[i]->toString(true) );
context->locals[i]->incRef();
context->runtime_stack_push(context->locals[i]);
Expand All @@ -1198,7 +1198,7 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
ASObject* obj=context->runtime_stack_pop();
if(context->locals[i])
context->locals[i]->decRef();
assert(obj);
assert_and_throw(obj);
context->locals[i]=obj;
break;
}
Expand Down
66 changes: 33 additions & 33 deletions abc_opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void ABCVm::callProperty(call_context* th, int n, int m)

if(o.obj)
{
assert(o.obj->getObjectType()==T_FUNCTION);
assert_and_throw(o.obj->getObjectType()==T_FUNCTION);

IFunction* f=static_cast<IFunction*>(o.obj);

Expand Down Expand Up @@ -323,7 +323,7 @@ void ABCVm::callProperty(call_context* th, int n, int m)
LOG(LOG_CALLS,"We got a function not yet valid");
Definable* d=static_cast<Definable*>(o.obj);
d->define(obj);
assert(obj==getGlobal());
assert_and_throw(obj==getGlobal());
o=obj->getVariableByMultiname(*name);
}

Expand All @@ -339,8 +339,8 @@ void ABCVm::callProperty(call_context* th, int n, int m)
if(name->ns.size()==1 && name->ns[0].name==flash_proxy)
{
Proxy* p=dynamic_cast<Proxy*>(obj);
assert(p);
assert(p->implEnable);
assert_and_throw(p);
assert_and_throw(p->implEnable);
p->implEnable=false;
ret=f->call(obj,args,m,o.level);
p->implEnable=true;
Expand Down Expand Up @@ -640,7 +640,7 @@ void ABCVm::construct(call_context* th, int m)
else if(obj->getObjectType()==T_FUNCTION)
{
SyntheticFunction* sf=dynamic_cast<SyntheticFunction*>(obj);
assert(sf);
assert_and_throw(sf);
ret=Class<ASObject>::getInstanceS();
if(sf->mi->body)
{
Expand All @@ -650,7 +650,7 @@ void ABCVm::construct(call_context* th, int m)
th->context->buildTrait(ret,&sf->mi->body->traits[i],false);
ret->initialized=true;
ret->incRef();
assert(sf->closure_this==NULL);
assert_and_throw(sf->closure_this==NULL);
ASObject* ret2=sf->call(ret,args,m,0);
if(ret2)
ret2->decRef();
Expand Down Expand Up @@ -698,7 +698,7 @@ void ABCVm::constructGenericType(call_context* th, int m)

LOG(LOG_CALLS,"Constructing");
Class_base* o_class=static_cast<Class_base*>(obj);
assert(o_class->getObjectType()==T_CLASS);
assert_and_throw(o_class->getObjectType()==T_CLASS);
ASObject* ret=o_class->getInstance(true,args,m);

obj->decRef();
Expand Down Expand Up @@ -762,7 +762,7 @@ void ABCVm::callPropVoid(call_context* th, int n, int m)

if(o.obj)
{
assert(o.obj->getObjectType()==T_FUNCTION);
assert_and_throw(o.obj->getObjectType()==T_FUNCTION);

IFunction* f=static_cast<IFunction*>(o.obj);

Expand Down Expand Up @@ -811,8 +811,8 @@ void ABCVm::callPropVoid(call_context* th, int n, int m)
if(name->ns.size()==1 && name->ns[0].name==flash_proxy)
{
Proxy* p=dynamic_cast<Proxy*>(obj);
assert(p);
assert(p->implEnable);
assert_and_throw(p);
assert_and_throw(p->implEnable);
p->implEnable=false;
ret=f->call(obj,args,m,o.level);
p->implEnable=true;
Expand Down Expand Up @@ -884,7 +884,7 @@ number_t ABCVm::subtract_oi(ASObject* val2, intptr_t val1)

number_t ABCVm::subtract_do(number_t val2, ASObject* val1)
{
assert(val1->getObjectType()!=T_UNDEFINED);
assert_and_throw(val1->getObjectType()!=T_UNDEFINED);
number_t num2=val2;
number_t num1=val1->toNumber();

Expand Down Expand Up @@ -1268,7 +1268,7 @@ void ABCVm::setSuper(call_context* th, int n)
//And the reset it using the stack
thisAndLevel tl=getVm()->getCurObjAndLevel();
//What if using [sg]etSuper not on this??
assert(tl.cur_this==obj);
assert_and_throw(tl.cur_this==obj);
tl.cur_this->setLevel(tl.cur_level);

obj->decRef();
Expand All @@ -1283,7 +1283,7 @@ void ABCVm::getSuper(call_context* th, int n)

thisAndLevel tl=getVm()->getCurObjAndLevel();
//What if using [sg]etSuper not on this??
assert(tl.cur_this==obj);
assert_and_throw(tl.cur_this==obj);

//We modify the cur_level of obj
obj->decLevel();
Expand All @@ -1293,7 +1293,7 @@ void ABCVm::getSuper(call_context* th, int n)

tl=getVm()->getCurObjAndLevel();
//What if using [sg]etSuper not on this??
assert(tl.cur_this==obj);
assert_and_throw(tl.cur_this==obj);
//And the reset it using the stack
tl.cur_this->setLevel(tl.cur_level);

Expand All @@ -1304,7 +1304,7 @@ void ABCVm::getSuper(call_context* th, int n)
LOG(LOG_CALLS,"We got an object not yet valid");
Definable* d=static_cast<Definable*>(o);
d->define(obj);
assert(obj==getGlobal());
assert_and_throw(obj==getGlobal());
o=obj->getVariableByMultiname(*name).obj;
}
o->incRef();
Expand Down Expand Up @@ -1352,7 +1352,7 @@ void ABCVm::getLex(call_context* th, int n)
LOG(LOG_CALLS,"Deferred definition of property " << *name);
Definable* d=static_cast<Definable*>(o);
d->define(*it);
assert(*it==getGlobal());
assert_and_throw(*it==getGlobal());
o=(*it)->getVariableByMultiname(*name).obj;
LOG(LOG_CALLS,"End of deferred definition of property " << *name);
}
Expand Down Expand Up @@ -1398,12 +1398,12 @@ void ABCVm::constructSuper(call_context* th, int m)

ASObject* obj=th->runtime_stack_pop();

assert(obj->getLevel()!=0);
assert_and_throw(obj->getLevel()!=0);

thisAndLevel tl=getVm()->getCurObjAndLevel();
//Check that current 'this' is the object
assert(tl.cur_this==obj);
assert(tl.cur_level==obj->getLevel());
assert_and_throw(tl.cur_this==obj);
assert_and_throw(tl.cur_level==obj->getLevel());

LOG(LOG_CALLS,"Cur prototype name " << obj->getActualPrototype()->class_name);
//Change current level
Expand Down Expand Up @@ -1450,7 +1450,7 @@ ASObject* ABCVm::findProperty(call_context* th, int n)
ret=getGlobal();
}

assert(ret);
assert_and_throw(ret);
ret->incRef();
return ret;
}
Expand Down Expand Up @@ -1492,7 +1492,7 @@ ASObject* ABCVm::findPropStrict(call_context* th, int n)
}
}

assert(ret);
assert_and_throw(ret);
ret->incRef();
return ret;
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ void ABCVm::callSuper(call_context* th, int n, int m)
//And the reset it using the stack
thisAndLevel tl=getVm()->getCurObjAndLevel();
//What if using [sg]etSuper not on this??
assert(tl.cur_this==obj);
assert_and_throw(tl.cur_this==obj);
tl.cur_this->setLevel(tl.cur_level);

if(o.obj)
Expand Down Expand Up @@ -1653,7 +1653,7 @@ void ABCVm::callSuperVoid(call_context* th, int n, int m)
//And the reset it using the stack
thisAndLevel tl=getVm()->getCurObjAndLevel();
//What if using [sg]etSuper not on this??
assert(tl.cur_this==obj);
assert_and_throw(tl.cur_this==obj);
tl.cur_this->setLevel(tl.cur_level);

if(o.obj)
Expand Down Expand Up @@ -1716,14 +1716,14 @@ bool ABCVm::isTypelate(ASObject* type, ASObject* obj)
Class_base* c=NULL;
if(obj->prototype)
{
assert(type->getObjectType()==T_CLASS);
assert_and_throw(type->getObjectType()==T_CLASS);
c=static_cast<Class_base*>(type);

objc=obj->prototype;
}
else if(obj->getObjectType()==T_CLASS)
{
assert(type->getObjectType()==T_CLASS);
assert_and_throw(type->getObjectType()==T_CLASS);
c=static_cast<Class_base*>(type);

//Special case for Class
Expand Down Expand Up @@ -1767,9 +1767,9 @@ bool ABCVm::isTypelate(ASObject* type, ASObject* obj)
ASObject* ABCVm::asTypelate(ASObject* type, ASObject* obj)
{
LOG(LOG_CALLS,"asTypelate");
assert(obj->getObjectType()!=T_FUNCTION);
assert_and_throw(obj->getObjectType()!=T_FUNCTION);

assert(type->getObjectType()==T_CLASS);
assert_and_throw(type->getObjectType()==T_CLASS);
Class_base* c=static_cast<Class_base*>(type);

Class_base* objc;
Expand Down Expand Up @@ -1904,7 +1904,7 @@ void ABCVm::constructProp(call_context* th, int n, int m)
else if(o->getObjectType()==T_FUNCTION)
{
SyntheticFunction* sf=dynamic_cast<SyntheticFunction*>(o);
assert(sf);
assert_and_throw(sf);
ret=Class<ASObject>::getInstanceS();
if(sf->mi->body)
{
Expand All @@ -1914,7 +1914,7 @@ void ABCVm::constructProp(call_context* th, int n, int m)
th->context->buildTrait(ret,&sf->mi->body->traits[i],false);
ret->initialized=true;
ret->incRef();
assert(sf->closure_this==NULL);
assert_and_throw(sf->closure_this==NULL);
ASObject* ret2=sf->call(ret,args,m,0);
if(ret2)
ret2->decRef();
Expand Down Expand Up @@ -2086,13 +2086,13 @@ void ABCVm::newClass(call_context* th, int n)
LOG(LOG_CALLS, "newClass " << n );
method_info* constructor=&th->context->methods[th->context->instances[n].init];
int name_index=th->context->instances[n].name;
assert(name_index);
assert_and_throw(name_index);
const multiname* mname=th->context->getMultiname(name_index,NULL);

Class_base* ret=new Class_inherit(mname->name_s);
ASObject* tmp=th->runtime_stack_pop();

assert(th->context);
assert_and_throw(th->context);
ret->context=th->context;

//Null is a "valid" base class
Expand Down Expand Up @@ -2147,15 +2147,15 @@ void ABCVm::newClass(call_context* th, int n)
d->define(getGlobal());
LOG(LOG_CALLS,"End of deferred init of class " << *name);
obj=getGlobal()->getVariableByMultiname(*name).obj;
assert(obj);
assert_and_throw(obj);
}
}

LOG(LOG_CALLS,"Calling Class init " << ret);
ret->incRef();
//Class init functions are called with global as this
ASObject* ret2=cinit->call(ret,NULL,0,ret->max_level);
assert(ret2==NULL);
assert_and_throw(ret2==NULL);
LOG(LOG_CALLS,"End of Class init " << ret);
th->runtime_stack_push(ret);
cinit->decRef();
Expand Down
8 changes: 4 additions & 4 deletions flashevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ASFUNCTIONBODY(Event,_constructor)
Event* th=static_cast<Event*>(obj);
if(argslen>=1)
{
assert(args[0]->getObjectType()==T_STRING);
assert_and_throw(args[0]->getObjectType()==T_STRING);
th->type=args[0]->toString();
}
return NULL;
Expand Down Expand Up @@ -268,7 +268,7 @@ ASFUNCTIONBODY(EventDispatcher,addEventListener)
ASFUNCTIONBODY(EventDispatcher,_hasEventListener)
{
EventDispatcher* th=static_cast<EventDispatcher*>(obj);
assert(argslen==1 && args[0]->getObjectType()==T_STRING);
assert_and_throw(argslen==1 && args[0]->getObjectType()==T_STRING);
const tiny_string& eventName=args[0]->toString();
bool ret=th->hasEventListener(eventName);
return abstract_b(ret);
Expand Down Expand Up @@ -312,7 +312,7 @@ ASFUNCTIONBODY(EventDispatcher,dispatchEvent)
return abstract_b(false);
//CHECK: maybe is to be cloned
e->incRef();
assert(e->type!="");
assert_and_throw(e->type!="");
th->handleEvent(e);
return abstract_b(true);
}
Expand Down Expand Up @@ -348,7 +348,7 @@ void EventDispatcher::handleEvent(Event* e)
//If the f is a class method, both the 'this' and level are ignored
ASObject* const arg0=e;
ASObject* ret=tmpListener[i].f->call(this,&arg0,1,0);
assert(ret==NULL);
assert_and_throw(ret==NULL);
//And now no more, f can also be deleted
tmpListener[i].f->decRef();
}
Expand Down
Loading

0 comments on commit 16ccc6f

Please sign in to comment.