2021/01/17

2021/01/17

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
+kajika+anatofuz$ perl generate_stub.pl --debug examples/generics_test/main.cbc > /dev/null
{
    createTask      [
        [0] "loopCounter",
        [1] "taskManager"
    ],
    initDataGears   [
        [0] "loopCounter",
        [1] "taskManager"
    ],
    prevTask        [
        [0] "loopCounter"
    ]
}
Use of uninitialized value $ntype in lcfirst at generate_stub.pl line 823.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 825.
Use of uninitialized value $ntype in hash element at generate_stub.pl line 827.
Use of uninitialized value $p in string eq at generate_stub.pl line 854.
Use of uninitialized value $p in substitution (s///) at generate_stub.pl line 855.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 909.
Use of uninitialized value $p in string eq at generate_stub.pl line 854.
Use of uninitialized value $p in substitution (s///) at generate_stub.pl line 855.
Use of uninitialized value $pType in substitution (s///) at generate_stub.pl line 859.
Use of uninitialized value $pType in pattern match (m//) at generate_stub.pl line 906.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 909.
{
    createTask      [
        [0] "loopCounter",
        [1] "taskManager"
    ],
    initDataGears   [
        [0] "loopCounter",
        [1] "taskManager"
    ],
    prevTask        [
        [0] "loopCounter"
    ],
    shutdown        [
        [0] "taskManager"
    ]
}

%dataGearVarTypeはgenerateStubArgsでしか呼ばれていないっぽい

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
+kajika+anatofuz$ perl generate_stub.pl --debug examples/generics_test/main.cbc
[getDataGear] match 175 : #interface "StackGenerics.h"
[interfacepath]
"/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/interface/StackGenerics.h"
[getDataGear] match 137 : typedef struct StackGenerics <T> {
[getDataGear] match 333 :     __code clear(Impl* stack,__code next(...));
[getDataGear] match 333 :     __code push(Impl* stack,T* data, __code next(...));
[getDataGear] match 333 :     __code pop(Impl* stack, __code next(T* data, ...));
[getDataGear] match 333 :     __code pop2(Impl* stack, __code next(T* data, T* data1, ...));
[getDataGear] match 333 :     __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
[getDataGear] match 333 :     __code get(Impl* stack, __code next(T* data, ...));
[getDataGear] match 333 :     __code get2(Impl* stack, __code next(T* data, T* data1, ...));
[getDataGear] match 333 :     __code next(...);
[getDataGear] match 333 :     __code whenEmpty(...);
[getDataGear] match 315 : } StackGenerics;
[getDataGear] match 342 : } StackGenerics;
[getCodeGear] match 389 : typedef struct StackGenerics <T> {
[getCodeGear] match 394 :     __code clear(Impl* stack,__code next(...));
[getCodeGear] match 394 :     __code push(Impl* stack,T* data, __code next(...));
[getCodeGear] match 394 :     __code pop(Impl* stack, __code next(T* data, ...));
[getCodeGear] match 394 :     __code pop2(Impl* stack, __code next(T* data, T* data1, ...));
[getCodeGear] match 394 :     __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
[getCodeGear] match 394 :     __code get(Impl* stack, __code next(T* data, ...));
[getCodeGear] match 394 :     __code get2(Impl* stack, __code next(T* data, T* data1, ...));
[getCodeGear] match 394 :     __code next(...);
[getCodeGear] match 394 :     __code whenEmpty(...);
[getDataGear] match 175 : #interface "Interger.h"
[interfacepath]
undef
[getDataGear] match 206 : __code gmain(){
[getCodeGear] match 423 : __code gmain(){
[getDataGear] match 240 :   StackGenerics<Integer>* generics_list = createStackGenericsImpl();
[getDataGear] match 240 :   Interger* intA = NEW(Interger);
[getDataGear] match 250 :   goto generics_list->push(intA, shutdown);
[getDataGear] match 175 : #interface "TaskManager.h"
[interfacepath]
"/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/TaskManager.h"
[getDataGear] match 137 : typedef struct TaskManager<>{
[getDataGear] match 333 :   __code spawn(Impl* taskManager, struct Context* task, __code next(...));
[getDataGear] match 333 :   __code spawnTasks(Impl* taskManagerImpl, struct Element* taskList, __code next1(...));
[getDataGear] match 333 :   __code setWaitTask(Impl* taskManagerImpl, struct Context* task, __code next(...));
[getDataGear] match 333 :   __code shutdown(Impl* taskManagerImpl, __code next(...));
[getDataGear] match 333 :   __code incrementTaskCount(Impl* taskManagerImpl, __code next(...));
[getDataGear] match 333 :   __code decrementTaskCount(Impl* taskManagerImpl, __code next(...));
[getDataGear] match 333 :   __code next(...);
[getDataGear] match 333 :   __code next1(...);
[getDataGear] match 315 : } TaskManager;
[getDataGear] match 342 : } TaskManager;
[getCodeGear] match 389 : typedef struct TaskManager<>{
[getCodeGear] match 394 :   __code spawn(Impl* taskManager, struct Context* task, __code next(...));
[getCodeGear] match 394 :   __code spawnTasks(Impl* taskManagerImpl, struct Element* taskList, __code next1(...));
[getCodeGear] match 394 :   __code setWaitTask(Impl* taskManagerImpl, struct Context* task, __code next(...));
[getCodeGear] match 394 :   __code shutdown(Impl* taskManagerImpl, __code next(...));
[getCodeGear] match 394 :   __code incrementTaskCount(Impl* taskManagerImpl, __code next(...));
[getCodeGear] match 394 :   __code decrementTaskCount(Impl* taskManagerImpl, __code next(...));
[getCodeGear] match 394 :   __code next(...);
[getCodeGear] match 394 :   __code next1(...);
[getDataGear] match 175 : #interface "StackGenerics.h"
[interfacepath]
"/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/interface/StackGenerics.h"
[getDataGear] match 137 : typedef struct StackGenerics <T> {
[getDataGear] match 333 :     __code clear(Impl* stack,__code next(...));
[getDataGear] match 333 :     __code push(Impl* stack,T* data, __code next(...));
[getDataGear] match 333 :     __code pop(Impl* stack, __code next(T* data, ...));
[getDataGear] match 333 :     __code pop2(Impl* stack, __code next(T* data, T* data1, ...));
[getDataGear] match 333 :     __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
[getDataGear] match 333 :     __code get(Impl* stack, __code next(T* data, ...));
[getDataGear] match 333 :     __code get2(Impl* stack, __code next(T* data, T* data1, ...));
[getDataGear] match 333 :     __code next(...);
[getDataGear] match 333 :     __code whenEmpty(...);
[getDataGear] match 315 : } StackGenerics;
[getDataGear] match 342 : } StackGenerics;
[getCodeGear] match 389 : typedef struct StackGenerics <T> {
[getCodeGear] match 394 :     __code clear(Impl* stack,__code next(...));
[getCodeGear] match 394 :     __code push(Impl* stack,T* data, __code next(...));
[getCodeGear] match 394 :     __code pop(Impl* stack, __code next(T* data, ...));
[getCodeGear] match 394 :     __code pop2(Impl* stack, __code next(T* data, T* data1, ...));
[getCodeGear] match 394 :     __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
[getCodeGear] match 394 :     __code get(Impl* stack, __code next(T* data, ...));
[getCodeGear] match 394 :     __code get2(Impl* stack, __code next(T* data, T* data1, ...));
[getCodeGear] match 394 :     __code next(...);
[getCodeGear] match 394 :     __code whenEmpty(...);
[getDataGear] match 175 : #interface "Interger.h"
[interfacepath]
undef
[getDataGear] match 206 : __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
[getDataGear] match 206 : __code prevTask(struct LoopCounter* loopCounter) {
[getDataGear] match 206 : __code createTask(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
[getDataGear] match 240 :   StackGenerics<Integer>* generics_list = createStackGenericsImpl();
[getDataGear] match 240 :   Interger* intA = NEW(Interger);
[getDataGear] match 250 :   goto generics_list->push(intA, shutdown);
[getDataGear] match 206 : __code shutdown(struct TaskManager* taskManager) {
[getDataGear] match 250 :     goto taskManager->shutdown(exit_code);
[getDataGear] match 206 : __code shutdown_stub(struct Context* context) {
[generateDataGear] match 794 : #include <stdio.h>
[generateDataGear] match 794 : #include <string.h>
[generateDataGear] match 794 : #include <stdlib.h>
[generateDataGear] match 794 : #include <unistd.h>
[generateDataGear] match 794 : #include <unistd.h>
[generateDataGear] match 660 : #interface "TaskManager.h"
[generateDataGear] match 660 : #interface "StackGenerics.h"
[generateDataGear] match 660 : #interface "Interger.h"
[generateDataGear] match 665 : #include "../../../context.h"
[generateDataGear] match 794 :
[generateDataGear] match 794 : int cpu_num = 1;
[generateDataGear] match 794 : int length = 102400;
[generateDataGear] match 794 : int split = 8;
[generateDataGear] match 794 : int* array_ptr;
[generateDataGear] match 794 : int gpu_num = 0;
[generateDataGear] match 794 : int CPU_ANY = -1;
[generateDataGear] match 794 : int CPU_CUDA = -1;
[generateDataGear] match 794 :
[generateDataGear] match 684 : __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
[
    [0] "initDataGears",
    [1] "loopCounter",
    [2] "LoopCounter",
    [3] "*",
    [4] "loopCounter",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[
    [0] "initDataGears",
    [1] "taskManager",
    [2] "TaskManager",
    [3] "*",
    [4] "taskManager",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[generateDataGear] match 1043 :     // loopCounter->tree = createRedBlackTree(context);
[generateDataGear] match 1043 :     loopCounter->i = 0;
[generateDataGear] match 1043 :     taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
[generateDataGear] match 981 :     goto prevTask();
[generateDataGear] match 1040 : }
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
[generateDataGear] match 684 : __code prevTask(struct LoopCounter* loopCounter) {
[
    [0] "prevTask",
    [1] "loopCounter",
    [2] "LoopCounter",
    [3] "*",
    [4] "loopCounter",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[generateDataGear] match 1043 :     printf("cpus:\t\t%d\n", cpu_num);
[generateDataGear] match 1043 :     printf("gpus:\t\t%d\n", gpu_num);
[generateDataGear] match 1043 :     printf("length:\t\t%d\n", length);
[generateDataGear] match 1043 :     printf("length/task:\t%d\n", length/split);
[generateDataGear] match 1043 :     /* puts("queue"); */
[generateDataGear] match 1043 :     /* print_queue(context->data[ActiveQueue]->queue.first); */
[generateDataGear] match 1043 :     /* puts("tree"); */
[generateDataGear] match 1043 :     /* print_tree(context->data[Tree]->tree.root); */
[generateDataGear] match 1043 :     /* puts("result"); */
[generateDataGear] match 981 :     goto createTask();
[generateDataGear] match 1040 : }
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
[generateDataGear] match 794 :
[generateDataGear] match 684 : __code createTask(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
[
    [0] "createTask",
    [1] "loopCounter",
    [2] "LoopCounter",
    [3] "*",
    [4] "loopCounter",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[
    [0] "createTask",
    [1] "taskManager",
    [2] "TaskManager",
    [3] "*",
    [4] "taskManager",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[generateDataGear] match 1043 :   StackGenerics<Integer>* generics_list = createStackGenericsImpl();
[generateDataGear] match 1034 :   Interger* intA = NEW(Interger);
[generateDataGear] match 1043 :   intA->value = 90;
[generateDataGear] match 799 :   goto generics_list->push(intA, shutdown);
Use of uninitialized value $ntype in lcfirst at generate_stub.pl line 826.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 828.
Use of uninitialized value $ntype in hash element at generate_stub.pl line 830.
Use of uninitialized value $p in string eq at generate_stub.pl line 857.
Use of uninitialized value $p in substitution (s///) at generate_stub.pl line 858.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 912.
Use of uninitialized value $p in string eq at generate_stub.pl line 857.
Use of uninitialized value $p in substitution (s///) at generate_stub.pl line 858.
Use of uninitialized value $pType in substitution (s///) at generate_stub.pl line 862.
Use of uninitialized value $pType in pattern match (m//) at generate_stub.pl line 909.
Use of uninitialized value $ntype in concatenation (.) or string at generate_stub.pl line 912.
[generateDataGear] match 1040 : }
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
[generateDataGear] match 684 : __code shutdown(struct TaskManager* taskManager) {
[
    [0] "shutdown",
    [1] "taskManager",
    [2] "TaskManager",
    [3] "*",
    [4] "taskManager",
    [5] {
        genConstructor        undef,
        implementation        undef,
        interface             undef,
        isImpl                undef,
        parsedInterfaceInfo   undef
    },
    [6] 0
]
[generateDataGear] match 799 :     goto taskManager->shutdown(exit_code);
[generateDataGear] match 1040 : }
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
[generateDataGear] match 684 : __code shutdown_stub(struct Context* context) {
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
[generateDataGear] match 794 :
[generateDataGear] match 794 :
[generateDataGear] match 794 : void init(int argc, char** argv) {
[generateDataGear] match 794 :     for (int i = 1; argv[i]; ++i) {
[generateDataGear] match 794 :         if (strcmp(argv[i], "-cpu") == 0)
[generateDataGear] match 794 :             cpu_num = (int)atoi(argv[i+1]);
[generateDataGear] match 794 :         else if (strcmp(argv[i], "-l") == 0)
[generateDataGear] match 794 :             length = (int)atoi(argv[i+1]);
[generateDataGear] match 794 :         else if (strcmp(argv[i], "-s") == 0)
[generateDataGear] match 794 :             split = (int)atoi(argv[i+1]);
[generateDataGear] match 794 :         else if (strcmp(argv[i], "-cuda") == 0) {
[generateDataGear] match 794 :             gpu_num = 1;
[generateDataGear] match 794 :             CPU_CUDA = 0;
[generateDataGear] match 794 :         }
[generateDataGear] match 794 :     }
[generateDataGear] match 794 : }
[generateDataGear] match 794 :
[generateDataGear] match 634 : int main(int argc, char** argv) {
[generateDataGear] match 1053 :     goto initDataGears();
[generateDataGear] match 1064 : }
[generateDataGear] match 794 :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  DB<19> n
main::generateDataGear(generate_stub.pl:821):
821:                        if ($v eq $next || $v eq "O_$next") {
  DB<19> n
main::generateDataGear(generate_stub.pl:826):
826:                    if (!defined $ntype) {
  DB<19> p $ntype
undef
undef

  DB<20> n
main::generateDataGear(generate_stub.pl:827):
827:                        $ntype = $localVarType{$next};
  DB<20> p %localVarType
{
    intA   "Interger"
}
{
    intA   "Interger"
}

  DB<21> p $next
"generics_list"
"generics_list"

  DB<22> p
Not enough arguments for Data::Printer::p at (eval 81)[/home/anatofuz/.plenv/versions/5.32.0/lib/perl5/5.32.0/perl5db.pl:738] line 2, at EOF

  DB<23> p $currentCodeGearInfo->{localVar}->{$next}
"StackGenerics"
"StackGenerics"

$currentCodeGearInfoがちゃんと動いていそう

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/usr/bin/env perl
use strict;
use warnings;
use DDP {deparse => 1};


my $line = 'StackGenerics<Integer>* generics_list = createStackGenericsImpl();';

if ($line =~ /^\s*(\w+)<(.+)>\*?\s*(\w+)\s*=\s*(.+)\(?/) {

  p $1;
  p $2;
  p $3;
  p $line;
}

# interfaceとgenerics

  • interfaceの実装がgenericsをどう使っているかが問題
    • interfaceと同じくgenerics( typed varibaleのまま)
    • 明示的に何かを実装してしまっているケース
      • これは許容しない?
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy