Added tons of opcode documentation, changed license to ISC and a lot of file refactoring.
This commit is contained in:
parent
50a91d0b6f
commit
d7843274ee
111 changed files with 2597 additions and 26 deletions
|
|
@ -1,3 +1,37 @@
|
|||
/**
|
||||
* This file is part of the Fun programming language.
|
||||
* https://hanez.org/project/fun/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the ISC license.
|
||||
* https://opensource.org/license/isc-license-txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file arr_pop.c
|
||||
* @brief Implements the OP_ARR_POP opcode for removing elements from arrays in the VM.
|
||||
*
|
||||
* This file handles the OP_ARR_POP instruction, which removes the last element from an array
|
||||
* and pushes the removed element onto the stack. The array is popped from the stack.
|
||||
*
|
||||
* Behavior:
|
||||
* - Pops the array from the stack.
|
||||
* - Removes the last element from the array.
|
||||
* - Pushes the removed element onto the stack.
|
||||
*
|
||||
* Error Handling:
|
||||
* - Exits with an error if the array is of the wrong type.
|
||||
* - Exits with an error if the array is empty.
|
||||
*
|
||||
* Example:
|
||||
* // Bytecode: OP_ARR_POP
|
||||
* // Stack before: [[10, 20, 30]]
|
||||
* // Stack after: [30]
|
||||
*
|
||||
* @author Johannes Findeisen
|
||||
* @date 2025-10-16
|
||||
*/
|
||||
|
||||
case OP_ARR_POP: {
|
||||
Value arr = pop_value(vm);
|
||||
if (arr.type != VAL_ARRAY) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue