diff --git a/clox/src/.clang-format b/clox/src/.clang-format new file mode 100644 index 0000000..668f43e --- /dev/null +++ b/clox/src/.clang-format @@ -0,0 +1 @@ +BreakBeforeBinaryOperators: All diff --git a/clox/src/chunk.c b/clox/src/chunk.c index 297dcb7..b6f69c4 100644 --- a/clox/src/chunk.c +++ b/clox/src/chunk.c @@ -23,8 +23,8 @@ void writeChunk(Chunk *chunk, uint8_t byte, int line) { if (chunk->capacity < chunk->count + 1) { int oldCapacity = chunk->capacity; chunk->capacity = GROW_CAPACITY(oldCapacity); - chunk->code = - GROW_ARRAY(uint8_t, chunk->code, oldCapacity, chunk->capacity); + chunk->code + = GROW_ARRAY(uint8_t, chunk->code, oldCapacity, chunk->capacity); chunk->lines = GROW_ARRAY(int, chunk->lines, oldCapacity, chunk->capacity); } diff --git a/clox/src/compiler.c b/clox/src/compiler.c index 4dded64..18ad4a7 100644 --- a/clox/src/compiler.c +++ b/clox/src/compiler.c @@ -208,8 +208,8 @@ static void initCompiler(Compiler *compiler, FunctionType type) { compiler->function = newFunction(); current = compiler; if (type != TYPE_SCRIPT) { - current->function->name = - copyString(parser.previous.start, parser.previous.length); + current->function->name + = copyString(parser.previous.start, parser.previous.length); } Local *local = ¤t->locals[current->localCount++]; @@ -245,8 +245,9 @@ static void beginScope() { current->scopeDepth++; } static void endScope() { current->scopeDepth--; - while (current->localCount > 0 && - current->locals[current->localCount - 1].depth > current->scopeDepth) { + while (current->localCount > 0 + && current->locals[current->localCount - 1].depth + > current->scopeDepth) { if (current->locals[current->localCount - 1].isCaptured) { emitByte(OP_CLOSE_UPVALUE); } else { @@ -399,8 +400,8 @@ static void method() { uint8_t constant = identifierConstant(&parser.previous); FunctionType type = TYPE_METHOD; - if (parser.previous.length == 4 && - memcmp(parser.previous.start, "init", 4) == 0) { + if (parser.previous.length == 4 + && memcmp(parser.previous.start, "init", 4) == 0) { type = TYPE_INITIALIZER; } diff --git a/clox/src/debug.h b/clox/src/debug.h index 5731d05..9381ba6 100644 --- a/clox/src/debug.h +++ b/clox/src/debug.h @@ -3,7 +3,7 @@ #include "chunk.h" -void disassembleChunk(Chunk* chunk, const char* name); -int disassembleInstruction(Chunk* chunk, int offset); +void disassembleChunk(Chunk *chunk, const char *name); +int disassembleInstruction(Chunk *chunk, int offset); #endif diff --git a/clox/src/memory.c b/clox/src/memory.c index abf1cdd..0a9e3f7 100644 --- a/clox/src/memory.c +++ b/clox/src/memory.c @@ -49,8 +49,8 @@ void markObject(Obj *object) { if (vm.grayCapacity < vm.grayCount + 1) { vm.grayCapacity = GROW_CAPACITY(vm.grayCapacity); - vm.grayStack = - (Obj **)realloc(vm.grayStack, sizeof(Obj *) * vm.grayCapacity); + vm.grayStack + = (Obj **)realloc(vm.grayStack, sizeof(Obj *) * vm.grayCapacity); if (vm.grayStack == NULL) exit(1); } diff --git a/clox/src/scanner.c b/clox/src/scanner.c index 5e0f4bf..dba1380 100644 --- a/clox/src/scanner.c +++ b/clox/src/scanner.c @@ -97,8 +97,8 @@ static void skipWhitespace() { static TokenType checkKeyword(int start, int length, const char *rest, TokenType type) { - if (scanner.current - scanner.start == start + length && - memcmp(scanner.start + start, rest, length) == 0) { + if (scanner.current - scanner.start == start + length + && memcmp(scanner.start + start, rest, length) == 0) { return type; } diff --git a/clox/src/table.c b/clox/src/table.c index 134f455..2405397 100644 --- a/clox/src/table.c +++ b/clox/src/table.c @@ -131,8 +131,8 @@ ObjString *tableFindString(Table *table, const char *chars, int length, /* Stop if we find an empty non-tombstone entry. */ if (IS_NIL(entry->value)) return NULL; - } else if (entry->key->length == length && entry->key->hash == hash && - memcmp(entry->key->chars, chars, length) == 0) { + } else if (entry->key->length == length && entry->key->hash == hash + && memcmp(entry->key->chars, chars, length) == 0) { /* We found it. */ return entry->key; } diff --git a/clox/src/value.c b/clox/src/value.c index 28d1c9f..e442181 100644 --- a/clox/src/value.c +++ b/clox/src/value.c @@ -15,8 +15,8 @@ void writeValueArray(ValueArray *array, Value value) { if (array->capacity < array->count + 1) { int oldCapacity = array->capacity; array->capacity = GROW_CAPACITY(oldCapacity); - array->values = - GROW_ARRAY(Value, array->values, oldCapacity, array->capacity); + array->values + = GROW_ARRAY(Value, array->values, oldCapacity, array->capacity); } array->values[array->count] = value;