2021/01/13

2021/01/13

 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
+kajika+anatofuz$ perl generate_stub.pl --debug AtomicTImpl.cbc
[getDataGear] match 174 : #interface "AtomicT.h"
[getDataGear] match 136 : typedef struct AtomicT <T>{
[getDataGear] match 308 :     union Data* atomicTImpl;
[getDataGear] match 308 :     T newData;
[getDataGear] match 308 :     T init;
[getDataGear] match 326 :     __code checkAndSet(Impl* atomicTImpl, T init, T newData, __code next(...), __code fail(...));
[getDataGear] match 326 :     __code set(Impl* atomicTImpl, T newData, __code next(...));
[getDataGear] match 326 :     __code next(...);
[getDataGear] match 326 :     __code fail(...);
[getDataGear] match 308 : } AtomicT;
[getDataGear] match 335 : } AtomicT;
[getCodeGear] match 380 : typedef struct AtomicT <T>{
[getCodeGear] match 385 :     __code checkAndSet(Impl* atomicTImpl, T init, T newData, __code next(...), __code fail(...));
[getCodeGear] match 385 :     __code set(Impl* atomicTImpl, T newData, __code next(...));
[getCodeGear] match 385 :     __code next(...);
[getCodeGear] match 385 :     __code fail(...);
[getDataGear] match 174 : #interface "AtomicTImpl.h"
[getDataGear] match 136 : typedef struct AtomicTImpl <T> impl AtomicT {
[getDataGear] match 308 :   T atomic;
[getDataGear] match 308 :   T init;
[getDataGear] match 326 :   __code next(...);
[getDataGear] match 308 : } AtomicTImpl;
[getDataGear] match 335 : } AtomicTImpl;
[getDataGear] match 205 : __code checkAndSetAtomicT(struct AtomicTImpl* atomicTImpl, T* ptr,T init, T newData, __code next(...), __code fail(...)) {
[getDataGear] match 205 : __code setAtomicT(struct AtomicTImpl* atomicTImpl, T* ptr, T newData, __code next(...) ) {
[generateDataGear] match 654 : #include "../context.h"
[generateDataGear] match 649 : #interface "AtomicT.h"
[generateDataGear] match 649 : #interface "AtomicTImpl.h"
[generateDataGear] match 784 : #include <stdio.h>
[generateDataGear] match 784 :
[generateDataGear] match 784 : AtomicT<T>* createAtomicT(struct Context* context,T init) {
[generateDataGear] match 784 :     struct AtomicT* atomicT = new AtomicT<T>();
[generateDataGear] match 784 :     struct AtomicTImpl<T>* atomicTImpl = new AtomicTImpl<T>();
[generateDataGear] match 784 :     atomicT->atomicTImpl = atomicTImpl;
[generateDataGear] match 784 :     atomicTImpl->atomic = init;
[generateDataGear] match 784 :     atomicTImpl->init = init;
[generateDataGear] match 784 :     atomic->checkAndSet = C_checkAndSetAtomicT;
[generateDataGear] match 784 :     return atomicT;
[generateDataGear] match 784 : }
[generateDataGear] match 784 :
[generateDataGear] match 673 : __code checkAndSetAtomicT(struct AtomicTImpl* atomicTImpl, T* ptr,T init, T newData, __code next(...), __code fail(...)) {
[generateDataGear] match 1034 :     if (__sync_bool_compare_and_swap(ptr, init, newData)) {
[generateDataGear] match 972 :         goto next(...);
[generateDataGear] match 1034 :     }
[generateDataGear] match 972 :     goto fail(...);
[generateDataGear] match 1031 : }
[generateDataGear] match 1055 : }
[generateDataGear] match 784 :
[generateDataGear] match 673 : __code setAtomicT(struct AtomicTImpl* atomicTImpl, T* ptr, T newData, __code next(...) ) {
[generateDataGear] match 1034 :         *ptr = newData;
[generateDataGear] match 972 :    goto next(...);
[generateDataGear] match 1031 : }
[generateDataGear] match 1055 : }
[generateDataGear] match 784 :
 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
#include "../context.h"
#include <stdio.h>

