Update to latest angelscript

This commit is contained in:
Marianne Gagnon
2015-05-11 19:40:43 -04:00
parent f269b44208
commit c48037984d
71 changed files with 11405 additions and 6307 deletions

View File

@@ -1,6 +1,6 @@
/*
AngelCode Scripting Library
Copyright (c) 2003-2013 Andreas Jonsson
Copyright (c) 2003-2015 Andreas Jonsson
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@@ -864,7 +864,6 @@ void asCByteCode::OptimizeLocally(const asCArray<int> &tempVariableOffsets)
instr = GoForward(curr);
}
}
else if( currOp == asBC_RDSPtr )
{
@@ -1553,6 +1552,7 @@ int asCByteCode::GetSize()
void asCByteCode::AddCode(asCByteCode *bc)
{
if( bc == this ) return;
if( bc->first )
{
if( first == 0 )
@@ -2037,7 +2037,14 @@ void asCByteCode::PostProcess()
DeleteInstruction(curr);
}
else
{
#ifndef AS_DEBUG
// If the stackSize is negative, then there is a problem with the bytecode.
// If AS_DEBUG is turned on, this same check is done in DebugOutput.
asASSERT( instr->stackSize >= 0 || asBCInfo[instr->op].type == asBCTYPE_INFO );
#endif
instr = instr->next;
}
}
}
@@ -2079,7 +2086,9 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
fprintf(file, "Variables: \n");
for( n = 0; n < func->scriptData->variables.GetLength(); n++ )
{
fprintf(file, " %.3d: %s %s\n", func->scriptData->variables[n]->stackOffset, func->scriptData->variables[n]->type.Format().AddressOf(), func->scriptData->variables[n]->name.AddressOf());
int idx = func->scriptData->objVariablePos.IndexOf(func->scriptData->variables[n]->stackOffset);
bool isOnHeap = asUINT(idx) < func->scriptData->objVariablesOnHeap ? true : false;
fprintf(file, " %.3d: %s%s %s\n", func->scriptData->variables[n]->stackOffset, isOnHeap ? "(heap) " : "", func->scriptData->variables[n]->type.Format(func->nameSpace).AddressOf(), func->scriptData->variables[n]->name.AddressOf());
}
asUINT offset = 0;
if( func->objectType )
@@ -2099,7 +2108,11 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
}
}
if( !found )
fprintf(file, " %.3d: %s {noname param}\n", offset, func->parameterTypes[n].Format().AddressOf());
{
int idx = func->scriptData->objVariablePos.IndexOf(offset);
bool isOnHeap = asUINT(idx) < func->scriptData->objVariablesOnHeap ? true : false;
fprintf(file, " %.3d: %s%s {noname param}\n", offset, isOnHeap ? "(heap) " : "", func->parameterTypes[n].Format(func->nameSpace).AddressOf());
}
offset -= func->parameterTypes[n].GetSizeOnStackDWords();
}
@@ -2115,10 +2128,20 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
}
}
if( !found )
fprintf(file, " %.3d: %s {noname}\n", func->scriptData->objVariablePos[n], func->scriptData->objVariableTypes[n]->name.AddressOf());
{
if( func->scriptData->objVariableTypes[n] )
{
int idx = func->scriptData->objVariablePos.IndexOf(func->scriptData->objVariablePos[n]);
bool isOnHeap = asUINT(idx) < func->scriptData->objVariablesOnHeap ? true : false;
fprintf(file, " %.3d: %s%s {noname}\n", func->scriptData->objVariablePos[n], isOnHeap ? "(heap) " : "", func->scriptData->objVariableTypes[n]->name.AddressOf());
}
else
fprintf(file, " %.3d: null handle {noname}\n", func->scriptData->objVariablePos[n]);
}
}
fprintf(file, "\n\n");
bool invalidStackSize = false;
int pos = 0;
asUINT lineIndex = 0;
asCByteInstruction *instr = first;
@@ -2131,10 +2154,19 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
lineIndex += 2;
}
fprintf(file, "%5d ", pos);
pos += instr->GetSize();
if( instr->GetSize() > 0 )
{
fprintf(file, "%5d ", pos);
pos += instr->GetSize();
fprintf(file, "%3d %c ", int(instr->stackSize + func->scriptData->variableSpace), instr->marked ? '*' : ' ');
fprintf(file, "%3d %c ", int(instr->stackSize + func->scriptData->variableSpace), instr->marked ? '*' : ' ');
if( instr->stackSize < 0 )
invalidStackSize = true;
}
else
{
fprintf(file, " ");
}
switch( asBCInfo[instr->op].type )
{
@@ -2182,7 +2214,10 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
switch( instr->op )
{
case asBC_OBJTYPE:
fprintf(file, " %-8s 0x%x\n", asBCInfo[instr->op].name, (asUINT)*ARG_DW(instr->arg));
{
asCObjectType *ot = *(asCObjectType**)ARG_DW(instr->arg);
fprintf(file, " %-8s 0x%x (type:%s)\n", asBCInfo[instr->op].name, (asUINT)*ARG_DW(instr->arg), ot->GetName());
}
break;
case asBC_PshC4:
@@ -2229,6 +2264,16 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
break;
case asBCTYPE_QW_ARG:
switch( instr->op )
{
case asBC_OBJTYPE:
{
asCObjectType *ot = *(asCObjectType**)ARG_DW(instr->arg);
fprintf(file, " %-8s 0x%x (type:%s)\n", asBCInfo[instr->op].name, (asUINT)*ARG_QW(instr->arg), ot->GetName());
}
break;
default:
#ifdef __GNUC__
#ifdef _LP64
fprintf(file, " %-8s 0x%lx (i:%ld, f:%g)\n", asBCInfo[instr->op].name, *ARG_QW(instr->arg), *((asINT64*) ARG_QW(instr->arg)), *((double*) ARG_QW(instr->arg)));
@@ -2238,6 +2283,7 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
#else
fprintf(file, " %-8s 0x%I64x (i:%I64d, f:%g)\n", asBCInfo[instr->op].name, *ARG_QW(instr->arg), *((asINT64*) ARG_QW(instr->arg)), *((double*) ARG_QW(instr->arg)));
#endif
}
break;
case asBCTYPE_wW_QW_ARG:
@@ -2257,7 +2303,8 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
if( instr->op == asBC_ALLOC )
{
asCObjectType *ot = *(asCObjectType**)ARG_DW(instr->arg);
fprintf(file, " %-8s 0x%x, %d (type:%s)\n", asBCInfo[instr->op].name, *(int*)ARG_DW(instr->arg), *(int*)(ARG_DW(instr->arg)+1), ot->GetName());
asCScriptFunction *func = engine->scriptFunctions[instr->wArg[0]];
fprintf(file, " %-8s 0x%x, %d (type:%s, %s)\n", asBCInfo[instr->op].name, *(int*)ARG_DW(instr->arg), *(int*)(ARG_DW(instr->arg)+1), ot->GetName(), func ? func->GetDeclaration() : "{no func}");
}
else
fprintf(file, " %-8s %u, %d\n", asBCInfo[instr->op].name, *(int*)ARG_DW(instr->arg), *(int*)(ARG_DW(instr->arg)+1));
@@ -2271,14 +2318,15 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
if( instr->op == asBC_ALLOC )
{
asCObjectType *ot = *(asCObjectType**)ARG_QW(instr->arg);
asCScriptFunction *func = engine->scriptFunctions[instr->wArg[0]];
#ifdef __GNUC__
#ifdef AS_64BIT_PTR
fprintf(file, " %-8s 0x%lx, %d (type:%s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName());
fprintf(file, " %-8s 0x%lx, %d (type:%s, %s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName(), func ? func->GetDeclaration() : "{no func}");
#else
fprintf(file, " %-8s 0x%llx, %d (type:%s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName());
fprintf(file, " %-8s 0x%llx, %d (type:%s, %s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName(), func ? func->GetDeclaration() : "{no func}");
#endif
#else
fprintf(file, " %-8s 0x%I64x, %d (type:%s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName());
fprintf(file, " %-8s 0x%I64x, %d (type:%s, %s)\n", asBCInfo[instr->op].name, *(asINT64*)ARG_QW(instr->arg), *(int*)(ARG_DW(instr->arg)+2), ot->GetName(), func ? func->GetDeclaration() : "{no func}");
#endif
}
else
@@ -2333,6 +2381,11 @@ void asCByteCode::DebugOutput(const char *name, asCScriptEngine *engine, asCScri
}
fclose(file);
// If the stackSize is negative then there is something wrong with the
// bytecode, i.e. there is a bug in the compiler or in the optimizer. We
// only check this here to have the bytecode available on file for verification
asASSERT( !invalidStackSize );
}
#endif