Apply new formatting

This commit is contained in:
Tom Willemse 2022-08-14 16:13:49 -07:00
parent cb42c81121
commit e91006b59a
8 changed files with 20 additions and 18 deletions

1
clox/src/.clang-format Normal file
View file

@ -0,0 +1 @@
BreakBeforeBinaryOperators: All

View file

@ -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);
}

View file

@ -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 = &current->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;
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;