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

Implements the OP_CALL opcode for function calls in the VM. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 if (argc< 0) argc=0
 if (argc > 0)
 if (fnv.type !=VAL_FUNCTION)
 vm_push_frame (vm, fnv.fn, argc, args)
 free (args)

Variables

case OP_CALL
Valueargs = NULL
Value fnv = pop_value(vm)
 break

Detailed Description

Implements the OP_CALL opcode for function calls in the VM.

This file handles the OP_CALL instruction, which calls a function with arguments.

Behavior:

  • operand specifies number of arguments
  • Pops args and function from stack
  • Creates new frame with args in locals
  • Sets IP to start of function

Error Handling:

  • Exits with error if not enough args
  • Exits if function isn't callable

Definition in file call.c.

Function Documentation

◆ free()

free(args)

◆ if() [1/3]

if(argc,
0 )

Definition at line 32 of file call.c.

◆ if() [2/3]

if()
pure virtual

Definition at line 42 of file insert.c.

◆ if() [3/3]

if(fnv.type ! = VAL_FUNCTION)

Definition at line 41 of file call.c.

◆ vm_push_frame()

vm_push_frame(vm,
fnv.fn,
argc,
args )

Variable Documentation

◆ args

Value* args = NULL

Definition at line 31 of file call.c.

◆ break

break

Definition at line 50 of file call.c.

◆ fnv

Value fnv = pop_value(vm)

Definition at line 40 of file call.c.

◆ OP_CALL

case OP_CALL

Definition at line 27 of file call.c.