Skip to content

Commit

Permalink
Really implement NaNs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed Feb 12, 2010
1 parent 58bab15 commit 13ec5ba
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
25 changes: 17 additions & 8 deletions abc.cpp
Expand Up @@ -31,6 +31,7 @@
#include "logger.h"
#include "swftypes.h"
#include <sstream>
#include <limits>
#include "swf.h"
#include "flashevents.h"
#include "flashdisplay.h"
Expand Down Expand Up @@ -1392,12 +1393,13 @@ void ABCContext::linkTrait(ASObject* obj, const traits_info* t)
LOG(LOG_CALLS,"Getter trait: " << ns << "::" << name);
method_info* m=&methods[t->method];
assert(m->body==0);
int level=obj->max_level;
int level=obj->max_level+1;
obj_var* var=NULL;

do
{
obj_var* var=obj->Variables.findObjVar(name,"",level,false,true);
level--;
var=obj->Variables.findObjVar(name,"",level,false,true);
}
while(var!=NULL && var->getter==NULL);

Expand All @@ -1422,12 +1424,13 @@ void ABCContext::linkTrait(ASObject* obj, const traits_info* t)
LOG(LOG_CALLS,"Setter trait: " << ns << "::" << name << " #" << t->method);
method_info* m=&methods[t->method];
assert(m->body==0);
int level=obj->max_level;
int level=obj->max_level+1;
obj_var* var=NULL;

do
{
obj_var* var=obj->Variables.findObjVar(name,"",level,false,true);
level--;
var=obj->Variables.findObjVar(name,"",level,false,true);
}
while(var!=NULL && var->setter==NULL);

Expand Down Expand Up @@ -1683,8 +1686,7 @@ void ABCContext::buildTrait(ASObject* obj, const traits_info* t, IFunction* defe
if(type->name_s=="int" || type->name_s=="uint" )
ret=abstract_i(0);
else if(type->name_s=="Number")
//Should be NaN
ret=abstract_d(0);
ret=abstract_d(numeric_limits<double>::quiet_NaN());
else
ret=new Undefined;
}
Expand Down Expand Up @@ -2135,10 +2137,12 @@ ASFUNCTIONBODY(lightspark,parseFloat)
return new Undefined;
else
{
return new Integer(atof(args->at(0)->toString().raw_buf()));
return new Number(atof(args->at(0)->toString().raw_buf()));
}
}


//DEPRECATED: use convert_i
intptr_t ABCVm::s_toInt(ASObject* o)
{
if(o->getObjectType()!=T_INTEGER)
Expand All @@ -2155,7 +2159,12 @@ ASFUNCTIONBODY(lightspark,isNaN)
else if(args->at(0)->getObjectType()==T_INTEGER)
return abstract_b(false);
else if(args->at(0)->getObjectType()==T_NUMBER)
return abstract_b(false);
{
if(isnan(args->at(0)->toNumber()))
return abstract_b(true);
else
return abstract_b(false);
}
else
abort();
}
Expand Down
15 changes: 9 additions & 6 deletions abc_opcodes.cpp
Expand Up @@ -18,7 +18,7 @@
**************************************************************************/

#include "abc.h"
#include <typeinfo>
#include <limits>
#include "class.h"

using namespace std;
Expand Down Expand Up @@ -71,9 +71,14 @@ void ABCVm::setProperty_i(intptr_t value,ASObject* obj,multiname* name)
number_t ABCVm::convert_d(ASObject* o)
{
LOG(LOG_CALLS, "convert_d" );
number_t ret=o->toNumber();
o->decRef();
return ret;
if(o->getObjectType()!=T_UNDEFINED)
{
number_t ret=o->toNumber();
o->decRef();
return ret;
}
else
return numeric_limits<double>::quiet_NaN();
}

bool ABCVm::convert_b(ASObject* o)
Expand Down Expand Up @@ -1293,8 +1298,6 @@ void ABCVm::getLex(call_context* th, int n)
else
{
LOG(LOG_NOT_IMPLEMENTED,"NOT found " << name->name_s<< ", pushing Undefined");
if(name->name_s=="SpriteAsset")
__asm__("int $3");
th->runtime_stack_push(new Undefined);
}
}
Expand Down
2 changes: 1 addition & 1 deletion asobjects.cpp
Expand Up @@ -989,7 +989,7 @@ ASObject* SyntheticFunction::fast_call(ASObject* obj, ASObject** args, int numAr
val=mi->synt_method();
}

assert(mi->needsArgs()==false)
assert(mi->needsArgs()==false);

int args_len=mi->numArgs();
int passedToLocals=min(numArgs,args_len);
Expand Down
9 changes: 8 additions & 1 deletion swftypes.cpp
Expand Up @@ -721,7 +721,14 @@ objAndLevel ASObject::getVariableByMultiname(const multiname& name)
if(obj->getter)
{
//Call the getter
LOG(LOG_CALLS,"Calling the getter");
if(prototype)
{
LOG(LOG_CALLS,"Calling the getter on type " << prototype->class_name);
}
else
{
LOG(LOG_CALLS,"Calling the getter");
}
ASObject* ret=obj->getter->call(this,NULL,level);
LOG(LOG_CALLS,"End of getter");
assert(ret);
Expand Down
2 changes: 1 addition & 1 deletion test2.mxml
Expand Up @@ -3,5 +3,5 @@
xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="middle">

<mx:VBox x="0" y="0" width="100" height="200" backgroundColor="0x0080C0" alpha="0.8"/>
<mx:VBox x="0" y="0" width="200" height="200" backgroundColor="0x0080C0" alpha="0.8"/>
</mx:Application>

0 comments on commit 13ec5ba

Please sign in to comment.