-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6b478d
commit c084846
Showing
13 changed files
with
1,458 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type == COMPILE_UCS_LEVEL && max_char_type <= 1 | ||
assert(_read_state.need_copy); | ||
switch (_read_state.max_char_type) { | ||
#if COMPILE_UCS_LEVEL == PYYJSON_STRING_TYPE_ASCII | ||
case PYYJSON_STRING_TYPE_ASCII: { | ||
// max char can only be greater than before | ||
// so before this loop we have | ||
// max_char_type == COMPILE_UCS_LEVEL <= 0 | ||
// therefore, need_check_max_char is false | ||
// 1_t_f | ||
goto loop_1_t_f; | ||
} | ||
#endif | ||
case PYYJSON_STRING_TYPE_LATIN1: { | ||
// max char can only be greater than before. | ||
// so "new max_char_type" == PYYJSON_STRING_TYPE_LATIN1 >= "old max_char_type" == COMPILE_UCS_LEVEL | ||
// 1_t_f | ||
goto loop_1_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type == 0 && COMPILE_UCS_LEVEL == 1 | ||
if (_read_state.need_copy) { | ||
// escaped. | ||
switch (_read_state.max_char_type) { | ||
case PYYJSON_STRING_TYPE_ASCII: { | ||
// max_char_type not updated | ||
// 1_t_t | ||
goto loop_1_t_t; | ||
} | ||
case PYYJSON_STRING_TYPE_LATIN1: { | ||
// 1_t_f | ||
goto loop_1_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} | ||
} else { | ||
// "check max char" is dirty without any escape, max_char_type must have been updated | ||
// so we must have "old max_char_type" == 0 and | ||
// 1 == "new max_char_type" <= COMPILE_UCS_LEVEL == 1, | ||
// since need_copy is false | ||
assert(_read_state.max_char_type == COMPILE_UCS_LEVEL && COMPILE_UCS_LEVEL == 1); | ||
goto loop_1_f_f; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: 1 >= max_char_type >= COMPILE_UCS_LEVEL | ||
assert(_read_state.need_copy); | ||
|
||
switch (_read_state.max_char_type) { | ||
#if !defined(NDEBUG) && COMPILE_UCS_LEVEL == PYYJSON_STRING_TYPE_ASCII | ||
case PYYJSON_STRING_TYPE_ASCII: { | ||
// max char can only be greater than before. | ||
// this means max_char == 0 | ||
assert(false); | ||
// 1_t_f (self), not really dirty. | ||
goto loop_1_t_f; | ||
} | ||
#endif | ||
#if !defined(NDEBUG) | ||
case PYYJSON_STRING_TYPE_LATIN1: { | ||
assert(false); | ||
// 1_t_f (self), not really dirty. | ||
goto loop_1_t_f; | ||
} | ||
#endif | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type == 0 && COMPILE_UCS_LEVEL == 1 | ||
switch (_read_state.max_char_type) { | ||
#if !defined(NDEBUG) | ||
case PYYJSON_STRING_TYPE_ASCII: { | ||
assert(false); | ||
// 1_t_t (self), not really dirty. | ||
goto loop_1_t_t; | ||
} | ||
#endif | ||
case PYYJSON_STRING_TYPE_LATIN1: { | ||
// 1_t_f | ||
goto loop_1_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: 2 == max_char_type == COMPILE_UCS_LEVEL | ||
assert(_read_state.need_copy); | ||
switch (_read_state.max_char_type) { | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type < COMPILE_UCS_LEVEL == 2 | ||
static_assert(COMPILE_UCS_LEVEL == 2, "COMPILE_UCS_LEVEL == 2"); | ||
if (_read_state.need_copy) { | ||
// escaped. | ||
switch (_read_state.max_char_type) { | ||
case PYYJSON_STRING_TYPE_ASCII: { | ||
// 1_t_t | ||
goto loop_2_t_t; | ||
} | ||
case PYYJSON_STRING_TYPE_LATIN1: { | ||
// 1_t_t | ||
goto loop_2_t_t; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS2: { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} | ||
case PYYJSON_STRING_TYPE_UCS4: { | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} | ||
default: { | ||
assert(false); | ||
Py_UNREACHABLE(); | ||
} | ||
} | ||
} else { | ||
// check max char is dirty without any escape, max_char_type must have been updated | ||
#if !defined(NDEBUG) | ||
if (_read_state.max_char_type < COMPILE_UCS_LEVEL) { | ||
assert(false); | ||
// 2_f_t (self), not really dirty. | ||
goto loop_2_f_t; | ||
} | ||
#endif | ||
// 2_f_f | ||
goto loop_2_f_f; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type == 2 >= COMPILE_UCS_LEVEL | ||
assert(_read_state.need_copy); | ||
|
||
#if !defined(NDEBUG) | ||
if (_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS2) { | ||
assert(false); | ||
// 2_t_f (self), not really dirty | ||
goto loop_2_t_f; | ||
} | ||
#endif | ||
assert(_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS4); | ||
// 4_t_f | ||
goto loop_4_t_f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type < COMPILE_UCS_LEVEL == 2 | ||
|
||
#if !defined(NDEBUG) | ||
if (_read_state.max_char_type < PYYJSON_STRING_TYPE_UCS2) { | ||
assert(false); | ||
// 2_t_t (self), not really dirty | ||
goto loop_2_t_t; | ||
} | ||
#endif | ||
assert(_read_state.max_char_type >= PYYJSON_STRING_TYPE_UCS2); | ||
|
||
if (_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS2) { | ||
// 2_t_f | ||
goto loop_2_t_f; | ||
} else { | ||
assert(_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS4); | ||
// 4_t_f | ||
goto loop_4_t_f; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type == COMPILE_UCS_LEVEL == 4 | ||
assert(_read_state.need_copy); | ||
assert(_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS4); | ||
goto loop_4_t_f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* NOTE: | ||
* write_as = max(_read_state.max_char_type, COMPILE_READ_UCS_LEVEL) | ||
* need_copy == <escape is met> | ||
* need_check_max_char = max_char_type < COMPILE_UCS_LEVEL | ||
* | ||
* additional note: | ||
* 1. need_copy == false => max_char_type <= COMPILE_UCS_LEVEL | ||
* !need_copy && !need_check_max_char => max_char_type == COMPILE_UCS_LEVEL | ||
* COMPILE_UCS_LEVEL < max_char_type == write_as => need_copy == true | ||
* 2. COMPILE_READ_UCS_LEVEL = COMPILE_UCS_LEVEL ? COMPILE_UCS_LEVEL : 1 | ||
* 3. max_char_type == 4 || COMPILE_UCS_LEVEL == 0 => need_check_max_char == false | ||
*/ | ||
|
||
// knowledge before loop: max_char_type < COMPILE_UCS_LEVEL == 4 | ||
if (_read_state.need_copy) { | ||
// escaped. | ||
if (_read_state.max_char_type == PYYJSON_STRING_TYPE_UCS4) { | ||
goto loop_4_t_f; | ||
} else { | ||
assert(_read_state.max_char_type >= PYYJSON_STRING_TYPE_ASCII && _read_state.max_char_type <= PYYJSON_STRING_TYPE_UCS2); | ||
goto loop_4_t_t; | ||
} | ||
} else { | ||
// check max char is dirty without any escape, max_char_type must have been updated | ||
#if !defined(NDEBUG) | ||
if (_read_state.max_char_type < COMPILE_UCS_LEVEL) { | ||
assert(false); | ||
// loop_4_f_t (self), not really dirty. | ||
goto loop_4_f_t; | ||
} | ||
#endif | ||
assert(_read_state.max_char_type == COMPILE_UCS_LEVEL); | ||
// 4_f_f | ||
goto loop_4_f_f; | ||
} |
Oops, something went wrong.