Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions codegen/gen_mbt_table/gen_mbt_table.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn codegen_tokens(
///|
fn decompressor() -> @mbt_ast.Item {
let int = @mbt_common.named_type("Int", [])
let array = @mbt_common.named_type("FixedArray", [int])
let array = @mbt_common.named_type("ReadOnlyArray", [int])
let repeated : @mbt_ast.Block = {
statements: [
Let(
Expand Down Expand Up @@ -113,7 +113,7 @@ fn decompressor() -> @mbt_ast.Item {
),
],
result: Some(
@mbt_common.call("FixedArray::from_array", [Ident("output")]),
@mbt_common.call("ReadOnlyArray::from_array", [Ident("output")]),
),
},
result=array,
Expand Down Expand Up @@ -248,7 +248,7 @@ fn codegen(
}
}

let int_array = @mbt_common.named_type("FixedArray", [
let int_array = @mbt_common.named_type("ReadOnlyArray", [
@mbt_common.named_type("Int", []),
])
items.push(
Expand Down Expand Up @@ -280,6 +280,8 @@ fn codegen(
Global(
"yy_prod_act_table",
Some(
// New native lowering in v0.10.14+00f066f21 rejects static arrays of
// direct references to named functions. Keep this as FixedArray.
@mbt_common.named_type("FixedArray", [
@mbt_common.named_type("YYAction", []),
]),
Expand Down
10 changes: 5 additions & 5 deletions tests/compressed_table_test/parser.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,16 @@ fn yy_input(token : Token, _start_pos : Int, _end_pos : Int) -> (
}

///|
let yy_prod_lhs_table : FixedArray[Int] = [5, 5]
let yy_prod_lhs_table : ReadOnlyArray[Int] = [5, 5]

///|
let yy_prod_len_table : FixedArray[Int] = [1, 3]
let yy_prod_len_table : ReadOnlyArray[Int] = [1, 3]

///|
let yy_prod_act_table : FixedArray[YYAction] = [yy_action_0, yy_action_1]

///|
fn yy_decompress(input : FixedArray[Int]) -> FixedArray[Int] {
fn yy_decompress(input : ReadOnlyArray[Int]) -> ReadOnlyArray[Int] {
let output = []
let mut last = 0
for val in input {
Expand All @@ -214,11 +214,11 @@ fn yy_decompress(input : FixedArray[Int]) -> FixedArray[Int] {
last = val
}
}
FixedArray::from_array(output)
ReadOnlyArray::from_array(output)
}

///|
let yy_state_table : FixedArray[Int] = yy_decompress(
let yy_state_table : ReadOnlyArray[Int] = yy_decompress(
[
0, 7, 4, 0, -2, 3, 0, 1, 0, -7, 7, 4, 0, -2, 5, 0, -4, 6, 0, -3, 11, 0, -2,
11, 0, -3, 10, 0, -2, 10, 0, -3
Expand Down
6 changes: 3 additions & 3 deletions tests/nonassoc_test/table_array/parser.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ fn yy_input(token : Token, _start_pos : Int, _end_pos : Int) -> (
}

///|
let yy_prod_lhs_table : FixedArray[Int] = [6, 7, 7, 7, 7]
let yy_prod_lhs_table : ReadOnlyArray[Int] = [6, 7, 7, 7, 7]

///|
let yy_prod_len_table : FixedArray[Int] = [1, 1, 3, 3, 3]
let yy_prod_len_table : ReadOnlyArray[Int] = [1, 1, 3, 3, 3]

///|
let yy_prod_act_table : FixedArray[YYAction] = [
yy_action_0, yy_action_1, yy_action_2, yy_action_3, yy_action_4
]

///|
let yy_state_table : FixedArray[Int] = [
let yy_state_table : ReadOnlyArray[Int] = [
0, 11, 0, 0, 4, 0, 3, 12, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 4, 0, 0,
5, 0, 0, 0, 9, 7, 0, 6, 0, 0, 0, 22, 0, 22, 22, 0, 22, 0, 0, 0, 0, 11, 0, 0,
4, 0, 0, 8, 0, 16, 0, 0, 0, 0, 16, 0, 0, 0, 0, 11, 0, 0, 4, 0, 0, 10, 0, 15,
Expand Down
10 changes: 5 additions & 5 deletions tests/ocaml_jsoncst_test/ocaml.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -19756,7 +19756,7 @@ fn yy_input(token : Token, _start_pos : Int, _end_pos : Int) -> (
}

///|
let yy_prod_lhs_table : FixedArray[Int] = [
let yy_prod_lhs_table : ReadOnlyArray[Int] = [
120, 121, 122, 122, 122, 123, 123, 124, 124, 125, 126, 126, 127, 127, 127,
127, 128, 129, 130, 131, 131, 132, 132, 133, 133, 134, 134, 134, 134, 134,
134, 134, 134, 135, 135, 135, 135, 135, 135, 136, 136, 137, 137, 137, 138,
Expand Down Expand Up @@ -19810,7 +19810,7 @@ let yy_prod_lhs_table : FixedArray[Int] = [
]

///|
let yy_prod_len_table : FixedArray[Int] = [
let yy_prod_len_table : ReadOnlyArray[Int] = [
2, 2, 2, 2, 1, 2, 1, 0, 2, 2, 1, 3, 0, 2, 2, 2, 2, 2, 2, 2, 5, 1, 1, 2, 1, 1,
4, 5, 2, 3, 1, 2, 1, 5, 3, 5, 7, 9, 7, 3, 1, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 4, 2, 4, 2, 5, 1, 2, 6, 5, 1, 4, 5, 3, 3, 5, 3, 1, 2, 0,
Expand Down Expand Up @@ -19996,7 +19996,7 @@ let yy_prod_act_table : FixedArray[YYAction] = [
]

///|
fn yy_decompress(input : FixedArray[Int]) -> FixedArray[Int] {
fn yy_decompress(input : ReadOnlyArray[Int]) -> ReadOnlyArray[Int] {
let output = []
let mut last = 0
for val in input {
Expand All @@ -20010,11 +20010,11 @@ fn yy_decompress(input : FixedArray[Int]) -> FixedArray[Int] {
last = val
}
}
FixedArray::from_array(output)
ReadOnlyArray::from_array(output)
}

///|
let yy_state_table : FixedArray[Int] = yy_decompress(
let yy_state_table : ReadOnlyArray[Int] = yy_decompress(
[
0, -6, 7, 0, -5, 24, 0, -16, 577, 0, 13, 22, 0, -18, 25, 0, 568, 35, 0, 30,
26, 0, -2, 4, 0, -4, 14, 544, 0, -5, 18, 0, -12, 15, 0, -12, 560, 0, -3, 23,
Expand Down
Loading