Skip to content

<c-void>, warning removal, external linkage for variables #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions melange-parser/alignment.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ define function do-coalesce-members (decl :: <structured-type-declaration>)
composite := make(<coalesced-bitfields>, name: name, dylan-name: name);
result := pair(composite, result);
end if;
decl-type.composite-field := composite;
decl-type.start-bit := composite.bit-size;
//unused decl-type.composite-field := composite;
//unused decl-type.start-bit := composite.bit-size;
composite.fields := add!(composite.fields, member);
let size = composite.bit-size + decl-type.bits-in-field;
if (size > composite.type.unix-type-size)
Expand Down
8 changes: 4 additions & 4 deletions melange-parser/c-decl-state.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ copyright: see below
define abstract class <parse-state> (<object>)
slot objects :: <table>;
slot structs :: <table>;
slot tokenizer :: <tokenizer>, required-init-keyword: #"tokenizer";
constant slot tokenizer :: <tokenizer>, required-init-keyword: #"tokenizer";
slot pointers :: <table>;
slot vectors :: <table>;
slot verbose :: <boolean>;
Expand All @@ -91,11 +91,11 @@ define class <parse-file-state> (<parse-state>)
// ".h" file.
slot declarations :: <deque> = make(<deque>);
slot current-file :: <string> = "<top-level>";
slot recursive-files-stack :: <deque> = make(<deque>);
constant slot recursive-files-stack :: <deque> = make(<deque>);
// maps a filename into a sequence of files which it recursively includes
slot recursive-include-table :: <table> = make(<string-table>);
constant slot recursive-include-table :: <table> = make(<string-table>);
// maps a filename into a sequence of declarations from that file
slot recursive-declaration-table :: <table> = make(<string-table>);
constant slot recursive-declaration-table :: <table> = make(<string-table>);
end class;

define method initialize (value :: <parse-file-state>, #key)
Expand Down
19 changes: 19 additions & 0 deletions melange-parser/c-decl-write-c-ffi.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ define method write-declaration (decl :: <declaration>, back-end :: <c-ffi-back-
format(back-end.stream, " /* Ignoring declaration for %= %=*/\n", decl, decl.dylan-name)
end;

define method write-declaration (decl :: <variable-declaration>, back-end :: <c-ffi-back-end>)
=> ()
register-written-name(back-end.written-names, decl.dylan-name, decl);
let stream = back-end.stream;
if ( instance?(decl.type, <struct-declaration>) | instance?(decl.type, <union-declaration>) )
format(stream, "define c-address %s :: %s\n", decl.dylan-name, decl.type.dylan-name);
else
format(stream, "define c-variable %s :: %s\n", decl.dylan-name, decl.mapped-name);
end;
if ( decl.read-only )
format(stream, " setter: #f,\n");
end;
if ( decl.external-linkage == #t )
format(stream, " import: #t,\n");
end;
format(stream, " c-name: \"%s\"\n", decl.simple-name);
format(stream, "end;\n\n");
end;

define method write-declaration (decl :: <struct-declaration>, back-end :: <c-ffi-back-end>)
=> ();
register-written-name(back-end.written-names, decl.dylan-name, decl);
Expand Down
2 changes: 1 addition & 1 deletion melange-parser/c-decl-write.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ define generic write-declaration
//------------------------------------------------------------------------

define class <written-name-record> (<object>)
slot written-name-table :: <table> /* <symbol> => <declaration> */
constant slot written-name-table :: <table> /* <symbol> => <declaration> */
= make(<table>);
end class <written-name-record>;

Expand Down
Loading