You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce data container feature and opcodes to support it.
Container instance is meant to store single kind of data type.
Available types: int, float, text
As far as it is technically possible types validation is performed in opcode commands at runtime. In case of mismatch error is thrown.
Class name: container
Opcodes:
create_container - container type
remove_container
container_size
container_clear
container_insert - one or multiple values
container_insert_front - one or multiple values
container_insert_at - index and one or multiple values
container_remove - optional count
container_remove_front - optional count
container_remove_at - index and optional count
container_get - one or multiple return values
container_get_front - one or multiple return values
container_get_at - index and one or multiple return values
container_get_random - one or multiple return values
container_contains - one or more search values
container_count - one search value
container_find - search value
container_find_back - search value
container_sort - sorting order and zero or more synchronized container handles
container_write_to_file
container_read_from_file
int_container = create_container type 0
container_add int_container 1 2 3
int x = get_by_index int_container 0 // x= 1
int y = get_by_index int_container 1 // y= 2
int z = get_by_index int_container 2 // z= 3
string_container = create_container type 1
container_add string_container "this is a very long string that couldn't live in a variable"
int s = get_by_index string_container 0 // s= pointer to "this is a very long string that couldn't live in a variable"
print_help_formatted s // prints "this is a very long string that couldn't live in a variable"
Will the getter opcode be able in every case to distinguish return parameter type and validate it? Especially float and int types.
I wouldn't care in runtime. you provide a 32-bit variable and runtime either copies the value (if it's int or float) or returns a pointer if it's a string, or other object.
Should container space be continuous, or it could contain empty slots and support setting variables on arbitrary indexes?
Hmm, probably not as it will cause problems when synchronizing multiple containers.
Activity
x87 commentedon Sep 21, 2024
I think type should be set in the constructor.
MiranDMC commentedon Sep 21, 2024
How getters will look then?
x87 commentedon Sep 21, 2024
names are temporary to illustrate the idea
MiranDMC commentedon Sep 21, 2024
Will the getter opcode be able in every case to distinguish return parameter type and validate it? Especially float and int types.
x87 commentedon Sep 21, 2024
addition
string containers return a pointer.
x87 commentedon Sep 21, 2024
I wouldn't care in runtime. you provide a 32-bit variable and runtime either copies the value (if it's int or float) or returns a pointer if it's a string, or other object.
validation can be done in compiler or linter
x87 commentedon Sep 23, 2024
runtime should keep track of created containers and delete them / free memory when the script ends (on game reload)
MiranDMC commentedon Dec 11, 2024
Should container space be continuous, or it could contain empty slots and support setting variables on arbitrary indexes?
Hmm, probably not as it will cause problems when synchronizing multiple containers.