AtomicT<T>* createAtomicT(struct Context* context,T init) {
    struct AtomicT* atomicT = new AtomicT<T>();
    struct AtomicTImpl<T>* atomicTImpl = new AtomicTImpl<T>();
    atomicT->atomicTImpl = atomicTImpl;
    atomicTImpl->atomic = init;
    atomicTImpl->init = init;
    atomic->checkAndSet = C_checkAndSetAtomicT;
    return atomicT;
}

__code checkAndSetAtomicT(struct Context *context,struct AtomicTImpl* atomicTImpl, T* ptr,T init, T newData, enum Code next, enum Code fail) {
    if (__sync_bool_compare_and_swap(ptr, init, newData)) {
        goto meta(context, next);
    }
    goto meta(context, fail);
}

__code checkAndSetAtomicT_stub(struct Context* context) {
	AtomicTImpl* atomicTImpl = Gearef(context, AtomicTImpl);
	T* ptr = Gearef(context, T);
	T init = Gearef(context, T);
	T newData = Gearef(context, T);
	Code next = Gearef(context, Code);
	Code fail = Gearef(context, Code);
	goto checkAndSetAtomicT(context, atomicTImpl, ptr, init, newData, next, fail);
}

__code setAtomicT(struct Context *context,struct AtomicTImpl* atomicTImpl, T* ptr, T newData, enum Code next ) {
	*ptr = newData;
   goto meta(context, next);
}

__code setAtomicT_stub(struct Context* context) {
	AtomicTImpl* atomicTImpl = Gearef(context, AtomicTImpl);
	T* ptr = Gearef(context, T);
	T newData = Gearef(context, T);
	Code next = Gearef(context, Code);
	goto setAtomicT(context, atomicTImpl, ptr, newData, next);
}
 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
+kajika+anatofuz$ perl tools/trans_impl.pl examples/pop_and_push/StackTest2Impl.h
#include "../../../context.h"
#interface "StackTest2.h"

// ----
// typedef struct StackTest2Impl <> impl StackTest2 {
//   __code next(...);
// } StackTest2Impl;
// ----

\ {
    codeName           {
        gotoOtherInterface   {
            argc   4,
            args   "Impl* stackTest2, struct Stack* stack, union Data* data1, struct StackTest* stackTest, __code next(...)",
            name   "gotoOtherInterface"
        },
        insertTest1          {
            argc   3,
            args   "Impl* stackTest2, struct Stack* stack, union Data* data1, __code next(...)",
            name   "insertTest1"
        }
    },
    codes              [
        [0] var{codeName}{insertTest1},
        [1] var{codeName}{gotoOtherInterface}
    ],
    content            [
        [0] "enum Code insertTest1;",
        [1] "union Data* stackTest2;",
        [2] "struct Stack* stack;",
        [3] "union Data* data1;",
        [4] "enum Code gotoOtherInterface;",
        [5] "struct StackTest* stackTest;",
        [6] "enum Code next;",
        [7] ""
    ],
    data               [
        [0] "union Data* stackTest2;",
        [1] "struct Stack* stack;",
        [2] "union Data* data1;",
        [3] "struct StackTest* stackTest;",
        [4] ""
    ],
    file_name          "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/tools/../examples/pop_and_push/StackTest2.h",
    hasOutputArgs      {},
    inner_code_gears   {
        next   1
    },
    name               "StackTest2"
}
\ {
    codeName           {
        next   {
            argc   1,
            args   "...",
            name   "next"
        }
    },
    codes              [
        [0] var{codeName}{next}
    ],
    content            [
        [0] "enum Code next;"
    ],
    data               [],
    file_name          "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/examples/pop_and_push/StackTest2Impl.h",
    hasOutputArgs      {},
    inner_code_gears   {},
    isa                "StackTest2",
    name               "StackTest2Impl"
}
StackTest2* createStackTest2Impl(struct Context* context) {
    struct StackTest2* stackTest2  = new StackTest2();
    struct StackTest2Impl* stack_test2impl = new StackTest2Impl();
    stackTest2->stackTest2 = (union Data*)stack_test2impl;
    stackTest2->stack = NULL;
    stackTest2->data1 = NULL;
    stackTest2->stackTest = NULL;
    stackTest2->insertTest1 = C_insertTest1StackTest2Impl;
    stackTest2->gotoOtherInterface = C_gotoOtherInterfaceStackTest2Impl;
    return stackTest2;
}
__code insertTest1_StackTest2Impl(struct StackTest2Impl* stackTest2, struct Stack* stack, union Data* data1, __code next(...)) {

    goto next(...);
}

