e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
581 lines
16 KiB
Plaintext
581 lines
16 KiB
Plaintext
fn __zero_std_parse_is_ascii_digit(value: Span<u8>) -> Bool {
|
|
return std.mem.len(value) > 0 && value[0] >= 48_u8 && value[0] <= 57_u8
|
|
}
|
|
|
|
fn __zero_std_parse_is_ascii_alpha(value: Span<u8>) -> Bool {
|
|
if std.mem.len(value) == 0 {
|
|
return false
|
|
}
|
|
let byte: u8 = value[0]
|
|
return (byte >= 65_u8 && byte <= 90_u8) || (byte >= 97_u8 && byte <= 122_u8)
|
|
}
|
|
|
|
fn __zero_std_parse_is_identifier_start(value: Span<u8>) -> Bool {
|
|
if std.mem.len(value) == 0 {
|
|
return false
|
|
}
|
|
let byte: u8 = value[0]
|
|
return __zero_std_parse_is_ascii_alpha(value) || byte == 95_u8
|
|
}
|
|
|
|
fn __zero_std_parse_is_whitespace(value: Span<u8>) -> Bool {
|
|
if std.mem.len(value) == 0 {
|
|
return false
|
|
}
|
|
let byte: u8 = value[0]
|
|
return byte == 32_u8 || byte == 9_u8 || byte == 10_u8 || byte == 13_u8
|
|
}
|
|
|
|
fn __zero_std_parse_scan_digits(value: Span<u8>) -> usize {
|
|
var index: usize = 0
|
|
while index < std.mem.len(value) && value[index] >= 48_u8 && value[index] <= 57_u8 {
|
|
index = index + 1
|
|
}
|
|
return index
|
|
}
|
|
|
|
fn __zero_std_parse_scan_whitespace(value: Span<u8>) -> usize {
|
|
var index: usize = 0
|
|
while index < std.mem.len(value) && (value[index] == 32_u8 || value[index] == 9_u8 || value[index] == 10_u8 || value[index] == 13_u8) {
|
|
index = index + 1
|
|
}
|
|
return index
|
|
}
|
|
|
|
fn __zero_std_parse_identifier_byte(byte: u8) -> Bool {
|
|
return (byte >= 65_u8 && byte <= 90_u8) || (byte >= 97_u8 && byte <= 122_u8) || (byte >= 48_u8 && byte <= 57_u8) || byte == 95_u8
|
|
}
|
|
|
|
fn __zero_std_parse_scan_identifier(value: Span<u8>) -> usize {
|
|
if !__zero_std_parse_is_identifier_start(value) {
|
|
return 0
|
|
}
|
|
var index: usize = 1
|
|
while index < std.mem.len(value) && __zero_std_parse_identifier_byte(value[index]) {
|
|
index = index + 1
|
|
}
|
|
return index
|
|
}
|
|
|
|
fn __zero_std_parse_scan_until_byte(value: Span<u8>, byte: u8) -> usize {
|
|
var index: usize = 0
|
|
while index < std.mem.len(value) {
|
|
if value[index] == byte {
|
|
return index
|
|
}
|
|
index = index + 1
|
|
}
|
|
return std.mem.len(value)
|
|
}
|
|
|
|
fn __zero_std_parse_token_ascii(value: Span<u8>) -> Span<u8> {
|
|
let start: usize = __zero_std_parse_scan_whitespace(value)
|
|
var end: usize = start
|
|
while end < std.mem.len(value) && !(value[end] == 32_u8 || value[end] == 9_u8 || value[end] == 10_u8 || value[end] == 13_u8) {
|
|
end = end + 1
|
|
}
|
|
return value[start..end]
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u32_max(value: Span<u8>, max: u32) -> Maybe<u32> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var total: u32 = 0
|
|
while index < std.mem.len(value) {
|
|
let byte: u8 = value[index]
|
|
if byte < 48_u8 || byte > 57_u8 {
|
|
return null
|
|
}
|
|
let digit: u32 = (byte - 48_u8) as u32
|
|
if total > (max - digit) / 10_u32 {
|
|
return null
|
|
}
|
|
total = total * 10_u32 + digit
|
|
index = index + 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
fn __zero_std_parse_digit_value(byte: u8) -> Maybe<u32> {
|
|
if byte >= 48_u8 && byte <= 57_u8 {
|
|
return (byte - 48_u8) as u32
|
|
}
|
|
if byte >= 65_u8 && byte <= 90_u8 {
|
|
return ((byte - 65_u8) as u32) + 10_u32
|
|
}
|
|
if byte >= 97_u8 && byte <= 122_u8 {
|
|
return ((byte - 97_u8) as u32) + 10_u32
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u32_base_max(value: Span<u8>, base: u32, max: u32) -> Maybe<u32> {
|
|
if std.mem.len(value) == 0 || base < 2_u32 || base > 36_u32 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var total: u32 = 0
|
|
while index < std.mem.len(value) {
|
|
let digit: Maybe<u32> = __zero_std_parse_digit_value(value[index])
|
|
if !digit.has || digit.value >= base {
|
|
return null
|
|
}
|
|
if total > (max - digit.value) / base {
|
|
return null
|
|
}
|
|
total = total * base + digit.value
|
|
index = index + 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u64_base_max(value: Span<u8>, base: u32, max: u64) -> Maybe<u64> {
|
|
if std.mem.len(value) == 0 || base < 2_u32 || base > 36_u32 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var total: u64 = 0_u64
|
|
let u64_base: u64 = base as u64
|
|
while index < std.mem.len(value) {
|
|
let digit: Maybe<u32> = __zero_std_parse_digit_value(value[index])
|
|
if !digit.has || digit.value >= base {
|
|
return null
|
|
}
|
|
let u64_digit: u64 = digit.value as u64
|
|
if total > (max - u64_digit) / u64_base {
|
|
return null
|
|
}
|
|
total = total * u64_base + u64_digit
|
|
index = index + 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u32_base(value: Span<u8>, base: u32) -> Maybe<u32> {
|
|
return __zero_std_parse_parse_u32_base_max(value, base, 4294967295_u32)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u64_base(value: Span<u8>, base: u32) -> Maybe<u64> {
|
|
return __zero_std_parse_parse_u64_base_max(value, base, 18446744073709551615_u64)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_usize_base(value: Span<u8>, base: u32) -> Maybe<usize> {
|
|
if std.mem.len(value) == 0 || base < 2_u32 || base > 36_u32 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var total: usize = 0
|
|
let max: usize = 18446744073709551615
|
|
let usize_base: usize = base as usize
|
|
while index < std.mem.len(value) {
|
|
let digit: Maybe<u32> = __zero_std_parse_digit_value(value[index])
|
|
if !digit.has || digit.value >= base {
|
|
return null
|
|
}
|
|
let usize_digit: usize = digit.value as usize
|
|
if total > (max - usize_digit) / usize_base {
|
|
return null
|
|
}
|
|
total = total * usize_base + usize_digit
|
|
index = index + 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i64_base(value: Span<u8>, base: u32) -> Maybe<i64> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var start: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 {
|
|
negative = true
|
|
start = 1
|
|
} else if value[0] == 43_u8 {
|
|
start = 1
|
|
}
|
|
if start == std.mem.len(value) {
|
|
return null
|
|
}
|
|
let limit: u64 = 9223372036854775808_u64
|
|
let parsed: Maybe<u64> = __zero_std_parse_parse_u64_base_max(value[start..], base, limit)
|
|
if !parsed.has {
|
|
return null
|
|
}
|
|
if negative {
|
|
if parsed.value == limit {
|
|
return 0_i64 - 9223372036854775807_i64 - 1_i64
|
|
}
|
|
return 0_i64 - (parsed.value as i64)
|
|
}
|
|
if parsed.value > 9223372036854775807_u64 {
|
|
return null
|
|
}
|
|
return parsed.value as i64
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i32_base(value: Span<u8>, base: u32) -> Maybe<i32> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var start: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 {
|
|
negative = true
|
|
start = 1
|
|
} else if value[0] == 43_u8 {
|
|
start = 1
|
|
}
|
|
if start == std.mem.len(value) {
|
|
return null
|
|
}
|
|
let limit: u32 = 2147483648_u32
|
|
let parsed: Maybe<u32> = __zero_std_parse_parse_u32_base_max(value[start..], base, limit)
|
|
if !parsed.has {
|
|
return null
|
|
}
|
|
if negative {
|
|
if parsed.value == limit {
|
|
return 0 - 2147483647 - 1
|
|
}
|
|
return 0 - (parsed.value as i32)
|
|
}
|
|
if parsed.value > 2147483647_u32 {
|
|
return null
|
|
}
|
|
return parsed.value as i32
|
|
}
|
|
|
|
fn __zero_std_parse_prefixed_base(value: Span<u8>) -> u32 {
|
|
if std.mem.len(value) >= 2 && value[0] == 48_u8 {
|
|
if value[1] == 120_u8 || value[1] == 88_u8 {
|
|
return 16_u32
|
|
}
|
|
if value[1] == 98_u8 || value[1] == 66_u8 {
|
|
return 2_u32
|
|
}
|
|
if value[1] == 111_u8 || value[1] == 79_u8 {
|
|
return 8_u32
|
|
}
|
|
}
|
|
return 10_u32
|
|
}
|
|
|
|
fn __zero_std_parse_prefixed_digits(value: Span<u8>) -> Span<u8> {
|
|
if std.mem.len(value) >= 2 && value[0] == 48_u8 {
|
|
if value[1] == 120_u8 || value[1] == 88_u8 || (value[1] == 98_u8 || value[1] == 66_u8) || (value[1] == 111_u8 || value[1] == 79_u8) {
|
|
return value[2..]
|
|
}
|
|
}
|
|
return value
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u32_prefix(value: Span<u8>) -> Maybe<u32> {
|
|
let base: u32 = __zero_std_parse_prefixed_base(value)
|
|
let digits: Span<u8> = __zero_std_parse_prefixed_digits(value)
|
|
return __zero_std_parse_parse_u32_base(digits, base)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u64_prefix(value: Span<u8>) -> Maybe<u64> {
|
|
let base: u32 = __zero_std_parse_prefixed_base(value)
|
|
let digits: Span<u8> = __zero_std_parse_prefixed_digits(value)
|
|
return __zero_std_parse_parse_u64_base(digits, base)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_usize_prefix(value: Span<u8>) -> Maybe<usize> {
|
|
let base: u32 = __zero_std_parse_prefixed_base(value)
|
|
let digits: Span<u8> = __zero_std_parse_prefixed_digits(value)
|
|
return __zero_std_parse_parse_usize_base(digits, base)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i64_prefix(value: Span<u8>) -> Maybe<i64> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var start: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 || value[0] == 43_u8 {
|
|
negative = value[0] == 45_u8
|
|
start = 1
|
|
}
|
|
if start == std.mem.len(value) {
|
|
return null
|
|
}
|
|
let base: u32 = __zero_std_parse_prefixed_base(value[start..])
|
|
let digits: Span<u8> = __zero_std_parse_prefixed_digits(value[start..])
|
|
let limit: u64 = 9223372036854775808_u64
|
|
let parsed: Maybe<u64> = __zero_std_parse_parse_u64_base_max(digits, base, limit)
|
|
if !parsed.has {
|
|
return null
|
|
}
|
|
if negative {
|
|
if parsed.value == limit {
|
|
return 0_i64 - 9223372036854775807_i64 - 1_i64
|
|
}
|
|
return 0_i64 - (parsed.value as i64)
|
|
}
|
|
if parsed.value > 9223372036854775807_u64 {
|
|
return null
|
|
}
|
|
return parsed.value as i64
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i32_prefix(value: Span<u8>) -> Maybe<i32> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var start: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 || value[0] == 43_u8 {
|
|
negative = value[0] == 45_u8
|
|
start = 1
|
|
}
|
|
if start == std.mem.len(value) {
|
|
return null
|
|
}
|
|
let base: u32 = __zero_std_parse_prefixed_base(value[start..])
|
|
let digits: Span<u8> = __zero_std_parse_prefixed_digits(value[start..])
|
|
let limit: u32 = 2147483648_u32
|
|
let parsed: Maybe<u32> = __zero_std_parse_parse_u32_base_max(digits, base, limit)
|
|
if !parsed.has {
|
|
return null
|
|
}
|
|
if negative {
|
|
if parsed.value == limit {
|
|
return 0 - 2147483647 - 1
|
|
}
|
|
return 0 - (parsed.value as i32)
|
|
}
|
|
if parsed.value > 2147483647_u32 {
|
|
return null
|
|
}
|
|
return parsed.value as i32
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u8(value: Span<u8>) -> Maybe<u8> {
|
|
let parsed: Maybe<u32> = __zero_std_parse_parse_u32_max(value, 255_u32)
|
|
if parsed.has {
|
|
return parsed.value as u8
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u16(value: Span<u8>) -> Maybe<u16> {
|
|
let parsed: Maybe<u32> = __zero_std_parse_parse_u32_max(value, 65535_u32)
|
|
if parsed.has {
|
|
return parsed.value as u16
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u32(value: Span<u8>) -> Maybe<u32> {
|
|
return __zero_std_parse_parse_u32_max(value, 4294967295_u32)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_u64(value: Span<u8>) -> Maybe<u64> {
|
|
return __zero_std_parse_parse_u64_base(value, 10_u32)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_usize(value: Span<u8>) -> Maybe<usize> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var total: usize = 0
|
|
let max: usize = 18446744073709551615
|
|
while index < std.mem.len(value) {
|
|
let byte: u8 = value[index]
|
|
if byte < 48_u8 || byte > 57_u8 {
|
|
return null
|
|
}
|
|
let digit: usize = (byte - 48_u8) as usize
|
|
if total > (max - digit) / 10 {
|
|
return null
|
|
}
|
|
total = total * 10 + digit
|
|
index = index + 1
|
|
}
|
|
return total
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i64(value: Span<u8>) -> Maybe<i64> {
|
|
return __zero_std_parse_parse_i64_base(value, 10_u32)
|
|
}
|
|
|
|
fn __zero_std_parse_parse_i32(value: Span<u8>) -> Maybe<i32> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var start: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 {
|
|
negative = true
|
|
start = 1
|
|
} else if value[0] == 43_u8 {
|
|
start = 1
|
|
}
|
|
if start == std.mem.len(value) {
|
|
return null
|
|
}
|
|
let limit: u32 = 2147483648_u32
|
|
let parsed: Maybe<u32> = __zero_std_parse_parse_u32_max(value[start..], limit)
|
|
if !parsed.has {
|
|
return null
|
|
}
|
|
if negative {
|
|
if parsed.value == limit {
|
|
return 0 - 2147483647 - 1
|
|
}
|
|
return 0 - (parsed.value as i32)
|
|
}
|
|
if parsed.value > 2147483647_u32 {
|
|
return null
|
|
}
|
|
return parsed.value as i32
|
|
}
|
|
|
|
fn __zero_std_parse_parse_bool(value: Span<u8>) -> Maybe<Bool> {
|
|
if std.mem.eql(value, "true") {
|
|
return true
|
|
}
|
|
if std.mem.eql(value, "false") {
|
|
return false
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_duration_unit_ns(value: Span<u8>) -> Maybe<u64> {
|
|
if std.mem.eql(value, "ns") {
|
|
return 1_u64
|
|
}
|
|
if std.mem.eql(value, "us") {
|
|
return 1000_u64
|
|
}
|
|
if std.mem.eql(value, "ms") {
|
|
return 1000000_u64
|
|
}
|
|
if std.mem.eql(value, "s") {
|
|
return 1000000000_u64
|
|
}
|
|
if std.mem.eql(value, "m") {
|
|
return 60000000000_u64
|
|
}
|
|
if std.mem.eql(value, "h") {
|
|
return 3600000000000_u64
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_parse_duration(value: Span<u8>) -> Maybe<Duration> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
var negative: Bool = false
|
|
if value[0] == 45_u8 || value[0] == 43_u8 {
|
|
negative = value[0] == 45_u8
|
|
index = 1
|
|
}
|
|
if index == std.mem.len(value) {
|
|
return null
|
|
}
|
|
var max: u64 = 9223372036854775807_u64
|
|
if negative {
|
|
max = 9223372036854775808_u64
|
|
}
|
|
var total: u64 = 0_u64
|
|
var saw_component: Bool = false
|
|
while index < std.mem.len(value) {
|
|
let digit_start: usize = index
|
|
while index < std.mem.len(value) && (value[index] >= 48_u8 && value[index] <= 57_u8) {
|
|
index = index + 1
|
|
}
|
|
if digit_start == index {
|
|
return null
|
|
}
|
|
let amount: Maybe<u64> = __zero_std_parse_parse_u64(value[digit_start..index])
|
|
if !amount.has {
|
|
return null
|
|
}
|
|
let unit_start: usize = index
|
|
while index < std.mem.len(value) && (value[index] < 48_u8 || value[index] > 57_u8) {
|
|
index = index + 1
|
|
}
|
|
if unit_start == index {
|
|
return null
|
|
}
|
|
let multiplier: Maybe<u64> = __zero_std_parse_duration_unit_ns(value[unit_start..index])
|
|
if !multiplier.has {
|
|
return null
|
|
}
|
|
if amount.value > (max - total) / multiplier.value {
|
|
return null
|
|
}
|
|
total = total + amount.value * multiplier.value
|
|
saw_component = true
|
|
}
|
|
if !saw_component {
|
|
return null
|
|
}
|
|
if negative {
|
|
if total == 9223372036854775808_u64 {
|
|
return std.time.ns(0_i64 - 9223372036854775807_i64 - 1_i64)
|
|
}
|
|
return std.time.ns(0_i64 - (total as i64))
|
|
}
|
|
return std.time.ns(total as i64)
|
|
}
|
|
|
|
fn __zero_std_parse_byte_size_multiplier(unit: Span<u8>) -> Maybe<usize> {
|
|
if std.mem.len(unit) == 0 || std.mem.eql(unit, "B") {
|
|
return 1_usize
|
|
}
|
|
if std.mem.eql(unit, "KB") {
|
|
return 1000_usize
|
|
}
|
|
if std.mem.eql(unit, "MB") {
|
|
return 1000000_usize
|
|
}
|
|
if std.mem.eql(unit, "GB") {
|
|
return 1000000000_usize
|
|
}
|
|
if std.mem.eql(unit, "KiB") {
|
|
return 1024_usize
|
|
}
|
|
if std.mem.eql(unit, "MiB") {
|
|
return 1048576_usize
|
|
}
|
|
if std.mem.eql(unit, "GiB") {
|
|
return 1073741824_usize
|
|
}
|
|
return null
|
|
}
|
|
|
|
fn __zero_std_parse_parse_byte_size(value: Span<u8>) -> Maybe<usize> {
|
|
if std.mem.len(value) == 0 {
|
|
return null
|
|
}
|
|
var index: usize = 0
|
|
while index < std.mem.len(value) && (value[index] >= 48_u8 && value[index] <= 57_u8) {
|
|
index = index + 1
|
|
}
|
|
if index == 0 {
|
|
return null
|
|
}
|
|
let amount: Maybe<usize> = __zero_std_parse_parse_usize(value[..index])
|
|
if !amount.has {
|
|
return null
|
|
}
|
|
let multiplier: Maybe<usize> = __zero_std_parse_byte_size_multiplier(value[index..])
|
|
if !multiplier.has {
|
|
return null
|
|
}
|
|
let max: usize = 18446744073709551615
|
|
if amount.value > max / multiplier.value {
|
|
return null
|
|
}
|
|
return amount.value * multiplier.value
|
|
}
|