Skip to content

Add bytecomp/opcodes.mli#2265

Merged
mshinwell merged 2 commits intoocaml:trunkfrom
mshinwell:opcodes_mli
Feb 26, 2019
Merged

Add bytecomp/opcodes.mli#2265
mshinwell merged 2 commits intoocaml:trunkfrom
mshinwell:opcodes_mli

Conversation

@mshinwell
Copy link
Copy Markdown
Contributor

This pull request adds a .mli file for bytecomp/opcodes.mli.

This is needed to simplify a patch I will post shortly to improve the packing mechanism used to build the various Dynlink libraries. (It will mean that every .ml file from compilerlibs that Dynlink depends on has a corresponding .mli file.)

In turn, that patch is needed for another patch I am preparing that overhauls the types used to represent various kinds of object file symbols throughout the compiler, which is in turn needed for Asm_directives, which is in turn needed for the gdb support.

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But as I mentioned to Mark, maybe ocamlc -i is a simpler way to go about it?

end;
if !print_opcodes then
List.iteri (fun i op -> printf "let op%s = %i\n" op i) opnames
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For symmetry with existing code, it would be better to write

if !print_opcodes_mli then
  List.iteri ...;
if !print_opnames then begin
  ...

"-opnames", Arg.Set print_opnames, " Dump opcode names";
"-opcodes", Arg.Set print_opcodes, " Dump opcode numbers";
"-opcodes-mli", Arg.Set print_opcodes_mli,
" Produce the .mli for opcodes.ml";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For symmetry the flags should be names -opcodes-ml and -opcodes-mli.

{
let print_opnames = ref false
let print_opcodes = ref false
let print_opcodes_mli = ref false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename print_opcodes by print_opcodes_ml.

@gasche
Copy link
Copy Markdown
Member

gasche commented Feb 26, 2019

Shouldn't names_of_... also show up in the .mli when its generation is enabled? (I don't remember what this is used for.)

@mshinwell
Copy link
Copy Markdown
Contributor Author

I think I'm going to try ocamlc -i instead, although in general, I think that generators should write the interface and the implementations themselves.

@nojb
Copy link
Copy Markdown
Contributor

nojb commented Feb 26, 2019

Shouldn't names_of_... also show up in the .mli when its generation is enabled? (I don't remember what this is used for.)

names_of_... is for different file, tools/opnames.ml, not bytecomp/opcodes.ml.

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I like the shorter patch better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants