mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-19 21:55:21 +02:00
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
Fiddled a bit the the testing system. Added a very simple SDL graphics demo.
This commit is contained in:
53
gen/logger.c
53
gen/logger.c
@@ -1,10 +1,9 @@
|
||||
#ifndef LLVMD_NO_LOGGER
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "gen/logger.h"
|
||||
@@ -12,36 +11,56 @@
|
||||
namespace Logger
|
||||
{
|
||||
static std::string indent_str;
|
||||
static std::ofstream null_out("/dev/null");
|
||||
|
||||
static bool enabled = false;
|
||||
void indent()
|
||||
{
|
||||
if (enabled)
|
||||
indent_str += " ";
|
||||
}
|
||||
void undent()
|
||||
{
|
||||
assert(!indent_str.empty());
|
||||
indent_str.resize(indent_str.size()-2);
|
||||
if (enabled) {
|
||||
assert(!indent_str.empty());
|
||||
indent_str.resize(indent_str.size()-2);
|
||||
}
|
||||
}
|
||||
std::ostream& cout()
|
||||
{
|
||||
return std::cout << indent_str;
|
||||
if (enabled)
|
||||
return std::cout << indent_str;
|
||||
else
|
||||
return null_out;
|
||||
}
|
||||
void println(const char* fmt,...)
|
||||
{
|
||||
printf(indent_str.c_str());
|
||||
va_list va;
|
||||
va_start(va,fmt);
|
||||
vprintf(fmt,va);
|
||||
va_end(va);
|
||||
printf("\n");
|
||||
if (enabled) {
|
||||
printf(indent_str.c_str());
|
||||
va_list va;
|
||||
va_start(va,fmt);
|
||||
vprintf(fmt,va);
|
||||
va_end(va);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
void print(const char* fmt,...)
|
||||
{
|
||||
printf(indent_str.c_str());
|
||||
va_list va;
|
||||
va_start(va,fmt);
|
||||
vprintf(fmt,va);
|
||||
va_end(va);
|
||||
if (enabled) {
|
||||
printf(indent_str.c_str());
|
||||
va_list va;
|
||||
va_start(va,fmt);
|
||||
vprintf(fmt,va);
|
||||
va_end(va);
|
||||
}
|
||||
}
|
||||
void enable()
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
void disable()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
26
gen/logger.h
26
gen/logger.h
@@ -5,44 +5,30 @@
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
#ifndef LLVMD_NO_LOGGER
|
||||
void indent();
|
||||
void undent();
|
||||
std::ostream& cout();
|
||||
void println(const char* fmt,...);
|
||||
void print(const char* fmt,...);
|
||||
#else
|
||||
inline void indent() {}
|
||||
inline void undent() {}
|
||||
inline std::ostream& cout() { return std::cout; }
|
||||
inline void println(const char* fmt, ...) {}
|
||||
inline void print(const char* fmt, ...) {}
|
||||
#endif
|
||||
void println(const char* fmt, ...);
|
||||
void print(const char* fmt, ...);
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
|
||||
struct LoggerScope
|
||||
{
|
||||
LoggerScope()
|
||||
{
|
||||
#ifndef LLVMD_NO_LOGGER
|
||||
//std::cout << "-->indented\n";
|
||||
Logger::indent();
|
||||
#endif
|
||||
|
||||
}
|
||||
~LoggerScope()
|
||||
{
|
||||
#ifndef LLVMD_NO_LOGGER
|
||||
//std::cout << "<--undented\n";
|
||||
Logger::undent();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#ifndef LLVMD_NO_LOGGER
|
||||
#define LOG_SCOPE Logger::LoggerScope _logscope;
|
||||
#else
|
||||
#define LOG_SCOPE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -133,14 +133,14 @@ void Module::genmoduleinfo()
|
||||
|
||||
void Dsymbol::toObjFile()
|
||||
{
|
||||
warning("Ignoring Dsymbol::toObjFile for %s", toChars());
|
||||
Logger::println("Ignoring Dsymbol::toObjFile for %s", toChars());
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
|
||||
void Declaration::toObjFile()
|
||||
{
|
||||
warning("Ignoring Declaration::toObjFile for %s", toChars());
|
||||
Logger::println("Ignoring Declaration::toObjFile for %s", toChars());
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
@@ -205,7 +205,7 @@ void ClassDeclaration::offsetToIndex(Type* t, unsigned os, std::vector<unsigned>
|
||||
|
||||
void InterfaceDeclaration::toObjFile()
|
||||
{
|
||||
warning("Ignoring InterfaceDeclaration::toObjFile for %s", toChars());
|
||||
Logger::println("Ignoring InterfaceDeclaration::toObjFile for %s", toChars());
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
@@ -621,7 +621,7 @@ void TypedefDeclaration::toObjFile()
|
||||
|
||||
void EnumDeclaration::toObjFile()
|
||||
{
|
||||
warning("Ignoring EnumDeclaration::toObjFile for %s", toChars());
|
||||
Logger::println("Ignoring EnumDeclaration::toObjFile for %s", toChars());
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
|
||||
Reference in New Issue
Block a user