pocketlang/src/core.h
Thakee Nathees 2c1468f0e8 Merge pull request #37 from ThakeeNathees/bug-fixes
controlflow bugs fixed
2021-06-02 19:53:04 +05:30

49 lines
1.5 KiB
C

/*
* Copyright (c) 2021 Thakee Nathees
* Licensed under: MIT License
*/
#ifndef CORE_H
#define CORE_H
#include "var.h"
#include "common.h"
// Initialize core language, builtin function and core libs.
void initializeCore(PKVM* vm);
// 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);
// Returns the builtin function at index [index].
Function* getBuiltinFunction(PKVM* vm, int index);
// Returns the builtin function's name at index [index].
const char* getBuiltinFunctionName(PKVM* vm, int index);
// Return the core library with the [name] if exists in the core libs,
// otherwise returns NULL.
Script* getCoreLib(PKVM* vm, String* name);
/*****************************************************************************/
/* OPERATORS */
/*****************************************************************************/
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);
bool varGreater(Var v1, Var v2);
bool varLesser(Var v1, Var v2);
Var varGetAttrib(PKVM* vm, Var on, String* attrib);
void varSetAttrib(PKVM* vm, Var on, String* name, Var value);
Var varGetSubscript(PKVM* vm, Var on, Var key);
void varsetSubscript(PKVM* vm, Var on, Var key, Var value);
#endif // CORE_H