mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 19:36:06 +03:00

* Fixed a minor linking order mishap * * Added an command line option -annotate * * Fixed some problems with running optimizations * * Added std.stdio and dependencies to lphobos (still not 100% working, but compiles and links) * * Fixed problems with passing aggregate types to variadic functions * * Added initial code towards full GC support, currently based on malloc and friends, not all the runtime calls the GC yet for memory * * Fixed problems with resolving nested function context pointers for some heavily nested cases * * Redid function argument passing + other minor code cleanups, still lots to do on this end... *
79 lines
1.5 KiB
C++
79 lines
1.5 KiB
C++
#include <cassert>
|
|
#include <cstdarg>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
#include "gen/logger.h"
|
|
|
|
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()
|
|
{
|
|
if (_enabled) {
|
|
assert(!indent_str.empty());
|
|
indent_str.resize(indent_str.size()-2);
|
|
}
|
|
}
|
|
std::ostream& cout()
|
|
{
|
|
if (_enabled)
|
|
return std::cout << indent_str;
|
|
else
|
|
return null_out;
|
|
}
|
|
void println(const char* fmt,...)
|
|
{
|
|
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,...)
|
|
{
|
|
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;
|
|
}
|
|
bool enabled()
|
|
{
|
|
return _enabled;
|
|
}
|
|
void attention(const char* fmt,...)
|
|
{
|
|
printf("***ATTENTION*** ");
|
|
va_list va;
|
|
va_start(va,fmt);
|
|
vprintf(fmt,va);
|
|
va_end(va);
|
|
printf("\n");
|
|
}
|
|
}
|