Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Make output_kind local to Context
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Apr 17, 2015
1 parent 9abc1f8 commit b43c2f4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
34 changes: 22 additions & 12 deletions lib/gccjit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ type global_kind =
| GLOBAL_Internal
| GLOBAL_Imported

type output_kind =
OUTPUT_Assembler
| OUTPUT_Object_file
| OUTPUT_Dynamic_library
| OUTPUT_Executable

type type_kind =
TYPE_Void
| TYPE_Void_ptr
Expand Down Expand Up @@ -151,12 +145,6 @@ let global_kind = function
| GLOBAL_Imported -> GCC_JIT_GLOBAL_IMPORTED
| GLOBAL_Internal -> GCC_JIT_GLOBAL_INTERNAL

let output_kind = function
| OUTPUT_Assembler -> GCC_JIT_OUTPUT_KIND_ASSEMBLER
| OUTPUT_Object_file -> GCC_JIT_OUTPUT_KIND_OBJECT_FILE
| OUTPUT_Dynamic_library -> GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY
| OUTPUT_Executable -> GCC_JIT_OUTPUT_KIND_EXECUTABLE

let wrap1 ctx f x1 =
let y = f x1 in
match gcc_jit_context_get_first_error ctx with
Expand Down Expand Up @@ -270,6 +258,18 @@ module Context = struct
Gc.finalise gcc_jit_result_release res;
res

type output_kind =
Assembler
| Object_file
| Dynamic_library
| Executable

let output_kind = function
| Assembler -> GCC_JIT_OUTPUT_KIND_ASSEMBLER
| Object_file -> GCC_JIT_OUTPUT_KIND_OBJECT_FILE
| Dynamic_library -> GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY
| Executable -> GCC_JIT_OUTPUT_KIND_EXECUTABLE

let compile_to_file ctx kind path =
wrap3 ctx gcc_jit_context_compile_to_file ctx (output_kind kind) path
end
Expand Down Expand Up @@ -576,6 +576,11 @@ module type S = sig
| Keep_intermediates : bool context_option
val set_option : 'a context_option -> 'a -> unit
val compile : unit -> result
type output_kind =
Assembler
| Object_file
| Dynamic_library
| Executable
val compile_to_file : output_kind -> string -> unit
end

Expand Down Expand Up @@ -704,6 +709,11 @@ module Make () = struct
| Keep_intermediates : bool context_option
let set_option o v = set_option ctx o v
let compile () = compile ctx
type output_kind = Context.output_kind =
Assembler
| Object_file
| Dynamic_library
| Executable
let compile_to_file = compile_to_file ctx
end

Expand Down
35 changes: 20 additions & 15 deletions lib/gccjit.mli
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ type global_kind =
| GLOBAL_Internal
| GLOBAL_Imported

(** Kinds of ahead-of-time compilation, for use with
{!Context.compile_to_file}. *)
type output_kind =
OUTPUT_Assembler
(** Compile the context to an assembly file. *)

| OUTPUT_Object_file
(** Compile the context to an object file. *)

| OUTPUT_Dynamic_library
(** Compile the context to a dynamic library. *)

| OUTPUT_Executable
(** Compile the context to an executable. *)

type type_kind =
TYPE_Void
| TYPE_Void_ptr
Expand Down Expand Up @@ -325,6 +310,21 @@ module Context : sig
(** This calls into GCC and builds the code, returning a {!result}. See
{{!inmemory}In-memory compilation}. *)

(** Kinds of ahead-of-time compilation, for use with
{!compile_to_file}. *)
type output_kind =
Assembler
(** Compile the context to an assembly file. *)

| Object_file
(** Compile the context to an object file. *)

| Dynamic_library
(** Compile the context to a dynamic library. *)

| Executable
(** Compile the context to an executable. *)

val compile_to_file : context -> output_kind -> string -> unit
(** Compile the context to a file of the given kind. This can be called more
that once on a given context, although any errors that occur will block
Expand Down Expand Up @@ -830,6 +830,11 @@ module type S = sig
| Keep_intermediates : bool context_option
val set_option : 'a context_option -> 'a -> unit
val compile : unit -> result
type output_kind =
Assembler
| Object_file
| Dynamic_library
| Executable
val compile_to_file : output_kind -> string -> unit
end

Expand Down

0 comments on commit b43c2f4

Please sign in to comment.