MCPcopy Create free account
hub / github.com/anjo76/angelscript / DebugOutput

Method DebugOutput

sdk/angelscript/source/as_bytecode.cpp:2129–2478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

CompileFunctionMethod · 0.80
CompileGlobalVariableMethod · 0.80

Calls 11

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

Tested by

no test coverage detected