Skip to content

Commit dc11b3f

Browse files
authored
Merge e5a2dd2 into e7e5495
2 parents e7e5495 + e5a2dd2 commit dc11b3f

File tree

13 files changed

+49
-90
lines changed

13 files changed

+49
-90
lines changed

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: moon info
4141
run: |
42-
moon info
42+
moon info --target wasm,wasm-gc,js,native
4343
git diff --exit-code
4444
4545
- name: Set ulimit and run moon test
@@ -206,7 +206,7 @@ jobs:
206206

207207
- name: moon info
208208
run: |
209-
moon info
209+
moon info --target wasm,wasm-gc,js,native
210210
git diff
211211
212212
- name: check core size
@@ -261,7 +261,7 @@ jobs:
261261

262262
- name: moon info
263263
run: |
264-
moon info
264+
moon info --target wasm,wasm-gc,js,native
265265
git diff
266266
267267
- name: check core size

array/array_js.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
///|
16-
type JSArray
16+
priv type JSArray
1717

1818
///|
1919
fn JSArray::ofAnyArray[T](array : Array[T]) -> JSArray = "%identity"

builtin/arraycore_js.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// generic type parameters of extern ffi
1818

1919
///|
20-
type JSValue
20+
priv type JSValue
2121

2222
///|
2323
fn JSValue::ofAny[T](array : T) -> JSValue = "%identity"
@@ -26,7 +26,7 @@ fn JSValue::ofAny[T](array : T) -> JSValue = "%identity"
2626
fn JSValue::toAny[T](self : JSValue) -> T = "%identity"
2727

2828
///|
29-
type JSArray
29+
priv type JSArray
3030

3131
///|
3232
fn JSArray::ofAnyArray[T](array : Array[T]) -> JSArray = "%identity"

builtin/bigint_js.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub fn pow(self : BigInt, exponent : BigInt, modulus? : BigInt) -> BigInt {
190190
}
191191

192192
///|
193-
pub extern "js" fn to_byte(self : BigInt) -> Byte =
193+
extern "js" fn to_byte(self : BigInt) -> Byte =
194194
#|(x) => Number(BigInt.asUintN(8, x)) | 0
195195

196196
///|

builtin/int64_js.mbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn MyInt64::op_mul(self : MyInt64, other : MyInt64) -> MyInt64 {
103103
}
104104

