add function object

This commit is contained in:
2025-06-26 05:11:34 +01:00
parent a275a0a0ad
commit a9d0ba0318
12 changed files with 80 additions and 11 deletions

View File

@@ -1,8 +1,10 @@
#ifndef OBJECT_H
#define OBJECT_H
#include "../internals/hashmap/hashmap.h"
#include "../../dynamic_array/darray.h"
#include <gmp.h>
#include <stdbool.h>
#include "../runtime.h"
extern ArgonObject *BASE_CLASS;
@@ -10,6 +12,12 @@ struct string_struct {
char *data;
size_t length;
};
struct argon_function_struct {
DArray bytecode;
struct Stack stack;
size_t number_of_parameters;
char** parameters;
};
typedef enum {
TYPE_NULL,
@@ -17,6 +25,7 @@ typedef enum {
TYPE_NUMBER,
TYPE_STRING,
TYPE_FUNCTION,
TYPE_NATIVE_FUNCTION,
TYPE_OBJECT, // generic user object
} ArgonType;
@@ -31,6 +40,7 @@ struct ArgonObject {
bool as_bool;
struct string_struct as_str;
void *native_fn;
struct argon_function_struct argon_fn;
// others as needed
} value;
};