Test and temporary version of compiler emiting PH7_OP_CLASS_INIT instruction.

However it works on ph7_class and thus passes whole class into the VM, what causes memory overhead,
as finally we have to find this class on the VM's stack. Instead, we could pass some ph7_class_info
structure containing a name of class to look for and information about its inheritances.
This commit is contained in:
2018-07-27 08:24:53 +02:00
parent c24a9bc251
commit b040886b97
4 changed files with 91 additions and 70 deletions

View File

@@ -1035,6 +1035,8 @@ struct ph7_class {
SyHash hMethod; /* Class methods */
sxu32 nLine; /* Line number on which this class was declared */
SySet aInterface; /* Implemented interface container */
SySet sExtends; /* List of inherited classes / interfaces */
SySet sImplements; /* List of implemented interfaces */
};
/* Class configuration flags */
#define PH7_CLASS_FINAL 0x001 /* Class is final [cannot be extended] */
@@ -1360,6 +1362,8 @@ enum ph7_vm_op {
PH7_OP_CVT_NULL, /* NULL cast */
PH7_OP_CVT_ARRAY, /* Array cast */
PH7_OP_CVT_OBJ, /* Object cast */
PH7_OP_CLASS_INIT, /* Class init */
PH7_OP_INTERFACE_INIT,/* Interface init */
PH7_OP_FOREACH_INIT, /* For each init */
PH7_OP_FOREACH_STEP, /* For each step */
PH7_OP_IS_A, /* Instanceof */