Phasor
2.2.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
coreutils_main.in.cpp
Go to the documentation of this file.
1
// coreutils_main -- wrapper to compile phs coreutils as native applications.
2
// Implementation of '@tgt@'
3
//
4
// Copyright (C) 2026 Daniel McGuire.
5
//
6
// This program is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19
#include <cstdint>
20
#include <cstdio>
21
#include <cstdlib>
22
#include <iostream>
23
#include <fstream>
24
#include <filesystem>
25
#include <string>
26
#include <vector>
27
28
#include "@HEADER@"
29
#include "@CMAKE_SOURCE_DIR@/src/Runtime/Value.hpp"
30
31
// Forward declare native runtime entry points (linked in from the runtime library)
32
extern
"C"
void
exec
(
const
unsigned
char
embeddedBytecode[],
size_t
embeddedBytecodeSize,
33
const
char
*moduleName,
const
void
*nativeFunctionsVector,
const
int
argc,
char
**argv);
34
35
// Main entry point
36
int
main
(
int
argc,
char
*argv[],
char
*envp[])
37
{
38
int
exitCode = 1;
39
40
try
41
{
42
exec
(embeddedBytecode, embeddedBytecodeSize, moduleName.c_str(),
nullptr
, argc, argv);
43
exitCode = 0;
44
}
45
catch
(
const
std::exception &e)
46
{
47
std::cerr <<
"Runtime Error: "
<< e.what() <<
"\n"
;
48
return
1;
49
}
50
51
return
exitCode;
52
}
main
fn main()
The main execution loop of the Phasor Shell.
Definition
Shell.dox:38
exec
void exec(const unsigned char embeddedBytecode[], size_t embeddedBytecodeSize, const char *moduleName, const void *nativeFunctionsVector, const int argc, char **argv)
src
App
utils
coreutils
coreutils_main.in.cpp
Generated by
1.16.1