Skip to content

Commit 6d8d0df

Browse files
committed
runtime: run code checks with biome in ci
Signed-off-by: Sora Morimoto <[email protected]>
1 parent c76f8cc commit 6d8d0df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6370
-5156
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.github/workflows/build.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,31 @@ jobs:
129129
steps:
130130
- name: Checkout tree
131131
uses: actions/checkout@v4
132-
133132
- name: Set-up OCaml
134133
uses: ocaml/setup-ocaml@v3
135134
with:
136135
ocaml-compiler: "5.2"
137136
dune-cache: true
138-
139137
- uses: ocaml/setup-ocaml/lint-opam@v3
140138

141139
lint-fmt:
142140
runs-on: ubuntu-latest
143141
steps:
144142
- name: Checkout tree
145143
uses: actions/checkout@v4
146-
147144
- name: Set-up OCaml
148145
uses: ocaml/setup-ocaml@v3
149146
with:
150147
ocaml-compiler: "5.2"
151148
dune-cache: true
152-
153149
- uses: ocaml/setup-ocaml/lint-fmt@v3
150+
151+
lint-runtime:
152+
runs-on: ubuntu-latest
153+
steps:
154+
- name: Checkout tree
155+
uses: actions/checkout@v4
156+
- name: Set-up Biome
157+
uses: biomejs/setup-biome@v2
158+
- name: Run biome
159+
run: biome ci

biome.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
3+
"files": {
4+
"include": ["runtime"]
5+
},
6+
"formatter": {
7+
"enabled": true,
8+
"useEditorconfig": true
9+
},
10+
"linter": {
11+
"enabled": false
12+
},
13+
"organizeImports": {
14+
"enabled": true
15+
},
16+
"vcs": {
17+
"clientKind": "git",
18+
"enabled": true,
19+
"useIgnoreFile": true
20+
}
21+
}

runtime/array.js

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,26 @@
1818
///////////// Array
1919

2020
//Provides: caml_array_sub mutable
21-
function caml_array_sub (a, i, len) {
22-
var a2 = new Array(len+1);
23-
a2[0]=0;
24-
for(var i2 = 1, i1= i+1; i2 <= len; i2++,i1++ ){
25-
a2[i2]=a[i1];
21+
function caml_array_sub(a, i, len) {
22+
var a2 = new Array(len + 1);
23+
a2[0] = 0;
24+
for (var i2 = 1, i1 = i + 1; i2 <= len; i2++, i1++) {
25+
a2[i2] = a[i1];
2626
}
2727
return a2;
2828
}
2929

3030
//Provides: caml_array_append mutable
3131
function caml_array_append(a1, a2) {
32-
var l1 = a1.length, l2 = a2.length;
33-
var l = l1+l2-1
32+
var l1 = a1.length,
33+
l2 = a2.length;
34+
var l = l1 + l2 - 1;
3435
var a = new Array(l);
3536
a[0] = 0;
36-
var i = 1,j = 1;
37-
for(;i<l1;i++) a[i]=a1[i];
38-
for(;i<l;i++,j++) a[i]=a2[j];
37+
var i = 1,
38+
j = 1;
39+
for (; i < l1; i++) a[i] = a1[i];
40+
for (; i < l; i++, j++) a[i] = a2[j];
3941
return a;
4042
}
4143

@@ -56,7 +58,7 @@ function caml_array_blit(a1, i1, a2, i2, len) {
5658
for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j];
5759
} else {
5860
for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j];
59-
};
61+
}
6062
return 0;
6163
}
6264

@@ -66,68 +68,69 @@ function caml_floatarray_blit(a1, i1, a2, i2, len) {
6668
for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j];
6769
} else {
6870
for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j];
69-
};
71+
}
7072
return 0;
7173
}
7274

