Squashed commit of the following:

commit f93ec6430f9629b5a28765a3961379d1e8296e50
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date:   Wed Mar 16 08:03:25 2016 -0700

    Tiny tweaks.

commit 332a08fe33cddffec82dbd377ee0c941a0066f64
Merge: a673981 14b7a08
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date:   Wed Mar 16 08:01:00 2016 -0700

    Merge branch 'errorFn' of https://github.com/ppvk/wren into ppvk-errorFn

commit 14b7a086ce3dae1b12697319bc2894048fad469f
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date:   Tue Mar 15 11:33:37 2016 -0500

    missing semicolon, accessing vm through parser in

commit 924eaa1f9d3fbb26dc07d3ac8be7dc00287138d9
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date:   Tue Mar 15 11:25:32 2016 -0500

    fixed missing errorFn in wren.h

commit 3761df111f9dce3bd67407754675c9efbbf2c0b4
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date:   Tue Mar 15 11:23:51 2016 -0500

    Added an errorFn to the CLI

commit d51137b4abe339a3f07d7e2f4c5ee0d8d062a009
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date:   Tue Mar 15 11:21:16 2016 -0500

    Added a WrenErrorFn typedef, an errorFn slot in WrenConfiguration.  exits early if  is not defined, otherwise it runs the errorFn .
This commit is contained in:
Bob Nystrom
2016-03-16 08:04:03 -07:00
parent a6739819b2
commit c5855a6fe9
4 changed files with 21 additions and 2 deletions
+4 -2
View File
@@ -394,14 +394,16 @@ static void printError(Parser* parser, int line, const char* label,
parser->hasError = true;
if (!parser->printErrors) return;
// Only report errors if there is a WrenErrorFn to handle them.
if (parser->vm->config.errorFn == NULL) return;
// Format the label and message.
char message[ERROR_MESSAGE_SIZE];
int length = sprintf(message, "%s: ", label);
length += vsprintf(message + length, format, args);
ASSERT(length < ERROR_MESSAGE_SIZE, "Error should not exceed buffer.");
fprintf(stderr, "[%s line %d] %s\n", parser->module->name->value, line,
message);
parser->vm->config.errorFn(parser->module->name->value, line, message);
}
// Outputs a compile or syntax error. This also marks the compilation as having
+1
View File
@@ -42,6 +42,7 @@ void wrenInitConfiguration(WrenConfiguration* config)
config->bindForeignMethodFn = NULL;
config->bindForeignClassFn = NULL;
config->writeFn = NULL;
config->errorFn = NULL;
config->initialHeapSize = 1024 * 1024 * 10;
config->minHeapSize = 1024 * 1024;
config->heapGrowthPercent = 50;