forked from rebolsource/r3
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Detect_Rebol_Pointer 100% robust, simpler
This simplifies the UTF8 detection and makes it basically foolproof. The leftmost bit is always 1 on Rebol series/values ("NODE_FLAG_NODE"), then the second bit is NODE_FLAG_FREE, which should be 0 on all valid series/values. That means all non-"free" series and non-trash values will start with 10, an invalid leading bit pattern in UTF-8. Then the special bytes 11000000 and 11000001, 192 and 193, are also illegal unicode (while in general 11xxxxxx are valid). So that means bit #8 is used for NODE_FLAG_CELL. Free series nodes use 11000000 as their first byte, trash cells use 11000001 for theirs. With this strategy, it is possible to tell the difference between basically everything with no false positives: free states of Rebol values and series are still distinguishable from UTF8. The simplified (and complete) list of detectable pointers are: DETECTED_AS_UTF8 DETECTED_AS_SERIES DETECTED_AS_FREED_SERIES DETECTED_AS_VALUE DETECTED_AS_END DETECTED_AS_TRASH_CELL The cost of the scheme is one bit: the high one that's always 1, which could be used for other things otherwise. However, this required a lot of flags to get shuffled around. As a side-effect of the new layout, an END cell does not need to have NODE_FLAG_MANAGED set. This helps with logic that needs to operate on a node that doesn't know if it's dealing with a series or a value cell, but wants to quickly test the managed flag for meaning.
- Loading branch information
1 parent
5edb677
commit 56680b5
Showing
25 changed files
with
565 additions
and
561 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
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
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
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
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
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
Oops, something went wrong.