Skip to content

FFI: finish implementing .isa ffi features#147

Open
alastairreid wants to merge 5 commits into
masterfrom
areid/fix-ffi
Open

FFI: finish implementing .isa ffi features#147
alastairreid wants to merge 5 commits into
masterfrom
areid/fix-ffi

Conversation

@alastairreid

Copy link
Copy Markdown

When I tried replacing the config.json files in tests, I found that the new .isa ffi language features were not fully implemented.
So this finishes the implementation (but leaves config.json support in place until others are updated).

See changes in tests for the new .isa way.

In several places, support for foreign types such as enums
and for foreign variables was incomplete and did not work
if you replaced the configuration json file with
the new .isa foreign import/export declarations.
Comment thread libISA/backend_c.ml
| AST.Decl_FunFFI (nm, is_export, x, _, _)
| AST.Decl_VarFFI (nm, is_export, x, _)
| AST.Decl_TypeFFI (nm, is_export, x, _)
when is_export == get_exports

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
when is_export == get_exports
when is_export = get_exports

Not a bug. But = is better by default (unless you optimize the comparison)

Comment thread libISA/backend_c.ml
let new_exports = List.filter_map (fun d ->
( match d with
| AST.Decl_FunFFI (nm, is_export, x, _, _)
| AST.Decl_VarFFI (nm, is_export, x, _)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Decl_VarFFI should be ignored here - it is handled in xform_foreign.ml

Suggested change
| AST.Decl_VarFFI (nm, is_export, x, _)

Comment thread libISA/isa_parser.mly
@@ -680,7 +680,7 @@ let ffi_definition :=
"var"; nm=STRINGLIT; "="; v=path; ";";
{ Decl_VarFFI(nm, is_export, v, Range($symbolstartpos, $endpos)) }
| "foreign"; is_export=ffi_direction;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What if I do foreign import type "E" = E; (import instead of export) by mistake, will it be simply ignored for now?

@nikolaykosarev nikolaykosarev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Left few comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants