2007-12-30 17:41:49 +01:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
|
gbx_exec_push.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
|
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +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
|
2009-08-17 12:41:51 +02:00
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
|
void EXEC_push_unknown(ushort code)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
{
|
|
|
|
|
static void *jump[] = {
|
|
|
|
|
/* 0 */ &&_PUSH_GENERIC,
|
|
|
|
|
/* 1 */ &&_PUSH_CONSTANT,
|
|
|
|
|
/* 2 */ &&_PUSH_VARIABLE,
|
|
|
|
|
/* 3 */ &&_PUSH_STATIC_VARIABLE,
|
|
|
|
|
/* 4 */ &&_PUSH_PROPERTY,
|
|
|
|
|
/* 5 */ &&_PUSH_METHOD,
|
|
|
|
|
/* 6 */ &&_PUSH_STATIC_METHOD,
|
|
|
|
|
/* 7 */ &&_PUSH_VARIABLE_AUTO,
|
|
|
|
|
/* 8 */ &&_PUSH_PROPERTY_AUTO,
|
|
|
|
|
/* 9 */ &&_PUSH_METHOD_AUTO,
|
2010-05-25 13:19:00 +02:00
|
|
|
|
/* 10 */ &&_PUSH_EXTERN,
|
|
|
|
|
/* 11 */ &&_PUSH_STRUCT_FIELD
|
2007-12-30 17:41:49 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char *name;
|
2008-01-17 22:39:26 +01:00
|
|
|
|
int index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
|
CLASS *class;
|
|
|
|
|
OBJECT *object;
|
2010-05-21 01:23:39 +02:00
|
|
|
|
void *ref;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
char *addr;
|
|
|
|
|
bool defined;
|
|
|
|
|
VALUE *val;
|
|
|
|
|
|
|
|
|
|
EXEC_object(&SP[-1], &class, &object, &defined);
|
|
|
|
|
|
|
|
|
|
goto *jump[code & 0xF];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_GENERIC:
|
|
|
|
|
|
|
|
|
|
name = CP->load->unknown[PC[1]];
|
|
|
|
|
|
|
|
|
|
// The first time we access a symbol, we must not be virtual to find it
|
|
|
|
|
val = &SP[-1];
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (LIKELY(defined && object && !VALUE_is_super(val)))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
index = CLASS_find_symbol(val->_object.class, name);
|
|
|
|
|
else
|
|
|
|
|
index = CLASS_find_symbol(class, name);
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(index == NO_SYMBOL))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
{
|
|
|
|
|
//index = CLASS_find_symbol(class, name);
|
|
|
|
|
|
|
|
|
|
if (class->special[SPEC_UNKNOWN] == NO_SYMBOL)
|
|
|
|
|
{
|
|
|
|
|
if (defined && object && !VALUE_is_super(val))
|
|
|
|
|
class = val->_object.class;
|
|
|
|
|
THROW(E_NSYMBOL, name, class->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto _PUSH_UNKNOWN_METHOD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
desc = class->table[index].desc;
|
|
|
|
|
|
|
|
|
|
switch (CLASS_DESC_get_type(desc))
|
|
|
|
|
{
|
|
|
|
|
case CD_CONSTANT:
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (LIKELY(defined))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
{
|
2009-10-05 01:32:14 +02:00
|
|
|
|
if ((PC[-1] & 0xF800) == C_PUSH_CLASS)
|
|
|
|
|
{
|
|
|
|
|
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;
|
2009-12-24 03:02:05 +01:00
|
|
|
|
PC[0] = desc->constant.value._integer & 0xFFFF;
|
|
|
|
|
PC[1] = desc->constant.value._integer >> 16;
|
2009-10-05 01:32:14 +02:00
|
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*PC |= 1;
|
|
|
|
|
PC[1] = index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto _PUSH_CONSTANT_2;
|
|
|
|
|
|
|
|
|
|
case CD_VARIABLE:
|
|
|
|
|
|
|
|
|
|
if (object == NULL)
|
|
|
|
|
{
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(!class->auto_create))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
THROW(E_DYNAMIC, class->name, name);
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
*PC |= 7;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (defined) *PC |= 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_VARIABLE_2;
|
|
|
|
|
|
2010-05-25 13:19:00 +02:00
|
|
|
|
case CD_STRUCT_FIELD:
|
|
|
|
|
|
|
|
|
|
if (object == NULL)
|
|
|
|
|
THROW(E_DYNAMIC, class->name, name);
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
{
|
|
|
|
|
*PC |= 11;
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto _PUSH_STRUCT_FIELD_2;
|
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
case CD_STATIC_VARIABLE:
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(object != NULL))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
THROW(E_STATIC, class->name, name);
|
|
|
|
|
|
|
|
|
|
if (defined) *PC |= 3;
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_STATIC_VARIABLE_2;
|
|
|
|
|
|
|
|
|
|
case CD_PROPERTY:
|
|
|
|
|
case CD_PROPERTY_READ:
|
|
|
|
|
|
|
|
|
|
if (object == NULL)
|
|
|
|
|
{
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(!class->auto_create))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
THROW(E_DYNAMIC, class->name, name);
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
*PC |= 8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (defined) *PC |= 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_PROPERTY_2;
|
|
|
|
|
|
|
|
|
|
case CD_STATIC_PROPERTY:
|
|
|
|
|
case CD_STATIC_PROPERTY_READ:
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(object != NULL))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
THROW(E_STATIC, class->name, name);
|
|
|
|
|
|
|
|
|
|
if (defined) *PC |= 4;
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_PROPERTY_2;
|
|
|
|
|
|
|
|
|
|
case CD_METHOD:
|
|
|
|
|
|
|
|
|
|
if (object == NULL)
|
|
|
|
|
{
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(!class->auto_create))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
THROW(E_DYNAMIC, class->name, name);
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
*PC |= 9;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (defined) *PC |= 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_METHOD_2;
|
|
|
|
|
|
|
|
|
|
case CD_STATIC_METHOD:
|
|
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
|
{
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_unknown");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
object = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defined) *PC |= 6;
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_METHOD_2;
|
|
|
|
|
|
|
|
|
|
case CD_EXTERN:
|
|
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
|
{
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_unknown");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
object = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defined) *PC |= 10;
|
|
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
|
PC[1] = index;
|
|
|
|
|
|
|
|
|
|
goto _PUSH_EXTERN_2;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
THROW(E_NSYMBOL, name, class->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_CONSTANT:
|
|
|
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_CONSTANT_2:
|
|
|
|
|
|
|
|
|
|
VALUE_read(&SP[-1], (void *)&desc->constant.value, desc->constant.type);
|
|
|
|
|
goto _FIN_DEFINED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_VARIABLE_AUTO:
|
|
|
|
|
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
|
|
|
|
|
_PUSH_VARIABLE:
|
|
|
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_VARIABLE_2:
|
|
|
|
|
|
|
|
|
|
addr = (char *)object + desc->variable.offset;
|
2010-05-21 01:23:39 +02:00
|
|
|
|
ref = object;
|
|
|
|
|
goto _READ_VARIABLE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_STATIC_VARIABLE:
|
|
|
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_STATIC_VARIABLE_2:
|
|
|
|
|
|
2009-06-17 16:13:50 +02:00
|
|
|
|
addr = (char *)desc->variable.class->stat + desc->variable.offset;
|
2010-05-21 01:23:39 +02:00
|
|
|
|
ref = desc->variable.class;
|
|
|
|
|
goto _READ_VARIABLE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
|
2010-05-25 13:19:00 +02:00
|
|
|
|
_PUSH_STRUCT_FIELD:
|
|
|
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
|
|
|
|
|
_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;
|
2010-05-25 13:19:00 +02:00
|
|
|
|
|
|
|
|
|
ref = object;
|
|
|
|
|
goto _READ_VARIABLE;
|
|
|
|
|
|
|
|
|
|
|
2010-05-21 01:23:39 +02:00
|
|
|
|
_READ_VARIABLE:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2010-05-21 01:23:39 +02:00
|
|
|
|
VALUE_class_read(desc->variable.class, &SP[-1], (void *)addr, desc->variable.ctype, ref);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
goto _FIN_DEFINED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_PROPERTY_AUTO:
|
|
|
|
|
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
|
|
|
|
|
_PUSH_PROPERTY:
|
|
|
|
|
|
|
|
|
|
desc = class->table[PC[1]].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_PROPERTY_2:
|
|
|
|
|
|
|
|
|
|
if (desc->property.native)
|
|
|
|
|
{
|
|
|
|
|
if (EXEC_call_native(desc->property.read, object, desc->property.type, NULL))
|
|
|
|
|
PROPAGATE();
|
|
|
|
|
|
2008-03-19 15:32:30 +01:00
|
|
|
|
//SP[-1] = TEMP;
|
|
|
|
|
VALUE_copy(&SP[-1], &TEMP);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
goto _FIN_DEFINED;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
EXEC.class = desc->property.class;
|
|
|
|
|
EXEC.object = object;
|
|
|
|
|
EXEC.drop = FALSE;
|
|
|
|
|
EXEC.nparam = 0;
|
|
|
|
|
EXEC.native = FALSE;
|
2008-01-17 22:39:26 +01:00
|
|
|
|
EXEC.index = (int)(intptr_t)desc->property.read;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
EXEC_function_keep();
|
|
|
|
|
|
2008-03-19 15:32:30 +01:00
|
|
|
|
//SP[-1] = *RP;
|
|
|
|
|
VALUE_copy(&SP[-1], RP);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
RP->type = T_VOID;
|
|
|
|
|
goto _FIN_DEFINED_NO_BORROW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_STATIC_METHOD:
|
|
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
|
{
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_unknown");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
object = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto _PUSH_METHOD;
|
|
|
|
|
|
|
|
|
|
_PUSH_METHOD_AUTO:
|
|
|
|
|
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
|
|
|
|
|
|
_PUSH_METHOD:
|
|
|
|
|
|
|
|
|
|
index = PC[1];
|
|
|
|
|
desc = class->table[index].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_METHOD_2:
|
|
|
|
|
|
|
|
|
|
//printf("PUSH_METHOD: %d %s\n", index, desc->method.name);
|
|
|
|
|
|
|
|
|
|
SP--;
|
|
|
|
|
SP->type = T_FUNCTION;
|
|
|
|
|
SP->_function.class = class;
|
|
|
|
|
SP->_function.object = object;
|
2008-01-17 22:39:26 +01:00
|
|
|
|
/*SP->_function.function = (int)&desc->method;*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
if (FUNCTION_is_native(&desc->method))
|
|
|
|
|
SP->_function.kind = FUNCTION_NATIVE;
|
|
|
|
|
else
|
|
|
|
|
SP->_function.kind = FUNCTION_PUBLIC;
|
|
|
|
|
|
|
|
|
|
SP->_function.index = index;
|
|
|
|
|
|
|
|
|
|
SP->_function.defined = defined;
|
|
|
|
|
|
|
|
|
|
SP++;
|
|
|
|
|
|
|
|
|
|
goto _FIN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PUSH_EXTERN:
|
|
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
|
{
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_unknown");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
object = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
index = PC[1];
|
|
|
|
|
desc = class->table[index].desc;
|
|
|
|
|
|
|
|
|
|
_PUSH_EXTERN_2:
|
|
|
|
|
|
|
|
|
|
//printf("PUSH_METHOD: %d %s\n", index, desc->method.name);
|
|
|
|
|
|
|
|
|
|
SP--;
|
|
|
|
|
SP->type = T_FUNCTION;
|
|
|
|
|
SP->_function.class = class;
|
|
|
|
|
SP->_function.object = object;
|
|
|
|
|
SP->_function.kind = FUNCTION_EXTERN;
|
2008-01-17 22:39:26 +01:00
|
|
|
|
SP->_function.index = (int)desc->ext.exec;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
SP->_function.defined = defined;
|
|
|
|
|
SP++;
|
|
|
|
|
|
|
|
|
|
goto _FIN;
|
|
|
|
|
|
|
|
|
|
_PUSH_UNKNOWN_METHOD:
|
|
|
|
|
|
|
|
|
|
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++;
|
|
|
|
|
|
|
|
|
|
//OBJECT_REF(&object, "EXEC_push_unknown: UNKNOWN");
|
|
|
|
|
|
|
|
|
|
goto _FIN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_FIN_DEFINED:
|
|
|
|
|
|
|
|
|
|
BORROW(&SP[-1]);
|
|
|
|
|
|
|
|
|
|
_FIN_DEFINED_NO_BORROW:
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(!defined))
|
2007-12-30 17:41:49 +01:00
|
|
|
|
VALUE_conv(&SP[-1], T_VARIANT);
|
|
|
|
|
|
|
|
|
|
/* sp[-1] contenait l'objet et a <20><><EFBFBD>ras<61> Il faut donc le d<><64><EFBFBD>encer
|
|
|
|
|
nous-m<EFBFBD>e. Sauf si c'est un appel de m<EFBFBD>hode statique (cf. plus haut) */
|
|
|
|
|
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_unknown");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
_FIN:
|
|
|
|
|
|
|
|
|
|
PC++;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
void EXEC_push_array(ushort code)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
{
|
2010-05-19 17:05:45 +02:00
|
|
|
|
static const void *jump[] = { &&__PUSH_GENERIC, &&__PUSH_QUICK_ARRAY, &&__PUSH_QUICK_COLLECTION, &&__PUSH_ARRAY };
|
2008-01-24 02:36:20 +01:00
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
CLASS *class;
|
|
|
|
|
OBJECT *object;
|
|
|
|
|
GET_NPARAM(np);
|
2010-05-14 23:30:54 +02:00
|
|
|
|
//int dim[MAX_ARRAY_DIM];
|
2007-12-30 17:41:49 +01:00
|
|
|
|
int i;
|
|
|
|
|
void *data;
|
2008-01-24 02:36:20 +01:00
|
|
|
|
bool defined;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
VALUE *val;
|
2010-05-19 17:05:45 +02:00
|
|
|
|
int fast;
|
2010-05-14 23:30:54 +02:00
|
|
|
|
//ARRAY_DESC *desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
val = &SP[-np];
|
|
|
|
|
np--;
|
|
|
|
|
|
2008-01-24 11:42:42 +01:00
|
|
|
|
goto *jump[(code >> 6) & 3];
|
2008-01-24 02:36:20 +01:00
|
|
|
|
|
|
|
|
|
__PUSH_GENERIC:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
EXEC_object(val, &class, &object, &defined);
|
|
|
|
|
|
2008-05-10 17:17:07 +02:00
|
|
|
|
// The first time we access a symbol, we must not be virtual to find it
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (LIKELY(defined && object && !VALUE_is_super(val)))
|
2008-05-10 17:17:07 +02:00
|
|
|
|
class = val->_object.class;
|
|
|
|
|
|
2010-05-19 17:05:45 +02:00
|
|
|
|
fast = 3;
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (LIKELY(defined))
|
2010-05-19 17:05:45 +02:00
|
|
|
|
{
|
|
|
|
|
if (class->quick_array == CQA_ARRAY)
|
|
|
|
|
fast = 1;
|
|
|
|
|
else if (class->quick_array == CQA_COLLECTION)
|
|
|
|
|
fast = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*PC |= fast << 6;
|
2008-01-24 02:36:20 +01:00
|
|
|
|
|
|
|
|
|
goto __PUSH_ARRAY_2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2010-05-14 23:30:54 +02:00
|
|
|
|
/*__PUSH_STATIC_ARRAY:
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
for (i = 1; i <= np; i++)
|
|
|
|
|
{
|
|
|
|
|
VALUE_conv(&val[i], T_INTEGER);
|
|
|
|
|
dim[i - 1] = val[i]._integer.value;
|
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
SP = val;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
desc = (ARRAY_DESC *)SP->_array.class->load->array[SP->_array.index];
|
|
|
|
|
data = ARRAY_get_address(desc, SP->_array.addr, np, dim);
|
|
|
|
|
|
|
|
|
|
VALUE_read(SP, data, CLASS_ctype_to_type(SP->_array.class, desc->type));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
PUSH();
|
2010-05-14 23:30:54 +02:00
|
|
|
|
return;*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
__PUSH_QUICK_ARRAY:
|
|
|
|
|
|
|
|
|
|
EXEC_object(val, &class, &object, &defined);
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (LIKELY(np == 1))
|
2008-01-24 11:42:42 +01:00
|
|
|
|
{
|
2010-05-19 17:05:45 +02:00
|
|
|
|
VALUE_conv(&val[1], T_INTEGER);
|
|
|
|
|
data = CARRAY_get_data((CARRAY *)object, val[1]._integer.value);
|
2008-01-24 11:42:42 +01:00
|
|
|
|
}
|
2010-05-19 17:05:45 +02:00
|
|
|
|
else
|
2008-01-24 11:42:42 +01:00
|
|
|
|
{
|
2010-05-19 17:05:45 +02:00
|
|
|
|
for (i = 1; i <= np; i++)
|
|
|
|
|
VALUE_conv(&val[i], T_INTEGER);
|
2008-09-13 17:35:13 +02:00
|
|
|
|
|
2010-05-19 17:05:45 +02:00
|
|
|
|
data = CARRAY_get_data_multi((CARRAY *)object, (GB_INTEGER *)&val[1], np);
|
2008-01-24 11:42:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(data == NULL))
|
2010-05-19 17:05:45 +02:00
|
|
|
|
PROPAGATE();
|
|
|
|
|
VALUE_read(val, data, ((CARRAY *)object)->type);
|
|
|
|
|
|
|
|
|
|
goto __PUSH_QUICK_END;
|
|
|
|
|
|
|
|
|
|
__PUSH_QUICK_COLLECTION:
|
|
|
|
|
|
|
|
|
|
EXEC_object(val, &class, &object, &defined);
|
|
|
|
|
|
|
|
|
|
VALUE_conv_string(&val[1]);
|
|
|
|
|
//fprintf(stderr, "GB_CollectionGet: %p '%.*s'\n", val[1]._string.addr, val[1]._string.len, val[1]._string.addr + val[1]._string.start);
|
|
|
|
|
GB_CollectionGet((GB_COLLECTION)object, val[1]._string.addr + val[1]._string.start, val[1]._string.len, (GB_VARIANT *)val);
|
2008-01-24 02:36:20 +01:00
|
|
|
|
|
2010-05-19 17:05:45 +02:00
|
|
|
|
RELEASE(&val[1]);
|
|
|
|
|
|
|
|
|
|
__PUSH_QUICK_END:
|
|
|
|
|
|
|
|
|
|
SP = val;
|
|
|
|
|
PUSH();
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_array");
|
2008-01-24 02:36:20 +01:00
|
|
|
|
return;
|
2010-05-19 17:05:45 +02:00
|
|
|
|
|
2008-01-24 02:36:20 +01:00
|
|
|
|
__PUSH_ARRAY:
|
|
|
|
|
|
|
|
|
|
EXEC_object(val, &class, &object, &defined);
|
|
|
|
|
|
|
|
|
|
__PUSH_ARRAY_2:
|
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(EXEC_special(SPEC_GET, class, object, np, FALSE)))
|
2008-01-24 02:36:20 +01:00
|
|
|
|
THROW(E_NARRAY, class->name);
|
|
|
|
|
|
2008-08-14 21:42:27 +02:00
|
|
|
|
OBJECT_UNREF(object, "EXEC_push_array");
|
2008-01-24 02:36:20 +01:00
|
|
|
|
SP--;
|
2008-03-19 15:32:30 +01:00
|
|
|
|
//SP[-1] = SP[0];
|
|
|
|
|
VALUE_copy(&SP[-1], &SP[0]);
|
2008-01-24 02:36:20 +01:00
|
|
|
|
|
2010-05-19 22:18:23 +02:00
|
|
|
|
if (UNLIKELY(!defined))
|
2008-01-24 02:36:20 +01:00
|
|
|
|
VALUE_conv(&SP[-1], T_VARIANT);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|