pocketlang/src/core.h

49 lines
1.5 KiB
C
Raw Normal View History

2021-02-11 01:23:48 +08:00
/*
* Copyright (c) 2021 Thakee Nathees
* Licensed under: MIT License
*/
#ifndef CORE_H
#define CORE_H
#include "var.h"
#include "common.h"
2021-02-12 01:35:43 +08:00
// Initialize core language, builtin function and core libs.
2021-05-09 18:28:00 +08:00
void initializeCore(PKVM* vm);
2021-02-12 01:35:43 +08:00
// Find the builtin function name and returns it's index in the builtins array
// if not found returns -1.
int findBuiltinFunction(PKVM* vm, const char* name, uint32_t length);
2021-02-12 01:35:43 +08:00
// Returns the builtin function at index [index].
Function* getBuiltinFunction(PKVM* vm, int index);
2021-02-12 01:35:43 +08:00
// Returns the builtin function's name at index [index].
const char* getBuiltinFunctionName(PKVM* vm, int index);
2021-05-07 17:41:19 +08:00
// Return the core library with the [name] if exists in the core libs,
// otherwise returns NULL.
Script* getCoreLib(PKVM* vm, String* name);
2021-05-07 17:41:19 +08:00
/*****************************************************************************/
/* OPERATORS */
/*****************************************************************************/
2021-02-11 01:23:48 +08:00
2021-05-09 18:28:00 +08:00
Var varAdd(PKVM* vm, Var v1, Var v2);
Var varSubtract(PKVM* vm, Var v1, Var v2);
Var varMultiply(PKVM* vm, Var v1, Var v2);
Var varDivide(PKVM* vm, Var v1, Var v2);
Var varModulo(PKVM* vm, Var v1, Var v2);
2021-02-11 01:23:48 +08:00
bool varGreater(Var v1, Var v2);
bool varLesser(Var v1, Var v2);
2021-02-16 02:51:00 +08:00
2021-05-09 18:28:00 +08:00
Var varGetAttrib(PKVM* vm, Var on, String* attrib);
void varSetAttrib(PKVM* vm, Var on, String* name, Var value);
2021-02-16 02:51:00 +08:00
2021-05-09 18:28:00 +08:00
Var varGetSubscript(PKVM* vm, Var on, Var key);
void varsetSubscript(PKVM* vm, Var on, Var key, Var value);
2021-02-15 20:49:19 +08:00
2021-02-11 01:23:48 +08:00
#endif // CORE_H