script-block: implement storing double values in constpool

This commit is contained in:
2026-05-24 20:15:30 +01:00
parent e829c77297
commit 30bfce5701
2 changed files with 23 additions and 3 deletions
+18 -1
View File
@@ -183,7 +183,7 @@ static unsigned long scriptblock_get_string(
goto cleanup;
}
*slot = FX_CSTR(s);
*slot = FX_VALUE_OBJECT(str);
cache_entry->e_index = index;
fx_namemap_put(
@@ -205,6 +205,14 @@ cleanup:
return POOL_INDEX_INVALID;
}
static unsigned long scriptblock_get_double(
struct bshell_scriptblock_p *block,
double v)
{
fx_value value = FX_DOUBLE(v);
return scriptblock_add_pool_value(block, &value);
}
size_t bshell_scriptblock_push_instruction(
bshell_scriptblock *block,
enum bshell_opcode opcode,
@@ -317,6 +325,15 @@ unsigned long bshell_scriptblock_get_string(
s);
}
unsigned long bshell_scriptblock_get_double(bshell_scriptblock *block, double v)
{
FX_CLASS_DISPATCH_STATIC(
BSHELL_TYPE_SCRIPTBLOCK,
scriptblock_get_double,
block,
v);
}
FX_TYPE_CLASS_BEGIN(bshell_scriptblock)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
+5 -2
View File
@@ -18,8 +18,6 @@ FX_DECLARE_TYPE(bshell_scriptblock);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_scriptblock)
FX_TYPE_CLASS_DECLARATION_END(bshell_scriptblock)
FX_DECLS_END;
extern fx_type_id bshell_scriptblock_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(bshell_scriptblock, BSHELL_TYPE_SCRIPTBLOCK);
@@ -58,5 +56,10 @@ extern fx_value *bshell_scriptblock_get_pool_value(
extern unsigned long bshell_scriptblock_get_string(
bshell_scriptblock *block,
const char *s);
extern unsigned long bshell_scriptblock_get_double(
bshell_scriptblock *block,
double v);
FX_DECLS_END;
#endif