2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
gbx_exec_push.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gb_limit.h"
|
|
|
|
#include "gbx_exec.h"
|
|
|
|
#include "gb_pcode.h"
|
|
|
|
#include "gbx_api.h"
|
|
|
|
|
|
|
|
#include "gbx_string.h"
|
2008-01-24 11:42:42 +01:00
|
|
|
#include "gbx_c_array.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbx_c_collection.h"
|
2008-01-24 11:42:42 +01:00
|
|
|
#include "gbx_api.h"
|
2010-05-25 13:19:00 +02:00
|
|
|
#include "gbx_struct.h"
|
2011-08-02 01:36:41 +02:00
|
|
|
#include "gbx_local.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2014-07-16 02:57:45 +02:00
|
|
|
void EXEC_push_unknown(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2011-08-02 01:36:41 +02:00
|
|
|
static void *jump[] = {
|
|
|
|
&&_PUSH_GENERIC, // 0
|
|
|
|
&&_PUSH_CONSTANT, // 1
|
|
|
|
&&_PUSH_VARIABLE, // 2
|
|
|
|
&&_PUSH_STATIC_VARIABLE, // 3
|
|
|
|
&&_PUSH_PROPERTY, // 4
|
|
|
|
&&_PUSH_METHOD, // 5
|
|
|
|
&&_PUSH_STATIC_METHOD, // 6
|
|
|
|
&&_PUSH_VARIABLE_AUTO, // 7
|
|
|
|
&&_PUSH_PROPERTY_AUTO, // 8
|
|
|
|
&&_PUSH_METHOD_AUTO, // 9
|
|
|
|
&&_PUSH_EXTERN, // 10
|
|
|
|
&&_PUSH_STRUCT_FIELD, // 11
|
2012-02-12 20:53:40 +01:00
|
|
|
&&_PUSH_CONST_STRING, // 12
|
2011-08-02 01:36:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
int index;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
CLASS *class;
|
|
|
|
OBJECT *object;
|
2010-05-21 01:23:39 +02:00
|
|
|
void *ref;
|
2011-08-02 01:36:41 +02:00
|
|
|
char *addr;
|
|
|
|
bool defined;
|
|
|
|
VALUE *val;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2014-07-16 02:57:45 +02:00
|
|
|
// EXEC_object can change *PC by calling EXEC_push_unknown() recursively
|
|
|
|
// So don't store *PC anywhere
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
defined = EXEC_object(&SP[-1], &class, &object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2014-07-16 02:57:45 +02:00
|
|
|
goto *jump[*PC & 0xF];
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_GENERIC:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
name = CP->load->unknown[PC[1]];
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
// The first time we access a symbol, we must not be virtual to find it
|
|
|
|
val = &SP[-1];
|
2013-11-03 14:30:02 +01:00
|
|
|
if (defined && object && !VALUE_is_super(val))
|
2011-08-02 01:36:41 +02:00
|
|
|
index = CLASS_find_symbol(val->_object.class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
else
|
2011-08-02 01:36:41 +02:00
|
|
|
index = CLASS_find_symbol(class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-11-03 14:30:02 +01:00
|
|
|
if (index == NO_SYMBOL)
|
2011-08-02 01:36:41 +02:00
|
|
|
{
|
|
|
|
//index = CLASS_find_symbol(class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (class->special[SPEC_UNKNOWN] == NO_SYMBOL)
|
|
|
|
{
|
2007-12-30 17:41:49 +01:00
|
|
|
if (defined && object && !VALUE_is_super(val))
|
|
|
|
class = val->_object.class;
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_NSYMBOL, CLASS_get_name(class), name);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2012-07-04 01:45:09 +02:00
|
|
|
if (class->unknown_static && object)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_STATIC, CLASS_get_name(class), name);
|
2012-07-04 01:45:09 +02:00
|
|
|
else if (!class->unknown_static && object == NULL)
|
|
|
|
{
|
|
|
|
if (!class->auto_create)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(class), name);
|
2012-07-04 01:45:09 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
}
|
|
|
|
|
2018-08-23 12:22:30 +02:00
|
|
|
index = CLASS_find_symbol(class, name);
|
|
|
|
if (index != NO_SYMBOL)
|
|
|
|
THROW(E_NSYMBOL, CLASS_get_name(val->_object.class), name);
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (class->special[SPEC_PROPERTY] != NO_SYMBOL)
|
2011-07-03 04:46:15 +02:00
|
|
|
{
|
|
|
|
EXEC_unknown_name = name;
|
2012-07-08 15:27:56 +02:00
|
|
|
if (!EXEC_special(SPEC_PROPERTY, class, class->property_static ? NULL : object, 0, FALSE))
|
2011-07-03 04:46:15 +02:00
|
|
|
{
|
2012-07-04 23:59:16 +02:00
|
|
|
VALUE_conv_boolean(&SP[-1]);
|
2011-07-03 04:46:15 +02:00
|
|
|
SP--;
|
2012-07-04 23:59:16 +02:00
|
|
|
if (SP->_boolean.value)
|
|
|
|
{
|
2012-07-08 16:29:44 +02:00
|
|
|
//SP--; Keep the object on the stack so that it is automatically freed if an error is raised
|
2012-07-05 00:06:19 +02:00
|
|
|
EXEC_special(SPEC_UNKNOWN, class, class->unknown_static ? NULL : object, 0, FALSE);
|
2012-07-04 23:59:16 +02:00
|
|
|
VALUE_conv_variant(&SP[-1]);
|
2012-07-08 16:29:44 +02:00
|
|
|
SP--;
|
|
|
|
SP[-1] = *SP;
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2012-07-04 23:59:16 +02:00
|
|
|
goto _FIN;
|
|
|
|
}
|
2011-07-03 04:46:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_UNKNOWN_METHOD;
|
|
|
|
}
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[index].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
switch (CLASS_DESC_get_type(desc))
|
|
|
|
{
|
|
|
|
case CD_CONSTANT:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-02-12 20:53:40 +01:00
|
|
|
if (TYPE_is_string(desc->constant.type))
|
2011-08-02 01:36:41 +02:00
|
|
|
{
|
|
|
|
if (defined)
|
2009-10-05 01:32:14 +02:00
|
|
|
{
|
2011-08-02 01:36:41 +02:00
|
|
|
*PC |= 12;
|
|
|
|
PC[1] = index;
|
|
|
|
}
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-02-12 20:53:40 +01:00
|
|
|
goto _PUSH_CONST_STRING_2;
|
2011-08-02 01:36:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined)
|
|
|
|
{
|
|
|
|
if ((PC[-1] & 0xF800) == C_PUSH_CLASS)
|
2009-10-05 01:32:14 +02:00
|
|
|
{
|
2011-08-02 01:36:41 +02:00
|
|
|
if (desc->constant.type == T_BOOLEAN)
|
|
|
|
{
|
|
|
|
PC[-1] = C_PUSH_MISC | (desc->constant.value._integer ? CPM_TRUE : CPM_FALSE);
|
|
|
|
PC[0] = C_NOP;
|
|
|
|
PC[1] = C_NOP;
|
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
}
|
|
|
|
else if (desc->constant.type == T_BYTE || desc->constant.type == T_SHORT)
|
|
|
|
{
|
|
|
|
PC[-1] = C_PUSH_INTEGER;
|
|
|
|
PC[0] = desc->constant.value._integer;
|
|
|
|
PC[1] = (CODE_CONV << 8) | desc->constant.type;
|
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
}
|
|
|
|
else if (desc->constant.type == T_INTEGER)
|
|
|
|
{
|
|
|
|
PC[-1] = C_PUSH_LONG;
|
|
|
|
PC[0] = desc->constant.value._integer & 0xFFFF;
|
|
|
|
PC[1] = desc->constant.value._integer >> 16;
|
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
}
|
2009-10-05 01:32:14 +02:00
|
|
|
}
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
*PC |= 1;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
PC[1] = index;
|
2009-10-05 01:32:14 +02:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_VARIABLE:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object == NULL)
|
|
|
|
{
|
2012-07-04 01:45:09 +02:00
|
|
|
if (!class->auto_create)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(class), name);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
*PC |= 7;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined) *PC |= 2;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_VARIABLE_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_STRUCT_FIELD:
|
2010-05-25 13:19:00 +02:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object == NULL)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(class), name);
|
2016-02-14 17:15:31 +01:00
|
|
|
|
|
|
|
if (defined)
|
2010-05-25 13:19:00 +02:00
|
|
|
{
|
|
|
|
*PC |= 11;
|
2011-08-02 01:36:41 +02:00
|
|
|
PC[1] = index;
|
2010-05-25 13:19:00 +02:00
|
|
|
}
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_STRUCT_FIELD_2;
|
2010-05-25 13:19:00 +02:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_STATIC_VARIABLE:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 17:12:18 +01:00
|
|
|
if (object)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_STATIC, CLASS_get_name(class), name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined) *PC |= 3;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_STATIC_VARIABLE_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_PROPERTY:
|
|
|
|
case CD_PROPERTY_READ:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object == NULL)
|
|
|
|
{
|
2013-11-03 14:30:02 +01:00
|
|
|
if (!class->auto_create)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(class), name);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
*PC |= 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined) *PC |= 4;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_PROPERTY_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_STATIC_PROPERTY:
|
|
|
|
case CD_STATIC_PROPERTY_READ:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-28 17:12:18 +01:00
|
|
|
if (object)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_STATIC, CLASS_get_name(class), name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined) *PC |= 4;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_PROPERTY_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_METHOD:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object == NULL)
|
|
|
|
{
|
2013-11-03 14:30:02 +01:00
|
|
|
if (!class->auto_create)
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(class), name);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
*PC |= 9;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined) *PC |= 5;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_METHOD_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_STATIC_METHOD:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object)
|
|
|
|
{
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = NULL;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined) *PC |= 6;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_METHOD_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
case CD_EXTERN:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object)
|
|
|
|
{
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = NULL;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined) *PC |= 10;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (defined)
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_EXTERN_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
default:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-19 23:00:35 +02:00
|
|
|
THROW(E_NSYMBOL, CLASS_get_name(class), name);
|
2011-08-02 01:36:41 +02:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
_PUSH_CONSTANT:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[PC[1]].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_CONSTANT_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
VALUE_read(&SP[-1], (void *)&desc->constant.value, desc->constant.type);
|
|
|
|
goto _FIN_DEFINED;
|
|
|
|
|
|
|
|
|
2012-02-12 20:53:40 +01:00
|
|
|
_PUSH_CONST_STRING:
|
2011-08-02 01:36:41 +02:00
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
2012-02-12 20:53:40 +01:00
|
|
|
_PUSH_CONST_STRING_2:
|
2011-08-02 01:36:41 +02:00
|
|
|
|
|
|
|
SP--;
|
|
|
|
SP->type = T_CSTRING;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2013-04-29 23:27:11 +02:00
|
|
|
if (!desc->constant.value._string)
|
|
|
|
{
|
|
|
|
SP->_string.addr = NULL;
|
|
|
|
SP->_string.len = 0;
|
|
|
|
}
|
2012-02-12 20:53:40 +01:00
|
|
|
else
|
2013-04-29 23:27:11 +02:00
|
|
|
{
|
|
|
|
if (desc->constant.translate)
|
|
|
|
SP->_string.addr = (char *)LOCAL_gettext(desc->constant.value._string);
|
|
|
|
else
|
|
|
|
SP->_string.addr = (char *)desc->constant.value._string;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2013-04-29 23:27:11 +02:00
|
|
|
SP->_string.len = strlen(SP->_string.addr);
|
|
|
|
}
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP->_string.start = 0;
|
|
|
|
SP++;
|
|
|
|
goto _FIN_DEFINED_NO_BORROW;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_VARIABLE_AUTO:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_VARIABLE:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[PC[1]].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_VARIABLE_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
addr = (char *)object + desc->variable.offset;
|
2010-05-21 01:23:39 +02:00
|
|
|
ref = object;
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _READ_VARIABLE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_STATIC_VARIABLE:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[PC[1]].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_STATIC_VARIABLE_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
addr = (char *)desc->variable.class->stat + desc->variable.offset;
|
2010-05-21 01:23:39 +02:00
|
|
|
ref = desc->variable.class;
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _READ_VARIABLE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2010-05-25 13:19:00 +02:00
|
|
|
_PUSH_STRUCT_FIELD:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[PC[1]].desc;
|
2010-05-25 13:19:00 +02:00
|
|
|
|
|
|
|
_PUSH_STRUCT_FIELD_2:
|
|
|
|
|
|
|
|
if (((CSTRUCT *)object)->ref)
|
2010-05-27 00:01:28 +02:00
|
|
|
addr = (char *)((CSTATICSTRUCT *)object)->addr + desc->variable.offset;
|
2010-05-25 13:19:00 +02:00
|
|
|
else
|
2010-05-27 00:01:28 +02:00
|
|
|
addr = (char *)object + sizeof(CSTRUCT) + desc->variable.offset;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2010-05-25 13:19:00 +02:00
|
|
|
ref = object;
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _READ_VARIABLE;
|
2010-05-25 13:19:00 +02:00
|
|
|
|
|
|
|
|
2010-05-21 01:23:39 +02:00
|
|
|
_READ_VARIABLE:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
VALUE_class_read(desc->variable.class, &SP[-1], (void *)addr, desc->variable.ctype, ref);
|
|
|
|
goto _FIN_DEFINED;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_PROPERTY_AUTO:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_PROPERTY:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
desc = class->table[PC[1]].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_PROPERTY_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (desc->property.native)
|
|
|
|
{
|
|
|
|
if (EXEC_call_native(desc->property.read, object, desc->property.type, NULL))
|
|
|
|
PROPAGATE();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
//SP[-1] = TEMP;
|
|
|
|
VALUE_copy(&SP[-1], &TEMP);
|
|
|
|
goto _FIN_DEFINED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EXEC.class = desc->property.class;
|
|
|
|
EXEC.object = object;
|
|
|
|
EXEC.nparam = 0;
|
|
|
|
EXEC.native = FALSE;
|
|
|
|
EXEC.index = (int)(intptr_t)desc->property.read;
|
|
|
|
|
|
|
|
EXEC_function_keep();
|
|
|
|
|
|
|
|
//SP[-1] = *RP;
|
|
|
|
VALUE_copy(&SP[-1], RP);
|
|
|
|
RP->type = T_VOID;
|
|
|
|
goto _FIN_DEFINED_NO_BORROW;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_STATIC_METHOD:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object)
|
|
|
|
{
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = NULL;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _PUSH_METHOD;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_METHOD_AUTO:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
object = EXEC_auto_create(class, TRUE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_METHOD:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
index = PC[1];
|
|
|
|
desc = class->table[index].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_METHOD_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
//printf("PUSH_METHOD: %d %s\n", index, desc->method.name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP--;
|
|
|
|
SP->type = T_FUNCTION;
|
|
|
|
SP->_function.class = class;
|
|
|
|
SP->_function.object = object;
|
|
|
|
/*SP->_function.function = (int)&desc->method;*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (FUNCTION_is_native(&desc->method))
|
2011-09-08 18:01:36 +02:00
|
|
|
{
|
|
|
|
if (desc->method.subr)
|
|
|
|
SP->_function.kind = FUNCTION_SUBR;
|
|
|
|
else
|
|
|
|
SP->_function.kind = FUNCTION_NATIVE;
|
|
|
|
}
|
2011-08-02 01:36:41 +02:00
|
|
|
else
|
|
|
|
SP->_function.kind = FUNCTION_PUBLIC;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP->_function.index = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP->_function.defined = defined;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP++;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _FIN;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
_PUSH_EXTERN:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (object)
|
|
|
|
{
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2011-08-02 01:36:41 +02:00
|
|
|
object = NULL;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
index = PC[1];
|
|
|
|
desc = class->table[index].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_EXTERN_2:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
//printf("PUSH_METHOD: %d %s\n", index, desc->method.name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP--;
|
|
|
|
SP->type = T_FUNCTION;
|
|
|
|
SP->_function.class = class;
|
|
|
|
SP->_function.object = object;
|
|
|
|
SP->_function.kind = FUNCTION_EXTERN;
|
|
|
|
SP->_function.index = (int)desc->ext.exec;
|
|
|
|
SP->_function.defined = defined;
|
|
|
|
SP++;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _FIN;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_PUSH_UNKNOWN_METHOD:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
SP--;
|
|
|
|
SP->type = T_FUNCTION;
|
|
|
|
SP->_function.class = class;
|
|
|
|
SP->_function.object = object;
|
|
|
|
SP->_function.kind = FUNCTION_UNKNOWN;
|
|
|
|
SP->_function.index = PC[1];
|
|
|
|
SP->_function.defined = FALSE;
|
|
|
|
SP++;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-03-30 14:51:10 +01:00
|
|
|
//OBJECT_REF(&object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
goto _FIN;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_FIN_DEFINED:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
BORROW(&SP[-1]);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_FIN_DEFINED_NO_BORROW:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
if (!defined)
|
|
|
|
VALUE_conv_variant(&SP[-1]);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-07-03 04:46:15 +02:00
|
|
|
// SP[-1] was the object and it has been erased. So we must unref it manually,
|
|
|
|
// unless we are calling a static method (see above)
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_FIN:
|
|
|
|
|
2011-08-02 01:36:41 +02:00
|
|
|
PC++;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
int EXEC_push_unknown_event(bool unknown)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
const char *name;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
if (unknown)
|
|
|
|
{
|
|
|
|
name = CP->load->unknown[PC[1]];
|
|
|
|
// The ':' is already in the name, thanks to the compiler.
|
|
|
|
index = CLASS_find_symbol(CP, name);
|
|
|
|
if (index == NO_SYMBOL)
|
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(CP), name);
|
|
|
|
|
|
|
|
desc = CP->table[index].desc;
|
|
|
|
if (CLASS_DESC_get_type(desc) != CD_EVENT)
|
|
|
|
THROW(E_DYNAMIC, CLASS_get_name(CP), name);
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
PC[1] = index;
|
|
|
|
PC[0] &= ~1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desc = CP->table[PC[1]].desc;
|
|
|
|
}
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
index = desc->event.index;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
//if (desc->event.class->parent)
|
|
|
|
// index += desc->event.class->parent->n_event;
|
2016-02-14 17:15:31 +01:00
|
|
|
|
2012-11-24 19:52:11 +01:00
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|