MCPcopy Create free account
hub / github.com/Siv3D/OpenSiv3D / DebugOutput

Method DebugOutput

Siv3D/src/ThirdParty/angelscript/as_bytecode.cpp:2137–2530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2135
2136#ifdef AS_DEBUG
2137void asCByteCode::DebugOutput(const char *name, asCScriptFunction *func)
2138{
2139#ifndef __MINGW32__
2140 // _mkdir is broken on mingw
2141 _mkdir("AS_DEBUG");
2142#endif
2143
2144 asCString path = "AS_DEBUG/";
2145 path += name;
2146
2147 // Anonymous functions created from within class methods will contain :: as part of the name
2148 // Replace :: with __ to avoid error when creating the file for debug output
2149 for (asUINT n = 0; n < path.GetLength(); n++)
2150 if (path[n] == ':') path[n] = '_';
2151
2152#if _MSC_VER >= 1500 && !defined(AS_MARMALADE)
2153 FILE *file;
2154 fopen_s(&file, path.AddressOf(), "w");
2155#else
2156 FILE *file = fopen(path.AddressOf(), "w");
2157#endif
2158
2159#if !defined(AS_XENON) && !defined(__MINGW32__)
2160 // XBox 360: When running in DVD Emu, no write is allowed
2161 // MinGW: As _mkdir is broken, don't assert on file not created if the AS_DEBUG directory doesn't exist
2162 asASSERT( file );
2163#endif
2164
2165 if( file == 0 )
2166 return;
2167
2168 asUINT n;
2169
2170 fprintf(file, "%s\n\n", func->GetDeclaration());
2171
2172 fprintf(file, "Temps: ");
2173 for( n = 0; n < temporaryVariables->GetLength(); n++ )
2174 {
2175 fprintf(file, "%d", (*temporaryVariables)[n]);
2176 if( n < temporaryVariables->GetLength()-1 )
2177 fprintf(file, ", ");
2178 }
2179 fprintf(file, "\n\n");
2180
2181 fprintf(file, "Variables: \n");
2182 for( n = 0; n < func->scriptData->variables.GetLength(); n++ )
2183 {
2184 int idx = func->scriptData->objVariablePos.IndexOf(func->scriptData->variables[n]->stackOffset);
2185 bool isOnHeap = asUINT(idx) < func->scriptData->objVariablesOnHeap ? true : false;
2186 fprintf(file, " %.3d: %s%s %s\n", func->scriptData->variables[n]->stackOffset, isOnHeap ? "(heap) " : "", func->scriptData->variables[n]->type.Format(func->nameSpace, true).AddressOf(), func->scriptData->variables[n]->name.AddressOf());
2187 }
2188 asUINT offset = 0;
2189 if( func->objectType )
2190 {
2191 fprintf(file, " %.3d: %s this\n", 0, func->objectType->name.AddressOf());
2192 offset -= AS_PTR_SIZE;
2193 }
2194 for( n = 0; n < func->parameterTypes.GetLength(); n++ )

Callers 3

CompileFunctionMethod · 0.80
CompileGlobalVariableMethod · 0.80

Calls 12

GetDeclarationMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
GetTypeDeclarationMethod · 0.80
MoveToMethod · 0.80
GetLengthMethod · 0.45
AddressOfMethod · 0.45
IndexOfMethod · 0.45
FormatMethod · 0.45
GetSizeMethod · 0.45
GetNameMethod · 0.45
SetLengthMethod · 0.45

Tested by

no test coverage detected