Implement #complete switch by default, replace with #partial switch #511

This commit is contained in:
gingerBill
2019-12-22 12:03:48 +00:00
parent 4593730632
commit d1c9fd4e01
19 changed files with 263 additions and 227 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
ti := type_info_base(type_info_of(v.id));
a := any{v.data, ti.id};
switch info in ti.variant {
#partial switch info in ti.variant {
case Type_Info_Named:
panic("Unreachable");
@@ -282,7 +282,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
return false;
}
t := runtime.type_info_base(ti);
switch info in t.variant {
#partial switch info in t.variant {
case runtime.Type_Info_Integer:
switch info.endianness {
case .Platform: return false;
+2 -2
View File
@@ -70,7 +70,7 @@ parse_value :: proc(p: ^Parser) -> (value: Value, err: Error) {
defer value.end = token_end_pos(p.prev_token);
token := p.curr_token;
switch token.kind {
#partial switch token.kind {
case Kind.Null:
value.value = Null{};
advance_token(p);
@@ -105,7 +105,7 @@ parse_value :: proc(p: ^Parser) -> (value: Value, err: Error) {
case:
if p.spec == Specification.JSON5 {
switch token.kind {
#partial switch token.kind {
case Kind.Infinity:
inf: u64 = 0x7ff0000000000000;
if token.text[0] == '-' {
+1 -1
View File
@@ -56,7 +56,7 @@ Error :: enum {
destroy_value :: proc(value: Value) {
switch v in value.value {
#partial switch v in value.value {
case Object:
for key, elem in v {
delete(key);
+8 -9
View File
@@ -91,28 +91,27 @@ validate_array :: proc(p: ^Parser) -> bool {
validate_value :: proc(p: ^Parser) -> bool {
token := p.curr_token;
using Kind;
switch token.kind {
case Null, False, True:
#partial switch token.kind {
case .Null, .False, .True:
advance_token(p);
return true;
case Integer, Float:
case .Integer, .Float:
advance_token(p);
return true;
case String:
case .String:
advance_token(p);
return is_valid_string_literal(token.text, p.spec);
case Open_Brace:
case .Open_Brace:
return validate_object(p);
case Open_Bracket:
case .Open_Bracket:
return validate_array(p);
case:
if p.spec == Specification.JSON5 {
switch token.kind {
case Infinity, NaN:
#partial switch token.kind {
case .Infinity, .NaN:
advance_token(p);
return true;
}