Răsfoiți Sursa

use u32 size value inner *.py.o

lyon 3 ani în urmă
părinte
comite
ed060f0c24

+ 2 - 2
package/PikaStdLib/PikaStdData_Dict.c

@@ -269,7 +269,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
     const uint8_t
         bytes[] =
             {
-                0x40, 0x00, /* instruct array size */
+                0x40, 0x00, 0x00, 0x00,/* instruct array size */
                 0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x04,
                 0x0d, 0x00, 0x00, 0x82, 0x11, 0x00, 0x00, 0x04, 0x1e, 0x00,
                 0x00, 0x0d, 0x1e, 0x00, 0x00, 0x07, 0x24, 0x00, 0x11, 0x81,
@@ -277,7 +277,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
                 0x21, 0x01, 0x1e, 0x00, 0x11, 0x1d, 0x00, 0x00, 0x01, 0x02,
                 0x2c, 0x00, 0x01, 0x04, 0x26, 0x00, 0x00, 0x86, 0x38, 0x00,
                 0x00, 0x8c, 0x0d, 0x00, /* instruct array */
-                0x3b, 0x00,             /* const pool size */
+                0x3b, 0x00, 0x00, 0x00,            /* const pool size */
                 0x00, 0x40, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x00, 0x69, 0x74,
                 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30,
                 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00,

+ 8 - 8
package/PikaStdLib/PikaStdLib_SysObj.c

@@ -161,9 +161,9 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
     //               "0 RUN __iter__\n"
     //               "0 OUT __res\n");
     const uint8_t bytes[] = {
-        0x08, 0x00, /* instruct array size */
+        0x08, 0x00, 0x00, 0x00,/* instruct array size */
         0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0a, 0x00, /* instruct array */
-        0x10, 0x00,                                     /* const pool size */
+        0x10, 0x00, 0x00, 0x00,                                    /* const pool size */
         0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f,
         0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
     };
@@ -247,11 +247,11 @@ Arg* PikaStdLib_SysObj___setitem__(PikaObj* self,
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x10, 0x01, 0x07, 0x00, 0x00, 0x02, 0x0d,
             0x00,
             /* instruct array */
-            0x19, 0x00, /* const pool size */
+            0x19, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x6b, 0x65, 0x79, 0x00, 0x5f, 0x5f, 0x76, 0x61,
             0x6c, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x69, 0x74, 0x65, 0x6d,
             0x5f, 0x5f, 0x00,
@@ -283,10 +283,10 @@ int PikaStdLib_SysObj_len(PikaObj* self, Arg* arg) {
         )
             /* clang-format on */
             const uint8_t bytes[] = {
-                0x08, 0x00, /* instruct array size */
+                0x08, 0x00, 0x00, 0x00,/* instruct array size */
                 0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
                                                                    array */
-                0x0f, 0x00, /* const pool size */
+                0x0f, 0x00, 0x00, 0x00,/* const pool size */
                 0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00,
                 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
             };
@@ -315,7 +315,7 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x3c, 0x00, /* instruct array size */
+            0x3c, 0x00, 0x00, 0x00,/* instruct array size */
             0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x07,
             0x00, 0x00, 0x02, 0x0e, 0x00, 0x00, 0x04, 0x13, 0x00, 0x00, 0x82,
             0x17, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x0d, 0x24, 0x00, 0x00,
@@ -323,7 +323,7 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
             0x00, 0x86, 0x3a, 0x00, 0x00, 0x8c, 0x13, 0x00, 0x00, 0x8c, 0x24,
             0x00, 0x00, 0x8c, 0x07, 0x00,
             /* instruct array */
-            0x3d, 0x00, /* const pool size */
+            0x3d, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, 0x5f, 0x5f, 0x6c, 0x69,
             0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30,
             0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74,

+ 8 - 8
package/PikaStdLib/PikaStdTask_Task.c

@@ -15,10 +15,10 @@ void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x10, 0x00, /* instruct array size */
+        0x10, 0x00, 0x00, 0x00,/* instruct array size */
         0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x10, 0x81, 0x15,
         0x00, 0x00, 0x02, 0x08, 0x00, /* instruct array */
-        0x1e, 0x00,                   /* const pool size */
+        0x1e, 0x00, 0x00, 0x00,                  /* const pool size */
         0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00, 0x63, 0x61, 0x6c,
         0x6c, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00, 0x66,
         0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f, 0x00, /* const pool */
@@ -39,11 +39,11 @@ void PikaStdTask_Task_call_when(PikaObj* self, Arg* fun_todo, Arg* fun_when) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x18, 0x00, /* instruct array size */
+        0x18, 0x00, 0x00, 0x00,/* instruct array size */
         0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x06, 0x00, 0x10, 0x81, 0x13, 0x00,
         0x00, 0x02, 0x06, 0x00, 0x10, 0x81, 0x1c, 0x00, 0x00, 0x02, 0x06, 0x00,
         /* instruct array */
-        0x25, 0x00, /* const pool size */
+        0x25, 0x00, 0x00, 0x00,/* const pool size */
         0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e,
         0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x77,
         0x68, 0x65, 0x6e, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f,
@@ -71,12 +71,12 @@ void PikaStdTask_Task_call_period_ms(PikaObj* self,
     /* clang-format on */
     const uint8_t bytes[] =
         {
-            0x28, 0x00, /* instruct array size */
+            0x28, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x0b, 0x00, 0x10, 0x81, 0x01,
             0x00, 0x00, 0x02, 0x0b, 0x00, 0x10, 0x81, 0x18, 0x00, 0x00, 0x02,
             0x0b, 0x00, 0x10, 0x85, 0x21, 0x00, 0x00, 0x02, 0x0b, 0x00, 0x00,
             0x85, 0x23, 0x00, 0x00, 0x04, 0x25, 0x00, /* instruct array */
-            0x2f, 0x00,                               /* const pool size */
+            0x2f, 0x00, 0x00, 0x00,                              /* const pool size */
             0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00,
             0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e,
             0x64, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f, 0x00,
@@ -128,7 +128,7 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0xf0, 0x01, /* instruct array size */
+        0xf0, 0x01, 0x00, 0x00,/* instruct array size */
         0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x83, 0x0f, 0x00,
         0x00, 0x04, 0x14, 0x00, 0x00, 0x85, 0x19, 0x00, 0x00, 0x04, 0x1b, 0x00,
         0x20, 0x85, 0x19, 0x00, 0x20, 0x01, 0x0b, 0x00, 0x10, 0x02, 0x26, 0x00,
@@ -171,7 +171,7 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
         0x14, 0x08, 0x75, 0x00, 0x04, 0x02, 0x77, 0x00, 0x04, 0x04, 0x4b, 0x00,
         0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x00, 0x86, 0x83, 0x00,
         0x00, 0x8c, 0x31, 0x00, /* instruct array */
-        0x86, 0x00,             /* const pool size */
+        0x86, 0x00, 0x00, 0x00,            /* const pool size */
         0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x6c,
         0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64, 0x65,
         0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65,

BIN
port/linux/package/pikascript/cjson_test.py.o


+ 2 - 2
port/linux/package/pikascript/pikascript-lib/PikaStdDevice/PikaStdDevice_Time.c

@@ -568,9 +568,9 @@ pika_float PikaStdDevice_Time_time(PikaObj* self) {
         )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x04, 0x00,             /* instruct array size */
+        0x04, 0x00, 0x00, 0x00,            /* instruct array size */
         0x00, 0x82, 0x01, 0x00, /* instruct array */
-        0x11, 0x00,             /* const pool size */
+        0x11, 0x00, 0x00, 0x00,            /* const pool size */
         0x00, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d,
         0x47, 0x65, 0x74, 0x54, 0x69, 0x63, 0x6b, 0x00, /* const pool */
     };

+ 2 - 2
port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdData_Dict.c

@@ -269,7 +269,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
     const uint8_t
         bytes[] =
             {
-                0x40, 0x00, /* instruct array size */
+                0x40, 0x00, 0x00, 0x00,/* instruct array size */
                 0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x04,
                 0x0d, 0x00, 0x00, 0x82, 0x11, 0x00, 0x00, 0x04, 0x1e, 0x00,
                 0x00, 0x0d, 0x1e, 0x00, 0x00, 0x07, 0x24, 0x00, 0x11, 0x81,
@@ -277,7 +277,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
                 0x21, 0x01, 0x1e, 0x00, 0x11, 0x1d, 0x00, 0x00, 0x01, 0x02,
                 0x2c, 0x00, 0x01, 0x04, 0x26, 0x00, 0x00, 0x86, 0x38, 0x00,
                 0x00, 0x8c, 0x0d, 0x00, /* instruct array */
-                0x3b, 0x00,             /* const pool size */
+                0x3b, 0x00, 0x00, 0x00,            /* const pool size */
                 0x00, 0x40, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x00, 0x69, 0x74,
                 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30,
                 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00,

+ 8 - 8
port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdLib_SysObj.c

@@ -161,9 +161,9 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
     //               "0 RUN __iter__\n"
     //               "0 OUT __res\n");
     const uint8_t bytes[] = {
-        0x08, 0x00, /* instruct array size */
+        0x08, 0x00, 0x00, 0x00,/* instruct array size */
         0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0a, 0x00, /* instruct array */
-        0x10, 0x00,                                     /* const pool size */
+        0x10, 0x00, 0x00, 0x00,                                    /* const pool size */
         0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f,
         0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
     };
@@ -247,11 +247,11 @@ Arg* PikaStdLib_SysObj___setitem__(PikaObj* self,
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x10, 0x01, 0x07, 0x00, 0x00, 0x02, 0x0d,
             0x00,
             /* instruct array */
-            0x19, 0x00, /* const pool size */
+            0x19, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x6b, 0x65, 0x79, 0x00, 0x5f, 0x5f, 0x76, 0x61,
             0x6c, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x69, 0x74, 0x65, 0x6d,
             0x5f, 0x5f, 0x00,
@@ -283,10 +283,10 @@ int PikaStdLib_SysObj_len(PikaObj* self, Arg* arg) {
         )
             /* clang-format on */
             const uint8_t bytes[] = {
-                0x08, 0x00, /* instruct array size */
+                0x08, 0x00, 0x00, 0x00,/* instruct array size */
                 0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
                                                                    array */
-                0x0f, 0x00, /* const pool size */
+                0x0f, 0x00, 0x00, 0x00,/* const pool size */
                 0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00,
                 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
             };
@@ -315,7 +315,7 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x3c, 0x00, /* instruct array size */
+            0x3c, 0x00, 0x00, 0x00,/* instruct array size */
             0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x07,
             0x00, 0x00, 0x02, 0x0e, 0x00, 0x00, 0x04, 0x13, 0x00, 0x00, 0x82,
             0x17, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x0d, 0x24, 0x00, 0x00,
@@ -323,7 +323,7 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
             0x00, 0x86, 0x3a, 0x00, 0x00, 0x8c, 0x13, 0x00, 0x00, 0x8c, 0x24,
             0x00, 0x00, 0x8c, 0x07, 0x00,
             /* instruct array */
-            0x3d, 0x00, /* const pool size */
+            0x3d, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, 0x5f, 0x5f, 0x6c, 0x69,
             0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30,
             0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74,

+ 8 - 8
port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdTask_Task.c

@@ -15,10 +15,10 @@ void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x10, 0x00, /* instruct array size */
+        0x10, 0x00, 0x00, 0x00,/* instruct array size */
         0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x10, 0x81, 0x15,
         0x00, 0x00, 0x02, 0x08, 0x00, /* instruct array */
-        0x1e, 0x00,                   /* const pool size */
+        0x1e, 0x00, 0x00, 0x00,                  /* const pool size */
         0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00, 0x63, 0x61, 0x6c,
         0x6c, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00, 0x66,
         0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f, 0x00, /* const pool */
@@ -39,11 +39,11 @@ void PikaStdTask_Task_call_when(PikaObj* self, Arg* fun_todo, Arg* fun_when) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x18, 0x00, /* instruct array size */
+        0x18, 0x00, 0x00, 0x00,/* instruct array size */
         0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x06, 0x00, 0x10, 0x81, 0x13, 0x00,
         0x00, 0x02, 0x06, 0x00, 0x10, 0x81, 0x1c, 0x00, 0x00, 0x02, 0x06, 0x00,
         /* instruct array */
-        0x25, 0x00, /* const pool size */
+        0x25, 0x00, 0x00, 0x00,/* const pool size */
         0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e,
         0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x77,
         0x68, 0x65, 0x6e, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f,
@@ -71,12 +71,12 @@ void PikaStdTask_Task_call_period_ms(PikaObj* self,
     /* clang-format on */
     const uint8_t bytes[] =
         {
-            0x28, 0x00, /* instruct array size */
+            0x28, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x83, 0x01, 0x00, 0x00, 0x02, 0x0b, 0x00, 0x10, 0x81, 0x01,
             0x00, 0x00, 0x02, 0x0b, 0x00, 0x10, 0x81, 0x18, 0x00, 0x00, 0x02,
             0x0b, 0x00, 0x10, 0x85, 0x21, 0x00, 0x00, 0x02, 0x0b, 0x00, 0x00,
             0x85, 0x23, 0x00, 0x00, 0x04, 0x25, 0x00, /* instruct array */
-            0x2f, 0x00,                               /* const pool size */
+            0x2f, 0x00, 0x00, 0x00,                              /* const pool size */
             0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00,
             0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e,
             0x64, 0x00, 0x66, 0x75, 0x6e, 0x5f, 0x74, 0x6f, 0x64, 0x6f, 0x00,
@@ -128,7 +128,7 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0xf0, 0x01, /* instruct array size */
+        0xf0, 0x01, 0x00, 0x00,/* instruct array size */
         0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x83, 0x0f, 0x00,
         0x00, 0x04, 0x14, 0x00, 0x00, 0x85, 0x19, 0x00, 0x00, 0x04, 0x1b, 0x00,
         0x20, 0x85, 0x19, 0x00, 0x20, 0x01, 0x0b, 0x00, 0x10, 0x02, 0x26, 0x00,
@@ -171,7 +171,7 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
         0x14, 0x08, 0x75, 0x00, 0x04, 0x02, 0x77, 0x00, 0x04, 0x04, 0x4b, 0x00,
         0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x00, 0x86, 0x83, 0x00,
         0x00, 0x8c, 0x31, 0x00, /* instruct array */
-        0x86, 0x00,             /* const pool size */
+        0x86, 0x00, 0x00, 0x00,            /* const pool size */
         0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x6c,
         0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64, 0x65,
         0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65,

+ 10 - 9
src/PikaCompiler.c

@@ -74,12 +74,13 @@ int pikaCompile(char* output_file_name, char* py_lines) {
     bytecode_frame.instruct_array.output_redirect_fun =
         __handler_instructArray_output_none;
     Parser_linesToBytes(&bytecode_frame, py_lines);
-    uint16_t const_pool_size = bytecode_frame.const_pool.size;
-    uint16_t instruct_array_size = bytecode_frame.instruct_array.size;
+    uint32_t const_pool_size = bytecode_frame.const_pool.size;
+    uint32_t instruct_array_size = bytecode_frame.instruct_array.size;
     byteCodeFrame_deinit(&bytecode_frame);
 
     /* step 2, write instruct array to file */
-    __platform_fwrite(&instruct_array_size, 1, 2, bytecode_f);
+    __platform_fwrite(&instruct_array_size, 1, sizeof(instruct_array_size),
+                      bytecode_f);
     byteCodeFrame_init(&bytecode_frame);
     bytecode_frame.const_pool.output_f = bytecode_f;
     bytecode_frame.instruct_array.output_f = bytecode_f;
@@ -90,7 +91,7 @@ int pikaCompile(char* output_file_name, char* py_lines) {
     byteCodeFrame_deinit(&bytecode_frame);
 
     /* step 3, write const pool to file */
-    __platform_fwrite(&const_pool_size, 1, 2, bytecode_f);
+    __platform_fwrite(&const_pool_size, 1, sizeof(const_pool_size), bytecode_f);
     char void_ = 0;
     /* add \0 at the start */
     __platform_fwrite(&void_, 1, 1, bytecode_f);
@@ -214,7 +215,7 @@ void LibObj_listModules(LibObj* self) {
     args_foreach(self->list, __foreach_handler_listModules, NULL);
 }
 
-static int32_t __foreach_handler_writeBytecode(Arg* argEach, Args* context) {
+static int32_t __foreach_handler_libWriteBytecode(Arg* argEach, Args* context) {
     FILE* out_file = args_getPtr(context, "out_file");
     if (argType_isObject(arg_getType(argEach))) {
         PikaObj* module_obj = arg_getPtr(argEach);
@@ -229,7 +230,7 @@ static int32_t __foreach_handler_writeBytecode(Arg* argEach, Args* context) {
     return 0;
 }
 
-static int32_t __foreach_handler_writeIndex(Arg* argEach, Args* context) {
+static int32_t __foreach_handler_libWriteIndex(Arg* argEach, Args* context) {
     FILE* out_file = args_getPtr(context, "out_file");
     if (argType_isObject(arg_getType(argEach))) {
         PikaObj* module_obj = arg_getPtr(argEach);
@@ -266,7 +267,7 @@ int LibObj_saveLibraryFile(LibObj* self, char* output_file_name) {
 
     /* meta info */
     char magic_code[] = {0x7f, 'p', 'y', 'a'};
-    uint32_t version_num = 1;
+    uint32_t version_num = LIB_VERSION_NUMBER;
     uint32_t module_num = args_getInt(&context, "module_num");
 
     /* write meta info */
@@ -281,9 +282,9 @@ int LibObj_saveLibraryFile(LibObj* self, char* output_file_name) {
     /* aline to 32 bytes */
     __platform_fwrite(buff, 1, LIB_INFO_BLOCK_SIZE, out_file);
     /* write module index to file */
-    args_foreach(self->list, __foreach_handler_writeIndex, &context);
+    args_foreach(self->list, __foreach_handler_libWriteIndex, &context);
     /* write module bytecode to file */
-    args_foreach(self->list, __foreach_handler_writeBytecode, &context);
+    args_foreach(self->list, __foreach_handler_libWriteBytecode, &context);
     args_deinit_stack(&context);
     /* main process */
     /* deinit */

+ 1 - 1
src/PikaCompiler.h

@@ -31,7 +31,7 @@ void pikaMaker_linkCompiledModules(PikaMaker* self, char* lib_name);
 int LibObj_loadLibrary(LibObj* self, uint8_t* library_bytes);
 void pikaMaker_linkCompiledModulesFullPath(PikaMaker* self, char* lib_path);
 
-#define LIB_VERSION_NUMBER 1
+#define LIB_VERSION_NUMBER 2
 #define LIB_INFO_BLOCK_SIZE 32
 
 #endif

+ 6 - 6
src/PikaObj.c

@@ -114,9 +114,9 @@ int32_t obj_deinit(PikaObj* self) {
     Arg* del = obj_getMethodArg(self, "__del__");
     if (NULL != del) {
         const uint8_t bytes[] = {
-            0x04, 0x00,             /* instruct array size */
+            0x04, 0x00, 0x00, 0x00, /* instruct array size */
             0x00, 0x82, 0x01, 0x00, /* instruct array */
-            0x09, 0x00,             /* const pool size */
+            0x09, 0x00, 0x00, 0x00, /* const pool size */
             0x00, 0x5f, 0x5f, 0x64, 0x65,
             0x6c, 0x5f, 0x5f, 0x00, /* const pool */
         };
@@ -1318,10 +1318,10 @@ char* obj_toStr(PikaObj* self) {
     if (NULL != method_arg) {
         arg_deinit(method_arg);
         const uint8_t bytes[] = {
-            0x08, 0x00, /* instruct array size */
+            0x08, 0x00, 0x00, 0x00,/* instruct array size */
             0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
                                                                array */
-            0x0f, 0x00, /* const pool size */
+            0x0f, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x73, 0x74, 0x72, 0x5f, 0x5f, 0x00,
             0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
         };
@@ -1397,9 +1397,9 @@ void pks_eventLisener_sendSignal(PikaEventListener* self,
 )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x08, 0x00, /* instruct array size */
+        0x08, 0x00, 0x00, 0x00,/* instruct array size */
         0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0d, 0x00, /* instruct array */
-        0x1b, 0x00,                                     /* const pool size */
+        0x1b, 0x00, 0x00, 0x00,                                    /* const pool size */
         0x00, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x67,
         0x6e, 0x61, 0x6c, 0x00, 0x65, 0x76, 0x65, 0x6e, 0x74,
         0x43, 0x61, 0x6c, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x00, /* const pool */

+ 4 - 4
src/PikaObj.h

@@ -43,8 +43,8 @@ struct InstructUnit {
 typedef struct ConstPool ConstPool;
 struct ConstPool {
     Arg* arg_buff;
-    uint16_t content_offset_now;
-    uint16_t size;
+    uint32_t content_offset_now;
+    uint32_t size;
     void* content_start;
     void (*output_redirect_fun)(ConstPool* self, char* content);
     FILE* output_f;
@@ -53,8 +53,8 @@ struct ConstPool {
 typedef struct InstructArray InstructArray;
 struct InstructArray {
     Arg* arg_buff;
-    uint16_t content_offset_now;
-    uint16_t size;
+    uint32_t content_offset_now;
+    uint32_t size;
     void* content_start;
     void (*output_redirect_fun)(InstructArray* self, InstructUnit* ins_unit);
     FILE* output_f;

+ 20 - 19
src/PikaVM.c

@@ -301,11 +301,11 @@ Arg* __vm_get(PikaObj* self, Arg* key, Arg* obj) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x13,
             0x00,
             /* instruct array */
-            0x19, 0x00, /* const pool size */
+            0x19, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x6b, 0x65, 0x79, 0x00, 0x5f, 0x5f, 0x67, 0x65,
             0x74, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72,
             0x65, 0x73, 0x00,
@@ -495,11 +495,11 @@ static Arg* _proxy_getattribute(PikaObj* host, char* name) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x18,
             0x00,
             /* instruct array */
-            0x1d, 0x00, /* const pool size */
+            0x1d, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x5f, 0x5f, 0x67, 0x65,
             0x74, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x5f,
             0x5f, 0x00, 0x40, 0x72, 0x65, 0x73, 0x00, /* const pool */
@@ -522,11 +522,11 @@ static Arg* _proxy_getattr(PikaObj* host, char* name) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x13,
             0x00,
             /* instruct array */
-            0x18, 0x00, /* const pool size */
+            0x18, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x5f, 0x5f, 0x67, 0x65,
             0x74, 0x61, 0x74, 0x74, 0x72, 0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65,
             0x73, 0x00, /* const pool */
@@ -1410,11 +1410,11 @@ static PIKA_BOOL _proxy_setattr(PikaObj* self, char* name, Arg* arg) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x10, 0x01, 0x07, 0x00, 0x00, 0x02, 0x0e,
             0x00,
             /* instruct array */
-            0x1a, 0x00, /* const pool size */
+            0x1a, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x40, 0x76, 0x61, 0x6c,
             0x75, 0x65, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x61, 0x74, 0x74,
             0x72, 0x5f, 0x5f, 0x00, /* const pool */
@@ -1708,11 +1708,11 @@ static void _OPT_ADD(OperatorInfo* op) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04, 0x12,
             0x00,
             /* instruct array */
-            0x18, 0x00, /* const pool size */
+            0x18, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00, 0x5f,
             0x5f, 0x61, 0x64, 0x64, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65,
             0x73, 0x00, /* const pool */
@@ -1771,11 +1771,11 @@ static void _OPT_SUB(OperatorInfo* op) {
         )
         /* clang-format on */
         const uint8_t bytes[] = {
-            0x0c, 0x00, /* instruct array size */
+            0x0c, 0x00, 0x00, 0x00,/* instruct array size */
             0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04, 0x12,
             0x00,
             /* instruct array */
-            0x18, 0x00, /* const pool size */
+            0x18, 0x00, 0x00, 0x00,/* const pool size */
             0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00, 0x5f,
             0x5f, 0x73, 0x75, 0x62, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65,
             0x73, 0x00, /* const pool */
@@ -2003,11 +2003,11 @@ static Arg* VM_instruction_handler_OPT(PikaObj* self,
                 obj_setArg(obj2, "__others", op.a1);
                 /* clang-format on */
                 const uint8_t bytes[] = {
-                    0x0c, 0x00, /* instruct array size */
+                    0x0c, 0x00, 0x00, 0x00,/* instruct array size */
                     0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04,
                     0x17, 0x00,
                     /* instruct array */
-                    0x1d, 0x00, /* const pool size */
+                    0x1d, 0x00, 0x00, 0x00,/* const pool size */
                     0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00,
                     0x5f, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73,
                     0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73,
@@ -2653,14 +2653,15 @@ void byteCodeFrame_init(ByteCodeFrame* self) {
 }
 
 void byteCodeFrame_loadByteCode(ByteCodeFrame* self, uint8_t* bytes) {
-    uint16_t* ins_size_p = (uint16_t*)bytes;
-    void* ins_start_p = (uint16_t*)(bytes + 2);
-    uint16_t* const_size_p =
-        (uint16_t*)((uintptr_t)ins_start_p + (uintptr_t)(*ins_size_p));
+    uint32_t* ins_size_p = (uint32_t*)bytes;
+    void* ins_start_p = (uint32_t*)((uintptr_t)bytes + sizeof(*ins_size_p));
+    uint32_t* const_size_p =
+        (uint32_t*)((uintptr_t)ins_start_p + (uintptr_t)(*ins_size_p));
     self->instruct_array.size = *ins_size_p;
     self->instruct_array.content_start = ins_start_p;
     self->const_pool.size = *const_size_p;
-    self->const_pool.content_start = (char*)((uintptr_t)const_size_p + 2);
+    self->const_pool.content_start =
+        (char*)((uintptr_t)const_size_p + sizeof(*const_size_p));
 }
 
 void byteCodeFrame_deinit(ByteCodeFrame* self) {

+ 1 - 1
src/PikaVersion.h

@@ -2,4 +2,4 @@
 #define PIKA_VERSION_MINOR       11
 #define PIKA_VERSION_MICRO       5
 
-#define PIKA_EDIT_TIME      "2022/10/21 12:27:40"
+#define PIKA_EDIT_TIME      "2022/10/23 18:55:43"

+ 6 - 6
test/VM-test.cpp

@@ -801,7 +801,7 @@ TEST(VM, for_break_byte) {
 
 TEST(VM, load_static_bytes) {
     const uint8_t bytes[] = {
-        0x08, 0x02, /* instruct array size */
+        0x08, 0x02, 0x00, 0x00,/* instruct array size */
         0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00,
         0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00,
         0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00,
@@ -846,7 +846,7 @@ TEST(VM, load_static_bytes) {
         0x14, 0x08, 0xa4, 0x00, 0x14, 0x03, 0x6e, 0x00, 0x04, 0x02, 0xa6, 0x00,
         0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x00, 0x86, 0xae, 0x00,
         0x00, 0x8c, 0x33, 0x00, /* instruct array */
-        0xb1, 0x00,             /* const pool size */
+        0xb1, 0x00, 0x00, 0x00,            /* const pool size */
         0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
         0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f,
         0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e,
@@ -1980,13 +1980,13 @@ TEST(vm, i_pp) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0x30, 0x00, /* instruct array size */
+        0x30, 0x00, 0x00, 0x00,/* instruct array size */
         0x00, 0x85, 0x01, 0x00, 0x00, 0x04, 0x03, 0x00, 0x10, 0x81, 0x03, 0x00,
         0x10, 0x05, 0x05, 0x00, 0x00, 0x08, 0x0b, 0x00, 0x00, 0x07, 0x0d, 0x00,
         0x11, 0x81, 0x03, 0x00, 0x21, 0x05, 0x0f, 0x00, 0x11, 0x02, 0x00, 0x00,
         0x01, 0x08, 0x11, 0x00, 0x01, 0x04, 0x03, 0x00, 0x00, 0x86, 0x13, 0x00,
         /* instruct array */
-        0x16, 0x00, /* const pool size */
+        0x16, 0x00, 0x00, 0x00,/* const pool size */
         0x00, 0x30, 0x00, 0x69, 0x00, 0x31, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3c,
         0x00, 0x32, 0x00, 0x31, 0x00, 0x2b, 0x00, 0x2d, 0x31,
         0x00, /* const pool */
@@ -2024,7 +2024,7 @@ TEST(vm, benchmark) {
     )
     /* clang-format on */
     const uint8_t bytes[] = {
-        0xac, 0x00, /* instruct array size */
+        0xac, 0x00, 0x00, 0x00,/* instruct array size */
         0x00, 0x85, 0x01, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x85, 0x07, 0x00,
         0x00, 0x04, 0x09, 0x00, 0x10, 0x81, 0x09, 0x00, 0x10, 0x05, 0x0b, 0x00,
         0x00, 0x08, 0x10, 0x00, 0x00, 0x07, 0x07, 0x00, 0x01, 0x85, 0x12, 0x00,
@@ -2040,7 +2040,7 @@ TEST(vm, benchmark) {
         0x02, 0x04, 0x03, 0x00, 0x11, 0x81, 0x09, 0x00, 0x21, 0x05, 0x12, 0x00,
         0x11, 0x02, 0x00, 0x00, 0x01, 0x08, 0x24, 0x00, 0x01, 0x04, 0x09, 0x00,
         0x00, 0x86, 0x26, 0x00, /* instruct array */
-        0x29, 0x00,             /* const pool size */
+        0x29, 0x00, 0x00, 0x00,            /* const pool size */
         0x00, 0x30, 0x00, 0x6e, 0x75, 0x6d, 0x00, 0x32, 0x00, 0x69, 0x00, 0x31,
         0x30, 0x30, 0x30, 0x00, 0x3c, 0x00, 0x31, 0x00, 0x69, 0x73, 0x5f, 0x70,
         0x72, 0x69, 0x6d, 0x65, 0x00, 0x6a, 0x00, 0x25, 0x00, 0x3d, 0x3d, 0x00,

BIN
tools/pikaCompiler/rust-msc-latest-win10.exe