Skip to content

Commit 4b56c53

Browse files
authored
feat(compiler)!: Custom Grain object files (#2104)
1 parent fbb08bf commit 4b56c53

File tree

396 files changed

+30687
-57102
lines changed

Some content is hidden

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

396 files changed

+30687
-57102
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ _build/
1717
.installed-pkgs
1818
notes.org
1919
node_modules/
20+
*.gro
2021
*.wasm
2122
*.wasm.map
2223
*.wat

cli/bin/grain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ program
179179
.action(function (file, options, program) {
180180
const success = exec.grainc(file, options, program);
181181
if (success) {
182-
const outFile = options.o ?? file.replace(/\.gr$/, ".gr.wasm");
182+
const outFile = options.o ?? file.replace(/\.gr$/, ".wasm");
183183
exec.grainrun(unprocessedArgs, outFile, options, program);
184184
}
185185
});

compiler/grainc/grainc.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ let compile_file = (name, outfile_arg) => {
3333
try({
3434
let outfile =
3535
Option.value(
36-
~default=Compile.default_output_filename(name),
36+
~default=Compile.default_wasm_filename(name),
3737
outfile_arg,
3838
);
3939
let hook =
4040
if (Grain_utils.Config.statically_link^) {
4141
Compile.stop_after_assembled;
4242
} else {
43-
Compile.stop_after_object_file_emitted;
43+
Compile.stop_after_object_emitted;
4444
};
4545
ignore(Compile.compile_file(~is_root_file=true, ~hook, ~outfile, name));
4646
}) {

compiler/src/codegen/comp_utils.re

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ let rec compile_const = (c): Literal.t => {
7979
| MConstU16(n) => Literal.int32(conv_short_int(n, Uint16Type))
8080
| MConstU32(n) => Literal.int32(conv_uint32(n))
8181
| MConstU64(n) => Literal.int64(conv_uint64(n))
82-
| MConstF32(n) => Literal.float32(conv_float32(n))
83-
| MConstF64(n) => Literal.float64(conv_float64(n))
82+
| MConstF32(n) => Literal.float32(conv_float32(Int64.float_of_bits(n)))
83+
| MConstF64(n) => Literal.float64(conv_float64(Int64.float_of_bits(n)))
8484
| MConstChar(c) => Literal.int32(conv_char(c))
8585
| MConstLiteral(MConstI8(n))
8686
| MConstLiteral(MConstI16(n))
@@ -90,8 +90,8 @@ let rec compile_const = (c): Literal.t => {
9090
| MConstLiteral(MConstU16(n))
9191
| MConstLiteral(MConstU32(n)) => Literal.int32(n)
9292
| MConstLiteral(MConstU64(n)) => Literal.int64(n)
93-
| MConstLiteral(MConstF32(n)) => Literal.float32(n)
94-
| MConstLiteral(MConstF64(n)) => Literal.float64(n)
93+
| MConstLiteral(MConstF32(n)) => Literal.float32(Int64.float_of_bits(n))
94+
| MConstLiteral(MConstF64(n)) => Literal.float64(Int64.float_of_bits(n))
9595
| MConstLiteral(MConstChar(c)) => Literal.int32(conv_char(c))
9696
};
9797
};
@@ -344,6 +344,3 @@ let write_universal_exports =
344344
)
345345
);
346346
};
347-
348-
let compiling_wasi_polyfill = name =>
349-
Option.is_some(Config.wasi_polyfill^) && Config.wasi_polyfill^ == name;

compiler/src/codegen/comp_utils.rei

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,3 @@ let get_exported_names:
6565

6666
let write_universal_exports:
6767
(Module.t, Cmi_format.cmi_infos, Hashtbl.t(string, string)) => unit;
68-
69-
let compiling_wasi_polyfill: option(string) => bool;

0 commit comments

Comments
 (0)