__code gotoOtherInterface_StackTest2Impl(struct StackTest2Impl* stackTest2, struct Stack* stack, union Data* data1, struct StackTest* stackTest, __code next(...)) {

    goto next(...);
}
 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
[0;36m1d0[0;0m
[0;31m< +kajika+anatofuz$ perl tools/trans_impl.pl examples/pop_and_push/StackTest2Impl.h[0;0m
[0;36m30,32c29,31[0;0m
[0;31m<         [1] "union Data* stackTest2;",[0;0m
[0;31m<         [2] "struct Stack* stack;",[0;0m
[0;31m<         [3] "union Data* data1;",[0;0m
[0;0m---[0;0m
[0;32m>         [1] "union Data stackTest2*;",[0;0m
[0;32m>         [2] "struct Stack stack*;",[0;0m
[0;32m>         [3] "union Data data1*;",[0;0m
[0;36m34c33[0;0m
[0;31m<         [5] "struct StackTest* stackTest;",[0;0m
[0;0m---[0;0m
[0;32m>         [5] "struct StackTest stackTest*;",[0;0m
[0;36m39,42c38,41[0;0m
[0;31m<         [0] "union Data* stackTest2;",[0;0m
[0;31m<         [1] "struct Stack* stack;",[0;0m
[0;31m<         [2] "union Data* data1;",[0;0m
[0;31m<         [3] "struct StackTest* stackTest;",[0;0m
[0;0m---[0;0m
[0;32m>         [0] "union Data stackTest2*;",[0;0m
[0;32m>         [1] "struct Stack stack*;",[0;0m
[0;32m>         [2] "union Data data1*;",[0;0m
[0;32m>         [3] "struct StackTest stackTest*;",[0;0m
[0;36m74c73[0;0m
[0;31m<     struct StackTest2* stackTest2  = new StackTest2();[0;0m
[0;0m---[0;0m
[0;32m>     struct StackTest2* union Data stackTest2*;  = new StackTest2();[0;0m
[0;36m76,82c75,84[0;0m
[0;31m<     stackTest2->stackTest2 = (union Data*)stack_test2impl;[0;0m
[0;31m<     stackTest2->stack = NULL;[0;0m
[0;31m<     stackTest2->data1 = NULL;[0;0m
[0;31m<     stackTest2->stackTest = NULL;[0;0m
[0;31m<     stackTest2->insertTest1 = C_insertTest1StackTest2Impl;[0;0m
[0;31m<     stackTest2->gotoOtherInterface = C_gotoOtherInterfaceStackTest2Impl;[0;0m
[0;31m<     return stackTest2;[0;0m
[0;0m---[0;0m
[0;32m>     union Data stackTest2*;->union Data stackTest2*; = (union Data*)stack_test2impl;[0;0m
[0;32m>     union Data stackTest2*;->stack = 0;[0;0m
[0;32m>     union Data stackTest2*;->Stack = 0;[0;0m
[0;32m>     union Data stackTest2*;->data1 = 0;[0;0m
[0;32m>     union Data stackTest2*;->Data = 0;[0;0m
[0;32m>     union Data stackTest2*;->stackTest = 0;[0;0m
[0;32m>     union Data stackTest2*;->StackTest = 0;[0;0m
[0;32m>     union Data stackTest2*;->insertTest1 = C_insertTest1StackTest2Impl;[0;0m
[0;32m>     union Data stackTest2*;->gotoOtherInterface = C_gotoOtherInterfaceStackTest2Impl;[0;0m
[0;32m>     return union Data stackTest2*;;[0;0m

これかぁ原因

1
2
3
4
5
6
7
<         [1] "union Data* stackTest2;",
<         [2] "struct Stack* stack;",
<         [3] "union Data* data1;",
---
>         [1] "union Data stackTest2*;",
>         [2] "struct Stack stack*;",
>         [3] "union Data data1*;",
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy