Beispiel #1
0
int Parser_AddConstant(Parser* parser, Value* value)
{

    Function* function = parser->function;
    ASSERT(function->numConstants < 262144);

    // We can't store a nil value in a table, so if it's a nil value we need
    // to use some other value to indicate that. We use the constant table
    // itself since this will never appear otherwise.
    Value _value;
    if (Value_GetIsNil(value))
    {
        SetValue(&_value, function->constants);
        value = &_value;
    }

    const Value* result = Table_GetTable(parser->L, function->constants, value);
    if (!Value_GetIsNil(result))
    {
        return Value_GetInteger(result);
    }

    Value index;
    SetValue(&index, function->numConstants);

    Table_SetTable(parser->L, function->constants, value, &index);
    ++function->numConstants;

    return Value_GetInteger(&index);

}
Beispiel #2
0
void lua_rawseti(lua_State* L, int index, int n)
{

    Value* table = GetValueForIndex(L, index);
    luai_apicheck(L, Value_GetIsTable(table) );    

    Value* value = GetValueForIndex(L, -1);
    Table_SetTable(L, table->table, n, value);
    Pop(L, 1);

}