Skip to content

Commit

Permalink
runtime: run code checks with biome in ci
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Sep 16, 2024
1 parent c76f8cc commit 6d8d0df
Show file tree
Hide file tree
Showing 46 changed files with 6,370 additions and 5,156 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,31 @@ jobs:
steps:
- name: Checkout tree
uses: actions/checkout@v4

- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true

- uses: ocaml/setup-ocaml/lint-opam@v3

lint-fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4

- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
dune-cache: true

- uses: ocaml/setup-ocaml/lint-fmt@v3

lint-runtime:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Set-up Biome
uses: biomejs/setup-biome@v2
- name: Run biome
run: biome ci
21 changes: 21 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"files": {
"include": ["runtime"]
},
"formatter": {
"enabled": true,
"useEditorconfig": true
},
"linter": {
"enabled": false
},
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true
}
}
69 changes: 36 additions & 33 deletions runtime/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@
///////////// Array

//Provides: caml_array_sub mutable
function caml_array_sub (a, i, len) {
var a2 = new Array(len+1);
a2[0]=0;
for(var i2 = 1, i1= i+1; i2 <= len; i2++,i1++ ){
a2[i2]=a[i1];
function caml_array_sub(a, i, len) {
var a2 = new Array(len + 1);
a2[0] = 0;
for (var i2 = 1, i1 = i + 1; i2 <= len; i2++, i1++) {
a2[i2] = a[i1];
}
return a2;
}

//Provides: caml_array_append mutable
function caml_array_append(a1, a2) {
var l1 = a1.length, l2 = a2.length;
var l = l1+l2-1
var l1 = a1.length,
l2 = a2.length;
var l = l1 + l2 - 1;
var a = new Array(l);
a[0] = 0;
var i = 1,j = 1;
for(;i<l1;i++) a[i]=a1[i];
for(;i<l;i++,j++) a[i]=a2[j];
var i = 1,
j = 1;
for (; i < l1; i++) a[i] = a1[i];
for (; i < l; i++, j++) a[i] = a2[j];
return a;
}

Expand All @@ -56,7 +58,7 @@ function caml_array_blit(a1, i1, a2, i2, len) {
for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j];
} else {
for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j];
};
}
return 0;
}

Expand All @@ -66,68 +68,69 @@ function caml_floatarray_blit(a1, i1, a2, i2, len) {
for (var j = 1; j <= len; j++) a2[i2 + j] = a1[i1 + j];
} else {
for (var j = len; j >= 1; j--) a2[i2 + j] = a1[i1 + j];
};
}
return 0;
}