105105
///|
106-
struct Int64WasmHelper {
106+
priv struct Int64WasmHelper {
107107
div_s : (Int, Int, Int, Int) -> Int
108108
div_u : (Int, Int, Int, Int) -> Int
109109
rem_s : (Int, Int, Int, Int) -> Int
@@ -502,7 +502,7 @@ pub fn Int64::to_int(self : Int64) -> Int {
502502
}
503503

504504
///|
505-
pub fn Int64::to_uint(self : Int64) -> UInt {
505+
fn Int64::to_uint(self : Int64) -> UInt {
506506
MyInt64::from_int64(self).to_uint()
507507
}
508508

@@ -566,7 +566,7 @@ pub fn Double::convert_uint64(value : UInt64) -> Double {
566566
}
567567

568568
///|
569-
pub fn Double::convert_int64(value : Int64) -> Double {
569+
fn Double::convert_int64(value : Int64) -> Double {
570570
MyInt64::convert_to_double(MyInt64::from_int64(value))
571571
}
572572

env/sys.mbt renamed to env/env.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
///|
1616
/// Get the command line arguments passed to the program.
1717
pub fn args() -> Array[String] {
18-
@ffi.get_cli_args()
18+
get_cli_args_internal()
1919
}
2020

2121
///|
2222
/// Get the current time in milliseconds since the Unix epoch.
2323
pub fn now() -> UInt64 {
24-
@ffi.now()
24+
now_internal()
2525
}

env/internal/ffi/sys_js.mbt renamed to env/env_js.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
///|
16-
pub extern "js" fn get_cli_args() -> Array[String] =
16+
extern "js" fn get_cli_args_internal() -> Array[String] =
1717
#| function() {
1818
#| if (typeof process !== "undefined" && typeof process.argv !== "undefined") {
1919
#| return process.argv;
@@ -23,7 +23,7 @@ pub extern "js" fn get_cli_args() -> Array[String] =
2323
#| }
2424

2525
///|
26-
pub extern "js" fn now() -> UInt64 =
26+
extern "js" fn now_internal() -> UInt64 =
2727
#| function() {
2828
#| const nowMs = Date.now();
2929
#| return ({ hi : Number(BigInt(nowMs) >> 32n), lo : nowMs & 0xFFFFFFFF });

env/internal/ffi/sys_native.mbt renamed to env/env_native.mbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
// limitations under the License.
1414

1515
///|
16-
fn internal_get_cli_args() -> FixedArray[Bytes] = "$moonbit.get_cli_args"
16+
fn get_cli_args_ffi() -> FixedArray[Bytes] = "$moonbit.get_cli_args"
1717

1818
///|
19-
pub fn get_cli_args() -> Array[String] {
19+
fn get_cli_args_internal() -> Array[String] {
2020
Array::from_fixed_array(
21-
internal_get_cli_args().map(fn {
21+
get_cli_args_ffi().map(fn {
2222
// Here we assume that the CLI arguments are encoded in well-formed UTF-8.
2323
arg => utf8_bytes_to_mbt_string(arg)
2424
}),
@@ -72,6 +72,6 @@ fn utf8_bytes_to_mbt_string(bytes : Bytes) -> String {
7272
extern "c" fn time(ptr : Int) -> UInt64 = "time"
7373

7474
///|
75-
pub fn now() -> UInt64 {
75+
fn now_internal() -> UInt64 {
7676
time(0)
7777
}

env/env_test.mbt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2025 International Digital Economy Academy
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
test {
16+
let args = @env.args()
17+
assert_true!(args.length() != 0)
18+
}

env/internal/ffi/sys_wasm.mbt renamed to env/env_wasm.mbt

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,10 @@
1313
// limitations under the License.
1414

1515
///|
16-
pub(all) type XStringCreateHandle
16+
priv type XStringReadHandle
1717

1818
///|
19-
pub(all) type XStringReadHandle
20-
21-
///|
22-
pub(all) type XExternString
23-
24-
///|
25-
fn begin_create_string() -> XStringCreateHandle = "__moonbit_fs_unstable" "begin_create_string"
26-
27-
///|
28-
fn string_append_char(handle : XStringCreateHandle, ch : Char) = "__moonbit_fs_unstable" "string_append_char"
29-
30-
///|
31-
fn finish_create_string(handle : XStringCreateHandle) -> XExternString = "__moonbit_fs_unstable" "finish_create_string"
32-
33-
///|
34-
pub fn string_to_extern(s : String) -> XExternString {
35-
let handle = begin_create_string()
36-
for i = 0; i < s.length(); i = i + 1 {
37-
string_append_char(handle, s[i])
38-
}
39-
finish_create_string(handle)
40-
}
19+
priv type XExternString
4120

4221
///|
4322
fn begin_read_string(s : XExternString) -> XStringReadHandle = "__moonbit_fs_unstable" "begin_read_string"
@@ -50,7 +29,7 @@ fn string_read_char(handle : XStringReadHandle) -> Int = "__moonbit_fs_unstable"
5029
fn finish_read_string(handle : XStringReadHandle) = "__moonbit_fs_unstable" "finish_read_string"
5130

5231
///|
53-
pub fn string_from_extern(e : XExternString) -> String {
32+
fn string_from_extern(e : XExternString) -> String {
5433
let buf = StringBuilder::new()
5534
let handle = begin_read_string(e)
5635
while true {
@@ -66,10 +45,10 @@ pub fn string_from_extern(e : XExternString) -> String {
6645
}
6746

6847
///|
69-
pub(all) type XStringArrayReadHandle
48+
priv type XStringArrayReadHandle
7049

7150
///|
72-
pub(all) type XExternStringArray
51+
priv type XExternStringArray
7352

7453
///|
7554
fn begin_read_string_array(sa : XExternStringArray) -> XStringArrayReadHandle = "__moonbit_fs_unstable" "begin_read_string_array"
@@ -81,7 +60,7 @@ fn string_array_read_string(handle : XStringArrayReadHandle) -> XExternString =
8160
fn finish_read_string_array(handle : XStringArrayReadHandle) = "__moonbit_fs_unstable" "finish_read_string_array"
8261

8362
///|
84-
pub fn string_array_from_extern(e : XExternStringArray) -> Array[String] {
63+
fn string_array_from_extern(e : XExternStringArray) -> Array[String] {
8564
let buf = Array::new()
8665
let handle = begin_read_string_array(e)
8766
while true {
@@ -99,7 +78,7 @@ pub fn string_array_from_extern(e : XExternStringArray) -> Array[String] {
9978
}
10079

10180
///|
102-
pub fn get_cli_args() -> Array[String] {
81+
fn get_cli_args_internal() -> Array[String] {
10382
let args = get_cli_args_ffi()
10483
string_array_from_extern(args)
10584
}
@@ -108,4 +87,4 @@ pub fn get_cli_args() -> Array[String] {
10887
fn get_cli_args_ffi() -> XExternStringArray = "__moonbit_fs_unstable" "args_get"
10988

11089
///|
111-
pub fn now() -> UInt64 = "__moonbit_time_unstable" "now"
90+
fn now_internal() -> UInt64 = "__moonbit_time_unstable" "now"

0 commit comments

Comments
 (0)