jitcraft/CompileContext.cpp
changeset 69 dfce0539a77d
parent 59 b7d61ddb3c8d
     1.1 --- a/jitcraft/CompileContext.cpp	Tue Jul 10 02:11:13 2012 -0700
     1.2 +++ b/jitcraft/CompileContext.cpp	Wed Jul 11 01:12:54 2012 -0700
     1.3 @@ -18,21 +18,30 @@
     1.4  #include <stdio.h>
     1.5  #include "Scanner.h"
     1.6  #include "CompileContext.h"
     1.7 +#include "Zone.h"
     1.8  
     1.9  using namespace ke;
    1.10  
    1.11 -CompileContext::CompileContext(Zone *zone)
    1.12 +CompileContext::CompileContext(Zone *zone, const char *file)
    1.13    : zone_(zone),
    1.14 -    failures_(0)
    1.15 +    failures_(0),
    1.16 +    file_(file)
    1.17  {
    1.18  }
    1.19  
    1.20 +CompileContext::~CompileContext()
    1.21 +{
    1.22 +    if (failures_)
    1.23 +        zone_->endCompilationErrors();
    1.24 +}
    1.25 +
    1.26  void
    1.27  CompileContext::reportErrorVa(const SourcePosition &pos, Message msg, va_list ap)
    1.28  {
    1.29 -    fprintf(stderr, "error on line %d, col %d: ", pos.line, pos.col);
    1.30 -    vfprintf(stderr, Messages[msg].format, ap);
    1.31 -    fprintf(stderr, "\n");
    1.32 +    if (!failures_)
    1.33 +        zone_->beginCompilationErrors(file_);
    1.34 +
    1.35 +    zone_->reportCompilationError(msg, pos.line, pos.col, ap);
    1.36  
    1.37      failures_++;
    1.38  }