///////////// Pervasive
//Provides: caml_array_set (mutable, const, mutable)
//Requires: caml_array_bound_error
function caml_array_set (array, index, newval) {
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
array[index+1]=newval; return 0;
function caml_array_set(array, index, newval) {
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
array[index + 1] = newval;
return 0;
}

//Provides: caml_array_get mutable (mutable, const)
//Requires: caml_array_bound_error
function caml_array_get (array, index) {
if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error();
return array[index+1];
function caml_array_get(array, index) {
if (index < 0 || index >= array.length - 1) caml_array_bound_error();
return array[index + 1];
}

//Provides: caml_array_fill
function caml_array_fill(array, ofs, len, v){
for(var i = 0; i < len; i++){
array[ofs+i+1] = v;
function caml_array_fill(array, ofs, len, v) {
for (var i = 0; i < len; i++) {
array[ofs + i + 1] = v;
}
return 0;
}

//Provides: caml_check_bound (mutable, const)
//Requires: caml_array_bound_error
function caml_check_bound (array, index) {
function caml_check_bound(array, index) {
if (index >>> 0 >= array.length - 1) caml_array_bound_error();
return array;
}

//Provides: caml_make_vect const (const, mutable)
//Requires: caml_array_bound_error
function caml_make_vect (len, init) {
function caml_make_vect(len, init) {
if (len < 0) caml_array_bound_error();
var len = len + 1 | 0;
var len = (len + 1) | 0;
var b = new Array(len);
b[0]=0;
b[0] = 0;
for (var i = 1; i < len; i++) b[i] = init;
return b;
}

//Provides: caml_make_float_vect const (const)
//Requires: caml_array_bound_error
function caml_make_float_vect(len){
function caml_make_float_vect(len) {
if (len < 0) caml_array_bound_error();
var len = len + 1 | 0;
var len = (len + 1) | 0;
var b = new Array(len);
b[0]=254;
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = 0;
return b
return b;
}
//Provides: caml_floatarray_create const (const)
//Requires: caml_array_bound_error
function caml_floatarray_create(len){
function caml_floatarray_create(len) {
if (len < 0) caml_array_bound_error();
var len = len + 1 | 0;
var len = (len + 1) | 0;
var b = new Array(len);
b[0]=254;
b[0] = 254;
for (var i = 1; i < len; i++) b[i] = 0;
return b
return b;
}
65 changes: 43 additions & 22 deletions runtime/backtrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,80 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


//Provides: caml_record_backtrace_env_flag
//Requires: jsoo_sys_getenv
var caml_record_backtrace_env_flag = FLAG("with-js-error");

(function () {
var r = jsoo_sys_getenv("OCAMLRUNPARAM")
if(r !== undefined){
var r = jsoo_sys_getenv("OCAMLRUNPARAM");
if (r !== undefined) {
var l = r.split(",");
for(var i = 0; i < l.length; i++){
if(l[i] == "b") { caml_record_backtrace_env_flag = 1; break }
else if (l[i].startsWith("b=")) {
caml_record_backtrace_env_flag = +(l[i].slice(2)) }
else continue;
for (var i = 0; i < l.length; i++) {
if (l[i] == "b") {
caml_record_backtrace_env_flag = 1;
break;
} else if (l[i].startsWith("b=")) {
caml_record_backtrace_env_flag = +l[i].slice(2);
} else continue;
}
}
}) ()
})();

//Provides: caml_record_backtrace_runtime_flag
//Requires: caml_record_backtrace_env_flag
var caml_record_backtrace_runtime_flag = caml_record_backtrace_env_flag;


//Provides: caml_ml_debug_info_status const
function caml_ml_debug_info_status () { return 0; }
function caml_ml_debug_info_status() {
return 0;
}
//Provides: caml_backtrace_status
//Requires: caml_record_backtrace_runtime_flag
function caml_backtrace_status (_unit) { return caml_record_backtrace_runtime_flag ? 1 : 0; }
function caml_backtrace_status(_unit) {
return caml_record_backtrace_runtime_flag ? 1 : 0;
}
//Provides: caml_get_exception_backtrace const
function caml_get_exception_backtrace () { return 0; }
function caml_get_exception_backtrace() {
return 0;
}
//Provides: caml_get_exception_raw_backtrace const
function caml_get_exception_raw_backtrace () { return [0]; }
function caml_get_exception_raw_backtrace() {
return [0];
}
//Provides: caml_record_backtrace
//Requires: caml_record_backtrace_runtime_flag
function caml_record_backtrace (b) { caml_record_backtrace_runtime_flag = b; return 0; }
function caml_record_backtrace(b) {
caml_record_backtrace_runtime_flag = b;
return 0;
}
//Provides: caml_convert_raw_backtrace const
function caml_convert_raw_backtrace () { return [0]; }
function caml_convert_raw_backtrace() {
return [0];
}
//Provides: caml_raw_backtrace_length
function caml_raw_backtrace_length() { return 0; }
function caml_raw_backtrace_length() {
return 0;
}
//Provides: caml_raw_backtrace_next_slot
function caml_raw_backtrace_next_slot() { return 0 }
function caml_raw_backtrace_next_slot() {
return 0;
}
//Provides: caml_raw_backtrace_slot
//Requires: caml_invalid_argument
function caml_raw_backtrace_slot () {
function caml_raw_backtrace_slot() {
caml_invalid_argument("Printexc.get_raw_backtrace_slot: index out of bounds");
}
//Provides: caml_restore_raw_backtrace
function caml_restore_raw_backtrace(exn, bt) { return 0 }
function caml_restore_raw_backtrace(exn, bt) {
return 0;
}
//Provides: caml_get_current_callstack const
function caml_get_current_callstack () { return [0]; }
function caml_get_current_callstack() {
return [0];
}

//Provides: caml_convert_raw_backtrace_slot
//Requires: caml_failwith
function caml_convert_raw_backtrace_slot(){
function caml_convert_raw_backtrace_slot() {
caml_failwith("caml_convert_raw_backtrace_slot");
}
Loading

0 comments on commit 6d8d0df

Please sign in to comment.