Remove usage of do in core library

This commit is contained in:
gingerBill
2020-09-23 17:17:14 +01:00
parent 4844dd4d96
commit fc4fdd588e
45 changed files with 960 additions and 520 deletions
+15 -9
View File
@@ -161,7 +161,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
case Type_Info_Array:
write_byte(b, '[');
for i in 0..<info.count {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
data := uintptr(v.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -172,7 +172,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '[');
array := cast(^mem.Raw_Dynamic_Array)v.data;
for i in 0..<array.len {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
data := uintptr(array.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -183,7 +183,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '[');
slice := cast(^mem.Raw_Slice)v.data;
for i in 0..<slice.len {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
data := uintptr(slice.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -205,7 +205,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
entry_size := ed.elem_size;
for i in 0..<entries.len {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
data := uintptr(entries.data) + uintptr(i*entry_size);
header := cast(^Map_Entry_Header)data;
@@ -223,7 +223,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
case Type_Info_Struct:
write_byte(b, '{');
for name, i in info.names {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
write_quoted_string(b, name);
write_string(b, ": ");
@@ -271,7 +271,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '{');
for name, i in info.names {
if i > 0 do write_string(b, ", ");
if i > 0 { write_string(b, ", "); }
bits := u64(info.bits[i]);
offset := u64(info.offsets[i]);
@@ -317,15 +317,21 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
bit_data = u64(x);
case 16:
x := (^u16)(v.data)^;
if do_byte_swap do x = bits.byte_swap(x);
if do_byte_swap {
x = bits.byte_swap(x);
}
bit_data = u64(x);
case 32:
x := (^u32)(v.data)^;
if do_byte_swap do x = bits.byte_swap(x);
if do_byte_swap {
x = bits.byte_swap(x);
}
bit_data = u64(x);
case 64:
x := (^u64)(v.data)^;
if do_byte_swap do x = bits.byte_swap(x);
if do_byte_swap {
x = bits.byte_swap(x);
}
bit_data = u64(x);
case: panic("unknown bit_size size");
}
+14 -6
View File
@@ -183,9 +183,11 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
case "false": token.kind = .False;
case "true": token.kind = .True;
case:
if t.spec == .JSON5 do switch str {
case "Infinity": token.kind = .Infinity;
case "NaN": token.kind = .NaN;
if t.spec == .JSON5 {
switch str {
case "Infinity": token.kind = .Infinity;
case "NaN": token.kind = .NaN;
}
}
}
@@ -361,7 +363,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
s = s[1:];
case '1'..'9':
s = s[1:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
s = s[1:];
}
case '.':
if spec == .JSON5 { // Allow leading decimal point
s = s[1:];
@@ -380,7 +384,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' {
s = s[2:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
s = s[1:];
}
}
if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') {
@@ -392,7 +398,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
return false;
}
}
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
s = s[1:];
}
}
// The string should be empty now to be valid
+3 -1
View File
@@ -65,7 +65,9 @@ destroy_value :: proc(value: Value) {
}
delete(v);
case Array:
for elem in v do destroy_value(elem);
for elem in v {
destroy_value(elem);
}
delete(v);
case String:
delete(v);