diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-10 16:26:08 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-09-10 16:26:27 -0700 |
| commit | 7c6047254e5aa7ce5a0667b14676b22a7447f956 (patch) | |
| tree | f98478e6c77257610e43dc45447cd23e91bdaaae /core/id.nom | |
| parent | c859eac2beb20889e162ca28f889cc02ac592266 (diff) | |
Upgraded to 3.8 (text method changes) and fixed some bugs in
tree_to_nomsu.
Diffstat (limited to 'core/id.nom')
| -rw-r--r-- | core/id.nom | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/core/id.nom b/core/id.nom index 8a213d4..9f41cfb 100644 --- a/core/id.nom +++ b/core/id.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.7.5.6 +#!/usr/bin/env nomsu -V3.8.7.6 # A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt @@ -10,14 +10,16 @@ use "core/control_flow.nom" %NaN_surrogate = {} %nil_surrogate = {} %obj_by_id = {} -set %obj_by_id's metatable to {__mode: "v"} +set %obj_by_id's metatable to {__mode:"v"} %id_by_obj = {} -set %id_by_obj's metatable to {..} - __mode: "k" +set %id_by_obj 's metatable to {..} + __mode:"k" __index: (..) [%self, %key] ->: - if (%key == (nil)): return %self.%nil_surrogate - if (%key != %key): return %self.%NaN_surrogate + if (%key == (nil)): + return %self.%nil_surrogate + if (%key != %key): + return %self.%NaN_surrogate --- %retry --- %id = (uuid) if (%obj_by_id.%id != (nil)): go to %retry @@ -28,16 +30,18 @@ set %id_by_obj's metatable to {..} action [uuid]: # Set all the other bits to randomly (or pseudo-randomly) chosen values. %bytes = [..] - randint (2^(4*8)), # time-low - randint (2^(2*8)), # time-mid - randint (2^(2*8 - 4)), # time-high-and-version - randint (2^(1*8 - 2)), # clock-seq-and-reserved - randint (2^(1*8)), # clock-seq-low - randint (2^(3*8)), randint (2^(3*8)), # node + # time-low, time-mid, time-high-and-version + randint (2 ^ (4 * 8)), randint (2 ^ (2 * 8)), randint (2 ^ (2 * 8 - 4)) + # clock-seq-and-reserved, clock-seq-low + randint (2 ^ (1 * 8 - 2)), randint (2 ^ (1 * 8)), randint (2 ^ (3 * 8)) + # node + randint (2 ^ (3 * 8)) + # Set the four most significant bits (bits 12 through 15) of the # time_hi_and_version field to the 4-bit version number from # Section 4.1.3. %bytes.3 += 0x4000 + # Set the two most significant bits (bits 6 and 7) of the # clock_seq_hi_and_reserved to zero and one, respectively. %bytes.4 += 0xC0 @@ -52,5 +56,4 @@ test: seed random with 0 assume ((id of %x) != (id of [])) seed random - action [id of %, %'s id, %' id] %id_by_obj.% |
