[DEVELOPMENT ENVIRONMENT]
* BUG: Fix profiling of Eval() calls. [INTERPRETER] * NEW: GB.ReturnBorrow() is a new API to temporarily borrow the return value. * NEW: GB.ReleaseBorrow() is a new API to release the return value borrowed by the previous function, without releasing it. [GB.DEBUG] * BUG: Fix profiling of Eval() calls. [GB.V4L] * BUG: Fix a compilation warning. git-svn-id: svn://localhost/gambas/trunk@5053 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
d94521db4c
commit
35368a3648
7 changed files with 107 additions and 85 deletions
|
@ -67,13 +67,13 @@ Fast Private Sub EnterFunction(sWhere As String, iTime As Long) As CProfile
|
|||
Else
|
||||
sKlass = $aIndex[CInt(sKlass) - 1]
|
||||
Endif
|
||||
Else
|
||||
Else If Left(sKlass) <> "." Then
|
||||
$aIndex.Add(sKlass)
|
||||
Endif
|
||||
|
||||
If IsDigit(Left(sFunc)) Then
|
||||
sFunc = $aIndex[CInt(sFunc) - 1]
|
||||
Else
|
||||
Else If sFunc <> "?" Then
|
||||
$aIndex.Add(sFunc)
|
||||
Endif
|
||||
|
||||
|
|
|
@ -43,6 +43,10 @@
|
|||
#undef EXTERN
|
||||
#endif
|
||||
|
||||
#ifdef INLINE
|
||||
#undef INLINE
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "CWebcam.h"
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@ const void *GAMBAS_Api[] =
|
|||
(void *)GB_ReturnFloat,
|
||||
(void *)GB_ReturnVariant,
|
||||
(void *)GB_ReturnConvVariant,
|
||||
(void *)GB_ReturnBorrow,
|
||||
(void *)GB_ReturnRelease,
|
||||
(void *)GB_ReturnPtr,
|
||||
(void *)GB_ReturnSelf,
|
||||
|
||||
|
@ -1453,6 +1455,15 @@ void GB_ReturnConvVariant(void)
|
|||
VALUE_conv(&TEMP, T_VARIANT);
|
||||
}
|
||||
|
||||
void GB_ReturnBorrow(void)
|
||||
{
|
||||
BORROW(&TEMP);
|
||||
}
|
||||
|
||||
void GB_ReturnRelease(void)
|
||||
{
|
||||
UNBORROW(&TEMP);
|
||||
}
|
||||
|
||||
void GB_ReturnPtr(GB_TYPE type, void *value)
|
||||
{
|
||||
|
|
|
@ -78,7 +78,10 @@ void GB_ReturnPtr(GB_TYPE type, void *value);
|
|||
void GB_ReturnDate(GB_DATE *date);
|
||||
void GB_ReturnSelf(void *object);
|
||||
void GB_ReturnVariant(GB_VARIANT_VALUE *value);
|
||||
|
||||
void GB_ReturnConvVariant(void);
|
||||
void GB_ReturnBorrow(void);
|
||||
void GB_ReturnRelease(void);
|
||||
|
||||
void GB_ReturnString(char *str);
|
||||
void GB_ReturnVoidString(void);
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
/***************************************************************************
|
||||
|
||||
gbx_eval.c
|
||||
gbx_eval.c
|
||||
|
||||
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
||||
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
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.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
@ -41,22 +41,22 @@ static EXPRESSION *EVAL;
|
|||
|
||||
static void EVAL_enter()
|
||||
{
|
||||
STACK_push_frame(&EXEC_current, EVAL->func.stack_usage);
|
||||
STACK_push_frame(&EXEC_current, EVAL->func.stack_usage);
|
||||
|
||||
BP = SP;
|
||||
PP = SP;
|
||||
FP = &EVAL->func;
|
||||
PC = EVAL->func.code;
|
||||
|
||||
OP = NULL;
|
||||
CP = &EVAL->exec_class;
|
||||
//AP = ARCH_from_class(CP);
|
||||
BP = SP;
|
||||
PP = SP;
|
||||
FP = &EVAL->func;
|
||||
PC = EVAL->func.code;
|
||||
|
||||
OP = NULL;
|
||||
CP = &EVAL->exec_class;
|
||||
//AP = ARCH_from_class(CP);
|
||||
|
||||
EP = NULL;
|
||||
EC = NULL;
|
||||
GP = NULL;
|
||||
EP = NULL;
|
||||
EC = NULL;
|
||||
GP = NULL;
|
||||
|
||||
RP->type = T_VOID;
|
||||
RP->type = T_VOID;
|
||||
|
||||
PROFILE_ENTER_FUNCTION();
|
||||
}
|
||||
|
@ -89,40 +89,40 @@ static void EVAL_exec()
|
|||
|
||||
bool EVAL_expression(EXPRESSION *expr, EVAL_FUNCTION func)
|
||||
{
|
||||
int i;
|
||||
EVAL_SYMBOL *sym;
|
||||
bool debug;
|
||||
bool error;
|
||||
int nvar;
|
||||
/*HASH_TABLE *hash_table;
|
||||
char *name;
|
||||
CCOL_ENUM enum_state;*/
|
||||
int i;
|
||||
EVAL_SYMBOL *sym;
|
||||
bool debug;
|
||||
bool error;
|
||||
int nvar;
|
||||
/*HASH_TABLE *hash_table;
|
||||
char *name;
|
||||
CCOL_ENUM enum_state;*/
|
||||
|
||||
EVAL = expr;
|
||||
EVAL = expr;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "EVAL: %s\n", EVAL->source);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "EVAL: %s\n", EVAL->source);
|
||||
#endif
|
||||
|
||||
nvar = EVAL->nvar;
|
||||
|
||||
STACK_check(nvar);
|
||||
STACK_check(nvar);
|
||||
|
||||
for (i = 0; i < nvar; i++)
|
||||
{
|
||||
SP[i].type = T_VARIANT;
|
||||
SP[i]._variant.vtype = T_NULL;
|
||||
for (i = 0; i < nvar; i++)
|
||||
{
|
||||
SP[i].type = T_VARIANT;
|
||||
SP[i]._variant.vtype = T_NULL;
|
||||
|
||||
sym = (EVAL_SYMBOL *)TABLE_get_symbol(EVAL->table, EVAL->var[EVAL->nvar - i - 1]);
|
||||
if ((*func)(sym->sym.name, sym->sym.len, (GB_VARIANT *)&SP[i]))
|
||||
{
|
||||
GB_Error("Unknown symbol");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvar; i++)
|
||||
BORROW(&SP[i]);
|
||||
sym = (EVAL_SYMBOL *)TABLE_get_symbol(EVAL->table, EVAL->var[EVAL->nvar - i - 1]);
|
||||
if ((*func)(sym->sym.name, sym->sym.len, (GB_VARIANT *)&SP[i]))
|
||||
{
|
||||
GB_Error("Unknown symbol");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nvar; i++)
|
||||
BORROW(&SP[i]);
|
||||
SP += nvar;
|
||||
|
||||
debug = EXEC_debug;
|
||||
|
@ -131,14 +131,14 @@ bool EVAL_expression(EXPRESSION *expr, EVAL_FUNCTION func)
|
|||
|
||||
TRY
|
||||
{
|
||||
EVAL_exec();
|
||||
}
|
||||
CATCH
|
||||
{
|
||||
error = TRUE;
|
||||
}
|
||||
END_TRY
|
||||
|
||||
EXEC_debug = debug;
|
||||
return error;
|
||||
EVAL_exec();
|
||||
}
|
||||
CATCH
|
||||
{
|
||||
error = TRUE;
|
||||
}
|
||||
END_TRY
|
||||
|
||||
EXEC_debug = debug;
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -1036,9 +1036,11 @@ const char *DEBUG_get_profile_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
|
|||
const char *func;
|
||||
char buffer[16], buffer2[16];
|
||||
|
||||
func = "?";
|
||||
|
||||
if (cp)
|
||||
{
|
||||
if (cp->load)
|
||||
if (cp->load && cp->load->prof)
|
||||
{
|
||||
if (cp->load->prof[0] == 0)
|
||||
{
|
||||
|
@ -1051,6 +1053,24 @@ const char *DEBUG_get_profile_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
|
|||
sprintf(buffer, "%u", cp->load->prof[0]);
|
||||
name = buffer;
|
||||
}
|
||||
|
||||
if (fp && fp->debug)
|
||||
{
|
||||
int i = fp->debug->index + 1;
|
||||
if (cp->load->prof[i] == 0)
|
||||
{
|
||||
prof_index++;
|
||||
cp->load->prof[i] = prof_index;
|
||||
func = fp->debug->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buffer2, "%u", cp->load->prof[i]);
|
||||
func = buffer2;
|
||||
}
|
||||
}
|
||||
else
|
||||
func = "?";
|
||||
}
|
||||
else
|
||||
name = cp->name;
|
||||
|
@ -1058,24 +1078,6 @@ const char *DEBUG_get_profile_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
|
|||
else
|
||||
name = "?";
|
||||
|
||||
if (fp && fp->debug)
|
||||
{
|
||||
int i = fp->debug->index + 1;
|
||||
if (cp->load->prof[i] == 0)
|
||||
{
|
||||
prof_index++;
|
||||
cp->load->prof[i] = prof_index;
|
||||
func = fp->debug->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buffer2, "%u", cp->load->prof[i]);
|
||||
func = buffer2;
|
||||
}
|
||||
}
|
||||
else
|
||||
func = "?";
|
||||
|
||||
if (pc)
|
||||
{
|
||||
ushort line = 0;
|
||||
|
|
|
@ -951,6 +951,8 @@ typedef
|
|||
void (*ReturnFloat)(double);
|
||||
void (*ReturnVariant)(GB_VARIANT_VALUE *);
|
||||
void (*ReturnConvVariant)();
|
||||
void (*ReturnBorrow)();
|
||||
void (*ReturnRelease)();
|
||||
void (*ReturnPtr)(GB_TYPE, void *);
|
||||
void (*ReturnSelf)(void *);
|
||||
|
||||
|
|
Loading…
Reference in a new issue