7375
///////////// Pervasive
7476
//Provides: caml_array_set (mutable, const, mutable)
7577
//Requires: caml_array_bound_error
76-
function caml_array_set (array, index, newval) {
77-
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
78-
array[index+1]=newval; return 0;
78+
function caml_array_set(array, index, newval) {
79+
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
80+
array[index + 1] = newval;
81+
return 0;
7982
}
8083

8184
//Provides: caml_array_get mutable (mutable, const)
8285
//Requires: caml_array_bound_error
83-
function caml_array_get (array, index) {
84-
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
85-
return array[index+1];
86+
function caml_array_get(array, index) {
87+
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
88+
return array[index + 1];
8689
}
8790

8891
//Provides: caml_array_fill
89-
function caml_array_fill(array, ofs, len, v){
90-
for(var i = 0; i < len; i++){
91-
array[ofs+i+1] = v;
92+
function caml_array_fill(array, ofs, len, v) {
93+
for (var i = 0; i < len; i++) {
94+
array[ofs + i + 1] = v;
9295
}
9396
return 0;
9497
}
9598

9699
//Provides: caml_check_bound (mutable, const)
97100
//Requires: caml_array_bound_error
98-
function caml_check_bound (array, index) {
101+
function caml_check_bound(array, index) {
99102
if (index >>> 0 >= array.length - 1) caml_array_bound_error();
100103
return array;
101104
}
102105

103106
//Provides: caml_make_vect const (const, mutable)
104107
//Requires: caml_array_bound_error
105-
function caml_make_vect (len, init) {
108+
function caml_make_vect(len, init) {
106109
if (len < 0) caml_array_bound_error();
107-
var len = len + 1 | 0;
110+
var len = (len + 1) | 0;
108111
var b = new Array(len);
109-
b[0]=0;
112+
b[0] = 0;
110113
for (var i = 1; i < len; i++) b[i] = init;
111114
return b;
112115
}
113116

114117
//Provides: caml_make_float_vect const (const)
115118
//Requires: caml_array_bound_error
116-
function caml_make_float_vect(len){
119+
function caml_make_float_vect(len) {
117120
if (len < 0) caml_array_bound_error();
118-
var len = len + 1 | 0;
121+
var len = (len + 1) | 0;
119122
var b = new Array(len);
120-
b[0]=254;
123+
b[0] = 254;
121124
for (var i = 1; i < len; i++) b[i] = 0;
122-
return b
125+
return b;
123126
}
124127
//Provides: caml_floatarray_create const (const)
125128
//Requires: caml_array_bound_error
126-
function caml_floatarray_create(len){
129+
function caml_floatarray_create(len) {
127130
if (len < 0) caml_array_bound_error();
128-
var len = len + 1 | 0;
131+
var len = (len + 1) | 0;
129132
var b = new Array(len);
130-
b[0]=254;
133+
b[0] = 254;
131134
for (var i = 1; i < len; i++) b[i] = 0;
132-
return b
135+
return b;
133136
}

runtime/backtrace.js

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,80 @@
1515
// along with this program; if not, write to the Free Software
1616
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717

18-
1918
//Provides: caml_record_backtrace_env_flag
2019
//Requires: jsoo_sys_getenv
2120
var caml_record_backtrace_env_flag = FLAG("with-js-error");
2221

2322
(function () {
24-
var r = jsoo_sys_getenv("OCAMLRUNPARAM")
25-
if(r !== undefined){
23+
var r = jsoo_sys_getenv("OCAMLRUNPARAM");
24+
if (r !== undefined) {
2625
var l = r.split(",");
27-
for(var i = 0; i < l.length; i++){
28-
if(l[i] == "b") { caml_record_backtrace_env_flag = 1; break }
29-
else if (l[i].startsWith("b=")) {
30-
caml_record_backtrace_env_flag = +(l[i].slice(2)) }
31-
else continue;
26+
for (var i = 0; i < l.length; i++) {
27+
if (l[i] == "b") {
28+
caml_record_backtrace_env_flag = 1;
29+
break;
30+
} else if (l[i].startsWith("b=")) {
31+
caml_record_backtrace_env_flag = +l[i].slice(2);
32+
} else continue;
3233
}
3334
}
34-
}) ()
35+
})();
3536

3637
//Provides: caml_record_backtrace_runtime_flag
3738
//Requires: caml_record_backtrace_env_flag
3839
var caml_record_backtrace_runtime_flag = caml_record_backtrace_env_flag;
3940

40-
4141
//Provides: caml_ml_debug_info_status const
42-
function caml_ml_debug_info_status () { return 0; }
42+
function caml_ml_debug_info_status() {
43+
return 0;
44+
}
4345
//Provides: caml_backtrace_status
4446
//Requires: caml_record_backtrace_runtime_flag
45-
function caml_backtrace_status (_unit) { return caml_record_backtrace_runtime_flag ? 1 : 0; }
47+
function caml_backtrace_status(_unit) {
48+
return caml_record_backtrace_runtime_flag ? 1 : 0;
49+
}
4650
//Provides: caml_get_exception_backtrace const
47-
function caml_get_exception_backtrace () { return 0; }
51+
function caml_get_exception_backtrace() {
52+
return 0;
53+
}
4854
//Provides: caml_get_exception_raw_backtrace const
49-
function caml_get_exception_raw_backtrace () { return [0]; }
55+
function caml_get_exception_raw_backtrace() {
56+
return [0];
57+
}
5058
//Provides: caml_record_backtrace
5159
//Requires: caml_record_backtrace_runtime_flag
52-
function caml_record_backtrace (b) { caml_record_backtrace_runtime_flag = b; return 0; }
60+
function caml_record_backtrace(b) {
61+
caml_record_backtrace_runtime_flag = b;
62+
return 0;
63+
}
5364
//Provides: caml_convert_raw_backtrace const
54-
function caml_convert_raw_backtrace () { return [0]; }
65+
function caml_convert_raw_backtrace() {
66+
return [0];
67+
}
5568
//Provides: caml_raw_backtrace_length
56-
function caml_raw_backtrace_length() { return 0; }
69+
function caml_raw_backtrace_length() {
70+
return 0;
71+
}
5772
//Provides: caml_raw_backtrace_next_slot
58-
function caml_raw_backtrace_next_slot() { return 0 }
73+
function caml_raw_backtrace_next_slot() {
74+
return 0;
75+
}
5976
//Provides: caml_raw_backtrace_slot
6077
//Requires: caml_invalid_argument
61-
function caml_raw_backtrace_slot () {
78+
function caml_raw_backtrace_slot() {
6279
caml_invalid_argument("Printexc.get_raw_backtrace_slot: index out of bounds");
6380
}
6481
//Provides: caml_restore_raw_backtrace
65-
function caml_restore_raw_backtrace(exn, bt) { return 0 }
82+
function caml_restore_raw_backtrace(exn, bt) {
83+
return 0;
84+
}
6685
//Provides: caml_get_current_callstack const
67-
function caml_get_current_callstack () { return [0]; }
86+
function caml_get_current_callstack() {
87+
return [0];
88+
}
6889

6990
//Provides: caml_convert_raw_backtrace_slot
7091
//Requires: caml_failwith
71-
function caml_convert_raw_backtrace_slot(){
92+
function caml_convert_raw_backtrace_slot() {
7293
caml_failwith("caml_convert_raw_backtrace_slot");
7394
}

0 commit comments

Comments
 (0)