From 9f64c05fa8fc4167c8342b2ab7afc1ccf28c3724 Mon Sep 17 00:00:00 2001 From: underscorediscovery Date: Mon, 8 Jun 2020 12:28:15 -0700 Subject: [PATCH] Make do blocks in macros consistent with the rest of the code --- src/vm/wren_common.h | 6 ++++-- src/vm/wren_primitive.h | 13 +++++++++---- src/vm/wren_vm.c | 12 ++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/vm/wren_common.h b/src/vm/wren_common.h index e04bcc9a..ad5a86cf 100644 --- a/src/vm/wren_common.h +++ b/src/vm/wren_common.h @@ -157,7 +157,8 @@ #include #define ASSERT(condition, message) \ - do { \ + do \ + { \ if (!(condition)) \ { \ fprintf(stderr, "[%s:%d] Assert failed in %s(): %s\n", \ @@ -174,7 +175,8 @@ // in some cases and also lets it perform some optimizations by assuming the // code is never reached. #define UNREACHABLE() \ - do { \ + do \ + { \ fprintf(stderr, "[%s:%d] This code should not be reached in %s()\n", \ __FILE__, __LINE__, __func__); \ abort(); \ diff --git a/src/vm/wren_primitive.h b/src/vm/wren_primitive.h index 21b6a00a..813300dc 100644 --- a/src/vm/wren_primitive.h +++ b/src/vm/wren_primitive.h @@ -6,7 +6,8 @@ // Binds a primitive method named [name] (in Wren) implemented using C function // [fn] to `ObjClass` [cls]. #define PRIMITIVE(cls, name, function) \ - do { \ + do \ + { \ int symbol = wrenSymbolTableEnsure(vm, \ &vm->methodNames, name, strlen(name)); \ Method method; \ @@ -22,7 +23,8 @@ static bool prim_##name(WrenVM* vm, Value* args) #define RETURN_VAL(value) \ - do { \ + do \ + { \ args[0] = value; \ return true; \ } while (false) @@ -35,13 +37,15 @@ #define RETURN_TRUE RETURN_VAL(TRUE_VAL) #define RETURN_ERROR(msg) \ - do { \ + do \ + { \ vm->fiber->error = wrenNewStringLength(vm, msg, sizeof(msg) - 1); \ return false; \ } while (false) #define RETURN_ERROR_FMT(msg, arg) \ - do { \ + do \ + { \ vm->fiber->error = wrenStringFormat(vm, msg, arg); \ return false; \ } while (false) @@ -49,6 +53,7 @@ // Validates that the given [arg] is a function. Returns true if it is. If not, // reports an error and returns false. bool validateFn(WrenVM* vm, Value arg, const char* argName); +bool validateFn(WrenVM* vm, Value arg, const char* argName); // Validates that the given [arg] is a Num. Returns true if it is. If not, // reports an error and returns false. diff --git a/src/vm/wren_vm.c b/src/vm/wren_vm.c index d272c0c6..1d4551bd 100644 --- a/src/vm/wren_vm.c +++ b/src/vm/wren_vm.c @@ -798,7 +798,8 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber) // Use this after a CallFrame has been pushed or popped to refresh the local // variables. #define LOAD_FRAME() \ - do { \ + do \ + { \ frame = &fiber->frames[fiber->numFrames - 1]; \ stackStart = frame->stackStart; \ ip = frame->ip; \ @@ -809,7 +810,8 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber) // fiber is willing to catch the error, transfers control to it, otherwise // exits the interpreter. #define RUNTIME_ERROR() \ - do { \ + do \ + { \ STORE_FRAME(); \ runtimeError(vm); \ if (vm->fiber == NULL) return WREN_RESULT_RUNTIME_ERROR; \ @@ -821,7 +823,8 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber) #if WREN_DEBUG_TRACE_INSTRUCTIONS // Prints the stack and instruction before each instruction is executed. #define DEBUG_TRACE_INSTRUCTIONS() \ - do { \ + do \ + { \ wrenDumpStack(fiber); \ wrenDumpInstruction(vm, fn, (int)(ip - fn->code.data)); \ } while (false) @@ -841,7 +844,8 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber) #define CASE_CODE(name) code_##name #define DISPATCH() \ - do { \ + do \ + { \ DEBUG_TRACE_INSTRUCTIONS(); \ goto *dispatchTable[instruction = (Code)READ_BYTE()]; \ } while (false)