Mercurial > hg > Members > Moririn
diff src/parallel_execution/generate_context.pl @ 277:9d671e63df74
generate extern
author | mir3636 |
---|---|
date | Thu, 02 Feb 2017 18:29:50 +0900 |
parents | 195518ab62fc |
children | 23767f714f4a |
line wrap: on
line diff
--- a/src/parallel_execution/generate_context.pl Wed Feb 01 21:29:21 2017 +0900 +++ b/src/parallel_execution/generate_context.pl Thu Feb 02 18:29:50 2017 +0900 @@ -63,6 +63,7 @@ my %codeGear; my %dataGear; +my %constructor; # gather module Information for code table initialization for (@ARGV) { @@ -86,6 +87,11 @@ while (<$fd>) { if (/^__code (\w+)_stub\(struct Context\* context\)/ or /^\s__code (\w+)_stub\(struct Context\* context\)/) { $codeGear{$1} = $filename; + } elsif (/^(\w+)(\*)+ create(\w+)\(([^]]*)\)/) { + my $interface = $1; + my $implementation = $3; + my $constructorArgs = $4; + $constructor{$implementation} = [$interface, $constructorArgs]; } } @@ -110,6 +116,10 @@ for my $code ( sort keys %codeGear ) { print $fd "extern __code ${code}_stub(struct Context*);\n"; } + for my $impl ( sort keys %constructor ) { + my ($interface, $constructorArgs) = @{$constructor{$impl}}; + print $fd "extern $interface create${impl}($constructorArgs);\n"; + } print $fd "\n"; open my $fd,">","$ddir/enumCode.h" or die("can't open $ddir/enumCode.h $!"); @@ -130,6 +140,11 @@ #include "../context.h" #include "extern.h" +extern __code start_code(struct Context* context); +extern __code exit_code(struct Context* context); +extern __code meta(struct Context* context, enum Code next); +extern void initContext(struct Context* context); + void initContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); @@ -152,7 +167,35 @@ open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!"); print $fd $context_c; - + +my $meta_call = <<"EOFEOF"; + +__code meta(struct Context* context, enum Code next) { + // printf("meta %d\n",next); + goto (context->code[next])(context); +} + +__code start_code(struct Context* context) { + goto meta(context, context->next); +} + +__code start_code_stub(struct Context* context) { + goto start_code(context); +} + +__code exit_code(struct Context* context) { + free(context->code); + free(context->data); + free(context->heapStart); + goto exit(0); +} + +__code exit_code_stub(struct Context* context) { + goto exit_code(context); +} + +// end $context_c +EOFEOF open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!"); print $fd "enum DataType {\n";