changeset 358:d2389a757323

...
author anatofuz
date Mon, 15 Jun 2020 18:54:23 +0900
parents e194c940c664
children 87a28b02c88f
files src/gearsTools/generate_context.pl src/gearsTools/lib/Gears/Context/Template/XV6.pm
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/gearsTools/generate_context.pl	Mon Jun 15 18:41:01 2020 +0900
+++ b/src/gearsTools/generate_context.pl	Mon Jun 15 18:54:23 2020 +0900
@@ -80,6 +80,7 @@
 
 if ($opt_project && exists $projects{$opt_project}) {
   $context_name = $projects{$opt_project}->{context};
+  $project  = $projects{$opt_project};
 }
 
 
@@ -100,7 +101,6 @@
 
   my $output     = $opt_w ? "context.h" : "stdout";
 
-  use Data::Dumper;
   my @cbc_files;
   map { push(@cbc_files,File::Spec->rel2abs($_)); }  @ARGV;
   my $gears      = Gears::Context->new(compile_sources => \@cbc_files, find_root => "$FindBin::Bin/../", output => $output, template => $project->{template});
@@ -190,7 +190,7 @@
    
     my $code_init = ''; 
     for my $code ( sort keys %mCodeGear ) {
-        $code_init .=  "    context->code[C_${code}]    = ${code}_stub;\n";
+        $code_init .=  "    ${context_name}->code[C_${code}]    = ${code}_stub;\n";
     }
 
     my $data_num = keys(%dataGear);
--- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Mon Jun 15 18:41:01 2020 +0900
+++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Mon Jun 15 18:54:23 2020 +0900
@@ -122,6 +122,13 @@
 };
 
 #include "c/enumData.h"
+EOFEOF
+    print $out $str;
+}
+
+sub emit_start_context {
+  my ($class, $out) = @_;
+my $str = << 'EOFEOF';
 #define NDIRECT 12 //fs.h
 
 
@@ -189,6 +196,13 @@
 EOF
 }
 
+sub emit_include_header {
+  my ($class, $out, $from_header_to_caller) = @_;
+  for my $header (keys %{$from_header_to_caller}) {
+    map { print $out "// use $_\n" }  @{$from_header_to_caller->{$header}};
+    print $out "#include \"$header\"\n";
+  }
+}
 
 sub emit_last_header {
   my($class, $out) = @_;