mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-17 13:32:38 +00:00
Remove unnecessary ACSVM files from libs
C API and Exec are unused, and ACSVM compiles based on what folders are present.
This commit is contained in:
parent
f8874f3460
commit
481cb3cfb0
27 changed files with 0 additions and 4822 deletions
|
|
@ -1,126 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Arrays.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
|
|
||||||
#include "Environment.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocArray
|
|
||||||
//
|
|
||||||
ACSVM_Array *ACSVM_AllocArray(void)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Array *>(new(std::nothrow) ACSVM::Array);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_FreeArray
|
|
||||||
//
|
|
||||||
void ACSVM_FreeArray(ACSVM_Array *arr)
|
|
||||||
{
|
|
||||||
delete reinterpret_cast<ACSVM::Array *>(arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_Clear
|
|
||||||
//
|
|
||||||
void ACSVM_Array_Clear(ACSVM_Array *arr)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array *>(arr)->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_Find
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Array_Find(ACSVM_Array const *arr, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::Array const *>(arr)->find(idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_Get
|
|
||||||
//
|
|
||||||
ACSVM_Word *ACSVM_Array_Get(ACSVM_Array *arr, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return &reinterpret_cast<ACSVM::Array &>(*arr)[idx];
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_LoadState
|
|
||||||
//
|
|
||||||
bool ACSVM_Array_LoadState(ACSVM_Array *arr, ACSVM_Serial *in)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array *>(arr)->loadState(
|
|
||||||
*reinterpret_cast<ACSVM::Serial *>(in));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_LockStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Array_LockStrings(ACSVM_Array const *arr, ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array const *>(arr)->lockStrings(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_RefStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Array_RefStrings(ACSVM_Array const *arr, ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array const *>(arr)->refStrings(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_SaveState
|
|
||||||
//
|
|
||||||
void ACSVM_Array_SaveState(ACSVM_Array const *arr, ACSVM_Serial *out)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array const *>(arr)->saveState(
|
|
||||||
*reinterpret_cast<ACSVM::Serial *>(out));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Array_UnlockStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Array_UnlockStrings(ACSVM_Array const *arr, ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::Array const *>(arr)->unlockStrings(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Arrays.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Array_H__
|
|
||||||
#define ACSVM__CAPI__Array_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Array.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_Array *ACSVM_AllocArray(void);
|
|
||||||
void ACSVM_FreeArray(ACSVM_Array *arr);
|
|
||||||
|
|
||||||
void ACSVM_Array_Clear(ACSVM_Array *arr);
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_Array_Find(ACSVM_Array const *arr, ACSVM_Word idx);
|
|
||||||
|
|
||||||
ACSVM_Word *ACSVM_Array_Get(ACSVM_Array *arr, ACSVM_Word idx);
|
|
||||||
|
|
||||||
bool ACSVM_Array_LoadState(ACSVM_Array *arr, ACSVM_Serial *in);
|
|
||||||
|
|
||||||
void ACSVM_Array_LockStrings(ACSVM_Array const *arr, ACSVM_Environment *env);
|
|
||||||
|
|
||||||
void ACSVM_Array_RefStrings(ACSVM_Array const *arr, ACSVM_Environment *env);
|
|
||||||
|
|
||||||
void ACSVM_Array_SaveState(ACSVM_Array const *arr, ACSVM_Serial *out);
|
|
||||||
|
|
||||||
void ACSVM_Array_UnlockStrings(ACSVM_Array const *arr, ACSVM_Environment *env);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Array_H__
|
|
||||||
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Binary data reading/writing.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "BinaryIO.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Buffer constructor
|
|
||||||
//
|
|
||||||
ACSVM_Buffer::ACSVM_Buffer(FILE *stream_) :
|
|
||||||
stream{stream_}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Buffer::overflow
|
|
||||||
//
|
|
||||||
int ACSVM_Buffer::overflow(int c)
|
|
||||||
{
|
|
||||||
return std::fputc(c, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Buffer::uflow
|
|
||||||
//
|
|
||||||
int ACSVM_Buffer::uflow()
|
|
||||||
{
|
|
||||||
return std::fgetc(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_IStream constructor
|
|
||||||
//
|
|
||||||
ACSVM_IStream::ACSVM_IStream(FILE *stream) :
|
|
||||||
buf{stream}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_OStream constructor
|
|
||||||
//
|
|
||||||
ACSVM_OStream::ACSVM_OStream(FILE *stream) :
|
|
||||||
buf{stream}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocIStream
|
|
||||||
//
|
|
||||||
ACSVM_IStream *ACSVM_AllocIStream_File(FILE *stream)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_IStream *>(
|
|
||||||
static_cast<std::istream *>(new(std::nothrow) ACSVM_IStream(stream)));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocOStream
|
|
||||||
//
|
|
||||||
ACSVM_OStream *ACSVM_AllocOStream_File(FILE *stream)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_OStream *>(
|
|
||||||
static_cast<std::ostream *>(new(std::nothrow) ACSVM_OStream(stream)));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ReadVLN
|
|
||||||
//
|
|
||||||
uintmax_t ACSVM_ReadVLN(ACSVM_IStream *in)
|
|
||||||
{
|
|
||||||
return ACSVM::ReadVLN<std::uintmax_t>(reinterpret_cast<std::istream &>(*in));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_WriteVLN
|
|
||||||
//
|
|
||||||
void ACSVM_WriteVLN(ACSVM_OStream *out, uintmax_t in)
|
|
||||||
{
|
|
||||||
ACSVM::WriteVLN(reinterpret_cast<std::ostream &>(*out), in);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Binary data reading/writing.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__BinaryIO_H__
|
|
||||||
#define ACSVM__CAPI__BinaryIO_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/BinaryIO.hpp"
|
|
||||||
|
|
||||||
#include <istream>
|
|
||||||
#include <ostream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
//
|
|
||||||
// ACSVM_Buffer
|
|
||||||
//
|
|
||||||
struct ACSVM_Buffer : std::streambuf
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACSVM_Buffer(FILE *stream);
|
|
||||||
|
|
||||||
FILE *stream;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int overflow(int c);
|
|
||||||
|
|
||||||
virtual int uflow();
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_IStream
|
|
||||||
//
|
|
||||||
struct ACSVM_IStream : std::istream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACSVM_IStream(FILE *stream);
|
|
||||||
|
|
||||||
ACSVM_Buffer buf;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_OStream
|
|
||||||
//
|
|
||||||
struct ACSVM_OStream : std::ostream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACSVM_OStream(FILE *stream);
|
|
||||||
|
|
||||||
ACSVM_Buffer buf;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_IStream *ACSVM_AllocIStream_File(FILE *stream);
|
|
||||||
void ACSVM_FreeIStream(ACSVM_IStream *stream);
|
|
||||||
|
|
||||||
ACSVM_OStream *ACSVM_AllocOStream_File(FILE *stream);
|
|
||||||
void ACSVM_FreeOStream(ACSVM_OStream *stream);
|
|
||||||
|
|
||||||
uintmax_t ACSVM_ReadVLN(ACSVM_IStream *in);
|
|
||||||
|
|
||||||
void ACSVM_WriteVLN(ACSVM_OStream *out, uintmax_t in);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__BinaryIO_H__
|
|
||||||
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
##
|
|
||||||
## Copyright (C) 2015 David Hill
|
|
||||||
##
|
|
||||||
## See COPYING for license information.
|
|
||||||
##
|
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
##
|
|
||||||
## CMake file for acsvm-capi.
|
|
||||||
##
|
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
##----------------------------------------------------------------------------|
|
|
||||||
## Environment Configuration |
|
|
||||||
##
|
|
||||||
|
|
||||||
include_directories(.)
|
|
||||||
|
|
||||||
|
|
||||||
##----------------------------------------------------------------------------|
|
|
||||||
## Targets |
|
|
||||||
##
|
|
||||||
|
|
||||||
##
|
|
||||||
## acsvm-capi
|
|
||||||
##
|
|
||||||
add_library(acsvm-capi ${ACSVM_SHARED_DECL}
|
|
||||||
Array.cpp
|
|
||||||
Array.h
|
|
||||||
BinaryIO.cpp
|
|
||||||
BinaryIO.h
|
|
||||||
Environment.cpp
|
|
||||||
Environment.h
|
|
||||||
Floats.cpp
|
|
||||||
Floats.h
|
|
||||||
Module.cpp
|
|
||||||
Module.h
|
|
||||||
PrintBuf.cpp
|
|
||||||
PrintBuf.h
|
|
||||||
Scope.cpp
|
|
||||||
Scope.h
|
|
||||||
String.cpp
|
|
||||||
String.h
|
|
||||||
Thread.cpp
|
|
||||||
Thread.h
|
|
||||||
Types.h
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(acsvm-capi acsvm-util)
|
|
||||||
|
|
||||||
ACSVM_INSTALL_LIB(acsvm-capi)
|
|
||||||
|
|
||||||
## EOF
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Codes.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Code_H__
|
|
||||||
#define ACSVM__CAPI__Code_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Code.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Code
|
|
||||||
//
|
|
||||||
// ACSVM::Code mirror.
|
|
||||||
//
|
|
||||||
typedef enum ACSVM_Code
|
|
||||||
{
|
|
||||||
#define ACSVM_CodeList(name, ...) ACSVM_Code_##name,
|
|
||||||
#include "../ACSVM/CodeList.hpp"
|
|
||||||
|
|
||||||
ACSVM_Code_None
|
|
||||||
} ACSVM_Code;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Func
|
|
||||||
//
|
|
||||||
// ACSVM::Func mirror.
|
|
||||||
//
|
|
||||||
typedef enum ACSVM_Func
|
|
||||||
{
|
|
||||||
#define ACSVM_FuncList(name) ACSVM_Func_##name,
|
|
||||||
#include "../ACSVM/CodeList.hpp"
|
|
||||||
|
|
||||||
ACSVM_Func_None
|
|
||||||
} ACSVM_Func;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_KillType
|
|
||||||
//
|
|
||||||
// ACSVM::KillType mirror.
|
|
||||||
//
|
|
||||||
typedef enum ACSVM_KillType
|
|
||||||
{
|
|
||||||
ACSVM_KillType_None,
|
|
||||||
ACSVM_KillType_OutOfBounds,
|
|
||||||
ACSVM_KillType_UnknownCode,
|
|
||||||
ACSVM_KillType_UnknownFunc,
|
|
||||||
ACSVM_KillType_BranchLimit,
|
|
||||||
} ACSVM_KillType;
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Code_H__
|
|
||||||
|
|
||||||
|
|
@ -1,484 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Environment.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Environment.h"
|
|
||||||
|
|
||||||
#include "Code.h"
|
|
||||||
#include "Module.h"
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
#include "ACSVM/CodeData.hpp"
|
|
||||||
#include "ACSVM/Error.hpp"
|
|
||||||
#include "ACSVM/Serial.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment constructor
|
|
||||||
//
|
|
||||||
ACSVM_Environment::ACSVM_Environment(ACSVM_EnvironmentFuncs const &funcs_, void *data_) :
|
|
||||||
funcs{funcs_}, data{data_}
|
|
||||||
{
|
|
||||||
if(funcs.ctor)
|
|
||||||
funcs.ctor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment destructor
|
|
||||||
//
|
|
||||||
ACSVM_Environment::~ACSVM_Environment()
|
|
||||||
{
|
|
||||||
if(funcs.dtor)
|
|
||||||
funcs.dtor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::allocThread
|
|
||||||
//
|
|
||||||
ACSVM::Thread *ACSVM_Environment::allocThread()
|
|
||||||
{
|
|
||||||
if(!funcs.allocThread)
|
|
||||||
return new ACSVM_Thread(this, {}, nullptr);
|
|
||||||
|
|
||||||
if(ACSVM_Thread *thread = funcs.allocThread(this))
|
|
||||||
return thread;
|
|
||||||
|
|
||||||
throw std::bad_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::callFunc
|
|
||||||
//
|
|
||||||
bool ACSVM_Environment::callFunc(ACSVM::Thread *thread, ACSVM::Word func,
|
|
||||||
ACSVM::Word const *argV, ACSVM::Word argC)
|
|
||||||
{
|
|
||||||
if(func <= static_cast<ACSVM::Word>(ACSVM::Func::None))
|
|
||||||
return ACSVM::Environment::callFunc(thread, func, argV, argC);
|
|
||||||
|
|
||||||
auto callFunc = callFuncV[func - static_cast<ACSVM::Word>(ACSVM::Func::None) - 1];
|
|
||||||
return callFunc(static_cast<ACSVM_Thread *>(thread), argV, argC);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::callSpecImpl
|
|
||||||
//
|
|
||||||
ACSVM::Word ACSVM_Environment::callSpecImpl(ACSVM::Thread *thread,
|
|
||||||
ACSVM::Word spec, ACSVM::Word const *argV, ACSVM::Word argC)
|
|
||||||
{
|
|
||||||
if(!funcs.callSpecImpl)
|
|
||||||
return ACSVM::Environment::callSpecImpl(thread, spec, argV, argC);
|
|
||||||
|
|
||||||
return funcs.callSpecImpl(this, static_cast<ACSVM_Thread *>(thread), spec, argV, argC);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::checkLock
|
|
||||||
//
|
|
||||||
bool ACSVM_Environment::checkLock(ACSVM::Thread *thread, ACSVM::Word lock, bool door)
|
|
||||||
{
|
|
||||||
if(!funcs.checkLock)
|
|
||||||
return ACSVM::Environment::checkLock(thread, lock, door);
|
|
||||||
|
|
||||||
return funcs.checkLock(this, static_cast<ACSVM_Thread *>(thread), lock, door);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::checkTag
|
|
||||||
//
|
|
||||||
bool ACSVM_Environment::checkTag(ACSVM::Word type, ACSVM::Word tag)
|
|
||||||
{
|
|
||||||
if(!funcs.checkTag)
|
|
||||||
return ACSVM::Environment::checkTag(type, tag);
|
|
||||||
|
|
||||||
return funcs.checkTag(this, type, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::getModuleName
|
|
||||||
//
|
|
||||||
ACSVM::ModuleName ACSVM_Environment::getModuleName(char const *str, std::size_t len)
|
|
||||||
{
|
|
||||||
if(!funcs.getModuleName)
|
|
||||||
return ACSVM::Environment::getModuleName(str, len);
|
|
||||||
|
|
||||||
auto name = funcs.getModuleName(this, str, len);
|
|
||||||
return {reinterpret_cast<ACSVM::String *>(name.s), name.p, name.i};
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::loadModule
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::loadModule(ACSVM::Module *module)
|
|
||||||
{
|
|
||||||
if(!funcs.loadModule)
|
|
||||||
throw ACSVM::ReadError();
|
|
||||||
|
|
||||||
if(!funcs.loadModule(this, reinterpret_cast<ACSVM_Module *>(module)))
|
|
||||||
throw ACSVM::ReadError();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::loadState
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::loadState(ACSVM::Serial &in)
|
|
||||||
{
|
|
||||||
ACSVM::Environment::loadState(in);
|
|
||||||
|
|
||||||
if(funcs.loadState)
|
|
||||||
funcs.loadState(this, reinterpret_cast<ACSVM_Serial *>(&in));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::printArray
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::printArray(ACSVM::PrintBuf &buf, ACSVM::Array const &array,
|
|
||||||
ACSVM::Word index, ACSVM::Word limit)
|
|
||||||
{
|
|
||||||
if(!funcs.printArray)
|
|
||||||
return ACSVM::Environment::printArray(buf, array, index, limit);
|
|
||||||
|
|
||||||
funcs.printArray(this, reinterpret_cast<ACSVM_PrintBuf *>(&buf),
|
|
||||||
reinterpret_cast<ACSVM_Array const *>(&array), index, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::printKill
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::printKill(ACSVM::Thread *thread, ACSVM::Word type, ACSVM::Word killData)
|
|
||||||
{
|
|
||||||
if(!funcs.printKill)
|
|
||||||
return ACSVM::Environment::printKill(thread, type, killData);
|
|
||||||
|
|
||||||
funcs.printKill(this, static_cast<ACSVM_Thread *>(thread), type, killData);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::readModuleName
|
|
||||||
//
|
|
||||||
ACSVM::ModuleName ACSVM_Environment::readModuleName(ACSVM::Serial &in) const
|
|
||||||
{
|
|
||||||
if(!funcs.readModuleName)
|
|
||||||
return ACSVM::Environment::readModuleName(in);
|
|
||||||
|
|
||||||
auto name = funcs.readModuleName(this, reinterpret_cast<ACSVM_Serial *>(&in));
|
|
||||||
return {reinterpret_cast<ACSVM::String *>(name.s), name.p, name.i};
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::refStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::refStrings()
|
|
||||||
{
|
|
||||||
ACSVM::Environment::refStrings();
|
|
||||||
|
|
||||||
if(funcs.refStrings)
|
|
||||||
funcs.refStrings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::resetStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::resetStrings()
|
|
||||||
{
|
|
||||||
ACSVM::Environment::resetStrings();
|
|
||||||
|
|
||||||
if(funcs.resetStrings)
|
|
||||||
funcs.resetStrings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::saveState
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::saveState(ACSVM::Serial &out) const
|
|
||||||
{
|
|
||||||
ACSVM::Environment::saveState(out);
|
|
||||||
|
|
||||||
if(funcs.saveState)
|
|
||||||
funcs.saveState(this, reinterpret_cast<ACSVM_Serial *>(&out));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment::writeModuleName
|
|
||||||
//
|
|
||||||
void ACSVM_Environment::writeModuleName(ACSVM::Serial &out, ACSVM::ModuleName const &in) const
|
|
||||||
{
|
|
||||||
if(!funcs.writeModuleName)
|
|
||||||
return ACSVM::Environment::writeModuleName(out, in);
|
|
||||||
|
|
||||||
funcs.writeModuleName(this, reinterpret_cast<ACSVM_Serial *>(&out),
|
|
||||||
{reinterpret_cast<ACSVM_String *>(in.s), in.p, in.i});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocEnvironment
|
|
||||||
//
|
|
||||||
ACSVM_Environment *ACSVM_AllocEnvironment(ACSVM_EnvironmentFuncs const *funcs, void *data)
|
|
||||||
{
|
|
||||||
return new(std::nothrow) ACSVM_Environment(*funcs, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_FreeEnvironment
|
|
||||||
//
|
|
||||||
void ACSVM_FreeEnvironment(ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
delete env;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_AddCallFunc
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Environment_AddCallFunc(ACSVM_Environment *env, ACSVM_CallFunc func)
|
|
||||||
{
|
|
||||||
env->callFuncV.push_back(func);
|
|
||||||
return env->callFuncV.size() + static_cast<ACSVM_Word>(ACSVM::Func::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_AddCodeDataACS0
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_AddCodeDataACS0(ACSVM_Environment *env, ACSVM_Word code,
|
|
||||||
char const *args, ACSVM_Code transCode_, ACSVM_Word stackArgC, ACSVM_Word transFunc)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
auto transCode = static_cast<ACSVM::Code>(transCode_);
|
|
||||||
env->addCodeDataACS0(code, {args, transCode, stackArgC, transFunc});
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_AddFuncDataACS0
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_AddFuncDataACS0(ACSVM_Environment *env, ACSVM_Word func,
|
|
||||||
ACSVM_Word transFunc, ACSVM_Word const *transCodeArgCV,
|
|
||||||
ACSVM_Code const *transCodeV, size_t transCodeC)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(transCodeC)
|
|
||||||
{
|
|
||||||
std::unique_ptr<ACSVM::FuncDataACS0::TransCode[]> transCodes
|
|
||||||
{new ACSVM::FuncDataACS0::TransCode[transCodeC]};
|
|
||||||
|
|
||||||
for(std::size_t i = 0; i != transCodeC; ++i)
|
|
||||||
transCodes[i] = {transCodeArgCV[i], static_cast<ACSVM::Code>(transCodeV[i])};
|
|
||||||
|
|
||||||
env->addFuncDataACS0(func, {transFunc, std::move(transCodes), transCodeC});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
env->addFuncDataACS0(func, transFunc);
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_CollectStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_CollectStrings(ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
env->collectStrings();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_Exec
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_Exec(ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
env->exec();
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_FreeGlobalScope
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_FreeGlobalScope(ACSVM_Environment *env, ACSVM_GlobalScope *scope)
|
|
||||||
{
|
|
||||||
env->freeGlobalScope(reinterpret_cast<ACSVM::GlobalScope *>(scope));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_FreeModule
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_FreeModule(ACSVM_Environment *env, ACSVM_Module *module)
|
|
||||||
{
|
|
||||||
env->freeModule(reinterpret_cast<ACSVM::Module *>(module));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetBranchLimit
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Environment_GetBranchLimit(ACSVM_Environment const *env)
|
|
||||||
{
|
|
||||||
return env->branchLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetData
|
|
||||||
//
|
|
||||||
void *ACSVM_Environment_GetData(ACSVM_Environment const *env)
|
|
||||||
{
|
|
||||||
return env->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetGlobalScope
|
|
||||||
//
|
|
||||||
ACSVM_GlobalScope *ACSVM_Environment_GetGlobalScope(ACSVM_Environment *env, ACSVM_Word id)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_GlobalScope *>(env->getGlobalScope(id));
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetModule
|
|
||||||
//
|
|
||||||
ACSVM_Module *ACSVM_Environment_GetModule(ACSVM_Environment *env, ACSVM_ModuleName name)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Module *>(env->getModule(
|
|
||||||
{reinterpret_cast<ACSVM::String *>(name.s), name.p, name.i}));
|
|
||||||
}
|
|
||||||
catch(ACSVM::ReadError const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.readError)
|
|
||||||
env->funcs.readError(env, e.what());
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetScriptLocRegC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Environment_GetScriptLocRegC(ACSVM_Environment const *env)
|
|
||||||
{
|
|
||||||
return env->scriptLocRegC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_GetStringTable
|
|
||||||
//
|
|
||||||
ACSVM_StringTable *ACSVM_Environment_GetStringTable(ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_StringTable *>(&env->stringTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_HasActiveThread
|
|
||||||
//
|
|
||||||
bool ACSVM_Environment_HasActiveThread(ACSVM_Environment const *env)
|
|
||||||
{
|
|
||||||
return env->hasActiveThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_LoadState
|
|
||||||
//
|
|
||||||
bool ACSVM_Environment_LoadState(ACSVM_Environment *env, ACSVM_Serial *in)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
env->loadState(*reinterpret_cast<ACSVM::Serial *>(in));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(ACSVM::SerialError const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.serialError)
|
|
||||||
env->funcs.serialError(env, e.what());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_SaveState
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_SaveState(ACSVM_Environment *env, ACSVM_Serial *out)
|
|
||||||
{
|
|
||||||
env->saveState(*reinterpret_cast<ACSVM::Serial *>(out));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_SetBranchLimit
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_SetBranchLimit(ACSVM_Environment *env, ACSVM_Word branchLimit)
|
|
||||||
{
|
|
||||||
env->branchLimit = branchLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_SetData
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_SetData(ACSVM_Environment *env, void *data)
|
|
||||||
{
|
|
||||||
env->data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Environment_SetScriptLocRegC
|
|
||||||
//
|
|
||||||
void ACSVM_Environment_SetScriptLocReg(ACSVM_Environment *env, ACSVM_Word scriptLocRegC)
|
|
||||||
{
|
|
||||||
env->scriptLocRegC = scriptLocRegC;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,198 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Environment.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Environment_H__
|
|
||||||
#define ACSVM__CAPI__Environment_H__
|
|
||||||
|
|
||||||
#include "Code.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Environment.hpp"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_EnvironmentFuncs
|
|
||||||
//
|
|
||||||
// Overridable virtual functions in ACSVM_Environment. If null, the base
|
|
||||||
// function is called. If the base function is pure virtual, then the function
|
|
||||||
// in this structure must not be null.
|
|
||||||
//
|
|
||||||
typedef struct ACSVM_EnvironmentFuncs
|
|
||||||
{
|
|
||||||
// Called in the event of a memory allocation failure. This function may
|
|
||||||
// return normally, but the ACSVM_Environment object must not be used
|
|
||||||
// afterward, except to be passed to ACSVM_FreeEnvironment.
|
|
||||||
void (*bad_alloc)(ACSVM_Environment *env, char const *what);
|
|
||||||
|
|
||||||
// Called if an ACSVM::ReadError is caught. This function may return
|
|
||||||
// normally.
|
|
||||||
void (*readError)(ACSVM_Environment *env, char const *what);
|
|
||||||
|
|
||||||
// Called if an ACSVM::SerialError is caught. This function may return
|
|
||||||
// normally, but the VM state is indeterminate.
|
|
||||||
void (*serialError)(ACSVM_Environment *env, char const *what);
|
|
||||||
|
|
||||||
// public
|
|
||||||
|
|
||||||
void (*ctor)(ACSVM_Environment *env);
|
|
||||||
void (*dtor)(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
bool (*checkLock)(ACSVM_Environment const *env, ACSVM_Thread *thread,
|
|
||||||
ACSVM_Word lock, bool door);
|
|
||||||
|
|
||||||
bool (*checkTag)(ACSVM_Environment const *env, ACSVM_Word type, ACSVM_Word tag);
|
|
||||||
|
|
||||||
ACSVM_ModuleName (*getModuleName)(ACSVM_Environment *env,
|
|
||||||
char const *str, size_t len);
|
|
||||||
|
|
||||||
// Called after base class's.
|
|
||||||
void (*loadState)(ACSVM_Environment *env, ACSVM_Serial *in);
|
|
||||||
|
|
||||||
void (*printArray)(ACSVM_Environment const *env, ACSVM_PrintBuf *buf,
|
|
||||||
ACSVM_Array const *array, ACSVM_Word index, ACSVM_Word limit);
|
|
||||||
|
|
||||||
void (*printKill)(ACSVM_Environment const *env, ACSVM_Thread *thread,
|
|
||||||
ACSVM_Word type, ACSVM_Word data);
|
|
||||||
|
|
||||||
ACSVM_ModuleName (*readModuleName)(ACSVM_Environment const *env, ACSVM_Serial *in);
|
|
||||||
|
|
||||||
// Called after base class's.
|
|
||||||
void (*refStrings)(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
// Called after base class's.
|
|
||||||
void (*resetStrings)(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
// Called after base class's.
|
|
||||||
void (*saveState)(ACSVM_Environment const *env, ACSVM_Serial *out);
|
|
||||||
|
|
||||||
void (*writeModuleName)(ACSVM_Environment const *env, ACSVM_Serial *out,
|
|
||||||
ACSVM_ModuleName in);
|
|
||||||
|
|
||||||
// protected
|
|
||||||
|
|
||||||
ACSVM_Thread *(*allocThread)(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
ACSVM_Word (*callSpecImpl)(ACSVM_Environment *env, ACSVM_Thread *thread,
|
|
||||||
ACSVM_Word spec, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
|
|
||||||
// Return false if load fails.
|
|
||||||
bool (*loadModule)(ACSVM_Environment *env, ACSVM_Module *module);
|
|
||||||
} ACSVM_EnvironmentFuncs;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
//
|
|
||||||
// ACSVM_Environment
|
|
||||||
//
|
|
||||||
struct ACSVM_Environment : ACSVM::Environment
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACSVM_Environment(ACSVM_EnvironmentFuncs const &funcs, void *data);
|
|
||||||
virtual ~ACSVM_Environment();
|
|
||||||
|
|
||||||
virtual bool callFunc(ACSVM::Thread *thread, ACSVM::Word func,
|
|
||||||
ACSVM::Word const *argV, ACSVM::Word argC);
|
|
||||||
|
|
||||||
virtual bool checkLock(ACSVM::Thread *thread, ACSVM::Word lock, bool door);
|
|
||||||
|
|
||||||
virtual bool checkTag(ACSVM::Word type, ACSVM::Word tag);
|
|
||||||
|
|
||||||
virtual ACSVM::ModuleName getModuleName(char const *str, size_t len);
|
|
||||||
|
|
||||||
virtual void loadState(ACSVM::Serial &in);
|
|
||||||
|
|
||||||
virtual void printArray(ACSVM::PrintBuf &buf, ACSVM::Array const &array,
|
|
||||||
ACSVM::Word index, ACSVM::Word limit);
|
|
||||||
|
|
||||||
virtual void printKill(ACSVM::Thread *thread, ACSVM::Word type, ACSVM::Word data);
|
|
||||||
|
|
||||||
virtual ACSVM::ModuleName readModuleName(ACSVM::Serial &in) const;
|
|
||||||
|
|
||||||
virtual void refStrings();
|
|
||||||
|
|
||||||
virtual void resetStrings();
|
|
||||||
|
|
||||||
virtual void saveState(ACSVM::Serial &out) const;
|
|
||||||
|
|
||||||
virtual void writeModuleName(ACSVM::Serial &out, ACSVM::ModuleName const &in) const;
|
|
||||||
|
|
||||||
std::vector<ACSVM_CallFunc> callFuncV;
|
|
||||||
ACSVM_EnvironmentFuncs funcs;
|
|
||||||
void *data;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ACSVM::Thread *allocThread();
|
|
||||||
|
|
||||||
virtual ACSVM::Word callSpecImpl(ACSVM::Thread *thread, ACSVM::Word spec,
|
|
||||||
ACSVM::Word const *argV, ACSVM::Word argC);
|
|
||||||
|
|
||||||
virtual void loadModule(ACSVM::Module *module);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_Environment *ACSVM_AllocEnvironment(ACSVM_EnvironmentFuncs const *funcs, void *data);
|
|
||||||
void ACSVM_FreeEnvironment(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_Environment_AddCallFunc(ACSVM_Environment *env, ACSVM_CallFunc func);
|
|
||||||
|
|
||||||
void ACSVM_Environment_AddCodeDataACS0(ACSVM_Environment *env, ACSVM_Word code,
|
|
||||||
char const *args, ACSVM_Code transCode, ACSVM_Word stackArgC, ACSVM_Word transFunc);
|
|
||||||
|
|
||||||
void ACSVM_Environment_AddFuncDataACS0(ACSVM_Environment *env, ACSVM_Word func,
|
|
||||||
ACSVM_Word transFunc, ACSVM_Word const *transCodeArgCV,
|
|
||||||
ACSVM_Code const *transCodeV, size_t transCodeC);
|
|
||||||
|
|
||||||
void ACSVM_Environment_CollectStrings(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
void ACSVM_Environment_Exec(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
void ACSVM_Environment_FreeGlobalScope(ACSVM_Environment *env, ACSVM_GlobalScope *scope);
|
|
||||||
void ACSVM_Environment_FreeModule(ACSVM_Environment *env, ACSVM_Module *module);
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_Environment_GetBranchLimit(ACSVM_Environment const *env);
|
|
||||||
void *ACSVM_Environment_GetData(ACSVM_Environment const *env);
|
|
||||||
ACSVM_GlobalScope *ACSVM_Environment_GetGlobalScope(ACSVM_Environment *env, ACSVM_Word id);
|
|
||||||
ACSVM_Module *ACSVM_Environment_GetModule(ACSVM_Environment *env, ACSVM_ModuleName name);
|
|
||||||
ACSVM_Word ACSVM_Environment_GetScriptLocRegC(ACSVM_Environment const *env);
|
|
||||||
ACSVM_StringTable *ACSVM_Environment_GetStringTable(ACSVM_Environment *env);
|
|
||||||
|
|
||||||
bool ACSVM_Environment_HasActiveThread(ACSVM_Environment const *env);
|
|
||||||
|
|
||||||
bool ACSVM_Environment_LoadState(ACSVM_Environment *env, ACSVM_Serial *in);
|
|
||||||
|
|
||||||
void ACSVM_Environment_SaveState(ACSVM_Environment *env, ACSVM_Serial *out);
|
|
||||||
|
|
||||||
void ACSVM_Environment_SetBranchLimit(ACSVM_Environment *env, ACSVM_Word branchLimit);
|
|
||||||
void ACSVM_Environment_SetData(ACSVM_Environment *env, void *data);
|
|
||||||
void ACSVM_Environment_SetScriptLocRegC(ACSVM_Environment *env, ACSVM_Word scriptLocRegC);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Environment_H__
|
|
||||||
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Floating-point utilities.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Floats.h"
|
|
||||||
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_CF_*
|
|
||||||
//
|
|
||||||
|
|
||||||
bool ACSVM_CF_AddF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_AddF_W1(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_AddF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_AddF_W2(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_DivF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_DivF_W1(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_DivF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_DivF_W2(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_MulF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_MulF_W1(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_MulF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_MulF_W2(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_SubF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_SubF_W1(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_SubF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_SubF_W2(thread, argV, argC);}
|
|
||||||
|
|
||||||
bool ACSVM_CF_PrintDouble(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_PrintDouble(thread, argV, argC);}
|
|
||||||
bool ACSVM_CF_PrintFloat(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{return ACSVM::CF_PrintFloat(thread, argV, argC);}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_DWordToDouble
|
|
||||||
//
|
|
||||||
double ACSVM_DWordToDouble(ACSVM_DWord w)
|
|
||||||
{
|
|
||||||
return ACSVM::WordsToFloat<double, 2>(
|
|
||||||
{{static_cast<ACSVM_Word>(w), static_cast<ACSVM_Word>(w >> 32)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_DoubleToDWord
|
|
||||||
//
|
|
||||||
ACSVM_DWord ACSBM_DoubleToDWord(double f)
|
|
||||||
{
|
|
||||||
auto w = ACSVM::FloatToWords<2>(f);
|
|
||||||
return (static_cast<ACSVM_DWord>(w[1]) << 32) | w[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_FloatToWord
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_FloatToWord(float f)
|
|
||||||
{
|
|
||||||
return ACSVM::FloatToWords<1>(f)[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_WordToFloat
|
|
||||||
//
|
|
||||||
float ACSVM_WordToFloat(ACSVM_Word w)
|
|
||||||
{
|
|
||||||
return ACSVM::WordsToFloat<float, 1>({{w}});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Floating-point utilities.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Floats_H__
|
|
||||||
#define ACSVM__CAPI__Floats_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../Util/Floats.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
bool ACSVM_CF_AddF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_AddF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_DivF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_DivF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_MulF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_MulF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_SubF_W1(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_SubF_W2(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
|
|
||||||
bool ACSVM_CF_PrintDouble(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
bool ACSVM_CF_PrintFloat(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);
|
|
||||||
|
|
||||||
double ACSVM_DWordToDouble(ACSVM_DWord w);
|
|
||||||
|
|
||||||
ACSVM_DWord ACSVM_DoubleToDWord(double f);
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_FloatToWord(float f);
|
|
||||||
|
|
||||||
float ACSVM_WordToFloat(ACSVM_Word w);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Floats_H__
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Modules.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Module.h"
|
|
||||||
|
|
||||||
#include "Environment.h"
|
|
||||||
|
|
||||||
#include "ACSVM/Error.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Module_GetName
|
|
||||||
//
|
|
||||||
ACSVM_ModuleName ACSVM_Module_GetName(ACSVM_Module const *module_)
|
|
||||||
{
|
|
||||||
auto module = reinterpret_cast<ACSVM::Module const *>(module_);
|
|
||||||
|
|
||||||
return {reinterpret_cast<ACSVM_String *>(module->name.s), module->name.p, module->name.i};
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Module_ReadBytecode
|
|
||||||
//
|
|
||||||
bool ACSVM_Module_ReadBytecode(ACSVM_Module *module_, ACSVM_Byte const *data, size_t size)
|
|
||||||
{
|
|
||||||
auto module = reinterpret_cast<ACSVM::Module *>(module_);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
module->readBytecode(data, size);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(ACSVM::ReadError const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(module->env);
|
|
||||||
if(env->funcs.readError)
|
|
||||||
env->funcs.readError(env, e.what());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(module->env);
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Modules.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Module_H__
|
|
||||||
#define ACSVM__CAPI__Module_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Module.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleName
|
|
||||||
//
|
|
||||||
// ACSVM::ModuleName mirror.
|
|
||||||
//
|
|
||||||
struct ACSVM_ModuleName
|
|
||||||
{
|
|
||||||
ACSVM_String *s;
|
|
||||||
void *p;
|
|
||||||
size_t i;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_ModuleName ACSVM_Module_GetName(ACSVM_Module const *module);
|
|
||||||
|
|
||||||
// Returns false if reading fails.
|
|
||||||
bool ACSVM_Module_ReadBytecode(ACSVM_Module *module, ACSVM_Byte const *data, size_t size);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Module_H__
|
|
||||||
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// PrintBuf class.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "PrintBuf.h"
|
|
||||||
|
|
||||||
#include <new>
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocPrintBuf
|
|
||||||
//
|
|
||||||
ACSVM_PrintBuf *ACSVM_AllocPrintBuf(void)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_PrintBuf *>(new(std::nothrow) ACSVM::PrintBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_FreePrintBuf
|
|
||||||
//
|
|
||||||
void ACSVM_FreePrintBuf(ACSVM_PrintBuf *buf)
|
|
||||||
{
|
|
||||||
delete reinterpret_cast<ACSVM::PrintBuf *>(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Clear
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_Clear(ACSVM_PrintBuf *buf)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Drop
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_Drop(ACSVM_PrintBuf *buf)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->drop();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Format
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_Format(ACSVM_PrintBuf *buf, char const *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list arg;
|
|
||||||
va_start(arg, fmt);
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->formatv(fmt, arg);
|
|
||||||
va_end(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_FormatV
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_FormatV(ACSVM_PrintBuf *buf, char const *fmt, va_list arg)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->formatv(fmt, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_GetBuf
|
|
||||||
//
|
|
||||||
char *ACSVM_PrintBuf_GetBuf(ACSVM_PrintBuf *buf, size_t count)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf *>(buf)->getBuf(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_GetData
|
|
||||||
//
|
|
||||||
char const *ACSVM_PrintBuf_GetData(ACSVM_PrintBuf const *buf)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf const *>(buf)->data();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_GetDataFull
|
|
||||||
//
|
|
||||||
char const *ACSVM_PrintBuf_GetDataFull(ACSVM_PrintBuf const *buf)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf const *>(buf)->dataFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_GetLoadBuf
|
|
||||||
//
|
|
||||||
char *ACSVM_PrintBuf_GetLoadBuf(ACSVM_PrintBuf *buf, size_t countFull, size_t count)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf *>(buf)->getLoadBuf(countFull, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Push
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_Push(ACSVM_PrintBuf *buf)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->push();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_PutC
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_PutC(ACSVM_PrintBuf *buf, char c)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->put(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_PutS
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_PutS(ACSVM_PrintBuf *buf, char const *s, size_t n)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->put(s, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Reserve
|
|
||||||
//
|
|
||||||
void ACSVM_PrintBuf_Reserve(ACSVM_PrintBuf *buf, size_t count)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::PrintBuf *>(buf)->reserve(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_Size
|
|
||||||
//
|
|
||||||
size_t ACSVM_PrintBuf_Size(ACSVM_PrintBuf const *buf)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf const *>(buf)->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_PrintBuf_SizeFull
|
|
||||||
//
|
|
||||||
size_t ACSVM_PrintBuf_SizeFull(ACSVM_PrintBuf const *buf)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::PrintBuf const *>(buf)->sizeFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// PrintBuf class.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__PrintBuf_H__
|
|
||||||
#define ACSVM__CAPI__PrintBuf_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/PrintBuf.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_PrintBuf *ACSVM_AllocPrintBuf(void);
|
|
||||||
void ACSVM_FreePrintBuf(ACSVM_PrintBuf *buf);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_Clear(ACSVM_PrintBuf *buf);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_Drop(ACSVM_PrintBuf *buf);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_Format(ACSVM_PrintBuf *buf, char const *fmt, ...);
|
|
||||||
void ACSVM_PrintBuf_FormatV(ACSVM_PrintBuf *buf, char const *fmt, va_list arg);
|
|
||||||
|
|
||||||
char *ACSVM_PrintBuf_GetBuf(ACSVM_PrintBuf *buf, size_t count);
|
|
||||||
|
|
||||||
char const *ACSVM_PrintBuf_GetData(ACSVM_PrintBuf const *buf);
|
|
||||||
char const *ACSVM_PrintBuf_GetDataFull(ACSVM_PrintBuf const *buf);
|
|
||||||
|
|
||||||
char *ACSVM_PrintBuf_GetLoadBuf(ACSVM_PrintBuf *buf, size_t countFull, size_t count);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_Push(ACSVM_PrintBuf *buf);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_PutC(ACSVM_PrintBuf *buf, char c);
|
|
||||||
void ACSVM_PrintBuf_PutS(ACSVM_PrintBuf *buf, char const *s, size_t n);
|
|
||||||
|
|
||||||
void ACSVM_PrintBuf_Reserve(ACSVM_PrintBuf *buf, size_t count);
|
|
||||||
|
|
||||||
size_t ACSVM_PrintBuf_Size(ACSVM_PrintBuf const *buf);
|
|
||||||
size_t ACSVM_PrintBuf_SizeFull(ACSVM_PrintBuf const *buf);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__PrintBuf_H__
|
|
||||||
|
|
||||||
|
|
@ -1,363 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Scopes.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Scope.h"
|
|
||||||
|
|
||||||
#include "Environment.h"
|
|
||||||
#include "Script.h"
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
#include "ACSVM/Action.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_FreeHubScope
|
|
||||||
//
|
|
||||||
void ACSVM_GlobalScope_FreeHubScope(ACSVM_GlobalScope *scope, ACSVM_HubScope *scopeHub)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::GlobalScope *>(scope)
|
|
||||||
->freeHubScope(reinterpret_cast<ACSVM::HubScope *>(scopeHub));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_GetGblArr
|
|
||||||
//
|
|
||||||
ACSVM_Array *ACSVM_GlobalScope_GetGblArr(ACSVM_GlobalScope *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Array *>(&reinterpret_cast<ACSVM::GlobalScope *>(scope)->arrV[idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_GetGblArrC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblArrC(ACSVM_GlobalScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::GlobalScope::ArrC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_GetHubScope
|
|
||||||
//
|
|
||||||
ACSVM_HubScope *ACSVM_GlobalScope_GetHubScope(ACSVM_GlobalScope *scope_, ACSVM_Word id)
|
|
||||||
{
|
|
||||||
auto scope = reinterpret_cast<ACSVM::GlobalScope *>(scope_);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_HubScope *>(scope->getHubScope(id));
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(scope->env);
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_GetGblReg
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblReg(ACSVM_GlobalScope const *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::GlobalScope const *>(scope)->regV[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_GetGblRegC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblRegC(ACSVM_GlobalScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::GlobalScope::RegC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_SetActive
|
|
||||||
//
|
|
||||||
void ACSVM_GlobalScope_SetActive(ACSVM_GlobalScope *scope, bool active)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::GlobalScope *>(scope)->active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_GlobalScope_SetGblReg
|
|
||||||
//
|
|
||||||
void ACSVM_GlobalScope_SetGblReg(ACSVM_GlobalScope *scope, ACSVM_Word idx, ACSVM_Word reg)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::GlobalScope *>(scope)->regV[idx] = reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_FreeMapScope
|
|
||||||
//
|
|
||||||
void ACSVM_HubScope_FreeMapScope(ACSVM_HubScope *scope, ACSVM_MapScope *scopeMap)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::HubScope *>(scope)
|
|
||||||
->freeMapScope(reinterpret_cast<ACSVM::MapScope *>(scopeMap));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_GetHubArr
|
|
||||||
//
|
|
||||||
ACSVM_Array *ACSVM_HubScope_GetHubArr(ACSVM_HubScope *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Array *>(&reinterpret_cast<ACSVM::HubScope *>(scope)->arrV[idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_GetHubArrC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubArrC(ACSVM_HubScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::HubScope::ArrC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_GetMapScope
|
|
||||||
//
|
|
||||||
ACSVM_MapScope *ACSVM_HubScope_GetMapScope(ACSVM_HubScope *scope_, ACSVM_Word id)
|
|
||||||
{
|
|
||||||
auto scope = reinterpret_cast<ACSVM::HubScope *>(scope_);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_MapScope *>(scope->getMapScope(id));
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(scope->env);
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_GetHubReg
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubReg(ACSVM_HubScope const *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::HubScope const *>(scope)->regV[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_GetHubRegC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubRegC(ACSVM_HubScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::HubScope::RegC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_SetActive
|
|
||||||
//
|
|
||||||
void ACSVM_HubScope_SetActive(ACSVM_HubScope *scope, bool active)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::HubScope *>(scope)->active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_HubScope_SetHubReg
|
|
||||||
//
|
|
||||||
void ACSVM_HubScope_SetHubReg(ACSVM_HubScope *scope, ACSVM_Word idx, ACSVM_Word reg)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::HubScope *>(scope)->regV[idx] = reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_AddModule
|
|
||||||
//
|
|
||||||
void ACSVM_MapScope_AddModules(ACSVM_MapScope *scope_,
|
|
||||||
ACSVM_Module *const *moduleV, size_t moduleC)
|
|
||||||
{
|
|
||||||
auto scope = reinterpret_cast<ACSVM::MapScope *>(scope_);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
scope->addModules(reinterpret_cast<ACSVM::Module *const *>(moduleV), moduleC);
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(scope->env);
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_GetModuleScope
|
|
||||||
//
|
|
||||||
ACSVM_ModuleScope *ACSVM_MapScope_GetModuleScope(ACSVM_MapScope *scope, ACSVM_Module *module)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_ModuleScope *>(
|
|
||||||
reinterpret_cast<ACSVM::MapScope *>(scope)->getModuleScope(
|
|
||||||
reinterpret_cast<ACSVM::Module *>(module)));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_HasModules
|
|
||||||
//
|
|
||||||
bool ACSVM_MapScope_HasModules(ACSVM_MapScope const *scope)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::MapScope const *>(scope)->hasModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptPause
|
|
||||||
//
|
|
||||||
bool ACSVM_MapScope_ScriptPause(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name_, ACSVM_ScopeID id)
|
|
||||||
{
|
|
||||||
ACSVM::ScriptName name{reinterpret_cast<ACSVM::String *>(name_.s), name_.i};
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptPause(name, {id.global, id.hub, id.map});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStart
|
|
||||||
//
|
|
||||||
bool ACSVM_MapScope_ScriptStart(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name_, ACSVM_ScopeID id, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread))
|
|
||||||
{
|
|
||||||
ACSVM::ScriptName name{reinterpret_cast<ACSVM::String *>(name_.s), name_.i};
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStart(name, {id.global, id.hub, id.map}, {argV, argC, info, func});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStartForced
|
|
||||||
//
|
|
||||||
bool ACSVM_MapScope_ScriptStartForced(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name_, ACSVM_ScopeID id, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread))
|
|
||||||
{
|
|
||||||
ACSVM::ScriptName name{reinterpret_cast<ACSVM::String *>(name_.s), name_.i};
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStartForced(name, {id.global, id.hub, id.map}, {argV, argC, info, func});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStartResult
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartResult(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name_, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread))
|
|
||||||
{
|
|
||||||
ACSVM::ScriptName name{reinterpret_cast<ACSVM::String *>(name_.s), name_.i};
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStartResult(name, {argV, argC, info, func});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStartType
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartType(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_Word type, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread))
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStartType(type, {argV, argC, info, func});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStartTypeForced
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartTypeForced(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_Word type, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread))
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStartTypeForced(type, {argV, argC, info, func});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_ScriptStop
|
|
||||||
//
|
|
||||||
bool ACSVM_MapScope_ScriptStop(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name_, ACSVM_ScopeID id)
|
|
||||||
{
|
|
||||||
ACSVM::ScriptName name{reinterpret_cast<ACSVM::String *>(name_.s), name_.i};
|
|
||||||
return reinterpret_cast<ACSVM::MapScope *>(scope)
|
|
||||||
->scriptStop(name, {id.global, id.hub, id.map});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_GetString
|
|
||||||
//
|
|
||||||
ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *scope, ACSVM::Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_String *>(
|
|
||||||
reinterpret_cast<ACSVM::MapScope *>(scope)->getString(idx));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_MapScope_SetActive
|
|
||||||
//
|
|
||||||
void ACSVM_MapScope_SetActive(ACSVM_MapScope *scope, bool active)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::MapScope *>(scope)->active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleScope_GetModArr
|
|
||||||
//
|
|
||||||
ACSVM_Array *ACSVM_ModuleScope_GetModArr(ACSVM_ModuleScope *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Array *>(reinterpret_cast<ACSVM::ModuleScope *>(scope)->arrV[idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleScope_GetModArrC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModArrC(ACSVM_ModuleScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::ModuleScope::ArrC;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleScope_SetModReg
|
|
||||||
//
|
|
||||||
void ACSVM_ModuleScope_SetModReg(ACSVM_ModuleScope *scope, ACSVM_Word idx, ACSVM_Word reg)
|
|
||||||
{
|
|
||||||
*reinterpret_cast<ACSVM::ModuleScope *>(scope)->regV[idx] = reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleScope_GetModReg
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModReg(ACSVM_ModuleScope const *scope, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
return *reinterpret_cast<ACSVM::ModuleScope const *>(scope)->regV[idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ModuleScope_GetModRegC
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModRegC(ACSVM_ModuleScope const *)
|
|
||||||
{
|
|
||||||
return ACSVM::ModuleScope::RegC;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Scopes.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Scope_H__
|
|
||||||
#define ACSVM__CAPI__Scope_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Scope.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ScopeID
|
|
||||||
//
|
|
||||||
struct ACSVM_ScopeID
|
|
||||||
{
|
|
||||||
ACSVM_Word global;
|
|
||||||
ACSVM_Word hub;
|
|
||||||
ACSVM_Word map;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
void ACSVM_GlobalScope_FreeHubScope(ACSVM_GlobalScope *scope, ACSVM_HubScope *scopeHub);
|
|
||||||
|
|
||||||
ACSVM_Array *ACSVM_GlobalScope_GetGblArr (ACSVM_GlobalScope *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblArrC (ACSVM_GlobalScope const *scope);
|
|
||||||
ACSVM_HubScope *ACSVM_GlobalScope_GetHubScope(ACSVM_GlobalScope *scope, ACSVM_Word id);
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblReg (ACSVM_GlobalScope const *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_GlobalScope_GetGblRegC (ACSVM_GlobalScope const *scope);
|
|
||||||
|
|
||||||
void ACSVM_GlobalScope_SetActive(ACSVM_GlobalScope *scope, bool active);
|
|
||||||
void ACSVM_GlobalScope_SetGblReg(ACSVM_GlobalScope *scope, ACSVM_Word idx, ACSVM_Word reg);
|
|
||||||
|
|
||||||
void ACSVM_HubScope_FreeMapScope(ACSVM_HubScope *scope, ACSVM_MapScope *scopeMap);
|
|
||||||
|
|
||||||
ACSVM_Array *ACSVM_HubScope_GetHubArr (ACSVM_HubScope *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubArrC (ACSVM_HubScope const *scope);
|
|
||||||
ACSVM_MapScope *ACSVM_HubScope_GetMapScope(ACSVM_HubScope *scope, ACSVM_Word id);
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubReg (ACSVM_HubScope const *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_HubScope_GetHubRegC (ACSVM_HubScope const *scope);
|
|
||||||
|
|
||||||
void ACSVM_HubScope_SetActive(ACSVM_HubScope *scope, bool active);
|
|
||||||
void ACSVM_HubScope_SetHubReg(ACSVM_HubScope *scope, ACSVM_Word idx, ACSVM_Word reg);
|
|
||||||
|
|
||||||
void ACSVM_MapScope_AddModules(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_Module *const *moduleV, size_t moduleC);
|
|
||||||
|
|
||||||
ACSVM_ModuleScope *ACSVM_MapScope_GetModuleScope(ACSVM_MapScope *scope, ACSVM_Module *module);
|
|
||||||
|
|
||||||
bool ACSVM_MapScope_HasModules(ACSVM_MapScope const *scope);
|
|
||||||
|
|
||||||
bool ACSVM_MapScope_ScriptPause(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name, ACSVM_ScopeID id);
|
|
||||||
|
|
||||||
bool ACSVM_MapScope_ScriptStart(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name, ACSVM_ScopeID id, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread));
|
|
||||||
|
|
||||||
bool ACSVM_MapScope_ScriptStartForced(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name, ACSVM_ScopeID id, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread));
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartResult(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread));
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartType(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_Word type, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread));
|
|
||||||
|
|
||||||
ACSVM_Word ACSVM_MapScope_ScriptStartTypeForced(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_Word type, ACSVM_Word const *argV, ACSVM_Word argC,
|
|
||||||
ACSVM_ThreadInfo const *info, void (*func)(void *thread));
|
|
||||||
|
|
||||||
bool ACSVM_MapScope_ScriptStop(ACSVM_MapScope *scope,
|
|
||||||
ACSVM_ScriptName name, ACSVM_ScopeID id);
|
|
||||||
|
|
||||||
ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *scope, ACSVM_Word idx);
|
|
||||||
|
|
||||||
void ACSVM_MapScope_SetActive(ACSVM_MapScope *scope, bool active);
|
|
||||||
|
|
||||||
ACSVM_Array *ACSVM_ModuleScope_GetModArr (ACSVM_ModuleScope *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModArrC(ACSVM_ModuleScope const *scope);
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModReg (ACSVM_ModuleScope const *scope, ACSVM_Word idx);
|
|
||||||
ACSVM_Word ACSVM_ModuleScope_GetModRegC(ACSVM_ModuleScope const *scope);
|
|
||||||
|
|
||||||
void ACSVM_ModuleScope_SetModReg(ACSVM_ModuleScope *scope, ACSVM_Word idx, ACSVM_Word reg);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Scope_H__
|
|
||||||
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Scripts.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Script_H__
|
|
||||||
#define ACSVM__CAPI__Script_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "ACSVM/Script.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ScriptName
|
|
||||||
//
|
|
||||||
// ACSVM::ScriptName mirror.
|
|
||||||
//
|
|
||||||
struct ACSVM_ScriptName
|
|
||||||
{
|
|
||||||
ACSVM_String *s;
|
|
||||||
ACSVM_Word i;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Script_H__
|
|
||||||
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Strings.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "ACS_String.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StrHash
|
|
||||||
//
|
|
||||||
size_t ACSVM_StrHash(char const *str, size_t len)
|
|
||||||
{
|
|
||||||
return ACSVM::StrHash(str, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetHash
|
|
||||||
//
|
|
||||||
size_t ACSVM_String_GetHash(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetIdx
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_String_GetIdx(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetLen
|
|
||||||
//
|
|
||||||
size_t ACSVM_String_GetLen(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->len;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetLen0
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_String_GetLen0(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->len0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetLock
|
|
||||||
//
|
|
||||||
size_t ACSVM_String_GetLock(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_GetStr
|
|
||||||
//
|
|
||||||
char const *ACSVM_String_GetStr(ACSVM_String const *s)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM::String const *>(s)->str;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_SetLock
|
|
||||||
//
|
|
||||||
void ACSVM_String_SetLock(ACSVM_String *s, size_t lock)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::String *>(s)->lock = lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_String_SetRef
|
|
||||||
//
|
|
||||||
void ACSVM_String_SetRef(ACSVM_String *s)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::String *>(s)->ref = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocStringTable
|
|
||||||
//
|
|
||||||
ACSVM_StringTable *ACSVM_AllocStringTable(void)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_StringTable *>(new(std::nothrow) ACSVM::StringTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_FreeStringTable
|
|
||||||
//
|
|
||||||
void ACSVM_FreeStringTable(ACSVM_StringTable *table)
|
|
||||||
{
|
|
||||||
delete reinterpret_cast<ACSVM::StringTable *>(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_Clear
|
|
||||||
//
|
|
||||||
void ACSVM_StringTable_Clear(ACSVM_StringTable *table)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::StringTable *>(table)->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_CollectBegin
|
|
||||||
//
|
|
||||||
void ACSVM_StringTable_CollectBegin(ACSVM_StringTable *table)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::StringTable *>(table)->collectBegin();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_CollectEnd
|
|
||||||
//
|
|
||||||
void ACSVM_StringTable_CollectEnd(ACSVM_StringTable *table)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::StringTable *>(table)->collectEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_GetNone
|
|
||||||
//
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetNone(ACSVM_StringTable *table)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_String *>(
|
|
||||||
&reinterpret_cast<ACSVM::StringTable *>(table)->getNone());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_GetStringByData
|
|
||||||
//
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetStringByData(ACSVM_StringTable *table,
|
|
||||||
char const *str, size_t len, size_t hash)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_String *>(
|
|
||||||
&reinterpret_cast<ACSVM::StringTable &>(*table)[{str, len, hash}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_GetStringByIdx
|
|
||||||
//
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetStringByIdx(ACSVM_StringTable *table, ACSVM::Word idx)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_String *>(
|
|
||||||
&reinterpret_cast<ACSVM::StringTable &>(*table)[idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_LoadState
|
|
||||||
//
|
|
||||||
void ACSVM_StringTable_LoadState(ACSVM_StringTable *table, ACSVM_IStream *in)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::StringTable *>(table)->loadState(
|
|
||||||
reinterpret_cast<std::istream &>(*in));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_StringTable_SaveState
|
|
||||||
//
|
|
||||||
void ACSVM_StringTable_SaveState(ACSVM_StringTable *table, ACSVM_OStream *out)
|
|
||||||
{
|
|
||||||
reinterpret_cast<ACSVM::StringTable *>(table)->saveState(
|
|
||||||
reinterpret_cast<std::ostream &>(*out));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Strings.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__String_H__
|
|
||||||
#define ACSVM__CAPI__String_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/String.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
size_t ACSVM_StrHash(char const *str, size_t len);
|
|
||||||
|
|
||||||
size_t ACSVM_String_GetHash(ACSVM_String const *s);
|
|
||||||
ACSVM_Word ACSVM_String_GetIdx (ACSVM_String const *s);
|
|
||||||
size_t ACSVM_String_GetLen (ACSVM_String const *s);
|
|
||||||
ACSVM_Word ACSVM_String_GetLen0(ACSVM_String const *s);
|
|
||||||
size_t ACSVM_String_GetLock(ACSVM_String const *s);
|
|
||||||
char const *ACSVM_String_GetStr (ACSVM_String const *s);
|
|
||||||
|
|
||||||
void ACSVM_String_SetLock(ACSVM_String *s, size_t lock);
|
|
||||||
void ACSVM_String_SetRef (ACSVM_String *s);
|
|
||||||
|
|
||||||
ACSVM_StringTable *ACSVM_AllocStringTable(void);
|
|
||||||
void ACSVM_FreeStringTable(ACSVM_StringTable *table);
|
|
||||||
|
|
||||||
void ACSVM_StringTable_Clear(ACSVM_StringTable *table);
|
|
||||||
|
|
||||||
void ACSVM_StringTable_CollectBegin(ACSVM_StringTable *table);
|
|
||||||
void ACSVM_StringTable_CollectEnd(ACSVM_StringTable *table);
|
|
||||||
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetNone(ACSVM_StringTable *table);
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetStringByData(ACSVM_StringTable *table,
|
|
||||||
char const *str, size_t len, size_t hash);
|
|
||||||
ACSVM_String *ACSVM_StringTable_GetStringByIdx(ACSVM_StringTable *table, ACSVM_Word idx);
|
|
||||||
|
|
||||||
void ACSVM_StringTable_LoadState(ACSVM_StringTable *table, ACSVM_IStream *in);
|
|
||||||
|
|
||||||
void ACSVM_StringTable_SaveState(ACSVM_StringTable *table, ACSVM_OStream *out);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__String_H__
|
|
||||||
|
|
||||||
|
|
@ -1,373 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Threads.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
#include "Environment.h"
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadInfo constructor
|
|
||||||
//
|
|
||||||
ACSVM_ThreadInfo::ACSVM_ThreadInfo(void *data_) :
|
|
||||||
data{data_}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadInfo destructor
|
|
||||||
//
|
|
||||||
ACSVM_ThreadInfo::~ACSVM_ThreadInfo()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread constructor
|
|
||||||
//
|
|
||||||
ACSVM_Thread::ACSVM_Thread(ACSVM_Environment *env_, ACSVM_ThreadFuncs const &funcs_, void *data_) :
|
|
||||||
ACSVM::Thread{env_}, funcs{funcs_}, info{data_}
|
|
||||||
{
|
|
||||||
if(funcs.ctor)
|
|
||||||
funcs.ctor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread destructor
|
|
||||||
//
|
|
||||||
ACSVM_Thread::~ACSVM_Thread()
|
|
||||||
{
|
|
||||||
if(funcs.dtor)
|
|
||||||
funcs.dtor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::getInfo
|
|
||||||
//
|
|
||||||
ACSVM::ThreadInfo const *ACSVM_Thread::getInfo() const
|
|
||||||
{
|
|
||||||
return &info;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::loadState
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::loadState(ACSVM::Serial &in)
|
|
||||||
{
|
|
||||||
ACSVM::Thread::loadState(in);
|
|
||||||
|
|
||||||
if(funcs.loadState)
|
|
||||||
funcs.loadState(this, reinterpret_cast<ACSVM_Serial *>(&in));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::lockStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::lockStrings() const
|
|
||||||
{
|
|
||||||
ACSVM::Thread::lockStrings();
|
|
||||||
|
|
||||||
if(funcs.lockStrings)
|
|
||||||
funcs.lockStrings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::refStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::refStrings() const
|
|
||||||
{
|
|
||||||
ACSVM::Thread::refStrings();
|
|
||||||
|
|
||||||
if(funcs.refStrings)
|
|
||||||
funcs.refStrings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::saveState
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::saveState(ACSVM::Serial &out) const
|
|
||||||
{
|
|
||||||
ACSVM::Thread::saveState(out);
|
|
||||||
|
|
||||||
if(funcs.saveState)
|
|
||||||
funcs.saveState(this, reinterpret_cast<ACSVM_Serial *>(&out));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::start
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::start(ACSVM::Script *script, ACSVM::MapScope *map,
|
|
||||||
ACSVM::ThreadInfo const *infoPtr, ACSVM::Word const *argV, ACSVM::Word argC)
|
|
||||||
{
|
|
||||||
ACSVM::Thread::start(script, map, infoPtr, argV, argC);
|
|
||||||
|
|
||||||
if(funcs.start)
|
|
||||||
{
|
|
||||||
auto infoDer = dynamic_cast<ACSVM_ThreadInfo const *>(infoPtr);
|
|
||||||
funcs.start(this, infoDer ? infoDer->data : nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::stop
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::stop()
|
|
||||||
{
|
|
||||||
ACSVM::Thread::stop();
|
|
||||||
|
|
||||||
if(funcs.stop)
|
|
||||||
funcs.stop(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread::unlockStrings
|
|
||||||
//
|
|
||||||
void ACSVM_Thread::unlockStrings() const
|
|
||||||
{
|
|
||||||
ACSVM::Thread::unlockStrings();
|
|
||||||
|
|
||||||
if(funcs.unlockStrings)
|
|
||||||
funcs.unlockStrings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocThread
|
|
||||||
//
|
|
||||||
ACSVM_Thread *ACSVM_AllocThread(ACSVM_Environment *env,
|
|
||||||
ACSVM_ThreadFuncs const *funcs, void *data)
|
|
||||||
{
|
|
||||||
return new(std::nothrow) ACSVM_Thread(env, *funcs, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_AllocThreadInfo
|
|
||||||
//
|
|
||||||
ACSVM_ThreadInfo *ACSVM_AllocThreadInfo(void *data)
|
|
||||||
{
|
|
||||||
return new(std::nothrow) ACSVM_ThreadInfo(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadFromVoid
|
|
||||||
//
|
|
||||||
ACSVM_Thread *ACSVM_ThreadFromVoid(void *thread)
|
|
||||||
{
|
|
||||||
return static_cast<ACSVM_Thread *>(static_cast<ACSVM::Thread *>(thread));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_Exec
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_Exec(ACSVM_Thread *thread)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
thread->exec();
|
|
||||||
}
|
|
||||||
catch(std::bad_alloc const &e)
|
|
||||||
{
|
|
||||||
auto env = static_cast<ACSVM_Environment *>(thread->env);
|
|
||||||
if(env->funcs.bad_alloc)
|
|
||||||
env->funcs.bad_alloc(env, e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetCodePtr
|
|
||||||
//
|
|
||||||
ACSVM_Word const *ACSVM_Thread_GetCodePtr(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return thread->codePtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetDelay
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Thread_GetDelay(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return thread->delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetEnv
|
|
||||||
//
|
|
||||||
ACSVM_Environment *ACSVM_Thread_GetEnv(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return static_cast<ACSVM_Environment *>(thread->env);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetInfo
|
|
||||||
//
|
|
||||||
void *ACSVM_Thread_GetInfo(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return thread->info.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetLocalArr
|
|
||||||
//
|
|
||||||
ACSVM_Array *ACSVM_Thread_GetLocalArr(ACSVM_Thread *thread, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
if(idx < thread->localArr.size())
|
|
||||||
return reinterpret_cast<ACSVM_Array *>(&thread->localArr[idx]);
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetLocalReg
|
|
||||||
//
|
|
||||||
ACSVM_Word *ACSVM_Thread_GetLocalReg(ACSVM_Thread *thread, ACSVM_Word idx)
|
|
||||||
{
|
|
||||||
if(idx < thread->localReg.size())
|
|
||||||
return &thread->localReg[idx];
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetModule
|
|
||||||
//
|
|
||||||
ACSVM_Module *ACSVM_Thread_GetModule(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Module *>(thread->module);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetPrintBuf
|
|
||||||
//
|
|
||||||
ACSVM_PrintBuf *ACSVM_Thread_GetPrintBuf(ACSVM_Thread *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_PrintBuf *>(&thread->printBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetResult
|
|
||||||
//
|
|
||||||
ACSVM_Word ACSVM_Thread_GetResult(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return thread->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetScopeGbl
|
|
||||||
//
|
|
||||||
ACSVM_GlobalScope *ACSVM_Thread_GetScopeGbl(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_GlobalScope *>(thread->scopeGbl);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetScopeHub
|
|
||||||
//
|
|
||||||
ACSVM_HubScope *ACSVM_Thread_GetScopeHub(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_HubScope *>(thread->scopeHub);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetScopeMap
|
|
||||||
//
|
|
||||||
ACSVM_MapScope *ACSVM_Thread_GetScopeMap(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_MapScope *>(thread->scopeMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetScopeMod
|
|
||||||
//
|
|
||||||
ACSVM_ModuleScope *ACSVM_Thread_GetScopeMod(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_ModuleScope *>(thread->scopeMod);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetScript
|
|
||||||
//
|
|
||||||
ACSVM_Script *ACSVM_Thread_GetScript(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<ACSVM_Script *>(thread->script);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_GetState
|
|
||||||
//
|
|
||||||
ACSVM_ThreadState ACSVM_Thread_GetState(ACSVM_Thread const *thread)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
{
|
|
||||||
static_cast<ACSVM_ThreadStateEnum>(thread->state.state),
|
|
||||||
thread->state.data, thread->state.type
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_DatakStk_Push
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_DataStk_Push(ACSVM_Thread *thread, ACSVM_Word data)
|
|
||||||
{
|
|
||||||
thread->dataStk.push(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_SetCodePtr
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_SetCodePtr(ACSVM_Thread *thread, ACSVM_Word const *codePtr)
|
|
||||||
{
|
|
||||||
thread->codePtr = codePtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_SetDelay
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_SetDelay(ACSVM_Thread *thread, ACSVM_Word delay)
|
|
||||||
{
|
|
||||||
thread->delay = delay;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_SetInfo
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_SetInfo(ACSVM_Thread *thread, void *info)
|
|
||||||
{
|
|
||||||
thread->info.data = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_SetResult
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_SetResult(ACSVM_Thread *thread, ACSVM_Word result)
|
|
||||||
{
|
|
||||||
thread->result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread_SetState
|
|
||||||
//
|
|
||||||
void ACSVM_Thread_SetState(ACSVM_Thread *thread, ACSVM_ThreadState state)
|
|
||||||
{
|
|
||||||
thread->state =
|
|
||||||
{static_cast<ACSVM::ThreadState::State>(state.state), state.data, state.type};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Threads.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Thread_H__
|
|
||||||
#define ACSVM__CAPI__Thread_H__
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Thread.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadStateEnum
|
|
||||||
//
|
|
||||||
typedef enum ACSVM_ThreadStateEnum
|
|
||||||
{
|
|
||||||
ACSVM_ThreadState_Inactive, // Inactive thread.
|
|
||||||
ACSVM_ThreadState_Running, // Running.
|
|
||||||
ACSVM_ThreadState_Stopped, // Will go inactive on next exec.
|
|
||||||
ACSVM_ThreadState_Paused, // Paused by instruction.
|
|
||||||
ACSVM_ThreadState_WaitScrI, // Waiting on a numbered script.
|
|
||||||
ACSVM_ThreadState_WaitScrS, // Waiting on a named script.
|
|
||||||
ACSVM_ThreadState_WaitTag, // Waiting on tagged object.
|
|
||||||
} ACSVM_ThreadStateEnum;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadFuncs
|
|
||||||
//
|
|
||||||
// ACSVM_Thread functions. If non-null, these get called after the base class.
|
|
||||||
//
|
|
||||||
typedef struct ACSVM_ThreadFuncs
|
|
||||||
{
|
|
||||||
// public
|
|
||||||
|
|
||||||
void (*ctor)(ACSVM_Thread *env);
|
|
||||||
void (*dtor)(ACSVM_Thread *env);
|
|
||||||
|
|
||||||
void (*loadState)(ACSVM_Thread *thread, ACSVM_Serial *in);
|
|
||||||
|
|
||||||
void (*lockStrings)(ACSVM_Thread const *thread);
|
|
||||||
|
|
||||||
void (*refStrings)(ACSVM_Thread const *thread);
|
|
||||||
|
|
||||||
void (*saveState)(ACSVM_Thread const *thread, ACSVM_Serial *out);
|
|
||||||
|
|
||||||
void (*start)(ACSVM_Thread *thread, void *data);
|
|
||||||
|
|
||||||
void (*stop)(ACSVM_Thread *thread);
|
|
||||||
|
|
||||||
void (*unlockStrings)(ACSVM_Thread const *thread);
|
|
||||||
} ACSVM_ThreadFuncs;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadState
|
|
||||||
//
|
|
||||||
// ACSVM::ThreadState mirror.
|
|
||||||
//
|
|
||||||
struct ACSVM_ThreadState
|
|
||||||
{
|
|
||||||
ACSVM_ThreadStateEnum state;
|
|
||||||
ACSVM_Word data;
|
|
||||||
ACSVM_Word type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
//
|
|
||||||
// ACSVM_ThreadInfo
|
|
||||||
//
|
|
||||||
struct ACSVM_ThreadInfo : ACSVM::ThreadInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ACSVM_ThreadInfo(void *data);
|
|
||||||
virtual ~ACSVM_ThreadInfo();
|
|
||||||
|
|
||||||
void *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// ACSVM_Thread
|
|
||||||
//
|
|
||||||
struct ACSVM_Thread : ACSVM::Thread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACSVM_Thread(ACSVM_Environment *env, ACSVM_ThreadFuncs const &funcs, void *data);
|
|
||||||
virtual ~ACSVM_Thread();
|
|
||||||
|
|
||||||
virtual ACSVM::ThreadInfo const *getInfo() const;
|
|
||||||
|
|
||||||
virtual void loadState(ACSVM::Serial &in);
|
|
||||||
|
|
||||||
virtual void lockStrings() const;
|
|
||||||
|
|
||||||
virtual void refStrings() const;
|
|
||||||
|
|
||||||
virtual void saveState(ACSVM::Serial &out) const;
|
|
||||||
|
|
||||||
virtual void start(ACSVM::Script *script, ACSVM::MapScope *map,
|
|
||||||
ACSVM::ThreadInfo const *info, ACSVM::Word const *argV, ACSVM::Word argC);
|
|
||||||
|
|
||||||
virtual void stop();
|
|
||||||
|
|
||||||
virtual void unlockStrings() const;
|
|
||||||
|
|
||||||
ACSVM_ThreadFuncs funcs;
|
|
||||||
ACSVM_ThreadInfo info;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
ACSVM_Thread *ACSVM_AllocThread(ACSVM_Environment *env,
|
|
||||||
ACSVM_ThreadFuncs const *funcs, void *data);
|
|
||||||
|
|
||||||
ACSVM_ThreadInfo *ACSVM_AllocThreadInfo(void *data);
|
|
||||||
|
|
||||||
ACSVM_Thread *ACSVM_ThreadFromVoid(void *thread);
|
|
||||||
|
|
||||||
void ACSVM_Thread_Exec(ACSVM_Thread *thread);
|
|
||||||
|
|
||||||
ACSVM_Word const *ACSVM_Thread_GetCodePtr (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_Word ACSVM_Thread_GetDelay (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_Environment *ACSVM_Thread_GetEnv (ACSVM_Thread const *thread);
|
|
||||||
void *ACSVM_Thread_GetInfo (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_Array *ACSVM_Thread_GetLocalArr(ACSVM_Thread *thread, ACSVM_Word idx);
|
|
||||||
ACSVM_Word *ACSVM_Thread_GetLocalReg(ACSVM_Thread *thread, ACSVM_Word idx);
|
|
||||||
ACSVM_Module *ACSVM_Thread_GetModule (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_PrintBuf *ACSVM_Thread_GetPrintBuf(ACSVM_Thread *thread);
|
|
||||||
ACSVM_Word ACSVM_Thread_GetResult (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_GlobalScope *ACSVM_Thread_GetScopeGbl(ACSVM_Thread const *thread);
|
|
||||||
ACSVM_HubScope *ACSVM_Thread_GetScopeHub(ACSVM_Thread const *thread);
|
|
||||||
ACSVM_MapScope *ACSVM_Thread_GetScopeMap(ACSVM_Thread const *thread);
|
|
||||||
ACSVM_ModuleScope *ACSVM_Thread_GetScopeMod(ACSVM_Thread const *thread);
|
|
||||||
ACSVM_Script *ACSVM_Thread_GetScript (ACSVM_Thread const *thread);
|
|
||||||
ACSVM_ThreadState ACSVM_Thread_GetState (ACSVM_Thread const *thread);
|
|
||||||
|
|
||||||
void ACSVM_Thread_DataStk_Push(ACSVM_Thread *thread, ACSVM_Word data);
|
|
||||||
|
|
||||||
void ACSVM_Thread_SetCodePtr(ACSVM_Thread *thread, ACSVM_Word const *codePtr);
|
|
||||||
void ACSVM_Thread_SetDelay (ACSVM_Thread *thread, ACSVM_Word delay);
|
|
||||||
void ACSVM_Thread_SetInfo (ACSVM_Thread *thread, void *info);
|
|
||||||
void ACSVM_Thread_SetResult (ACSVM_Thread *thread, ACSVM_Word result);
|
|
||||||
void ACSVM_Thread_SetState (ACSVM_Thread *thread, ACSVM_ThreadState state);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Thread_H__
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Common typedefs and struct declarations.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACSVM__CAPI__Types_H__
|
|
||||||
#define ACSVM__CAPI__Types_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include "../ACSVM/Types.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef unsigned char ACSVM_Byte;
|
|
||||||
typedef uint64_t ACSVM_DWord;
|
|
||||||
typedef int64_t ACSVM_SDWord;
|
|
||||||
typedef int32_t ACSVM_SWord;
|
|
||||||
typedef uint32_t ACSVM_Word;
|
|
||||||
|
|
||||||
typedef struct ACSVM_Array ACSVM_Array;
|
|
||||||
typedef struct ACSVM_Environment ACSVM_Environment;
|
|
||||||
typedef struct ACSVM_GlobalScope ACSVM_GlobalScope;
|
|
||||||
typedef struct ACSVM_HubScope ACSVM_HubScope;
|
|
||||||
typedef struct ACSVM_IStream ACSVM_IStream;
|
|
||||||
typedef struct ACSVM_MapScope ACSVM_MapScope;
|
|
||||||
typedef struct ACSVM_Module ACSVM_Module;
|
|
||||||
typedef struct ACSVM_ModuleName ACSVM_ModuleName;
|
|
||||||
typedef struct ACSVM_ModuleScope ACSVM_ModuleScope;
|
|
||||||
typedef struct ACSVM_OStream ACSVM_OStream;
|
|
||||||
typedef struct ACSVM_PrintBuf ACSVM_PrintBuf;
|
|
||||||
typedef struct ACSVM_ScopeID ACSVM_ScopeID;
|
|
||||||
typedef struct ACSVM_Script ACSVM_Script;
|
|
||||||
typedef struct ACSVM_ScriptName ACSVM_ScriptName;
|
|
||||||
typedef struct ACSVM_Serial ACSVM_Serial;
|
|
||||||
typedef struct ACSVM_String ACSVM_String;
|
|
||||||
typedef struct ACSVM_StringTable ACSVM_StringTable;
|
|
||||||
typedef struct ACSVM_Thread ACSVM_Thread;
|
|
||||||
typedef struct ACSVM_ThreadInfo ACSVM_ThreadInfo;
|
|
||||||
typedef struct ACSVM_ThreadState ACSVM_ThreadState;
|
|
||||||
|
|
||||||
typedef bool (*ACSVM_CallFunc)(ACSVM_Thread *, ACSVM_Word const *, ACSVM_Word);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ACSVM__CAPI__Types_H__
|
|
||||||
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
##
|
|
||||||
## Copyright (C) 2015 David Hill
|
|
||||||
##
|
|
||||||
## See COPYING for license information.
|
|
||||||
##
|
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
##
|
|
||||||
## CMake file for acsvm-exec.
|
|
||||||
##
|
|
||||||
##-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
##----------------------------------------------------------------------------|
|
|
||||||
## Environment Configuration |
|
|
||||||
##
|
|
||||||
|
|
||||||
include_directories(.)
|
|
||||||
|
|
||||||
|
|
||||||
##----------------------------------------------------------------------------|
|
|
||||||
## Targets |
|
|
||||||
##
|
|
||||||
|
|
||||||
##
|
|
||||||
## acsvm-exec
|
|
||||||
##
|
|
||||||
add_executable(acsvm-exec
|
|
||||||
main_exec.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(acsvm-exec acsvm-util)
|
|
||||||
|
|
||||||
##
|
|
||||||
## acsvm-execc
|
|
||||||
##
|
|
||||||
## Used to test the C API.
|
|
||||||
##
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/CAPI")
|
|
||||||
add_executable(acsvm-execc
|
|
||||||
main_execc.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(acsvm-execc acsvm-capi)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
## EOF
|
|
||||||
|
|
||||||
|
|
@ -1,264 +0,0 @@
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Program entry point.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "ACSVM/Code.hpp"
|
|
||||||
#include "ACSVM/CodeData.hpp"
|
|
||||||
#include "ACSVM/Environment.hpp"
|
|
||||||
#include "ACSVM/Error.hpp"
|
|
||||||
#include "ACSVM/Module.hpp"
|
|
||||||
#include "ACSVM/Scope.hpp"
|
|
||||||
#include "ACSVM/Script.hpp"
|
|
||||||
#include "ACSVM/Serial.hpp"
|
|
||||||
#include "ACSVM/Thread.hpp"
|
|
||||||
|
|
||||||
#include "Util/Floats.hpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Types |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment
|
|
||||||
//
|
|
||||||
class Environment : public ACSVM::Environment
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Environment();
|
|
||||||
|
|
||||||
virtual void exec() {++timer; ACSVM::Environment::exec();}
|
|
||||||
|
|
||||||
ACSVM::Word timer;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void loadModule(ACSVM::Module *module);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Static Objects |
|
|
||||||
//
|
|
||||||
|
|
||||||
static bool NeedExit = false;
|
|
||||||
static bool NeedTestSaveEnv = false;
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Static Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_CollectStrings
|
|
||||||
//
|
|
||||||
static bool CF_CollectStrings(ACSVM::Thread *thread, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
std::size_t countOld = thread->env->stringTable.size();
|
|
||||||
thread->env->collectStrings();
|
|
||||||
std::size_t countNew = thread->env->stringTable.size();
|
|
||||||
thread->dataStk.push(countOld - countNew);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_DumpLocals
|
|
||||||
//
|
|
||||||
static bool CF_DumpLocals(ACSVM::Thread *thread, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
// LocReg store info.
|
|
||||||
std::cout << "LocReg="
|
|
||||||
<< thread->localReg.begin() << '+' << thread->localReg.size() << " / "
|
|
||||||
<< thread->localReg.beginFull() << '+' << thread->localReg.sizeFull() << "\n";
|
|
||||||
|
|
||||||
// LocReg values for current function.
|
|
||||||
for(std::size_t i = 0, e = thread->localReg.size(); i != e; ++i)
|
|
||||||
std::cout << " [" << i << "]=" << thread->localReg[i] << '\n';
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_EndPrint
|
|
||||||
//
|
|
||||||
static bool CF_EndPrint(ACSVM::Thread *thread, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
std::cout << thread->printBuf.data() << '\n';
|
|
||||||
thread->printBuf.drop();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_Exit
|
|
||||||
//
|
|
||||||
static bool CF_Exit(ACSVM::Thread *thread, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
NeedExit = true;
|
|
||||||
thread->state = ACSVM::ThreadState::Stopped;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_TestSave
|
|
||||||
//
|
|
||||||
static bool CF_TestSave(ACSVM::Thread *, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
NeedTestSaveEnv = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_Timer
|
|
||||||
//
|
|
||||||
static bool CF_Timer(ACSVM::Thread *thread, ACSVM::Word const *, ACSVM::Word)
|
|
||||||
{
|
|
||||||
thread->dataStk.push(static_cast<Environment *>(thread->env)->timer);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// LoadModules
|
|
||||||
//
|
|
||||||
static void LoadModules(Environment &env, char const *const *argv, std::size_t argc)
|
|
||||||
{
|
|
||||||
// Load modules.
|
|
||||||
std::vector<ACSVM::Module *> modules;
|
|
||||||
for(std::size_t i = 1; i < argc; ++i)
|
|
||||||
modules.push_back(env.getModule(env.getModuleName(argv[i])));
|
|
||||||
|
|
||||||
// Create and activate scopes.
|
|
||||||
ACSVM::GlobalScope *global = env.getGlobalScope(0); global->active = true;
|
|
||||||
ACSVM::HubScope *hub = global->getHubScope(0); hub ->active = true;
|
|
||||||
ACSVM::MapScope *map = hub->getMapScope(0); map ->active = true;
|
|
||||||
|
|
||||||
// Register modules with map scope.
|
|
||||||
map->addModules(modules.data(), modules.size());
|
|
||||||
|
|
||||||
// Start Open scripts.
|
|
||||||
map->scriptStartType(1, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment constructor
|
|
||||||
//
|
|
||||||
Environment::Environment() :
|
|
||||||
timer{0}
|
|
||||||
{
|
|
||||||
ACSVM::Word funcCollectStrings = addCallFunc(CF_CollectStrings);
|
|
||||||
ACSVM::Word funcDumpLocals = addCallFunc(CF_DumpLocals);
|
|
||||||
ACSVM::Word funcEndPrint = addCallFunc(CF_EndPrint);
|
|
||||||
ACSVM::Word funcExit = addCallFunc(CF_Exit);
|
|
||||||
ACSVM::Word funcTestSave = addCallFunc(CF_TestSave);
|
|
||||||
ACSVM::Word funcTimer = addCallFunc(CF_Timer);
|
|
||||||
|
|
||||||
addCodeDataACS0( 86, {"", 0, funcEndPrint});
|
|
||||||
addCodeDataACS0( 93, {"", 0, funcTimer});
|
|
||||||
addCodeDataACS0(270, {"", 0, funcEndPrint});
|
|
||||||
|
|
||||||
addFuncDataACS0(0x10000, funcTestSave);
|
|
||||||
addFuncDataACS0(0x10001, funcCollectStrings);
|
|
||||||
addFuncDataACS0(0x10002, funcDumpLocals);
|
|
||||||
addFuncDataACS0(0x10003, funcExit);
|
|
||||||
|
|
||||||
addFuncDataACS0(0x10100, addCallFunc(ACSVM::CF_AddF_W1));
|
|
||||||
addFuncDataACS0(0x10101, addCallFunc(ACSVM::CF_DivF_W1));
|
|
||||||
addFuncDataACS0(0x10102, addCallFunc(ACSVM::CF_MulF_W1));
|
|
||||||
addFuncDataACS0(0x10103, addCallFunc(ACSVM::CF_SubF_W1));
|
|
||||||
addFuncDataACS0(0x10104, addCallFunc(ACSVM::CF_AddF_W2));
|
|
||||||
addFuncDataACS0(0x10105, addCallFunc(ACSVM::CF_DivF_W2));
|
|
||||||
addFuncDataACS0(0x10106, addCallFunc(ACSVM::CF_MulF_W2));
|
|
||||||
addFuncDataACS0(0x10107, addCallFunc(ACSVM::CF_SubF_W2));
|
|
||||||
addFuncDataACS0(0x10108, addCallFunc(ACSVM::CF_PrintFloat));
|
|
||||||
addFuncDataACS0(0x10109, addCallFunc(ACSVM::CF_PrintDouble));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment::loadModule
|
|
||||||
//
|
|
||||||
void Environment::loadModule(ACSVM::Module *module)
|
|
||||||
{
|
|
||||||
std::ifstream in{module->name.s->str, std::ios_base::in | std::ios_base::binary};
|
|
||||||
|
|
||||||
if(!in) throw ACSVM::ReadError("file open failure");
|
|
||||||
|
|
||||||
std::vector<ACSVM::Byte> data;
|
|
||||||
|
|
||||||
for(int c; c = in.get(), in;)
|
|
||||||
data.push_back(c);
|
|
||||||
|
|
||||||
module->readBytecode(data.data(), data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// main
|
|
||||||
//
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
Environment env;
|
|
||||||
|
|
||||||
// Load modules.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadModules(env, argv, argc);
|
|
||||||
}
|
|
||||||
catch(ACSVM::ReadError &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Error loading modules: " << e.what() << std::endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute until all threads terminate.
|
|
||||||
while(!NeedExit && env.hasActiveThread())
|
|
||||||
{
|
|
||||||
std::chrono::duration<double> rate{1.0 / 35};
|
|
||||||
auto time = std::chrono::steady_clock::now() + rate;
|
|
||||||
|
|
||||||
env.exec();
|
|
||||||
|
|
||||||
if(NeedTestSaveEnv)
|
|
||||||
{
|
|
||||||
std::stringstream buf;
|
|
||||||
|
|
||||||
{
|
|
||||||
ACSVM::Serial out{static_cast<std::ostream &>(buf)};
|
|
||||||
out.signs = true;
|
|
||||||
out.saveHead();
|
|
||||||
env.saveState(out);
|
|
||||||
out.saveTail();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
ACSVM::Serial in{static_cast<std::istream &>(buf)};
|
|
||||||
in.loadHead();
|
|
||||||
env.loadState(in);
|
|
||||||
in.loadTail();
|
|
||||||
}
|
|
||||||
|
|
||||||
NeedTestSaveEnv = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::this_thread::sleep_until(time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
|
|
@ -1,231 +0,0 @@
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015-2017 David Hill
|
|
||||||
//
|
|
||||||
// See COPYING for license information.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Program entry point.
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "CAPI/BinaryIO.h"
|
|
||||||
#include "CAPI/Environment.h"
|
|
||||||
#include "CAPI/Module.h"
|
|
||||||
#include "CAPI/PrintBuf.h"
|
|
||||||
#include "CAPI/Scope.h"
|
|
||||||
#include "CAPI/ACS_String.h"
|
|
||||||
#include "CAPI/Thread.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Static Objects |
|
|
||||||
//
|
|
||||||
|
|
||||||
static ACSVM_Word ExecTime = 0;
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Static Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_EndPrint
|
|
||||||
//
|
|
||||||
static bool CF_EndPrint(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{
|
|
||||||
(void)argV; (void)argC;
|
|
||||||
|
|
||||||
ACSVM_PrintBuf *buf = ACSVM_Thread_GetPrintBuf(thread);
|
|
||||||
|
|
||||||
printf("%s\n", ACSVM_PrintBuf_GetData(buf));
|
|
||||||
ACSVM_PrintBuf_Drop(buf);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// CF_Timer
|
|
||||||
//
|
|
||||||
static bool CF_Timer(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC)
|
|
||||||
{
|
|
||||||
(void)argV; (void)argC;
|
|
||||||
|
|
||||||
ACSVM_Thread_DataStk_Push(thread, ExecTime);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment_BadAlloc
|
|
||||||
//
|
|
||||||
static void Environment_BadAlloc(ACSVM_Environment *env, char const *what)
|
|
||||||
{
|
|
||||||
(void)env;
|
|
||||||
|
|
||||||
fprintf(stderr, "bad_alloc: %s\n", what);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment_Construct
|
|
||||||
//
|
|
||||||
static void Environment_Construct(ACSVM_Environment *env)
|
|
||||||
{
|
|
||||||
ACSVM_Word funcEndPrint = ACSVM_Environment_AddCallFunc(env, CF_EndPrint);
|
|
||||||
ACSVM_Word funcTimer = ACSVM_Environment_AddCallFunc(env, CF_Timer);
|
|
||||||
|
|
||||||
ACSVM_Environment_AddCodeDataACS0(env, 86, "", ACSVM_Code_CallFunc, 0, funcEndPrint);
|
|
||||||
ACSVM_Environment_AddCodeDataACS0(env, 93, "", ACSVM_Code_CallFunc, 0, funcTimer);
|
|
||||||
ACSVM_Environment_AddCodeDataACS0(env, 270, "", ACSVM_Code_CallFunc, 0, funcEndPrint);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment_LoadModule
|
|
||||||
//
|
|
||||||
static bool Environment_LoadModule(ACSVM_Environment *env, ACSVM_Module *module)
|
|
||||||
{
|
|
||||||
(void)env;
|
|
||||||
|
|
||||||
ACSVM_ModuleName name = ACSVM_Module_GetName(module);
|
|
||||||
|
|
||||||
FILE *stream = fopen(ACSVM_String_GetStr(name.s), "rb");
|
|
||||||
if(!stream)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to fopen: %s\n", strerror(errno));
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ACSVM_Byte *data = NULL;
|
|
||||||
size_t size = 0;
|
|
||||||
size_t alloc = 0;
|
|
||||||
|
|
||||||
for(int c; (c = fgetc(stream)) != EOF;)
|
|
||||||
{
|
|
||||||
if(size == alloc)
|
|
||||||
{
|
|
||||||
alloc = alloc + alloc / 2 + 256;
|
|
||||||
data = realloc(data, alloc);
|
|
||||||
if(!data)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to allocate %zu\n", alloc);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data[size++] = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(stream);
|
|
||||||
|
|
||||||
bool res = ACSVM_Module_ReadBytecode(module, data, size);
|
|
||||||
|
|
||||||
free(data);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Environment_ReadError
|
|
||||||
//
|
|
||||||
static void Environment_ReadError(ACSVM_Environment *env, char const *what)
|
|
||||||
{
|
|
||||||
(void)env;
|
|
||||||
|
|
||||||
fprintf(stderr, "ReadError: %s\n", what);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// LoadModules
|
|
||||||
//
|
|
||||||
static void LoadModules(ACSVM_Environment *env, char **argv, int argc)
|
|
||||||
{
|
|
||||||
ACSVM_StringTable *strTab = ACSVM_Environment_GetStringTable(env);
|
|
||||||
|
|
||||||
// Create and activate scopes.
|
|
||||||
ACSVM_GlobalScope *global = ACSVM_Environment_GetGlobalScope(env, 0);
|
|
||||||
ACSVM_GlobalScope_SetActive(global, true);
|
|
||||||
ACSVM_HubScope *hub = ACSVM_GlobalScope_GetHubScope(global, 0);
|
|
||||||
ACSVM_HubScope_SetActive(hub, true);
|
|
||||||
ACSVM_MapScope *map = ACSVM_HubScope_GetMapScope(hub, 0);
|
|
||||||
ACSVM_MapScope_SetActive(map, true);
|
|
||||||
|
|
||||||
// Load modules.
|
|
||||||
|
|
||||||
size_t moduleC = argc - 1;
|
|
||||||
ACSVM_Module **moduleV = malloc(sizeof(ACSVM_Module *) * moduleC);
|
|
||||||
if(!moduleV)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to alloc moduleV[%zu]\n", moduleC);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int argi = 1; argi < argc; ++argi)
|
|
||||||
{
|
|
||||||
char const *arg = argv[argi];
|
|
||||||
size_t len = strlen(arg);
|
|
||||||
size_t hash = ACSVM_StrHash(arg, len);
|
|
||||||
ACSVM_ModuleName name =
|
|
||||||
{ACSVM_StringTable_GetStringByData(strTab, arg, len, hash), NULL, 0};
|
|
||||||
|
|
||||||
moduleV[argi - 1] = ACSVM_Environment_GetModule(env, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register modules with map scope.
|
|
||||||
ACSVM_MapScope_AddModules(map, moduleV, moduleC);
|
|
||||||
|
|
||||||
// Start Open scripts.
|
|
||||||
ACSVM_MapScope_ScriptStartType(map, 1, NULL, 0, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------|
|
|
||||||
// Extern Functions |
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// main
|
|
||||||
//
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
ACSVM_Environment *env = ACSVM_AllocEnvironment(
|
|
||||||
&(ACSVM_EnvironmentFuncs)
|
|
||||||
{
|
|
||||||
.bad_alloc = Environment_BadAlloc,
|
|
||||||
.readError = Environment_ReadError,
|
|
||||||
|
|
||||||
.ctor = Environment_Construct,
|
|
||||||
|
|
||||||
.loadModule = Environment_LoadModule,
|
|
||||||
},
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if(!env)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to allocate environment\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadModules(env, argv, argc);
|
|
||||||
|
|
||||||
while(ACSVM_Environment_HasActiveThread(env))
|
|
||||||
{
|
|
||||||
++ExecTime;
|
|
||||||
ACSVM_Environment_Exec(env);
|
|
||||||
|
|
||||||
// TODO: Sleep.
|
|
||||||
}
|
|
||||||
|
|
||||||
ACSVM_FreeEnvironment(env);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
Loading…
Add table
Reference in a new issue