Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tesi

  • Loading branch information...
commit f9eb8e6b9c8655223e0b4b93bdc1d3301fc837d9 1 parent 2f420bf
@alexp-sssup alexp-sssup authored
View
4 Makefile
@@ -1,6 +1,6 @@
# User-overridable flags:
-CXXFLAGS = -g -O0 -D_GLIBCXX_NO_DEBUG -fpermissive -Wnon-virtual-dtor
-#CXXFLAGS = -O3 -DNDEBUG -fpermissive -Wnon-virtual-dtor
+#CXXFLAGS = -g -O0 -D_GLIBCXX_NO_DEBUG -fpermissive -Wnon-virtual-dtor
+CXXFLAGS = -O3 -DNDEBUG -fpermissive -Wnon-virtual-dtor
LLVMLIBS = `llvm-config --libfiles engine`
prefix = /usr
bindir = $(prefix)/bin
View
4 abc.cpp
@@ -563,6 +563,7 @@ multiname* ABCContext::getMultiname(unsigned int n, call_context* th)
ret->nskind.push_back(n->kind);
ret->name_s=getString(m->name);
ret->name_type=multiname::NAME_STRING;
+ ret->name_s.len();
break;
}
case 0x09:
@@ -581,6 +582,7 @@ multiname* ABCContext::getMultiname(unsigned int n, call_context* th)
ret->name_s=getString(m->name);
ret->name_type=multiname::NAME_STRING;
+ ret->name_s.len();
break;
}
case 0x1b:
@@ -601,6 +603,7 @@ multiname* ABCContext::getMultiname(unsigned int n, call_context* th)
ret->name_s=n->toString();
ret->name_type=multiname::NAME_STRING;
n->decRef();
+ ret->name_s.len();
break;
}
/* case 0x0d:
@@ -676,6 +679,7 @@ multiname* ABCContext::getMultiname(unsigned int n, call_context* th)
LOG(ERROR,"Multiname to String not yet implemented for this kind " << hex << m->kind);
break;
}
+ ret->name_s.len();
return ret;
}
}
View
6 asobjects.cpp
@@ -1068,14 +1068,16 @@ ASFUNCTIONBODY(Math,max)
ASFUNCTIONBODY(Math,cos)
{
+ //Angle is in radians
double n=args->at(0)->toNumber();
- return abstract_d(::cos(n*M_PI/180));
+ return abstract_d(::cos(n));
}
ASFUNCTIONBODY(Math,sin)
{
+ //Angle is in radians
double n=args->at(0)->toNumber();
- return abstract_d(::sin(n*M_PI/180));
+ return abstract_d(::sin(n));
}
ASFUNCTIONBODY(Math,abs)
View
2  logger.h
@@ -6,7 +6,7 @@
enum LOG_LEVEL { NO_INFO=0, ERROR=1, NOT_IMPLEMENTED=2,CALLS=3,TRACE=4};
-#if 1
+#if 0
#define LOG(level,esp) \
{ \
if(level<=Log::getLevel()) \
View
84 swftypes.h
@@ -55,42 +55,94 @@ class tiny_string
{
friend std::ostream& operator<<(std::ostream& s, const tiny_string& r);
private:
- #define SIZE 1024
- char buf[SIZE];
+ #define SIZE 256
+ char _buf_static[SIZE];
+ char* buf;
+ bool isStatic;
public:
- tiny_string(){buf[0]=0;}
- tiny_string(const char* s)
+ tiny_string():buf(_buf_static),isStatic(true){buf[0]=0;}
+ tiny_string(const char* s):buf(_buf_static),isStatic(true)
{
if(strlen(s)>(SIZE-1))
- abort();
+ {
+ isStatic=false;
+ buf=new char[4096];
+ }
+ assert(strlen(s)<=4096);
strcpy(buf,s);
}
- explicit tiny_string(intptr_t i)
+ tiny_string(const tiny_string& r):isStatic(true),buf(_buf_static)
+ {
+ if(strlen(r.buf)>(SIZE-1))
+ {
+ isStatic=false;
+ buf=new char[4096];
+ abort();
+ }
+ assert(strlen(r.buf)<=4096);
+ strcpy(buf,r.buf);
+ }
+ ~tiny_string()
+ {
+ if(isStatic==false)
+ delete[] buf;
+ }
+ explicit tiny_string(intptr_t i):isStatic(true),buf(_buf_static)
{
sprintf(buf,"%i",i);
}
- explicit tiny_string(number_t d)
+ explicit tiny_string(number_t d):isStatic(true),buf(_buf_static)
{
sprintf(buf,"%g",d);
}
+ tiny_string& operator=(const tiny_string& s)
+ {
+ if(s.len()>(SIZE-1))
+ {
+ isStatic=false;
+ assert(s.len()<=4096);
+ buf=new char[4096];
+ }
+ //Lenght is already checked
+ strcpy(buf,s.buf);
+ return *this;
+ }
tiny_string& operator=(const std::string& s)
{
- strncpy(buf,s.c_str(),SIZE);
+ if(s.size()>(SIZE-1))
+ {
+ isStatic=false;
+ assert(s.size()<=4096);
+ buf=new char[4096];
+ }
+ //Lenght is already checked
+ strcpy(buf,s.c_str());
return *this;
}
tiny_string& operator=(const char* s)
{
- strncpy(buf,s,SIZE);
+ if(strlen(s)>(SIZE-1))
+ {
+ isStatic=false;
+ assert(strlen(s)<=4096);
+ buf=new char[4096];
+ }
+ //Lenght is already checked
+ strcpy(buf,s);
return *this;
}
tiny_string& operator+=(const char* s)
{
- strncat(buf,s,SIZE-1-strlen(buf));
+ int newlen=strlen(buf)+strlen(s)+1;
+ assert(newlen<SIZE);
+ strcat(buf,s);
return *this;
}
tiny_string& operator+=(const tiny_string& r)
{
- strncat(buf,r.buf,SIZE-1-strlen(buf));
+ int newlen=strlen(buf)+strlen(r.buf)+1;
+ assert(newlen<SIZE);
+ strcat(buf,r.buf);
return *this;
}
const tiny_string operator+(const tiny_string& r)
@@ -101,23 +153,23 @@ friend std::ostream& operator<<(std::ostream& s, const tiny_string& r);
}
bool operator<(const tiny_string& r) const
{
- return strncmp(buf,r.buf,SIZE)<0;
+ return strcmp(buf,r.buf)<0;
}
bool operator==(const tiny_string& r) const
{
- return strncmp(buf,r.buf,SIZE)==0;
+ return strcmp(buf,r.buf)==0;
}
bool operator!=(const tiny_string& r) const
{
- return strncmp(buf,r.buf,SIZE)!=0;
+ return strcmp(buf,r.buf)!=0;
}
bool operator==(const char* r) const
{
- return strncmp(buf,r,SIZE)==0;
+ return strcmp(buf,r)==0;
}
bool operator!=(const char* r) const
{
- return strncmp(buf,r,SIZE)!=0;
+ return strcmp(buf,r)!=0;
}
const char* raw_buf() const
{
View
2  tightspark.cpp
@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
rl.rlim_max=rl.rlim_cur;
//setrlimit(RLIMIT_AS,&rl);
- Log::initLogging(NOT_IMPLEMENTED);
+ Log::initLogging(NO_INFO);
sys=new SystemState;
sys->fps_prof=new fps_profiling();
Please sign in to comment.
Something went wrong with that request. Please try again.