Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
random_seed.c File Reference

Implements the OP_RANDOM_SEED opcode for seeding the random number generator in the VM. More...

Go to the source code of this file.

Functions

 if (seed.type !=VAL_INT)
 srand ((unsigned int) seed.i)
 free_value (seed)
 push_value (vm, make_int(0))

Variables

case OP_RANDOM_SEED
 break

Detailed Description

Implements the OP_RANDOM_SEED opcode for seeding the random number generator in the VM.

This file handles the OP_RANDOM_SEED instruction, which seeds the random number generator with a specified value. The seed is popped from the stack.

Behavior:

  • Pops the seed value from the stack.
  • Seeds the random number generator with the value.

Error Handling:

  • Exits with an error if the seed is not an integer.

Example: // Bytecode: OP_RANDOM_SEED // Stack before: [42] // Stack after: []

Definition in file random_seed.c.

Function Documentation

◆ free_value()

free_value(seed)

◆ if()

if(seed.type ! = VAL_INT)

Definition at line 32 of file random_seed.c.

◆ push_value()

push_value(vm,
make_int(0) )

◆ srand()

srand((unsigned int) seed.i)

Variable Documentation

◆ break

break

Definition at line 39 of file random_seed.c.

◆ OP_RANDOM_SEED

case OP_RANDOM_SEED

Definition at line 30 of file random_seed.c.