Skip to content

Commit

Permalink
tools/bin/jsc: tentatively add support for preprocessing .s/.c
Browse files Browse the repository at this point in the history
  • Loading branch information
pipcet committed Jan 29, 2021
1 parent d6bf2ab commit d8701fe
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tools/bin/jsc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ int main(void) {
return $cache->{$c};
}

my $mode;
if ($ARGV[0] eq "--s") {
shift;
$mode = "s";
}
if ($ARGV[0] eq "--c") {
shift;
$mode = "c";
}

$prefix = $ARGV[0] // "wasm32-unknown-none";

if (-e "tools/cache/jsc/${prefix}.pl") {
Expand All @@ -83,7 +93,13 @@ while ($in =~ s/(\%[l.0-9]*[defgosx])(\{((?:(?>[^\{\}]+)|(?-2))*)\})/do_subst($1

while ($in =~ s/\%(\{((?:(?>[^\{\}]+)|(?-2))*)\})/do_cpp_subst($2, $preamble)/mesgx) {}

$in = "// autogenerated. do not edit.\n\"use strict\";\n" . $in;
if ($mode eq "s") {
$in = " ;; autogenerated. Do not edit.\n" . $in;
} elsif ($mode eq "c") {
$in = "/* Autogenerated. Do not edit. */\n" . $in;
} else {
$in = "// autogenerated. do not edit.\n\"use strict\";\n" . $in;
}

print $in;

Expand Down

0 comments on commit d8701fe

Please sign in to comment.