mirror of
https://git.tesses.org/tesses50/crosslang.git
synced 2026-10-01 17:14:13 +00:00
Compare commits
18
Commits
v0.0.6
..
bf445ef68b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf445ef68b | ||
|
|
adc0bc2985 | ||
|
|
94d0e1db25 | ||
|
|
8df639399f | ||
|
|
1c4f3e2428 | ||
|
|
354fb4293d | ||
|
|
175afbafeb | ||
|
|
4aab28411a | ||
|
|
c1c3d02bf0 | ||
|
|
2430b62232 | ||
|
|
56b74dc6fc | ||
|
|
a6be15410d | ||
|
|
7aa7635ab6 | ||
|
|
15785225e0 | ||
|
|
1c3fda37f5 | ||
|
|
a72ab256f2 | ||
|
|
671a4c88b7 | ||
|
|
bdbdfde646 |
+50
-16
@@ -5,6 +5,7 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
TF_VERSION: 0.0.9
|
||||||
PACKAGE_AND_BREW: ${{ secrets.PACKAGE_AND_BREW }}
|
PACKAGE_AND_BREW: ${{ secrets.PACKAGE_AND_BREW }}
|
||||||
VERSION: ${{ gitea.ref_name }}
|
VERSION: ${{ gitea.ref_name }}
|
||||||
RESULT_IMAGE_NAME: tesses50/crosslang
|
RESULT_IMAGE_NAME: tesses50/crosslang
|
||||||
@@ -12,23 +13,14 @@ env:
|
|||||||
GITEA_REGISTRY_USER: tesses50
|
GITEA_REGISTRY_USER: tesses50
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-arch:
|
build-ppc:
|
||||||
runs-on: arch-builder
|
name: "🔨 Build for PowerPC"
|
||||||
|
runs-on: asrock
|
||||||
|
container:
|
||||||
|
image: git.tesses.org/tesses50/linux-ppc:latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: wget -O /root/repository.key https://git.tesses.org/api/packages/tesses50/arch/repository.key
|
- run: bash build-for-ppc.sh
|
||||||
- run: pacman-key --add /root/repository.key
|
|
||||||
- run: pacman-key --config /opt/cross/ppc/pacman.conf --add /root/repository.key
|
|
||||||
- run: printf "[tesses50.git.tesses.org]\nSigLevel = Optional TrustAll\nServer = https://git.tesses.org/api/packages/tesses50/arch/core/\$arch\n" >> /etc/pacman.conf
|
|
||||||
- run: printf "[tesses50.git.tesses.org]\nSigLevel = Optional TrustAll\nServer = https://git.tesses.org/api/packages/tesses50/arch/core/\$arch\n" >> /opt/cross/ppc/pacman.conf
|
|
||||||
- run: pacman --noconfirm -Sy mbedtls tessesframework zip zig ninja
|
|
||||||
- run: pacman --config /opt/cross/ppc/pacman.conf --noconfirm -Sy mbedtls tessesframework
|
|
||||||
- run: cp Packaging/Linux/PKGBUILD /home/build/PKGBUILD
|
|
||||||
- run: cp Packaging/Linux/build-arch.sh /home/build/build-arch.sh
|
|
||||||
- run: chmod 755 /home/build/build-arch.sh
|
|
||||||
- run: chown build:build /home/build/PKGBUILD
|
|
||||||
- run: chown build:build /home/build/build-arch.sh
|
|
||||||
- run: su build -c /home/build/build-arch.sh
|
|
||||||
- uses: akkuman/gitea-release-action@v1
|
- uses: akkuman/gitea-release-action@v1
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
|
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
|
||||||
@@ -36,9 +28,51 @@ jobs:
|
|||||||
prerelease: true
|
prerelease: true
|
||||||
files: |-
|
files: |-
|
||||||
artifacts/**
|
artifacts/**
|
||||||
|
|
||||||
|
build-packages:
|
||||||
|
name: "🔨 Build for everything else"
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- container: "git.tesses.org/tesses50/linux-x64:latest"
|
||||||
|
puter: "msi-walmart"
|
||||||
|
nfpmName: "amd64"
|
||||||
|
debianName: "x86_64-linux-gnu"
|
||||||
|
- container: "git.tesses.org/tesses50/linux-x86:latest"
|
||||||
|
puter: "asrock"
|
||||||
|
nfpmName: "386"
|
||||||
|
debianName: "i386-linux-gnu"
|
||||||
|
- container: "git.tesses.org/tesses50/linux-arm:latest"
|
||||||
|
puter: "fw13-ubuntu-latest"
|
||||||
|
nfpmName: "arm7"
|
||||||
|
debianName: "arm-linux-gnueabihf"
|
||||||
|
- container: "git.tesses.org/tesses50/linux-arm64:latest"
|
||||||
|
puter: "msi-walmart"
|
||||||
|
nfpmName: "arm64"
|
||||||
|
debianName: "aarch64-linux-gnu"
|
||||||
|
- container: "git.tesses.org/tesses50/linux-riscv64:latest"
|
||||||
|
nfpmName: "riscv64"
|
||||||
|
debianName: "riscv64-linux-gnu"
|
||||||
|
puter: "asrock"
|
||||||
|
runs-on: ${{ matrix.puter }}
|
||||||
|
container:
|
||||||
|
image: ${{ matrix.container }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: bash build-for-nfpm.sh ${{ matrix.nfpmName }} ${{ matrix.debianName }}
|
||||||
|
- uses: akkuman/gitea-release-action@v1
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18
|
||||||
|
with:
|
||||||
|
prerelease: true
|
||||||
|
files: |-
|
||||||
|
artifacts/**
|
||||||
|
|
||||||
|
|
||||||
update-tap:
|
update-tap:
|
||||||
runs-on: global-container-mingw
|
runs-on: msi-walmart
|
||||||
|
container: git.tesses.org/tesses50/global-containers-mingw:latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: |
|
- run: |
|
||||||
|
|||||||
Vendored
+5
-3
@@ -8,8 +8,11 @@
|
|||||||
"name": "(gdb) Launch",
|
"name": "(gdb) Launch",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/builds/l/crossint",
|
"program": "${workspaceFolder}/build/crosslang",
|
||||||
"args": ["queryable.tcross"],
|
"args": [
|
||||||
|
"webapp",
|
||||||
|
"tytd2025"
|
||||||
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}/builds/l",
|
"cwd": "${workspaceFolder}/builds/l",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
@@ -28,6 +31,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -32,4 +32,13 @@ include(cmake/app.cmake)
|
|||||||
|
|
||||||
if(CROSSLANG_INSTALL_DEVELOPMENT)
|
if(CROSSLANG_INSTALL_DEVELOPMENT)
|
||||||
add_subdirectory(pkgconfig)
|
add_subdirectory(pkgconfig)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CROSSLANG_TF_VERSION STREQUAL "")
|
||||||
|
if(NOT CROSSLANG_NFPM_ARCH STREQUAL "")
|
||||||
|
configure_file(nfpm.yaml.in nfpm.yaml @ONLY)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file(ppc-pkgbuild.in ppc-pkgbuild @ONLY)
|
||||||
endif()
|
endif()
|
||||||
@@ -0,0 +1,633 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
INTERPRETER BINDINGS EXCEPTION
|
||||||
|
|
||||||
|
This exception is an additional permission under section 7 of the GNU General Public License, version 3.
|
||||||
|
|
||||||
|
As a special exception, you may convey a work that combines this Library with code written in an interpreted language (including tree-walk interpreters, bytecode interpreters, or WebAssembly modules), without requiring the interpreted code to be licensed under the terms of this License, provided that:
|
||||||
|
|
||||||
|
1. The Library operates on the host side of the execution environment.
|
||||||
|
2. The interpreted code is not statically or dynamically linked to the Library in a manner that creates a single combined executable binary outside of the standard interpretation process.
|
||||||
|
3. Communication between the Library and the interpreted code occurs solely through standard interpreter bindings or interfaces.
|
||||||
|
|
||||||
|
If the Library is modified and linked directly into the bytecode module or interpreted executable (violating condition 2), this exception does not apply, and the resulting work must be conveyed under the terms of the GNU General Public License.
|
||||||
-675
@@ -1,675 +0,0 @@
|
|||||||
# GNU GENERAL PUBLIC LICENSE
|
|
||||||
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
|
||||||
<https://fsf.org/>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this
|
|
||||||
license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
## Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom
|
|
||||||
to share and change all versions of a program--to make sure it remains
|
|
||||||
free software for all its users. We, the Free Software Foundation, use
|
|
||||||
the GNU General Public License for most of our software; it applies
|
|
||||||
also to any other work released this way by its authors. You can apply
|
|
||||||
it to your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you
|
|
||||||
have certain responsibilities if you distribute copies of the
|
|
||||||
software, or if you modify it: responsibilities to respect the freedom
|
|
||||||
of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the
|
|
||||||
manufacturer can do so. This is fundamentally incompatible with the
|
|
||||||
aim of protecting users' freedom to change the software. The
|
|
||||||
systematic pattern of such abuse occurs in the area of products for
|
|
||||||
individuals to use, which is precisely where it is most unacceptable.
|
|
||||||
Therefore, we have designed this version of the GPL to prohibit the
|
|
||||||
practice for those products. If such problems arise substantially in
|
|
||||||
other domains, we stand ready to extend this provision to those
|
|
||||||
domains in future versions of the GPL, as needed to protect the
|
|
||||||
freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish
|
|
||||||
to avoid the special danger that patents applied to a free program
|
|
||||||
could make it effectively proprietary. To prevent this, the GPL
|
|
||||||
assures that patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
## TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
### 0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds
|
|
||||||
of works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of
|
|
||||||
an exact copy. The resulting work is called a "modified version" of
|
|
||||||
the earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user
|
|
||||||
through a computer network, with no transfer of a copy, is not
|
|
||||||
conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices" to
|
|
||||||
the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
### 1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. "Object code" means any non-source form of
|
|
||||||
a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can
|
|
||||||
regenerate automatically from other parts of the Corresponding Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same
|
|
||||||
work.
|
|
||||||
|
|
||||||
### 2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey,
|
|
||||||
without conditions so long as your license otherwise remains in force.
|
|
||||||
You may convey covered works to others for the sole purpose of having
|
|
||||||
them make modifications exclusively for you, or provide you with
|
|
||||||
facilities for running those works, provided that you comply with the
|
|
||||||
terms of this License in conveying all material for which you do not
|
|
||||||
control copyright. Those thus making or running the covered works for
|
|
||||||
you must do so exclusively on your behalf, under your direction and
|
|
||||||
control, on terms that prohibit them from making any copies of your
|
|
||||||
copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the
|
|
||||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
|
||||||
it unnecessary.
|
|
||||||
|
|
||||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such
|
|
||||||
circumvention is effected by exercising rights under this License with
|
|
||||||
respect to the covered work, and you disclaim any intention to limit
|
|
||||||
operation or modification of the work as a means of enforcing, against
|
|
||||||
the work's users, your or third parties' legal rights to forbid
|
|
||||||
circumvention of technological measures.
|
|
||||||
|
|
||||||
### 4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
### 5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
- a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
- b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under
|
|
||||||
section 7. This requirement modifies the requirement in section 4
|
|
||||||
to "keep intact all notices".
|
|
||||||
- c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
- d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
### 6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms of
|
|
||||||
sections 4 and 5, provided that you also convey the machine-readable
|
|
||||||
Corresponding Source under the terms of this License, in one of these
|
|
||||||
ways:
|
|
||||||
|
|
||||||
- a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
- b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the Corresponding
|
|
||||||
Source from a network server at no charge.
|
|
||||||
- c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
- d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
- e) Convey the object code using peer-to-peer transmission,
|
|
||||||
provided you inform other peers where the object code and
|
|
||||||
Corresponding Source of the work are being offered to the general
|
|
||||||
public at no charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal,
|
|
||||||
family, or household purposes, or (2) anything designed or sold for
|
|
||||||
incorporation into a dwelling. In determining whether a product is a
|
|
||||||
consumer product, doubtful cases shall be resolved in favor of
|
|
||||||
coverage. For a particular product received by a particular user,
|
|
||||||
"normally used" refers to a typical or common use of that class of
|
|
||||||
product, regardless of the status of the particular user or of the way
|
|
||||||
in which the particular user actually uses, or expects or is expected
|
|
||||||
to use, the product. A product is a consumer product regardless of
|
|
||||||
whether the product has substantial commercial, industrial or
|
|
||||||
non-consumer uses, unless such uses represent the only significant
|
|
||||||
mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to
|
|
||||||
install and execute modified versions of a covered work in that User
|
|
||||||
Product from a modified version of its Corresponding Source. The
|
|
||||||
information must suffice to ensure that the continued functioning of
|
|
||||||
the modified object code is in no case prevented or interfered with
|
|
||||||
solely because modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or
|
|
||||||
updates for a work that has been modified or installed by the
|
|
||||||
recipient, or for the User Product in which it has been modified or
|
|
||||||
installed. Access to a network may be denied when the modification
|
|
||||||
itself materially and adversely affects the operation of the network
|
|
||||||
or violates the rules and protocols for communication across the
|
|
||||||
network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
### 7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders
|
|
||||||
of that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
- a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
- b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
- c) Prohibiting misrepresentation of the origin of that material,
|
|
||||||
or requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
- d) Limiting the use for publicity purposes of names of licensors
|
|
||||||
or authors of the material; or
|
|
||||||
- e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
- f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions
|
|
||||||
of it) with contractual assumptions of liability to the recipient,
|
|
||||||
for any liability that these contractual assumptions directly
|
|
||||||
impose on those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions; the
|
|
||||||
above requirements apply either way.
|
|
||||||
|
|
||||||
### 8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license
|
|
||||||
from a particular copyright holder is reinstated (a) provisionally,
|
|
||||||
unless and until the copyright holder explicitly and finally
|
|
||||||
terminates your license, and (b) permanently, if the copyright holder
|
|
||||||
fails to notify you of the violation by some reasonable means prior to
|
|
||||||
60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
### 9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or run
|
|
||||||
a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
### 10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
### 11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims owned
|
|
||||||
or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within the
|
|
||||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
|
||||||
the non-exercise of one or more of the rights that are specifically
|
|
||||||
granted under this License. You may not convey a covered work if you
|
|
||||||
are a party to an arrangement with a third party that is in the
|
|
||||||
business of distributing software, under which you make payment to the
|
|
||||||
third party based on the extent of your activity of conveying the
|
|
||||||
work, and under which the third party grants, to any of the parties
|
|
||||||
who would receive the covered work from you, a discriminatory patent
|
|
||||||
license (a) in connection with copies of the covered work conveyed by
|
|
||||||
you (or copies made from those copies), or (b) primarily for and in
|
|
||||||
connection with specific products or compilations that contain the
|
|
||||||
covered work, unless you entered into that arrangement, or that patent
|
|
||||||
license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
### 12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under
|
|
||||||
this License and any other pertinent obligations, then as a
|
|
||||||
consequence you may not convey it at all. For example, if you agree to
|
|
||||||
terms that obligate you to collect a royalty for further conveying
|
|
||||||
from those to whom you convey the Program, the only way you could
|
|
||||||
satisfy both those terms and this License would be to refrain entirely
|
|
||||||
from conveying the Program.
|
|
||||||
|
|
||||||
### 13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
### 14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the GNU General Public License from time to time. Such new versions
|
|
||||||
will be similar in spirit to the present version, but may differ in
|
|
||||||
detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies that a certain numbered version of the GNU General Public
|
|
||||||
License "or any later version" applies to it, you have the option of
|
|
||||||
following the terms and conditions either of that numbered version or
|
|
||||||
of any later version published by the Free Software Foundation. If the
|
|
||||||
Program does not specify a version number of the GNU General Public
|
|
||||||
License, you may choose any version ever published by the Free
|
|
||||||
Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions
|
|
||||||
of the GNU General Public License can be used, that proxy's public
|
|
||||||
statement of acceptance of a version permanently authorizes you to
|
|
||||||
choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
### 15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
|
||||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
|
||||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
|
||||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
|
||||||
CORRECTION.
|
|
||||||
|
|
||||||
### 16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
|
||||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
|
||||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
|
||||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
|
||||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
|
||||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
|
||||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
### 17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
## How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these
|
|
||||||
terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to
|
|
||||||
attach them to the start of each source file to most effectively state
|
|
||||||
the exclusion of warranty; and each file should have at least the
|
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper
|
|
||||||
mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands \`show w' and \`show c' should show the
|
|
||||||
appropriate parts of the General Public License. Of course, your
|
|
||||||
program's commands might be different; for a GUI interface, you would
|
|
||||||
use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. For more information on this, and how to apply and follow
|
|
||||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your
|
|
||||||
program into proprietary programs. If your program is a subroutine
|
|
||||||
library, you may consider it more useful to permit linking proprietary
|
|
||||||
applications with the library. If this is what you want to do, use the
|
|
||||||
GNU Lesser General Public License instead of this License. But first,
|
|
||||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
# Maintainer: Mike Nolan <tesses@tesses.net>
|
|
||||||
pkgname=crosslang # '-bzr', '-git', '-hg' or '-svn'
|
|
||||||
pkgver=0.0.6
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc=""
|
|
||||||
arch=('x86_64' 'powerpc')
|
|
||||||
url="https://git.tesses.org/tesses50/crosslang"
|
|
||||||
license=('GPLv3')
|
|
||||||
groups=()
|
|
||||||
depends=('mbedtls' 'tessesframework=0.0.4')
|
|
||||||
makedepends=('git' 'cmake' 'make' 'base-devel' 'wget') # 'bzr', 'git', 'mercurial' or 'subversion'
|
|
||||||
install=
|
|
||||||
source=('crosslang::git+https://git.tesses.org/tesses50/crosslang')
|
|
||||||
noextract=()
|
|
||||||
sha256sums=('SKIP')
|
|
||||||
if [[ -z "$CMAKE_TOOLCHAIN" ]]; then
|
|
||||||
options=(!strip)
|
|
||||||
else
|
|
||||||
options=(!buildflags !strip)
|
|
||||||
fi
|
|
||||||
# Please refer to the 'USING VCS SOURCES' section of the PKGBUILD man page for
|
|
||||||
# a description of each element in the source array.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
prepare() {
|
|
||||||
cd "$srcdir/${pkgname}"
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
cd "$srcdir/${pkgname}"
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
|
|
||||||
if [[ -z "$CMAKE_TOOLCHAIN" ]]; then
|
|
||||||
cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=/usr -DCROSSLANG_FETCHCONTENT=OFF -DCMAKE_BUILD_TYPE=Release
|
|
||||||
else
|
|
||||||
cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=/usr -DCROSSLANG_FETCHCONTENT=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j`nproc`
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "$srcdir/${pkgname}/build"
|
|
||||||
make install DESTDIR="$pkgdir/"
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd /home/build
|
|
||||||
mkdir x86_64
|
|
||||||
cd x86_64
|
|
||||||
cp ../PKGBUILD .
|
|
||||||
makepkg
|
|
||||||
curl --user tesses50:$PACKAGE_AND_BREW \
|
|
||||||
--upload-file *.pkg.tar.zst \
|
|
||||||
https://git.tesses.org/api/packages/tesses50/arch/core
|
|
||||||
cd ..
|
|
||||||
mkdir powerpc
|
|
||||||
cd powerpc
|
|
||||||
cp ../PKGBUILD .
|
|
||||||
CARCH=powerpc CMAKE_TOOLCHAIN=/opt/cross/ppc/toolchain.cmake makepkg
|
|
||||||
curl --user tesses50:$PACKAGE_AND_BREW \
|
|
||||||
--upload-file *.pkg.tar.zst \
|
|
||||||
https://git.tesses.org/api/packages/tesses50/arch/core
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
export HASH=`curl https://git.tesses.org/tesses50/crosslang/archive/$VERSION.tar.gz 2> /dev/null | shasum -a 256 | awk '{print $1}'`
|
export HASH=`curl https://git.tesses.org/tesses50/crosslang/archive/$VERSION.tar.gz 2> /dev/null | shasum -a 256 | awk '{print $1}'`
|
||||||
|
|
||||||
echo "class Crosslang < Formula" > "Formula/crosslang.rb"
|
echo "class Crosslang < Formula" > "Formula/crosslang.rb"
|
||||||
echo " desc \"\"" >> "Formula/crosslang.rb"
|
echo " desc \"CrossLang is a dynamically-typed scripting language built on TessesFramework, named in honor of Jesus's sacrifice.\"" >> "Formula/crosslang.rb"
|
||||||
echo " homepage \"\"" >> "Formula/crosslang.rb"
|
echo " homepage \"https://crosslang.tesseslanguage.com/\"" >> "Formula/crosslang.rb"
|
||||||
echo " url \"https://git.tesses.org/tesses50/crosslang/archive/$VERSION.tar.gz\"" >> "Formula/crosslang.rb"
|
echo " url \"https://git.tesses.org/tesses50/crosslang/archive/$VERSION.tar.gz\"" >> "Formula/crosslang.rb"
|
||||||
echo " sha256 \"$HASH\"" >> "Formula/crosslang.rb"
|
echo " sha256 \"$HASH\"" >> "Formula/crosslang.rb"
|
||||||
echo " license \"GPLv3\"" >> "Formula/crosslang.rb"
|
echo " license \"GPLv3\"" >> "Formula/crosslang.rb"
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
Tesses Cross Language
|
CrossLang
|
||||||
=====================
|
=========
|
||||||
|
CrossLang is a dynamically-typed scripting language built on TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
[WebSite](https://crosslang.tesseslanguage.com/)
|
[WebSite](https://crosslang.tesseslanguage.com/)
|
||||||
|
|
||||||
## What is required to build this project
|
## What is required to build this project
|
||||||
- [TessesFramework](https://git.tesses.org/tesses50/tessesframework) (if you turn CROSSLANG_FETCHCONTENT off otherwise it will be grabbed automaticly)
|
- [TessesFramework](https://git.tesses.org/tesses50/tessesframework) (if you turn CROSSLANG_FETCHCONTENT off otherwise it will be grabbed automatically)
|
||||||
- CMake
|
- CMake
|
||||||
|
|
||||||
|
|
||||||
## Use in docker (use my container)
|
## Use in docker (use my container)
|
||||||
```bash
|
```bash
|
||||||
sudo docker pull -t git.tesses.org/tesses50/crosslang:latest
|
sudo docker pull git.tesses.org/tesses50/crosslang:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use in docker (build the container yourself)
|
## Use in docker (build the container yourself)
|
||||||
@@ -23,16 +24,15 @@ Tesses Cross Language
|
|||||||
```
|
```
|
||||||
|
|
||||||
## To Install
|
## To Install
|
||||||
- Install [mbedtls](https://github.com/Mbed-TLS/mbedtls) (use sudo apt install libmbedtls-dev on debian) for TessesFramework (no longer works on debian, needs -DTESSESFRAMEWORK_FETCHCONTENT=ON for debian)
|
Pick one depending on what you need
|
||||||
- Follow the commands bellow
|
|
||||||
|
|
||||||
## Run these commands to install crosslang (with plugin support)
|
### Run these commands to install crosslang (with plugin support)
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.tesses.org/tesses50/tessesframework
|
git clone https://git.tesses.org/tesses50/tessesframework
|
||||||
cd tessesframework
|
cd tessesframework
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -S .. -B . -DTESSESFRAMEWORK_FETCHCONTENT=OFF
|
cmake -S .. -B .
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
cd ../..
|
cd ../..
|
||||||
@@ -45,13 +45,18 @@ make
|
|||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build with shared libs only (self contained dependencies)
|
### Build with shared libs only (self contained dependencies)
|
||||||
```bash
|
```bash
|
||||||
cmake -S ../.. -B .
|
cmake -S ../.. -B .
|
||||||
make -j`nproc`
|
make -j`nproc`
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Installing or Updating the Shell
|
||||||
|
```bash
|
||||||
|
crosslang update-shell
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
Ye are of God, little children, and have overcome them: because greater is he that is in you, than he that is in the world. (1 John 4:4)
|
Ye are of God, little children, and have overcome them: because greater is he that is in you, than he that is in the world. (1 John 4:4)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
if [ $# -lt 2 ]
|
||||||
|
then
|
||||||
|
echo "Not enough args, pass nfpm arch and debian tripple as argument"
|
||||||
|
echo "This script requires our docker container: git.tesses.org/tesses50/linux-*:latest"
|
||||||
|
else
|
||||||
|
curl https://git.tesses.org/tesses50/tessesframework/releases/download/v$TF_VERSION/tessesframework-v$TF_VERSION-$1.tar.gz | tar xz -C /opt/cross/staging
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake-cross -S .. -B . -DCROSSLANG_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib/$2 -DCMAKE_BUILD_TYPE=Release -DCROSSLANG_FETCHCONTENT=OFF -DCROSSLANG_TF_VERSION=$TF_VERSION
|
||||||
|
make -j`nproc`
|
||||||
|
make install DESTDIR=debian
|
||||||
|
cd debian
|
||||||
|
nfpm package -f ../nfpm.yaml -p deb
|
||||||
|
curl --user tesses50:$PACKAGE_AND_BREW \
|
||||||
|
--upload-file *.deb \
|
||||||
|
https://git.tesses.org/api/packages/tesses50/debian/pool/universal/main/upload
|
||||||
|
#debian/pool/bionic
|
||||||
|
cd ..
|
||||||
|
if [ "$1" = "386" ] || [ "$1" = "arm7" ]
|
||||||
|
then
|
||||||
|
cmake-cross -S .. -B . -DCROSSLANG_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib32
|
||||||
|
else
|
||||||
|
cmake-cross -S .. -B . -DCROSSLANG_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib64
|
||||||
|
fi
|
||||||
|
make install DESTDIR=fedora
|
||||||
|
cd fedora
|
||||||
|
nfpm package -f ../nfpm.yaml -p rpm
|
||||||
|
curl --user tesses50:$PACKAGE_AND_BREW \
|
||||||
|
--upload-file *.rpm \
|
||||||
|
https://git.tesses.org/api/packages/tesses50/rpm/upload
|
||||||
|
cd ..
|
||||||
|
cmake-cross -S .. -B . -DCROSSLANG_NFPM_ARCH=$1 -DCMAKE_INSTALL_LIBDIR=lib
|
||||||
|
make install DESTDIR=arch
|
||||||
|
cd arch
|
||||||
|
nfpm package -f ../nfpm.yaml -p archlinux
|
||||||
|
curl --user tesses50:$PACKAGE_AND_BREW \
|
||||||
|
--upload-file *.pkg.tar.zst \
|
||||||
|
https://git.tesses.org/api/packages/tesses50/arch/core
|
||||||
|
mkdir -p ../../artifacts
|
||||||
|
tar czf ../../artifacts/crosslang-$VERSION\-$1\.tar.gz --owner=1000 --group=1000 -C usr/ . -C /opt/cross/staging/ .
|
||||||
|
fi
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
curl https://git.tesses.org/tesses50/tessesframework/releases/download/v$TF_VERSION/tessesframework-v$TF_VERSION-powerpc.tar.gz | tar xz -C /opt/cross/staging
|
||||||
|
|
||||||
|
mkdir -p build
|
||||||
|
pushd build
|
||||||
|
cmake-cross -S .. -B . -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCROSSLANG_FETCHCONTENT=OFF -DCROSSLANG_TF_VERSION=$TF_VERSION
|
||||||
|
make -j`nproc`
|
||||||
|
mkdir -p /home/build/cl
|
||||||
|
chown build:build -R /home/build
|
||||||
|
make install DESTDIR=/home/build/cl/src
|
||||||
|
cp ppc-pkgbuild /home/build/cl/PKGBUILD
|
||||||
|
chmod 644 /home/build/cl/PKGBUILD
|
||||||
|
chown build:build -R /home/build/cl
|
||||||
|
pushd /home/build/cl
|
||||||
|
su build -c 'CARCH=powerpc makepkg -d'
|
||||||
|
curl --user tesses50:$PACKAGE_AND_BREW \
|
||||||
|
--upload-file *.pkg.tar.zst \
|
||||||
|
https://git.tesses.org/api/packages/tesses50/arch/core
|
||||||
|
popd
|
||||||
|
popd
|
||||||
|
mkdir -p artifacts
|
||||||
|
tar czf artifacts/crosslang-$VERSION\-powerpc.tar.gz --owner=1000 --group=1000 -C /home/build/cl/src/usr . -C /opt/cross/staging/ .
|
||||||
+16
-1
@@ -1,5 +1,20 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.11
|
||||||
|
Add htmlparser, conditional variables, make alloc_threshold overridable in prefs.json
|
||||||
|
|
||||||
|
## 0.0.10
|
||||||
|
Replace time-based GC with allocation-count trigger, migrate all Create factories to GCList::Create(), fix VFSPath root path, reorder TObject variant
|
||||||
|
|
||||||
|
## 0.0.9
|
||||||
|
Fixed Process.ShellFileOrUrl was broken New.ShellFileOrUrl
|
||||||
|
|
||||||
|
## 0.0.8
|
||||||
|
Use new build setup
|
||||||
|
|
||||||
|
## 0.0.7
|
||||||
|
Fix a security vulnerability in crossdump that is supposed to use uint32_t but accidentally used uint8_t, set to tessesframework=0.0.5
|
||||||
|
|
||||||
## 0.0.6
|
## 0.0.6
|
||||||
Fix bug with classes, use slim exclusively, add package private data and change rehaul cmake configs
|
Fix bug with classes, use slim exclusively, add package private data and change rehaul cmake configs
|
||||||
|
|
||||||
@@ -10,7 +25,7 @@ Fix crosslang Stat, StatVFS for custom crosslang filesystems and add queryable
|
|||||||
Rework for git.tesses.org, GC* is std::shared_ptr maybe will fix crash during exit
|
Rework for git.tesses.org, GC* is std::shared_ptr maybe will fix crash during exit
|
||||||
|
|
||||||
## 0.0.3
|
## 0.0.3
|
||||||
Fixed cmake, unnecessary itteration on dictionary, and a crosslang binary bug when shell is not installed
|
Fixed cmake, unnecessary iteration on dictionary, and a crosslang binary bug when shell is not installed
|
||||||
|
|
||||||
## 0.0.2
|
## 0.0.2
|
||||||
Add uuids, bytestreams and single file runtime binaries
|
Add uuids, bytestreams and single file runtime binaries
|
||||||
|
|||||||
+3
-4
@@ -1,6 +1,6 @@
|
|||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
set(CPACK_PACKAGE_CONTACT "Mike Nolan <tesses@tesses.net>")
|
set(CPACK_PACKAGE_CONTACT "Mike Nolan <tesses@tesses.net>")
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "${TessesCrossLang_VERSION_MAJOR}")
|
set(CPACK_PACKAGE_VERSION_MAJOR "${TessesCrossLang_VERSION_MAJOR}")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "${TessesCrossLang_VERSION_MINOR}")
|
set(CPACK_PACKAGE_VERSION_MINOR "${TessesCrossLang_VERSION_MINOR}")
|
||||||
|
|
||||||
@@ -32,8 +32,7 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
|
|||||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/winicon.ico")
|
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/winicon.ico")
|
||||||
set(CPACK_NSIS_MODIFY_PATH ON)
|
set(CPACK_NSIS_MODIFY_PATH ON)
|
||||||
set(CPACK_PACKAGE_VENDOR "Tesses")
|
set(CPACK_PACKAGE_VENDOR "Tesses")
|
||||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$DESKTOP\\\\CrossLang Interperter.lnk' '$INSTDIR\\\\bin\\\\crossint.exe'")
|
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$DESKTOP\\\\CrossLang Menu.lnk' '$INSTDIR\\\\bin\\\\crosslang.exe' 'interactive'")
|
||||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\CrossLang Interperter.lnk' '$INSTDIR\\\\bin\\\\crossint.exe'")
|
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\CrossLang Menu.lnk' '$INSTDIR\\\\bin\\\\crosslang.exe' 'interactive'")
|
||||||
|
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
+2
-2
@@ -5,10 +5,10 @@ set(CROSSLANG_STATIC ${TESSESFRAMEWORK_STATIC} CACHE INTERNAL "For CrossLang" FO
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
TessesFramework
|
TessesFramework
|
||||||
GIT_REPOSITORY https://git.tesses.org/tesses50/tessesframework.git
|
GIT_REPOSITORY https://git.tesses.org/tesses50/tessesframework.git
|
||||||
GIT_TAG 25d67053ccebf209f50e6928fad8827164eb4c28
|
GIT_TAG e4ca34aa597c9b0955aa23c18c500048af697c92
|
||||||
)
|
)
|
||||||
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF)
|
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF)
|
||||||
FetchContent_MakeAvailable(TessesFramework)
|
FetchContent_MakeAvailable(TessesFramework)
|
||||||
else()
|
else()
|
||||||
find_package(TessesFramework REQUIRED)
|
find_package(TessesFramework REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ option(CROSSLANG_ENABLE_FFI "Enable libffi" OFF)
|
|||||||
option(CROSSLANG_ENABLE_RPATH "Enable RPATH" ON)
|
option(CROSSLANG_ENABLE_RPATH "Enable RPATH" ON)
|
||||||
option(CROSSLANG_CUSTOM_CONSOLE "Enable custom Console" OFF)
|
option(CROSSLANG_CUSTOM_CONSOLE "Enable custom Console" OFF)
|
||||||
option(CROSSLANG_STATIC "Build with static libraries instead of shared" OFF)
|
option(CROSSLANG_STATIC "Build with static libraries instead of shared" OFF)
|
||||||
|
option(CROSSLANG_NFPM_ARCH "Architecture for NFPM" "")
|
||||||
|
option(CROSSLANG_TF_VERSION "TessesFramework Version for nfpm and pkgbuild" "")
|
||||||
+1
-1
@@ -12,7 +12,6 @@ src/vm/bc/tobool.cpp
|
|||||||
src/compiler/codegen.cpp
|
src/compiler/codegen.cpp
|
||||||
src/compiler/lexer.cpp
|
src/compiler/lexer.cpp
|
||||||
src/compiler/parser.cpp
|
src/compiler/parser.cpp
|
||||||
src/compiler/ast.cpp
|
|
||||||
src/runtime_methods/uuid.cpp
|
src/runtime_methods/uuid.cpp
|
||||||
src/runtime_methods/class.cpp
|
src/runtime_methods/class.cpp
|
||||||
src/runtime_methods/console.cpp
|
src/runtime_methods/console.cpp
|
||||||
@@ -47,6 +46,7 @@ src/types/class.cpp
|
|||||||
src/types/classenvironment.cpp
|
src/types/classenvironment.cpp
|
||||||
src/types/random.cpp
|
src/types/random.cpp
|
||||||
src/types/queryable.cpp
|
src/types/queryable.cpp
|
||||||
|
src/types/exception.cpp
|
||||||
src/vm/filereader.cpp
|
src/vm/filereader.cpp
|
||||||
src/vm/gc.cpp
|
src/vm/gc.cpp
|
||||||
src/vm/gclist.cpp
|
src/vm/gclist.cpp
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
set(CROSSLANG_MAJOR_VERSION 0)
|
set(CROSSLANG_MAJOR_VERSION 0)
|
||||||
set(CROSSLANG_MINOR_VERSION 0)
|
set(CROSSLANG_MINOR_VERSION 0)
|
||||||
set(CROSSLANG_PATCH_VERSION 6)
|
set(CROSSLANG_PATCH_VERSION 11)
|
||||||
|
|||||||
+251
-84
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <TessesFramework/TessesFramework.hpp>
|
#include <TessesFramework/TessesFramework.hpp>
|
||||||
#include <any>
|
#include <any>
|
||||||
@@ -14,6 +34,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unordered_set>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -35,6 +56,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
constexpr uint32_t ALLOC_THRESHOLD = 10000;
|
||||||
using BitConverter = Tesses::Framework::Serialization::BitConverter;
|
using BitConverter = Tesses::Framework::Serialization::BitConverter;
|
||||||
constexpr std::string_view VMName = "CrossLangVM";
|
constexpr std::string_view VMName = "CrossLangVM";
|
||||||
constexpr std::string_view VMHowToGet = "https://crosslang.tesseslanguage.com/";
|
constexpr std::string_view VMHowToGet = "https://crosslang.tesseslanguage.com/";
|
||||||
@@ -794,14 +816,16 @@ class ResourceByteArray : public ResourceBase {
|
|||||||
GetLength(std::shared_ptr<Tesses::Framework::Filesystem::VFS> embedFS);
|
GetLength(std::shared_ptr<Tesses::Framework::Filesystem::VFS> embedFS);
|
||||||
void Write(std::shared_ptr<Tesses::Framework::Streams::Stream> output);
|
void Write(std::shared_ptr<Tesses::Framework::Streams::Stream> output);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CodeGen {
|
class CodeGen {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t NewId();
|
uint32_t NewId();
|
||||||
|
|
||||||
void GetFunctionArgs(std::vector<uint32_t> &args, SyntaxNode n);
|
void GetFunctionArgs(std::vector<uint32_t> &args,
|
||||||
|
std::vector<ByteCodeInstruction *> &instructions,
|
||||||
|
SyntaxNode n);
|
||||||
|
void FlattenCommas(std::vector<uint32_t> &args, SyntaxNode n);
|
||||||
void GetFunctionName(std::vector<uint32_t> &name, SyntaxNode n);
|
void GetFunctionName(std::vector<uint32_t> &name, SyntaxNode n);
|
||||||
void GetFunctionArgs(std::vector<SyntaxNode> &args, SyntaxNode n);
|
void FlattenCommas(std::vector<SyntaxNode> &args, SyntaxNode n);
|
||||||
SyntaxNode StringifyListOfVars(SyntaxNode n);
|
SyntaxNode StringifyListOfVars(SyntaxNode n);
|
||||||
|
|
||||||
uint32_t GetString(std::string str);
|
uint32_t GetString(std::string str);
|
||||||
@@ -1275,9 +1299,6 @@ class AdvancedSyntaxNode {
|
|||||||
std::vector<SyntaxNode> n);
|
std::vector<SyntaxNode> n);
|
||||||
};
|
};
|
||||||
|
|
||||||
SyntaxNode Deserialize(std::string astData);
|
|
||||||
|
|
||||||
std::string Serialize(SyntaxNode node);
|
|
||||||
class GC;
|
class GC;
|
||||||
class TRootEnvironment;
|
class TRootEnvironment;
|
||||||
/**
|
/**
|
||||||
@@ -1347,15 +1368,10 @@ class THeapObject {
|
|||||||
public:
|
public:
|
||||||
bool marked;
|
bool marked;
|
||||||
virtual void Mark() { marked = true; }
|
virtual void Mark() { marked = true; }
|
||||||
|
THeapObject() = default;
|
||||||
virtual ~THeapObject() {}
|
THeapObject(const THeapObject &) = delete;
|
||||||
};
|
THeapObject &operator=(const THeapObject &) = delete;
|
||||||
|
virtual ~THeapObject() = default;
|
||||||
class THeapObjectHolder {
|
|
||||||
public:
|
|
||||||
THeapObject *obj;
|
|
||||||
THeapObjectHolder(THeapObject *obj) { this->obj = obj; }
|
|
||||||
THeapObjectHolder() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is a dummy type with
|
// this is a dummy type with
|
||||||
@@ -1369,9 +1385,9 @@ class TContinue {};
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using TObject =
|
using TObject =
|
||||||
std::variant<int64_t, double, char, bool, std::string, std::regex,
|
std::variant<Undefined, int64_t, double, char, bool, std::string,
|
||||||
Tesses::Framework::Filesystem::VFSPath, std::nullptr_t,
|
std::regex, Tesses::Framework::Filesystem::VFSPath,
|
||||||
Undefined, MethodInvoker, THeapObjectHolder, TVMVersion,
|
MethodInvoker, THeapObject *, TVMVersion,
|
||||||
std::shared_ptr<Tesses::Framework::Date::DateTime>,
|
std::shared_ptr<Tesses::Framework::Date::DateTime>,
|
||||||
std::shared_ptr<Tesses::Framework::Date::TimeSpan>, TBreak,
|
std::shared_ptr<Tesses::Framework::Date::TimeSpan>, TBreak,
|
||||||
TContinue, std::shared_ptr<Tesses::Framework::Streams::Stream>,
|
TContinue, std::shared_ptr<Tesses::Framework::Streams::Stream>,
|
||||||
@@ -1387,50 +1403,73 @@ using TObject =
|
|||||||
Tesses::Framework::Uuid>;
|
Tesses::Framework::Uuid>;
|
||||||
|
|
||||||
class TRootEnvironment;
|
class TRootEnvironment;
|
||||||
|
class GCList;
|
||||||
|
|
||||||
class GC : public std::enable_shared_from_this<GC> {
|
class GC : public std::enable_shared_from_this<GC> {
|
||||||
Tesses::Framework::Threading::Thread *thrd;
|
Tesses::Framework::Threading::Thread *thrd;
|
||||||
Tesses::Framework::Threading::Mutex *mtx;
|
Tesses::Framework::Threading::Mutex mtx;
|
||||||
|
Tesses::Framework::Threading::Cond cond;
|
||||||
|
uint32_t allocs = 0;
|
||||||
|
uint32_t threshold = ALLOC_THRESHOLD;
|
||||||
volatile std::atomic<bool> running;
|
volatile std::atomic<bool> running;
|
||||||
std::vector<THeapObject *> roots;
|
std::unordered_set<GCList *> roots;
|
||||||
std::vector<THeapObject *> objects;
|
std::unordered_set<THeapObject *> objects;
|
||||||
|
|
||||||
Tesses::Framework::Lazy<Tesses::Framework::Threading::ThreadPool *> *tpool;
|
Tesses::Framework::Lazy<Tesses::Framework::Threading::ThreadPool *> *tpool;
|
||||||
std::vector<
|
std::vector<
|
||||||
std::function<void(std::shared_ptr<GC> gc, TRootEnvironment *env)>>
|
std::function<void(std::shared_ptr<GC> gc, TRootEnvironment *env)>>
|
||||||
register_everything;
|
register_everything;
|
||||||
|
|
||||||
|
void SetRoot(GCList *obj);
|
||||||
|
void UnsetRoot(GCList *obj);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tesses::Framework::Threading::ThreadPool *GetPool();
|
Tesses::Framework::Threading::ThreadPool *GetPool();
|
||||||
bool UsingNullThreads();
|
bool UsingNullThreads();
|
||||||
GC();
|
GC();
|
||||||
|
GC(const GC &) = delete;
|
||||||
|
GC &operator=(const GC &) = delete;
|
||||||
void Start();
|
void Start();
|
||||||
bool IsRunning();
|
bool IsRunning();
|
||||||
void BarrierBegin();
|
void BarrierBegin();
|
||||||
void BarrierEnd();
|
void BarrierEnd();
|
||||||
void Collect();
|
void Collect(std::vector<THeapObject *> &to_delete);
|
||||||
void Watch(TObject obj);
|
void Watch(TObject obj);
|
||||||
void Unwatch(TObject obj);
|
void Unwatch(TObject obj);
|
||||||
void SetRoot(TObject obj);
|
|
||||||
void UnsetRoot(TObject obj);
|
|
||||||
static void Mark(TObject obj);
|
static void Mark(TObject obj);
|
||||||
void RegisterEverythingCallback(
|
void RegisterEverythingCallback(
|
||||||
std::function<void(std::shared_ptr<GC> gc, TRootEnvironment *env)> cb);
|
std::function<void(std::shared_ptr<GC> gc, TRootEnvironment *env)> cb);
|
||||||
void RegisterEverything(TRootEnvironment *env);
|
void RegisterEverything(TRootEnvironment *env);
|
||||||
~GC();
|
~GC();
|
||||||
|
|
||||||
|
// uses thread_local or std::map
|
||||||
|
static void SetCurrentFunction(CallStackEntry *fn);
|
||||||
|
// uses thread local or std::map
|
||||||
|
static CallStackEntry *GetCurrentFunction();
|
||||||
|
friend class GCList;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string GetObjectTypeString(TObject obj);
|
std::string GetObjectTypeString(TObject obj);
|
||||||
std::string ToString(std::shared_ptr<GC> gc, TObject obj);
|
std::string ToString(std::shared_ptr<GC> gc, TObject obj);
|
||||||
|
|
||||||
class GCList : public THeapObject {
|
class GCList {
|
||||||
std::vector<THeapObject *> items;
|
std::vector<THeapObject *> items;
|
||||||
|
|
||||||
std::shared_ptr<GC> gc;
|
std::shared_ptr<GC> gc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GCList(std::shared_ptr<GC> gc);
|
GCList(std::shared_ptr<GC> gc);
|
||||||
std::shared_ptr<GC> GetGC();
|
GCList(const GCList &) = delete;
|
||||||
|
GCList &operator=(const GCList &) = delete;
|
||||||
|
std::shared_ptr<GC> GetGC() const;
|
||||||
|
|
||||||
|
template <typename T, typename... TArgs> T *Create(TArgs &&...args) {
|
||||||
|
T *obj = new T(std::forward<TArgs>(args)...);
|
||||||
|
Add(obj);
|
||||||
|
gc->Watch(obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
void Add(TObject v);
|
void Add(TObject v);
|
||||||
void Remove(TObject v);
|
void Remove(TObject v);
|
||||||
void Mark();
|
void Mark();
|
||||||
@@ -1443,7 +1482,9 @@ class TFile;
|
|||||||
|
|
||||||
class TFileChunk : public THeapObject {
|
class TFileChunk : public THeapObject {
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TFileChunk *Create(GCList *gc);
|
static TFileChunk *Create(GCList *gc);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TFileChunk *Create(GCList &gc);
|
static TFileChunk *Create(GCList &gc);
|
||||||
TFile *file;
|
TFile *file;
|
||||||
std::vector<uint8_t> code;
|
std::vector<uint8_t> code;
|
||||||
@@ -1455,7 +1496,9 @@ class TFileChunk : public THeapObject {
|
|||||||
class TByteArray : public THeapObject {
|
class TByteArray : public THeapObject {
|
||||||
public:
|
public:
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TByteArray *Create(GCList *gc);
|
static TByteArray *Create(GCList *gc);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TByteArray *Create(GCList &gc);
|
static TByteArray *Create(GCList &gc);
|
||||||
};
|
};
|
||||||
enum class TClassModifier { Private, Protected, Public, Static };
|
enum class TClassModifier { Private, Protected, Public, Static };
|
||||||
@@ -1488,7 +1531,9 @@ class TClassObjectEntry {
|
|||||||
class TDictionary;
|
class TDictionary;
|
||||||
class TFile : public THeapObject {
|
class TFile : public THeapObject {
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TFile *Create(GCList *gc);
|
static TFile *Create(GCList *gc);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TFile *Create(GCList &gc);
|
static TFile *Create(GCList &gc);
|
||||||
std::vector<TFileChunk *> chunks;
|
std::vector<TFileChunk *> chunks;
|
||||||
|
|
||||||
@@ -1504,7 +1549,7 @@ class TFile : public THeapObject {
|
|||||||
std::string name;
|
std::string name;
|
||||||
TVMVersion version;
|
TVMVersion version;
|
||||||
std::string info;
|
std::string info;
|
||||||
int32_t icon;
|
int32_t icon = -1;
|
||||||
|
|
||||||
void Load(std::shared_ptr<GC> gc,
|
void Load(std::shared_ptr<GC> gc,
|
||||||
std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
|
std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
|
||||||
@@ -1528,7 +1573,9 @@ class TFile : public THeapObject {
|
|||||||
class TAssociativeArray : public THeapObject {
|
class TAssociativeArray : public THeapObject {
|
||||||
public:
|
public:
|
||||||
std::vector<std::pair<TObject, TObject>> items;
|
std::vector<std::pair<TObject, TObject>> items;
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAssociativeArray *Create(GCList &ls);
|
static TAssociativeArray *Create(GCList &ls);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAssociativeArray *Create(GCList *ls);
|
static TAssociativeArray *Create(GCList *ls);
|
||||||
void Set(std::shared_ptr<GC> gc, TObject key, TObject value);
|
void Set(std::shared_ptr<GC> gc, TObject key, TObject value);
|
||||||
TObject Get(std::shared_ptr<GC> gc, TObject key);
|
TObject Get(std::shared_ptr<GC> gc, TObject key);
|
||||||
@@ -1542,29 +1589,33 @@ class TAssociativeArray : public THeapObject {
|
|||||||
|
|
||||||
class TList : public THeapObject {
|
class TList : public THeapObject {
|
||||||
public:
|
public:
|
||||||
|
TList() = default;
|
||||||
|
template <typename Itterator>
|
||||||
|
TList(Itterator begin, Itterator end) : items(begin, end) {}
|
||||||
|
TList(std::initializer_list<TObject> il) : items(il) {}
|
||||||
|
TList(int64_t capacity) { items.reserve(capacity); }
|
||||||
std::vector<TObject> items;
|
std::vector<TObject> items;
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList *gc);
|
static TList *Create(GCList *gc);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList &gc);
|
static TList *Create(GCList &gc);
|
||||||
template <typename Itterator>
|
template <typename Itterator>
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList *gc, Itterator begin, Itterator end) {
|
static TList *Create(GCList *gc, Itterator begin, Itterator end) {
|
||||||
auto list = Create(gc);
|
return gc->Create<TList>(begin, end);
|
||||||
gc->GetGC()->BarrierBegin();
|
|
||||||
for (Itterator i = begin; i != end; ++i) {
|
|
||||||
TObject item = *i;
|
|
||||||
list->Add(item);
|
|
||||||
}
|
|
||||||
gc->GetGC()->BarrierEnd();
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
template <typename Itterator>
|
template <typename Itterator>
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList &gc, Itterator begin, Itterator end) {
|
static TList *Create(GCList &gc, Itterator begin, Itterator end) {
|
||||||
return Create(&gc, begin, end);
|
return gc.Create<TList>(begin, end);
|
||||||
}
|
}
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList *gc, std::initializer_list<TObject> il) {
|
static TList *Create(GCList *gc, std::initializer_list<TObject> il) {
|
||||||
return Create(gc, il.begin(), il.end());
|
return gc->Create<TList>(il);
|
||||||
}
|
}
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TList *Create(GCList &gc, std::initializer_list<TObject> il) {
|
static TList *Create(GCList &gc, std::initializer_list<TObject> il) {
|
||||||
return Create(gc, il.begin(), il.end());
|
return gc.Create<TList>(il);
|
||||||
}
|
}
|
||||||
virtual int64_t Count();
|
virtual int64_t Count();
|
||||||
virtual TObject Get(int64_t index);
|
virtual TObject Get(int64_t index);
|
||||||
@@ -1578,30 +1629,37 @@ class TList : public THeapObject {
|
|||||||
using TDItem = std::pair<std::string, TObject>;
|
using TDItem = std::pair<std::string, TObject>;
|
||||||
class TDictionary : public THeapObject {
|
class TDictionary : public THeapObject {
|
||||||
public:
|
public:
|
||||||
|
TDictionary() = default;
|
||||||
|
template <typename Itterator> TDictionary(Itterator begin, Itterator end) {
|
||||||
|
for (Itterator i = begin; i != end; ++i) {
|
||||||
|
TDItem &item = *i;
|
||||||
|
SetValue(item.first, item.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TDictionary(std::initializer_list<TDItem> il) {
|
||||||
|
for (auto &item : il) {
|
||||||
|
SetValue(item.first, item.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
std::map<std::string, TObject> items;
|
std::map<std::string, TObject> items;
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDictionary *Create(GCList *gc);
|
static TDictionary *Create(GCList *gc);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDictionary *Create(GCList &gc);
|
static TDictionary *Create(GCList &gc);
|
||||||
template <typename Itterator>
|
template <typename Itterator>
|
||||||
static TDictionary *Create(GCList *gc, Itterator begin, Itterator end) {
|
static TDictionary *Create(GCList *gc, Itterator begin, Itterator end) {
|
||||||
auto dict = Create(gc);
|
return gc->Create<TDictionary>(begin, end);
|
||||||
gc->GetGC()->BarrierBegin();
|
|
||||||
for (Itterator i = begin; i != end; ++i) {
|
|
||||||
TDItem item = *i;
|
|
||||||
dict->SetValue(item.first, item.second);
|
|
||||||
}
|
|
||||||
gc->GetGC()->BarrierEnd();
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
template <typename Itterator>
|
template <typename Itterator>
|
||||||
static TDictionary *Create(GCList &gc, Itterator begin, Itterator end) {
|
static TDictionary *Create(GCList &gc, Itterator begin, Itterator end) {
|
||||||
return Create(&gc, begin, end);
|
return gc.Create<TDictionary>(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TDictionary *Create(GCList *gc, std::initializer_list<TDItem> il) {
|
static TDictionary *Create(GCList *gc, std::initializer_list<TDItem> il) {
|
||||||
return Create(gc, il.begin(), il.end());
|
return gc->Create<TDictionary>(il);
|
||||||
}
|
}
|
||||||
static TDictionary *Create(GCList &gc, std::initializer_list<TDItem> il) {
|
static TDictionary *Create(GCList &gc, std::initializer_list<TDItem> il) {
|
||||||
return Create(gc, il.begin(), il.end());
|
return gc.Create<TDictionary>(il);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasValue(std::string key);
|
virtual bool HasValue(std::string key);
|
||||||
@@ -1641,9 +1699,11 @@ class TCallable : public THeapObject {
|
|||||||
void ThrowFatalError(std::exception &ex);
|
void ThrowFatalError(std::exception &ex);
|
||||||
|
|
||||||
void ThrowConstError(std::string key);
|
void ThrowConstError(std::string key);
|
||||||
|
enum class TEnvironmentDeclType { TEDT_VAR, TEDT_CONST };
|
||||||
|
|
||||||
class TEnvironment : public THeapObject {
|
class TEnvironment : public THeapObject {
|
||||||
std::vector<std::string> consts;
|
protected:
|
||||||
|
std::unordered_map<std::string, TEnvironmentDeclType> decls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<TCallable *> defers;
|
std::vector<TCallable *> defers;
|
||||||
@@ -1700,8 +1760,10 @@ class TClassObject : public THeapObject {
|
|||||||
std::vector<std::string> inherit_tree;
|
std::vector<std::string> inherit_tree;
|
||||||
std::vector<TClassObjectEntry> entries;
|
std::vector<TClassObjectEntry> entries;
|
||||||
|
|
||||||
|
// This is the only place where the old way is
|
||||||
static TClassObject *Create(GCList &ls, TFile *f, uint32_t classIndex,
|
static TClassObject *Create(GCList &ls, TFile *f, uint32_t classIndex,
|
||||||
TEnvironment *env, std::vector<TObject> args);
|
TEnvironment *env, std::vector<TObject> args);
|
||||||
|
// this too
|
||||||
static TClassObject *Create(GCList *ls, TFile *f, uint32_t classIndex,
|
static TClassObject *Create(GCList *ls, TFile *f, uint32_t classIndex,
|
||||||
TEnvironment *env, std::vector<TObject> args);
|
TEnvironment *env, std::vector<TObject> args);
|
||||||
|
|
||||||
@@ -1720,8 +1782,10 @@ class TClassEnvironment : public TEnvironment {
|
|||||||
TClassObject *clsObj;
|
TClassObject *clsObj;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TClassEnvironment *Create(GCList *gc, TEnvironment *env,
|
static TClassEnvironment *Create(GCList *gc, TEnvironment *env,
|
||||||
TClassObject *obj);
|
TClassObject *obj);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TClassEnvironment *Create(GCList &gc, TEnvironment *env,
|
static TClassEnvironment *Create(GCList &gc, TEnvironment *env,
|
||||||
TClassObject *obj);
|
TClassObject *obj);
|
||||||
TClassEnvironment(TEnvironment *env, TClassObject *obj);
|
TClassEnvironment(TEnvironment *env, TClassObject *obj);
|
||||||
@@ -1762,7 +1826,7 @@ class EnvironmentPermissions {
|
|||||||
bool canRegisterPath;
|
bool canRegisterPath;
|
||||||
bool canRegisterOGC;
|
bool canRegisterOGC;
|
||||||
bool canRegisterEnv;
|
bool canRegisterEnv;
|
||||||
bool canRegisterClass;
|
bool canRegisterZeClass;
|
||||||
bool sqlite3Scoped;
|
bool sqlite3Scoped;
|
||||||
bool locked;
|
bool locked;
|
||||||
TDictionary *customConsole = nullptr;
|
TDictionary *customConsole = nullptr;
|
||||||
@@ -1796,7 +1860,9 @@ class TRootEnvironment : public TEnvironment {
|
|||||||
Tesses::Framework::Filesystem::VFSPath path);
|
Tesses::Framework::Filesystem::VFSPath path);
|
||||||
|
|
||||||
TDictionary *GetDictionary();
|
TDictionary *GetDictionary();
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TRootEnvironment *Create(GCList *gc, TDictionary *dict);
|
static TRootEnvironment *Create(GCList *gc, TDictionary *dict);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TRootEnvironment *Create(GCList &gc, TDictionary *dict);
|
static TRootEnvironment *Create(GCList &gc, TDictionary *dict);
|
||||||
TRootEnvironment(TDictionary *dict);
|
TRootEnvironment(TDictionary *dict);
|
||||||
bool HasVariable(std::string key);
|
bool HasVariable(std::string key);
|
||||||
@@ -1848,7 +1914,7 @@ class TStd {
|
|||||||
static void RegisterOGC(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
static void RegisterOGC(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
||||||
static void RegisterEnv(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
static void RegisterEnv(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
||||||
static void RegisterProcess(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
static void RegisterProcess(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
||||||
static void RegisterClass(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
static void RegisterZeClass(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TSubEnvironment : public TEnvironment {
|
class TSubEnvironment : public TEnvironment {
|
||||||
@@ -1856,8 +1922,10 @@ class TSubEnvironment : public TEnvironment {
|
|||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TSubEnvironment *Create(GCList *gc, TEnvironment *env,
|
static TSubEnvironment *Create(GCList *gc, TEnvironment *env,
|
||||||
TDictionary *dict);
|
TDictionary *dict);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TSubEnvironment *Create(GCList &gc, TEnvironment *env,
|
static TSubEnvironment *Create(GCList &gc, TEnvironment *env,
|
||||||
TDictionary *dict);
|
TDictionary *dict);
|
||||||
TSubEnvironment(TEnvironment *env, TDictionary *dict);
|
TSubEnvironment(TEnvironment *env, TDictionary *dict);
|
||||||
@@ -1883,7 +1951,10 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached);
|
|||||||
class TArgWrapper : public TCallable {
|
class TArgWrapper : public TCallable {
|
||||||
public:
|
public:
|
||||||
TCallable *callable;
|
TCallable *callable;
|
||||||
|
TArgWrapper(TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TArgWrapper *Create(GCList &ls, TCallable *callable);
|
static TArgWrapper *Create(GCList &ls, TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TArgWrapper *Create(GCList *ls, TCallable *callable);
|
static TArgWrapper *Create(GCList *ls, TCallable *callable);
|
||||||
TObject Call(GCList &ls, std::vector<TObject> args);
|
TObject Call(GCList &ls, std::vector<TObject> args);
|
||||||
void Mark();
|
void Mark();
|
||||||
@@ -1897,24 +1968,28 @@ class TExternalMethod : public TCallable {
|
|||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
std::vector<TObject> watch;
|
std::vector<TObject> watch;
|
||||||
TExternalMethod(
|
TExternalMethod(
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
|
||||||
std::string documentation, std::vector<std::string> argNames,
|
std::string documentation, std::vector<std::string> argNames,
|
||||||
std::function<void()> destroy);
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
|
std::function<void()> destroy = nullptr);
|
||||||
|
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TExternalMethod *
|
static TExternalMethod *
|
||||||
Create(GCList &ls, std::string documentation,
|
Create(GCList &ls, std::string documentation,
|
||||||
std::vector<std::string> argNames,
|
std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
std::function<void()> destroy);
|
std::function<void()> destroy);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TExternalMethod *
|
static TExternalMethod *
|
||||||
Create(GCList *ls, std::string documentation,
|
Create(GCList *ls, std::string documentation,
|
||||||
std::vector<std::string> argNames,
|
std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
std::function<void()> destroy);
|
std::function<void()> destroy);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TExternalMethod *
|
static TExternalMethod *
|
||||||
Create(GCList &ls, std::string documentation,
|
Create(GCList &ls, std::string documentation,
|
||||||
std::vector<std::string> argNames,
|
std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb);
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TExternalMethod *
|
static TExternalMethod *
|
||||||
Create(GCList *ls, std::string documentation,
|
Create(GCList *ls, std::string documentation,
|
||||||
std::vector<std::string> argNames,
|
std::vector<std::string> argNames,
|
||||||
@@ -1943,8 +2018,11 @@ class TAssociativeArrayEnumerator : public TEnumerator {
|
|||||||
TAssociativeArray *ls;
|
TAssociativeArray *ls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TAssociativeArrayEnumerator(TAssociativeArray *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAssociativeArrayEnumerator *Create(GCList &ls,
|
static TAssociativeArrayEnumerator *Create(GCList &ls,
|
||||||
TAssociativeArray *list);
|
TAssociativeArray *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAssociativeArrayEnumerator *Create(GCList *ls,
|
static TAssociativeArrayEnumerator *Create(GCList *ls,
|
||||||
TAssociativeArray *list);
|
TAssociativeArray *list);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
@@ -1955,10 +2033,13 @@ class TAssociativeArrayEnumerator : public TEnumerator {
|
|||||||
class TCustomEnumerator : public TEnumerator {
|
class TCustomEnumerator : public TEnumerator {
|
||||||
public:
|
public:
|
||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
|
TCustomEnumerator(TDictionary *dict);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
void Mark();
|
void Mark();
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TCustomEnumerator *Create(GCList &ls, TDictionary *dict);
|
static TCustomEnumerator *Create(GCList &ls, TDictionary *dict);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TCustomEnumerator *Create(GCList *ls, TDictionary *dict);
|
static TCustomEnumerator *Create(GCList *ls, TDictionary *dict);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1968,10 +2049,13 @@ class TYieldEnumerator : public TEnumerator {
|
|||||||
TObject current;
|
TObject current;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TYieldEnumerator(TObject v);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
void Mark();
|
void Mark();
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TYieldEnumerator *Create(GCList &ls, TObject v);
|
static TYieldEnumerator *Create(GCList &ls, TObject v);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TYieldEnumerator *Create(GCList *ls, TObject v);
|
static TYieldEnumerator *Create(GCList *ls, TObject v);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1981,7 +2065,10 @@ class TStringEnumerator : public TEnumerator {
|
|||||||
std::string str;
|
std::string str;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TStringEnumerator(std::string str);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TStringEnumerator *Create(GCList &ls, std::string str);
|
static TStringEnumerator *Create(GCList &ls, std::string str);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TStringEnumerator *Create(GCList *ls, std::string str);
|
static TStringEnumerator *Create(GCList *ls, std::string str);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
@@ -1992,7 +2079,10 @@ class TListEnumerator : public TEnumerator {
|
|||||||
TList *ls;
|
TList *ls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TListEnumerator(TList *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TListEnumerator *Create(GCList &ls, TList *list);
|
static TListEnumerator *Create(GCList &ls, TList *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TListEnumerator *Create(GCList *ls, TList *list);
|
static TListEnumerator *Create(GCList *ls, TList *list);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
@@ -2005,7 +2095,10 @@ class TDynamicListEnumerator : public TEnumerator {
|
|||||||
TDynamicList *ls;
|
TDynamicList *ls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TDynamicListEnumerator(TDynamicList *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicListEnumerator *Create(GCList &ls, TDynamicList *list);
|
static TDynamicListEnumerator *Create(GCList &ls, TDynamicList *list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicListEnumerator *Create(GCList *ls, TDynamicList *list);
|
static TDynamicListEnumerator *Create(GCList *ls, TDynamicList *list);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
@@ -2015,8 +2108,11 @@ class TVFSPathEnumerator : public TEnumerator {
|
|||||||
Tesses::Framework::Filesystem::VFSPathEnumerator enumerator;
|
Tesses::Framework::Filesystem::VFSPathEnumerator enumerator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TVFSPathEnumerator(Tesses::Framework::Filesystem::VFSPathEnumerator list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TVFSPathEnumerator *
|
static TVFSPathEnumerator *
|
||||||
Create(GCList &ls, Tesses::Framework::Filesystem::VFSPathEnumerator list);
|
Create(GCList &ls, Tesses::Framework::Filesystem::VFSPathEnumerator list);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TVFSPathEnumerator *
|
static TVFSPathEnumerator *
|
||||||
Create(GCList *ls, Tesses::Framework::Filesystem::VFSPathEnumerator list);
|
Create(GCList *ls, Tesses::Framework::Filesystem::VFSPathEnumerator list);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
@@ -2105,7 +2201,10 @@ class TDictionaryEnumerator : public TEnumerator {
|
|||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TDictionaryEnumerator(TDictionary *dict);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDictionaryEnumerator *Create(GCList &ls, TDictionary *dict);
|
static TDictionaryEnumerator *Create(GCList &ls, TDictionary *dict);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDictionaryEnumerator *Create(GCList *ls, TDictionary *dict);
|
static TDictionaryEnumerator *Create(GCList *ls, TDictionary *dict);
|
||||||
bool MoveNext(std::shared_ptr<GC> ls);
|
bool MoveNext(std::shared_ptr<GC> ls);
|
||||||
TObject GetCurrent(GCList &ls);
|
TObject GetCurrent(GCList &ls);
|
||||||
@@ -2114,8 +2213,12 @@ class TDictionaryEnumerator : public TEnumerator {
|
|||||||
|
|
||||||
class TClosure : public TCallable {
|
class TClosure : public TCallable {
|
||||||
public:
|
public:
|
||||||
|
TClosure(TEnvironment *env, TFile *file, uint32_t chunkId,
|
||||||
|
bool ownScope = true);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TClosure *Create(GCList &ls, TEnvironment *env, TFile *file,
|
static TClosure *Create(GCList &ls, TEnvironment *env, TFile *file,
|
||||||
uint32_t chunkId, bool ownScope = true);
|
uint32_t chunkId, bool ownScope = true);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TClosure *Create(GCList *ls, TEnvironment *env, TFile *file,
|
static TClosure *Create(GCList *ls, TEnvironment *env, TFile *file,
|
||||||
uint32_t chunkId, bool ownScope = true);
|
uint32_t chunkId, bool ownScope = true);
|
||||||
bool ownScope;
|
bool ownScope;
|
||||||
@@ -2130,7 +2233,10 @@ class TClosure : public TCallable {
|
|||||||
class TDynamicList : public THeapObject {
|
class TDynamicList : public THeapObject {
|
||||||
public:
|
public:
|
||||||
TCallable *cb;
|
TCallable *cb;
|
||||||
|
TDynamicList(TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicList *Create(GCList &ls, TCallable *callable);
|
static TDynamicList *Create(GCList &ls, TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicList *Create(GCList *ls, TCallable *callable);
|
static TDynamicList *Create(GCList *ls, TCallable *callable);
|
||||||
|
|
||||||
void Mark();
|
void Mark();
|
||||||
@@ -2154,8 +2260,10 @@ class TDynamicList : public THeapObject {
|
|||||||
class TDynamicDictionary : public THeapObject {
|
class TDynamicDictionary : public THeapObject {
|
||||||
public:
|
public:
|
||||||
TCallable *cb;
|
TCallable *cb;
|
||||||
|
TDynamicDictionary(TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicDictionary *Create(GCList &ls, TCallable *callable);
|
static TDynamicDictionary *Create(GCList &ls, TCallable *callable);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TDynamicDictionary *Create(GCList *ls, TCallable *callable);
|
static TDynamicDictionary *Create(GCList *ls, TCallable *callable);
|
||||||
|
|
||||||
void Mark();
|
void Mark();
|
||||||
@@ -2176,17 +2284,19 @@ class InterperterThread;
|
|||||||
|
|
||||||
class CallStackEntry : public THeapObject {
|
class CallStackEntry : public THeapObject {
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static CallStackEntry *Create(GCList *ls);
|
static CallStackEntry *Create(GCList *ls);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static CallStackEntry *Create(GCList &ls);
|
static CallStackEntry *Create(GCList &ls);
|
||||||
InterperterThread *thread;
|
InterperterThread *thread = nullptr;
|
||||||
std::vector<TObject> stack;
|
std::vector<TObject> stack;
|
||||||
TEnvironment *env;
|
TEnvironment *env = nullptr;
|
||||||
TClosure *callable;
|
TClosure *callable = nullptr;
|
||||||
uint32_t ip;
|
uint32_t ip;
|
||||||
uint32_t scopes;
|
uint32_t scopes;
|
||||||
int64_t srcline;
|
int64_t srcline = -1;
|
||||||
std::string srcfile;
|
std::string srcfile = "";
|
||||||
bool mustReturn;
|
bool mustReturn = false;
|
||||||
|
|
||||||
void Mark();
|
void Mark();
|
||||||
void Push(std::shared_ptr<GC> gc, TObject v);
|
void Push(std::shared_ptr<GC> gc, TObject v);
|
||||||
@@ -2203,6 +2313,7 @@ class TTask : public THeapObject {
|
|||||||
TTask(std::shared_ptr<GC> gc);
|
TTask(std::shared_ptr<GC> gc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// this still is needed
|
||||||
static TTask *Create(GCList &ls);
|
static TTask *Create(GCList &ls);
|
||||||
bool IsCompleted();
|
bool IsCompleted();
|
||||||
|
|
||||||
@@ -2223,7 +2334,6 @@ class TTask : public THeapObject {
|
|||||||
|
|
||||||
static TTask *FromResult(GCList &ls, TObject v);
|
static TTask *FromResult(GCList &ls, TObject v);
|
||||||
};
|
};
|
||||||
extern thread_local CallStackEntry *current_function;
|
|
||||||
|
|
||||||
class InterperterThread : public THeapObject {
|
class InterperterThread : public THeapObject {
|
||||||
private:
|
private:
|
||||||
@@ -2309,7 +2419,9 @@ class InterperterThread : public THeapObject {
|
|||||||
bool PushPrivateExpression(std::shared_ptr<GC> gc);
|
bool PushPrivateExpression(std::shared_ptr<GC> gc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static InterperterThread *Create(GCList *ls);
|
static InterperterThread *Create(GCList *ls);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static InterperterThread *Create(GCList &ls);
|
static InterperterThread *Create(GCList &ls);
|
||||||
std::vector<CallStackEntry *> call_stack_entries;
|
std::vector<CallStackEntry *> call_stack_entries;
|
||||||
virtual void Execute(std::shared_ptr<GC> gc);
|
virtual void Execute(std::shared_ptr<GC> gc);
|
||||||
@@ -2328,34 +2440,31 @@ class VMException : public std::exception {
|
|||||||
error_message.append(ex);
|
error_message.append(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string &GetMessage() { return error_message; }
|
||||||
|
|
||||||
const char *what() const noexcept override { return error_message.c_str(); }
|
const char *what() const noexcept override { return error_message.c_str(); }
|
||||||
};
|
};
|
||||||
class TAny : public THeapObject {
|
class TAny : public THeapObject {
|
||||||
public:
|
public:
|
||||||
std::any any;
|
std::any any;
|
||||||
TObject other;
|
TObject other;
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAny *Create(GCList &ls);
|
static TAny *Create(GCList &ls);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TAny *Create(GCList *ls);
|
static TAny *Create(GCList *ls);
|
||||||
void Mark();
|
void Mark();
|
||||||
};
|
};
|
||||||
class TNativeObject : public THeapObject {
|
class TNativeObject : public THeapObject {
|
||||||
public:
|
public:
|
||||||
template <typename T, typename... TArgs>
|
template <typename T, typename... TArgs>
|
||||||
static T *Create(GCList &ls, TArgs... args) {
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
T *obj = new T(args...);
|
static T *Create(GCList &ls, TArgs &&...args) {
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
return ls.Create<T>(std::forward<TArgs>(args)...);
|
||||||
ls.Add(obj);
|
|
||||||
gc->Watch(obj);
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
template <typename T, typename... TArgs>
|
template <typename T, typename... TArgs>
|
||||||
static T *Create(GCList *ls, TArgs... args) {
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
T *obj = new T(args...);
|
static T *Create(GCList *ls, TArgs &&...args) {
|
||||||
std::shared_ptr<GC> gc = ls->GetGC();
|
return ls->Create<T>(std::forward<TArgs>(args)...);
|
||||||
ls->Add(obj);
|
|
||||||
gc->Watch(obj);
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual TObject CallMethod(GCList &ls, std::string name,
|
virtual TObject CallMethod(GCList &ls, std::string name,
|
||||||
@@ -2363,7 +2472,6 @@ class TNativeObject : public THeapObject {
|
|||||||
virtual std::string TypeName() = 0;
|
virtual std::string TypeName() = 0;
|
||||||
virtual bool ToBool();
|
virtual bool ToBool();
|
||||||
virtual bool Equals(std::shared_ptr<GC> gc, TObject right);
|
virtual bool Equals(std::shared_ptr<GC> gc, TObject right);
|
||||||
virtual ~TNativeObject();
|
|
||||||
};
|
};
|
||||||
class TRandom : public TNativeObject {
|
class TRandom : public TNativeObject {
|
||||||
public:
|
public:
|
||||||
@@ -2380,13 +2488,15 @@ class TNative : public THeapObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TObject other;
|
TObject other;
|
||||||
TNative(void *ptr, std::function<void(void *)> destroy);
|
TNative(void *ptr, std::function<void(void *)> destroy = nullptr);
|
||||||
bool GetDestroyed();
|
bool GetDestroyed();
|
||||||
void *GetPointer();
|
void *GetPointer();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void Mark();
|
void Mark();
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TNative *Create(GCList &ls, void *ptr,
|
static TNative *Create(GCList &ls, void *ptr,
|
||||||
std::function<void(void *)> destroy);
|
std::function<void(void *)> destroy);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TNative *Create(GCList *ls, void *ptr,
|
static TNative *Create(GCList *ls, void *ptr,
|
||||||
std::function<void(void *)> destroy);
|
std::function<void(void *)> destroy);
|
||||||
~TNative();
|
~TNative();
|
||||||
@@ -2479,6 +2589,22 @@ template <typename T> bool GetObject(TObject &obj, T &res) {
|
|||||||
res = std::get<T>(obj);
|
res = std::get<T>(obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool IsNull(const TObject &obj) {
|
||||||
|
if (!std::holds_alternative<THeapObject *>(obj))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return std::get<THeapObject *>(obj) == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[deprecated("Use GetObjectHeap() with TString instead")]]
|
||||||
|
inline bool GetObject(TObject &obj, std::string &str) {
|
||||||
|
if (!std::holds_alternative<std::string>(obj))
|
||||||
|
return false;
|
||||||
|
str = std::get<std::string>(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool GetArgument(std::vector<TObject> &args, size_t index, T &obj) {
|
bool GetArgument(std::vector<TObject> &args, size_t index, T &obj) {
|
||||||
if (index >= args.size())
|
if (index >= args.size())
|
||||||
@@ -2487,10 +2613,10 @@ bool GetArgument(std::vector<TObject> &args, size_t index, T &obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> bool GetObjectHeap(TObject &obj, T &res) {
|
template <typename T> bool GetObjectHeap(TObject &obj, T &res) {
|
||||||
THeapObjectHolder h;
|
THeapObject *h;
|
||||||
if (!GetObject<THeapObjectHolder>(obj, h))
|
if (!GetObject<THeapObject *>(obj, h))
|
||||||
return false;
|
return false;
|
||||||
auto v = dynamic_cast<T>(h.obj);
|
auto v = dynamic_cast<T>(h);
|
||||||
if (v == nullptr)
|
if (v == nullptr)
|
||||||
return false;
|
return false;
|
||||||
res = v;
|
res = v;
|
||||||
@@ -2525,9 +2651,9 @@ typedef void (*PluginFunction)(std::shared_ptr<GC> gc, TRootEnvironment *env);
|
|||||||
void LoadPlugin(std::shared_ptr<GC> gc, TRootEnvironment *env,
|
void LoadPlugin(std::shared_ptr<GC> gc, TRootEnvironment *env,
|
||||||
Tesses::Framework::Filesystem::VFSPath sharedObjectPath);
|
Tesses::Framework::Filesystem::VFSPath sharedObjectPath);
|
||||||
std::string Json_Encode(TObject o, bool indent = false);
|
std::string Json_Encode(TObject o, bool indent = false);
|
||||||
TObject Json_Decode(GCList ls, std::string str);
|
TObject Json_Decode(GCList &ls, std::string str);
|
||||||
std::string Json_DocEncode(TObject o, bool indent);
|
std::string Json_DocEncode(TObject o, bool indent);
|
||||||
TObject Json_DocDecode(GCList ls, std::string str);
|
TObject Json_DocDecode(GCList &ls, std::string str);
|
||||||
// DO NOT USE DIRECTLY
|
// DO NOT USE DIRECTLY
|
||||||
class SharedPtrTObject {
|
class SharedPtrTObject {
|
||||||
GCList *ls;
|
GCList *ls;
|
||||||
@@ -2586,6 +2712,44 @@ class EmbedDirectory : public Tesses::Framework::Filesystem::VFS {
|
|||||||
Tesses::Framework::Filesystem::StatData &data);
|
Tesses::Framework::Filesystem::StatData &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TNativeException : public TNativeObject {
|
||||||
|
std::string what;
|
||||||
|
std::exception_ptr ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TNativeException() = delete;
|
||||||
|
TNativeException(const char *what, std::exception_ptr ptr);
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args);
|
||||||
|
std::string TypeName();
|
||||||
|
std::string What();
|
||||||
|
std::exception_ptr GetPointer();
|
||||||
|
void ThrowIt();
|
||||||
|
};
|
||||||
|
|
||||||
|
class TException : public TNativeObject {
|
||||||
|
private:
|
||||||
|
TDictionary *extraFields;
|
||||||
|
TObject innerException;
|
||||||
|
|
||||||
|
std::string message;
|
||||||
|
std::string type;
|
||||||
|
std::optional<std::string> filename;
|
||||||
|
std::optional<uint32_t> line;
|
||||||
|
std::optional<uint32_t> column;
|
||||||
|
std::optional<uint32_t> offset;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TException() = delete;
|
||||||
|
TException(std::string message, std::string type = "Exception",
|
||||||
|
TDictionary *extraFields = nullptr,
|
||||||
|
TObject innerException = Undefined());
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args);
|
||||||
|
std::string TypeName();
|
||||||
|
bool ToBool();
|
||||||
|
void Mark();
|
||||||
|
~TException() = default;
|
||||||
|
};
|
||||||
|
|
||||||
namespace Programs {
|
namespace Programs {
|
||||||
int64_t CrossArchiveCreate(std::vector<std::string> &argv);
|
int64_t CrossArchiveCreate(std::vector<std::string> &argv);
|
||||||
int64_t CrossArchiveExtract(std::vector<std::string> &argv);
|
int64_t CrossArchiveExtract(std::vector<std::string> &argv);
|
||||||
@@ -2615,11 +2779,14 @@ class TQueryable : public THeapObject {
|
|||||||
TObject parent;
|
TObject parent;
|
||||||
TQueryableMode mode;
|
TQueryableMode mode;
|
||||||
std::vector<TObject> args;
|
std::vector<TObject> args;
|
||||||
|
|
||||||
|
public:
|
||||||
TQueryable(TObject parent);
|
TQueryable(TObject parent);
|
||||||
TQueryable(TObject parent, TQueryableMode mode, std::vector<TObject> args);
|
TQueryable(TObject parent, TQueryableMode mode, std::vector<TObject> args);
|
||||||
|
|
||||||
public:
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TQueryable *Create(GCList &ls, TObject parent);
|
static TQueryable *Create(GCList &ls, TObject parent);
|
||||||
|
[[deprecated("Use GCList::Create<T>() instead")]]
|
||||||
static TQueryable *Create(GCList &ls, TObject parent, TQueryableMode mode,
|
static TQueryable *Create(GCList &ls, TObject parent, TQueryableMode mode,
|
||||||
std::vector<TObject> args);
|
std::vector<TObject> args);
|
||||||
|
|
||||||
|
|||||||
+183
@@ -0,0 +1,183 @@
|
|||||||
|
# Name. (required)
|
||||||
|
name: crosslang
|
||||||
|
|
||||||
|
# Architecture. (required)
|
||||||
|
# This will expand any env var you set in the field, e.g. arch: ${GOARCH}
|
||||||
|
# The architecture is specified using Go nomenclature (GOARCH) and translated
|
||||||
|
# to the platform specific equivalent. In order to manually set the architecture
|
||||||
|
# to a platform specific value, set `{format}.arch`.
|
||||||
|
# Examples: `all`, `amd64`, `386`, `arm5`, `arm6`, `arm7`, `arm64`, `mips`,
|
||||||
|
# `mipsle`, `mips64le`, `ppc64le`, `s390`, `riscv64`
|
||||||
|
arch: @CROSSLANG_NFPM_ARCH@
|
||||||
|
|
||||||
|
# Platform.
|
||||||
|
# This will expand any env var you set in the field, e.g. platform: ${GOOS}
|
||||||
|
# This is only used by the rpm and deb packagers.
|
||||||
|
# Examples: `linux` (default), `darwin`
|
||||||
|
platform: linux
|
||||||
|
|
||||||
|
# Version. (required)
|
||||||
|
# This will expand any env var you set in the field, e.g. version: ${SEMVER}
|
||||||
|
# Some package managers, like deb, require the version to start with a digit.
|
||||||
|
# Hence, you should not prefix the version with 'v'.
|
||||||
|
version: @CROSSLANG_MAJOR_VERSION@.@CROSSLANG_MINOR_VERSION@.@CROSSLANG_PATCH_VERSION@
|
||||||
|
|
||||||
|
# Version Schema allows you to specify how to parse the version string.
|
||||||
|
# Default is `semver`
|
||||||
|
# `semver` attempt to parse the version string as a valid semver version.
|
||||||
|
# The parser is lenient; it will strip a `v` prefix and will accept
|
||||||
|
# versions with fewer than 3 components, like `v1.2`.
|
||||||
|
# If parsing succeeds, then the version will be molded into a format
|
||||||
|
# compatible with the specific packager used.
|
||||||
|
# If parsing fails, then the version is used as-is.
|
||||||
|
# `none` skip trying to parse the version string and just use what is passed in
|
||||||
|
version_schema: semver
|
||||||
|
|
||||||
|
# Version Epoch.
|
||||||
|
# A package with a higher version epoch will always be considered newer.
|
||||||
|
# See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#epochs-should-be-used-sparingly
|
||||||
|
#epoch: 1
|
||||||
|
|
||||||
|
# Version Prerelease.
|
||||||
|
# Default is extracted from `version` if it is semver compatible.
|
||||||
|
# This is appended to the `version`, e.g. `1.2.3+beta1`. If the `version` is
|
||||||
|
# semver compatible, then this replaces the prerelease component of the semver.
|
||||||
|
#prerelease: alpha
|
||||||
|
|
||||||
|
# Version Metadata (previously deb.metadata).
|
||||||
|
# Default is extracted from `version` if it is semver compatible.
|
||||||
|
# Setting metadata might interfere with version comparisons depending on the
|
||||||
|
# packager. If the `version` is semver compatible, then this replaces the
|
||||||
|
# version metadata component of the semver.
|
||||||
|
# version_metadata: git
|
||||||
|
|
||||||
|
# Version Release, aka revision.
|
||||||
|
# This will expand any env var you set in the field, e.g. release: ${VERSION_RELEASE}
|
||||||
|
# This is appended to the `version` after `prerelease`. This should be
|
||||||
|
# incremented if you release an updated package of the same upstream version,
|
||||||
|
# and it should reset to 1 when bumping the version.
|
||||||
|
release: 1
|
||||||
|
|
||||||
|
# Section.
|
||||||
|
# This is only used by the deb packager.
|
||||||
|
# See: https://www.debian.org/doc/debian-policy/ch-archive.html#sections
|
||||||
|
section: default
|
||||||
|
|
||||||
|
# Priority.
|
||||||
|
# Defaults to `optional` on deb
|
||||||
|
# Defaults to empty on rpm and apk
|
||||||
|
# See: https://www.debian.org/doc/debian-policy/ch-archive.html#priorities
|
||||||
|
priority: extra
|
||||||
|
|
||||||
|
# Maintainer. (required)
|
||||||
|
# This will expand any env var you set in the field, e.g. maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}>
|
||||||
|
# Defaults to empty on rpm and apk
|
||||||
|
# Leaving the 'maintainer' field unset will not be allowed in a future version
|
||||||
|
maintainer: Mike Nolan <tesses@tesses.net>
|
||||||
|
|
||||||
|
# Description.
|
||||||
|
# This will expand any env var you set in the field, e.g. description: ${DESCRIPTION}
|
||||||
|
# Defaults to `no description given`.
|
||||||
|
# Most packagers call for a one-line synopsis of the package. Some (like deb)
|
||||||
|
# also call for a multi-line description starting on the second line.
|
||||||
|
description: CrossLang is a dynamically-typed scripting language built on TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
# Vendor.
|
||||||
|
# This will expand any env var you set in the field, e.g. vendor: ${VENDOR}
|
||||||
|
# This is only used by the rpm packager.
|
||||||
|
vendor: Tesses
|
||||||
|
|
||||||
|
# Package's homepage.
|
||||||
|
# This will expand any env var you set in the field, e.g. homepage: ${CI_PROJECT_URL}
|
||||||
|
homepage: https://git.tesses.org/tesses50/crosslang
|
||||||
|
|
||||||
|
# License.
|
||||||
|
license: GPLv3
|
||||||
|
|
||||||
|
# Date to be used as mtime on internal files.
|
||||||
|
#
|
||||||
|
# Default is the value of $SOURCE_DATE_EPOCH (which should be an Unix time),
|
||||||
|
# or the current time.
|
||||||
|
# Read more about SOURCE_DATE_EPOCH at https://reproducible-builds.org/docs/source-date-epoch/
|
||||||
|
#mtime: "2009-11-10T23:00:00Z"
|
||||||
|
|
||||||
|
# Changelog YAML file, see: https://github.com/goreleaser/chglog
|
||||||
|
# changelog: "changelog.yaml"
|
||||||
|
|
||||||
|
# Disables globbing for files, config_files, etc.
|
||||||
|
# disable_globbing: false
|
||||||
|
|
||||||
|
|
||||||
|
# Packages it replaces. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${REPLACE_BLA}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
#replaces:
|
||||||
|
# - foobar
|
||||||
|
# - ${REPLACE_BLA}
|
||||||
|
|
||||||
|
# Packages it provides. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${PROVIDES_BLA}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
#provides:
|
||||||
|
# - bar
|
||||||
|
# - ${PROVIDES_BLA}
|
||||||
|
|
||||||
|
# Dependencies. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${DEPENDS_NGINX}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
# e.g. rhel needs nginx >= 1:1.18 and deb needs nginx (>= 1.18.0)
|
||||||
|
#depends:
|
||||||
|
# - git
|
||||||
|
# - ${DEPENDS_NGINX}
|
||||||
|
|
||||||
|
# Recommended packages. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${RECOMMENDS_BLA}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
#recommends:
|
||||||
|
# - golang
|
||||||
|
# - ${RECOMMENDS_BLA}
|
||||||
|
|
||||||
|
# Suggested packages. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${SUGGESTS_BLA}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
#suggests:
|
||||||
|
# - bzr
|
||||||
|
|
||||||
|
# Packages it conflicts with. (overridable)
|
||||||
|
# This will expand any env var you set in the field, e.g. ${CONFLICTS_BLA}
|
||||||
|
# the env var approach can be used to account for differences in platforms
|
||||||
|
#conflicts:
|
||||||
|
# - mercurial
|
||||||
|
# - ${CONFLICTS_BLA}
|
||||||
|
|
||||||
|
# Contents to add to the package
|
||||||
|
# This can be binaries or any other files.
|
||||||
|
contents:
|
||||||
|
- src: usr/
|
||||||
|
dst: /usr/
|
||||||
|
type: tree
|
||||||
|
|
||||||
|
# Umask to be used on files without explicit mode set.
|
||||||
|
#
|
||||||
|
# By default, nFPM will inherit the mode of the original file that's being
|
||||||
|
# added.
|
||||||
|
# This may lead to issues if these files are checkout out in Git, for example,
|
||||||
|
# as it won't keep all the permissions on fresh checkouts, or if the local
|
||||||
|
# system has a problematic umask setting.
|
||||||
|
#
|
||||||
|
# This setting allows to set the umask for all files that are added to the
|
||||||
|
# package without a specific file_info.mode set.
|
||||||
|
#
|
||||||
|
# Default: 0o002 (will remove world-writable permissions)
|
||||||
|
umask: 0o002
|
||||||
|
|
||||||
|
overrides:
|
||||||
|
deb:
|
||||||
|
depends:
|
||||||
|
- "tessesframework (= @CROSSLANG_TF_VERSION@-1)"
|
||||||
|
rpm:
|
||||||
|
depends:
|
||||||
|
- "tessesframework = @CROSSLANG_TF_VERSION@-1"
|
||||||
|
archlinux:
|
||||||
|
depends:
|
||||||
|
- "tessesframework=@CROSSLANG_TF_VERSION@-1"
|
||||||
@@ -10,6 +10,8 @@ else()
|
|||||||
set(PKGCONFIG_DEPS "")
|
set(PKGCONFIG_DEPS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
message(NOTICE "SrcFile ${CMAKE_CURRENT_BINARY_DIR}/crosslang.pc")
|
||||||
|
message(NOTICE "Outdir ${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
|
||||||
configure_file(crosslang.pc.in crosslang.pc @ONLY)
|
configure_file(crosslang.pc.in crosslang.pc @ONLY)
|
||||||
install(FILES
|
install(FILES
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Maintainer: Mike Nolan <tesses@tesses.net>
|
||||||
|
pkgname=crosslang # '-bzr', '-git', '-hg' or '-svn'
|
||||||
|
pkgver=@CROSSLANG_MAJOR_VERSION@.@CROSSLANG_MINOR_VERSION@.@CROSSLANG_PATCH_VERSION@
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc=""
|
||||||
|
arch=('powerpc')
|
||||||
|
url="https://git.tesses.org/tesses50/crosslang"
|
||||||
|
license=('GPLv3')
|
||||||
|
groups=()
|
||||||
|
depends=('tessesframework=@CROSSLANG_TF_VERSION@-1')
|
||||||
|
makedepends=('git' 'cmake' 'make' 'base-devel' 'wget') # 'bzr', 'git', 'mercurial' or 'subversion'
|
||||||
|
install=
|
||||||
|
source=()
|
||||||
|
noextract=()
|
||||||
|
sha256sums=()
|
||||||
|
options=(!buildflags !strip)
|
||||||
|
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cp -r "${srcdir}/"* "${pkgdir}/"
|
||||||
|
}
|
||||||
+21
-1
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -44,7 +64,7 @@ void CrossArchiveCreate(
|
|||||||
strs.push_back("Console");
|
strs.push_back("Console");
|
||||||
strs.push_back("WriteLine");
|
strs.push_back("WriteLine");
|
||||||
strs.push_back("You are trying to run a crvm archive, stop it you won't "
|
strs.push_back("You are trying to run a crvm archive, stop it you won't "
|
||||||
"get anywhere!\nUse crossarchiveextract instead.");
|
"get anywhere!\nUse crosslang archiveextract instead.");
|
||||||
|
|
||||||
std::vector<std::string> resources;
|
std::vector<std::string> resources;
|
||||||
|
|
||||||
|
|||||||
@@ -1,139 +0,0 @@
|
|||||||
#include "CrossLang.hpp"
|
|
||||||
#if defined(CROSSLANG_ENABLE_JSON)
|
|
||||||
#include <jansson.h>
|
|
||||||
#endif
|
|
||||||
namespace Tesses::CrossLang {
|
|
||||||
AdvancedSyntaxNode AdvancedSyntaxNode::Create(std::string_view nodeName,
|
|
||||||
bool isExpression,
|
|
||||||
std::vector<SyntaxNode> nodes) {
|
|
||||||
AdvancedSyntaxNode asn;
|
|
||||||
asn.nodeName = std::string(nodeName);
|
|
||||||
asn.isExpression = isExpression;
|
|
||||||
asn.nodes = nodes;
|
|
||||||
return asn;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CROSSLANG_ENABLE_JSON)
|
|
||||||
static SyntaxNode Deserialize2(json_t *json) {
|
|
||||||
if (json_is_null(json))
|
|
||||||
return nullptr;
|
|
||||||
if (json_is_true(json))
|
|
||||||
return true;
|
|
||||||
if (json_is_false(json))
|
|
||||||
return false;
|
|
||||||
if (json_is_integer(json))
|
|
||||||
return (int64_t)json_integer_value(json);
|
|
||||||
if (json_is_real(json))
|
|
||||||
return json_real_value(json);
|
|
||||||
if (json_is_string(json))
|
|
||||||
return std::string(json_string_value(json), json_string_length(json));
|
|
||||||
if (json_is_object(json)) {
|
|
||||||
json_t *typ = json_object_get(json, "type");
|
|
||||||
if (json_is_string(typ)) {
|
|
||||||
std::string type(json_string_value(typ), json_string_length(typ));
|
|
||||||
if (type == CharExpression) {
|
|
||||||
json_t *chrData = json_object_get(json, "value");
|
|
||||||
if (json_is_integer(chrData)) {
|
|
||||||
return (char)(uint8_t)json_integer_value(chrData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type == UndefinedExpression) {
|
|
||||||
return Undefined();
|
|
||||||
}
|
|
||||||
json_t *isExpr = json_object_get(json, "isExpression");
|
|
||||||
bool isExprB = json_is_true(isExpr);
|
|
||||||
AdvancedSyntaxNode asn;
|
|
||||||
asn.nodeName = type;
|
|
||||||
asn.isExpression = isExprB;
|
|
||||||
json_t *args = json_object_get(json, "args");
|
|
||||||
if (json_is_array(args)) {
|
|
||||||
size_t index;
|
|
||||||
json_t *value;
|
|
||||||
|
|
||||||
json_array_foreach(args, index, value) {
|
|
||||||
asn.nodes.push_back(Deserialize2(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return asn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SyntaxNode Deserialize(std::string astData) {
|
|
||||||
#if defined(CROSSLANG_ENABLE_JSON)
|
|
||||||
json_t *json = json_loadb(astData.c_str(), astData.size(), 0, NULL);
|
|
||||||
|
|
||||||
auto r = Deserialize2(json);
|
|
||||||
json_decref(json);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#if defined(CROSSLANG_ENABLE_JSON)
|
|
||||||
static json_t *Serialize2(SyntaxNode node) {
|
|
||||||
if (std::holds_alternative<std::nullptr_t>(node))
|
|
||||||
return json_null();
|
|
||||||
if (std::holds_alternative<int64_t>(node)) {
|
|
||||||
return json_integer(std::get<int64_t>(node));
|
|
||||||
}
|
|
||||||
if (std::holds_alternative<double>(node)) {
|
|
||||||
return json_real(std::get<double>(node));
|
|
||||||
}
|
|
||||||
if (std::holds_alternative<bool>(node)) {
|
|
||||||
return json_boolean(std::get<bool>(node));
|
|
||||||
}
|
|
||||||
if (std::holds_alternative<std::string>(node)) {
|
|
||||||
std::string str = std::get<std::string>(node);
|
|
||||||
return json_stringn(str.c_str(), str.size());
|
|
||||||
}
|
|
||||||
if (std::holds_alternative<char>(node)) {
|
|
||||||
char c = std::get<char>(node);
|
|
||||||
json_t *json = json_object();
|
|
||||||
json_object_set_new(json, "type",
|
|
||||||
json_string((const char *)CharExpression.data()));
|
|
||||||
json_object_set_new(json, "value", json_integer((uint8_t)c));
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
if (std::holds_alternative<Undefined>(node)) {
|
|
||||||
json_t *json = json_object();
|
|
||||||
json_object_set_new(
|
|
||||||
json, "type",
|
|
||||||
json_string((const char *)UndefinedExpression.data()));
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::holds_alternative<AdvancedSyntaxNode>(node)) {
|
|
||||||
auto asn = std::get<AdvancedSyntaxNode>(node);
|
|
||||||
json_t *j = json_object();
|
|
||||||
json_object_set_new(j, "type", json_string(asn.nodeName.c_str()));
|
|
||||||
json_object_set_new(j, "isExpression", json_boolean(asn.isExpression));
|
|
||||||
json_t *arr = json_array();
|
|
||||||
for (auto item : asn.nodes) {
|
|
||||||
json_array_append_new(arr, Serialize2(item));
|
|
||||||
}
|
|
||||||
json_object_set_new(j, "args", arr);
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_null();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string Serialize(SyntaxNode node) {
|
|
||||||
|
|
||||||
#if defined(CROSSLANG_ENABLE_JSON)
|
|
||||||
json_t *json = Serialize2(node);
|
|
||||||
char *txt = json_dumps(json, 0);
|
|
||||||
std::string str(txt);
|
|
||||||
free(json);
|
|
||||||
json_decref(json);
|
|
||||||
return str;
|
|
||||||
#endif
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tesses::CrossLang
|
|
||||||
+145
-42
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -175,7 +195,7 @@ void CodeGen::WriteMetadataObject(std::vector<uint8_t> &bytes, SyntaxNode n) {
|
|||||||
std::vector<SyntaxNode> itms;
|
std::vector<SyntaxNode> itms;
|
||||||
if (asn.nodes.size() > 0)
|
if (asn.nodes.size() > 0)
|
||||||
|
|
||||||
GetFunctionArgs(itms, asn.nodes[0]);
|
FlattenCommas(itms, asn.nodes[0]);
|
||||||
bytes.push_back(7);
|
bytes.push_back(7);
|
||||||
size_t offset = bytes.size();
|
size_t offset = bytes.size();
|
||||||
bytes.resize(offset + 4);
|
bytes.resize(offset + 4);
|
||||||
@@ -189,7 +209,7 @@ void CodeGen::WriteMetadataObject(std::vector<uint8_t> &bytes, SyntaxNode n) {
|
|||||||
std::vector<SyntaxNode> itms;
|
std::vector<SyntaxNode> itms;
|
||||||
if (asn.nodes.size() > 0)
|
if (asn.nodes.size() > 0)
|
||||||
|
|
||||||
GetFunctionArgs(itms, asn.nodes[0]);
|
FlattenCommas(itms, asn.nodes[0]);
|
||||||
bytes.push_back(8);
|
bytes.push_back(8);
|
||||||
size_t offset = bytes.size();
|
size_t offset = bytes.size();
|
||||||
bytes.resize(offset + 4);
|
bytes.resize(offset + 4);
|
||||||
@@ -827,6 +847,8 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
size_t fnindex = this->chunks.size();
|
size_t fnindex = this->chunks.size();
|
||||||
ent.closure = (uint32_t)fnindex;
|
ent.closure = (uint32_t)fnindex;
|
||||||
this->chunks.resize(fnindex + 1);
|
this->chunks.resize(fnindex + 1);
|
||||||
|
|
||||||
|
std::vector<ByteCodeInstruction *> fnInstructions;
|
||||||
auto &nameAndArgs =
|
auto &nameAndArgs =
|
||||||
std::get<AdvancedSyntaxNode>(adv2.nodes[2]);
|
std::get<AdvancedSyntaxNode>(adv2.nodes[2]);
|
||||||
if (nameAndArgs.nodeName == FunctionCallExpression &&
|
if (nameAndArgs.nodeName == FunctionCallExpression &&
|
||||||
@@ -844,14 +866,13 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
std::get<std::string>(getvar.nodes[0]));
|
std::get<std::string>(getvar.nodes[0]));
|
||||||
if (nameAndArgs.nodes.size() > 1) {
|
if (nameAndArgs.nodes.size() > 1) {
|
||||||
GetFunctionArgs(ent.arguments,
|
GetFunctionArgs(ent.arguments,
|
||||||
|
fnInstructions,
|
||||||
nameAndArgs.nodes[1]);
|
nameAndArgs.nodes[1]);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ByteCodeInstruction *> fnInstructions;
|
|
||||||
|
|
||||||
GenNode(fnInstructions, adv2.nodes[3], 0, -1, -1, -1,
|
GenNode(fnInstructions, adv2.nodes[3], 0, -1, -1, -1,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
@@ -881,8 +902,8 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
ent.name = GetString(
|
ent.name = GetString(
|
||||||
std::get<std::string>(getvar.nodes[0]));
|
std::get<std::string>(getvar.nodes[0]));
|
||||||
if (nameAndArgs.nodes.size() > 1) {
|
if (nameAndArgs.nodes.size() > 1) {
|
||||||
GetFunctionArgs(ent.arguments,
|
FlattenCommas(ent.arguments,
|
||||||
nameAndArgs.nodes[1]);
|
nameAndArgs.nodes[1]);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
@@ -1041,13 +1062,13 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
}
|
}
|
||||||
if (item.first.second.nodeName == DefaultStatement) {
|
if (item.first.second.nodeName == DefaultStatement) {
|
||||||
if (!defaultJmp.empty())
|
if (!defaultJmp.empty())
|
||||||
std::cout << "ERROR: multiple default in "
|
Tesses::Framework::Console::WriteLine(
|
||||||
"switch statement will cause "
|
"ERROR: multiple default in "
|
||||||
"undefined behaviour, this is not "
|
"switch statement will cause "
|
||||||
"an exception due to not allowing "
|
"undefined behaviour, this is not "
|
||||||
"exceptions in codegen stage (the "
|
"an exception due to not allowing "
|
||||||
"compilation shouldn't fail)"
|
"exceptions in codegen stage (the "
|
||||||
<< std::endl;
|
"compilation shouldn't fail)");
|
||||||
defaultJmp = item.first.first;
|
defaultJmp = item.first.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1084,16 +1105,15 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
GenNode(instructions, adv.nodes[0], scope, contscope, brkscope,
|
GenNode(instructions, adv.nodes[0], scope, contscope, brkscope,
|
||||||
contI, brkI);
|
contI, brkI);
|
||||||
instructions.push_back(new JumpStyleInstruction(JMPC, ifIdTrue));
|
instructions.push_back(new JumpStyleInstruction(JMPC, ifIdTrue));
|
||||||
if (!std::holds_alternative<std::nullptr_t>(adv.nodes[2])) {
|
|
||||||
GenNode(instructions, adv.nodes[2], scope, contscope, brkscope,
|
GenNode(instructions, adv.nodes[2], scope, contscope, brkscope,
|
||||||
contI, brkI);
|
contI, brkI);
|
||||||
}
|
|
||||||
instructions.push_back(new JumpStyleInstruction(JMP, ifIdEnd));
|
instructions.push_back(new JumpStyleInstruction(JMP, ifIdEnd));
|
||||||
instructions.push_back(new LabelInstruction(ifIdTrue));
|
instructions.push_back(new LabelInstruction(ifIdTrue));
|
||||||
if (!std::holds_alternative<std::nullptr_t>(adv.nodes[1])) {
|
GenNode(instructions, adv.nodes[1], scope, contscope, brkscope,
|
||||||
GenNode(instructions, adv.nodes[1], scope, contscope, brkscope,
|
contI, brkI);
|
||||||
contI, brkI);
|
|
||||||
}
|
|
||||||
instructions.push_back(new LabelInstruction(ifIdEnd));
|
instructions.push_back(new LabelInstruction(ifIdEnd));
|
||||||
|
|
||||||
} else if (adv.nodeName == CompoundAssignExpression &&
|
} else if (adv.nodeName == CompoundAssignExpression &&
|
||||||
@@ -1223,7 +1243,7 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
std::vector<SyntaxNode> itms;
|
std::vector<SyntaxNode> itms;
|
||||||
if (adv.nodes.size() > 0)
|
if (adv.nodes.size() > 0)
|
||||||
|
|
||||||
GetFunctionArgs(itms, adv.nodes[0]);
|
FlattenCommas(itms, adv.nodes[0]);
|
||||||
for (auto item : itms) {
|
for (auto item : itms) {
|
||||||
GenNode(instructions, item, scope, contscope, brkscope, contI,
|
GenNode(instructions, item, scope, contscope, brkscope, contI,
|
||||||
brkI);
|
brkI);
|
||||||
@@ -1233,7 +1253,7 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
instructions.push_back(new SimpleInstruction(CREATEDICTIONARY));
|
instructions.push_back(new SimpleInstruction(CREATEDICTIONARY));
|
||||||
std::vector<SyntaxNode> itms;
|
std::vector<SyntaxNode> itms;
|
||||||
if (adv.nodes.size() > 0)
|
if (adv.nodes.size() > 0)
|
||||||
GetFunctionArgs(itms, adv.nodes[0]);
|
FlattenCommas(itms, adv.nodes[0]);
|
||||||
for (auto item : itms) {
|
for (auto item : itms) {
|
||||||
if (std::holds_alternative<AdvancedSyntaxNode>(item)) {
|
if (std::holds_alternative<AdvancedSyntaxNode>(item)) {
|
||||||
auto tkn = std::get<AdvancedSyntaxNode>(item);
|
auto tkn = std::get<AdvancedSyntaxNode>(item);
|
||||||
@@ -1273,7 +1293,7 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
contI, brkI);
|
contI, brkI);
|
||||||
if (adv.nodes.size() == 2) {
|
if (adv.nodes.size() == 2) {
|
||||||
std::vector<SyntaxNode> nodes;
|
std::vector<SyntaxNode> nodes;
|
||||||
GetFunctionArgs(nodes, adv.nodes[1]);
|
FlattenCommas(nodes, adv.nodes[1]);
|
||||||
for (auto item : nodes)
|
for (auto item : nodes)
|
||||||
GenNode(instructions, item, scope, contscope, brkscope,
|
GenNode(instructions, item, scope, contscope, brkscope,
|
||||||
contI, brkI);
|
contI, brkI);
|
||||||
@@ -1288,7 +1308,7 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
contI, brkI);
|
contI, brkI);
|
||||||
if (adv.nodes.size() == 2) {
|
if (adv.nodes.size() == 2) {
|
||||||
std::vector<SyntaxNode> nodes;
|
std::vector<SyntaxNode> nodes;
|
||||||
GetFunctionArgs(nodes, adv.nodes[1]);
|
FlattenCommas(nodes, adv.nodes[1]);
|
||||||
for (auto item : nodes)
|
for (auto item : nodes)
|
||||||
GenNode(instructions, item, scope, contscope, brkscope,
|
GenNode(instructions, item, scope, contscope, brkscope,
|
||||||
contI, brkI);
|
contI, brkI);
|
||||||
@@ -1555,7 +1575,8 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
|
|
||||||
} else if (adv.nodeName == ContinueStatement) {
|
} else if (adv.nodeName == ContinueStatement) {
|
||||||
if (contscope == -1) {
|
if (contscope == -1) {
|
||||||
std::cout << "WARN: continue does nothing here\n";
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
"WARN: continue does nothing here");
|
||||||
} else if (contscope == -2) {
|
} else if (contscope == -2) {
|
||||||
instructions.push_back(new SimpleInstruction(PUSHCONTINUE));
|
instructions.push_back(new SimpleInstruction(PUSHCONTINUE));
|
||||||
instructions.push_back(new SimpleInstruction(RET));
|
instructions.push_back(new SimpleInstruction(RET));
|
||||||
@@ -1572,7 +1593,8 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
}
|
}
|
||||||
} else if (adv.nodeName == BreakStatement) {
|
} else if (adv.nodeName == BreakStatement) {
|
||||||
if (brkscope == -1) {
|
if (brkscope == -1) {
|
||||||
std::cout << "WARN: break does nothing here\n";
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
"WARN: break does nothing here");
|
||||||
} else if (brkscope == -2) {
|
} else if (brkscope == -2) {
|
||||||
instructions.push_back(new SimpleInstruction(PUSHBREAK));
|
instructions.push_back(new SimpleInstruction(PUSHBREAK));
|
||||||
instructions.push_back(new SimpleInstruction(RET));
|
instructions.push_back(new SimpleInstruction(RET));
|
||||||
@@ -1978,7 +2000,7 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
//(a,b) => {}
|
//(a,b) => {}
|
||||||
// it has two args
|
// it has two args
|
||||||
std::vector<uint32_t> args;
|
std::vector<uint32_t> args;
|
||||||
GetFunctionArgs(args, adv.nodes[0]);
|
FlattenCommas(args, adv.nodes[0]);
|
||||||
|
|
||||||
std::vector<ByteCodeInstruction *> fnInstructions;
|
std::vector<ByteCodeInstruction *> fnInstructions;
|
||||||
size_t fnindex = this->chunks.size();
|
size_t fnindex = this->chunks.size();
|
||||||
@@ -2008,12 +2030,11 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
// Name => {}
|
// Name => {}
|
||||||
//(a,b) => {}
|
//(a,b) => {}
|
||||||
// it has two args
|
// it has two args
|
||||||
std::vector<uint32_t> args;
|
|
||||||
GetFunctionArgs(args, adv.nodes[0]);
|
|
||||||
|
|
||||||
std::vector<ByteCodeInstruction *> fnInstructions;
|
std::vector<ByteCodeInstruction *> fnInstructions;
|
||||||
size_t fnindex = this->chunks.size();
|
size_t fnindex = this->chunks.size();
|
||||||
this->chunks.resize(fnindex + 1);
|
this->chunks.resize(fnindex + 1);
|
||||||
|
std::vector<uint32_t> args;
|
||||||
|
GetFunctionArgs(args, fnInstructions, adv.nodes[0]);
|
||||||
|
|
||||||
auto body = adv.nodes[1];
|
auto body = adv.nodes[1];
|
||||||
|
|
||||||
@@ -2060,18 +2081,20 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CodeGen::GetFunctionArgs(std::vector<SyntaxNode> &args, SyntaxNode n) {
|
void CodeGen::FlattenCommas(std::vector<SyntaxNode> &args, SyntaxNode n) {
|
||||||
AdvancedSyntaxNode sn;
|
AdvancedSyntaxNode sn;
|
||||||
if (std::holds_alternative<AdvancedSyntaxNode>(n) &&
|
if (std::holds_alternative<AdvancedSyntaxNode>(n) &&
|
||||||
(sn = std::get<AdvancedSyntaxNode>(n)).nodeName == CommaExpression &&
|
(sn = std::get<AdvancedSyntaxNode>(n)).nodeName == CommaExpression &&
|
||||||
sn.nodes.size() == 2) {
|
sn.nodes.size() == 2) {
|
||||||
GetFunctionArgs(args, sn.nodes[0]);
|
FlattenCommas(args, sn.nodes[0]);
|
||||||
GetFunctionArgs(args, sn.nodes[1]);
|
FlattenCommas(args, sn.nodes[1]);
|
||||||
} else {
|
} else {
|
||||||
args.push_back(n);
|
args.push_back(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CodeGen::GetFunctionArgs(std::vector<uint32_t> &name, SyntaxNode n) {
|
void CodeGen::GetFunctionArgs(std::vector<uint32_t> &name,
|
||||||
|
std::vector<ByteCodeInstruction *> &instrs,
|
||||||
|
SyntaxNode n) {
|
||||||
if (std::holds_alternative<std::nullptr_t>(n))
|
if (std::holds_alternative<std::nullptr_t>(n))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2079,10 +2102,90 @@ void CodeGen::GetFunctionArgs(std::vector<uint32_t> &name, SyntaxNode n) {
|
|||||||
auto res = std::get<AdvancedSyntaxNode>(n);
|
auto res = std::get<AdvancedSyntaxNode>(n);
|
||||||
if (res.nodeName == ParenthesesExpression) {
|
if (res.nodeName == ParenthesesExpression) {
|
||||||
for (auto n : res.nodes)
|
for (auto n : res.nodes)
|
||||||
GetFunctionArgs(name, n);
|
GetFunctionArgs(name, instrs, n);
|
||||||
|
} else if (res.nodeName == AssignExpression && res.nodes.size() == 2) {
|
||||||
|
// ennsure the left argument is a getVariableExpression
|
||||||
|
if (std::holds_alternative<AdvancedSyntaxNode>(res.nodes[0])) {
|
||||||
|
auto left = std::get<AdvancedSyntaxNode>(res.nodes[0]);
|
||||||
|
|
||||||
|
if (left.nodeName == GetVariableExpression &&
|
||||||
|
!left.nodes.empty() &&
|
||||||
|
std::holds_alternative<std::string>(left.nodes[0])) {
|
||||||
|
std::string key = std::get<std::string>(left.nodes[0]);
|
||||||
|
if (key.size() >= 2 && key[0] == '$' && key[1] == '$') {
|
||||||
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
"WARN: you can't assign variadic functions to a "
|
||||||
|
"default value, this will be an "
|
||||||
|
"error on future release.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.size() > 0 && key[0] == '$') {
|
||||||
|
key.erase(key.cbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
name.push_back(GetString('$' + key));
|
||||||
|
|
||||||
|
uint32_t ifId = NewId();
|
||||||
|
std::string compGenSetVar = "__compGenSetVar";
|
||||||
|
compGenSetVar.append(std::to_string(ifId));
|
||||||
|
|
||||||
|
std::string compGenSetVarEnd = "__compGenSetVarEnd";
|
||||||
|
compGenSetVarEnd.append(std::to_string(ifId));
|
||||||
|
GenNode(instrs,
|
||||||
|
AdvancedSyntaxNode::Create(GetVariableExpression,
|
||||||
|
true, {key}),
|
||||||
|
0, -1, -1, -1, -1);
|
||||||
|
instrs.push_back(new JumpStyleInstruction(
|
||||||
|
Tesses::CrossLang::Instruction::JMPUNDEFINED,
|
||||||
|
compGenSetVar));
|
||||||
|
instrs.push_back(new SimpleInstruction(POP));
|
||||||
|
instrs.push_back(new JumpStyleInstruction(
|
||||||
|
Tesses::CrossLang::Instruction::JMP, compGenSetVarEnd));
|
||||||
|
instrs.push_back(new LabelInstruction(compGenSetVar));
|
||||||
|
GenNode(instrs,
|
||||||
|
AdvancedSyntaxNode::Create(
|
||||||
|
AssignExpression, true,
|
||||||
|
{AdvancedSyntaxNode::Create(DeclareExpression,
|
||||||
|
true, {key}),
|
||||||
|
res.nodes[1]}),
|
||||||
|
|
||||||
|
0, -1, -1, -1, -1);
|
||||||
|
instrs.push_back(new SimpleInstruction(POP));
|
||||||
|
instrs.push_back(new LabelInstruction(compGenSetVarEnd));
|
||||||
|
} else {
|
||||||
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
"WARN: assignment does not assign arg, this will be an "
|
||||||
|
"error on future release.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
"WARN: assignment does not assign arg, this will be an "
|
||||||
|
"error on future release.");
|
||||||
|
}
|
||||||
} else if (res.nodeName == CommaExpression && res.nodes.size() == 2) {
|
} else if (res.nodeName == CommaExpression && res.nodes.size() == 2) {
|
||||||
GetFunctionArgs(name, res.nodes[0]);
|
GetFunctionArgs(name, instrs, res.nodes[0]);
|
||||||
GetFunctionArgs(name, res.nodes[1]);
|
GetFunctionArgs(name, instrs, res.nodes[1]);
|
||||||
|
} else if (res.nodeName == GetVariableExpression &&
|
||||||
|
res.nodes.size() == 1) {
|
||||||
|
if (std::holds_alternative<std::string>(res.nodes[0])) {
|
||||||
|
name.push_back(GetString(std::get<std::string>(res.nodes[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CodeGen::FlattenCommas(std::vector<uint32_t> &name, SyntaxNode n) {
|
||||||
|
if (std::holds_alternative<std::nullptr_t>(n))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (std::holds_alternative<AdvancedSyntaxNode>(n)) {
|
||||||
|
auto res = std::get<AdvancedSyntaxNode>(n);
|
||||||
|
if (res.nodeName == ParenthesesExpression) {
|
||||||
|
for (auto n : res.nodes)
|
||||||
|
FlattenCommas(name, n);
|
||||||
|
} else if (res.nodeName == CommaExpression && res.nodes.size() == 2) {
|
||||||
|
FlattenCommas(name, res.nodes[0]);
|
||||||
|
FlattenCommas(name, res.nodes[1]);
|
||||||
} else if (res.nodeName == GetVariableExpression &&
|
} else if (res.nodeName == GetVariableExpression &&
|
||||||
res.nodes.size() == 1) {
|
res.nodes.size() == 1) {
|
||||||
if (std::holds_alternative<std::string>(res.nodes[0])) {
|
if (std::holds_alternative<std::string>(res.nodes[0])) {
|
||||||
@@ -2175,14 +2278,14 @@ void CodeGen::GenRoot(SyntaxNode n) {
|
|||||||
functionName.insert(
|
functionName.insert(
|
||||||
functionName.begin(),
|
functionName.begin(),
|
||||||
{GetString(documentation)});
|
{GetString(documentation)});
|
||||||
if (fcalli.nodes.size() == 2)
|
|
||||||
GetFunctionArgs(args,
|
|
||||||
fcalli.nodes[1]);
|
|
||||||
|
|
||||||
std::vector<ByteCodeInstruction *>
|
std::vector<ByteCodeInstruction *>
|
||||||
fnInstructions;
|
fnInstructions;
|
||||||
size_t fnindex = this->chunks.size();
|
size_t fnindex = this->chunks.size();
|
||||||
this->chunks.resize(fnindex + 1);
|
this->chunks.resize(fnindex + 1);
|
||||||
|
if (fcalli.nodes.size() == 2)
|
||||||
|
GetFunctionArgs(args,
|
||||||
|
fnInstructions,
|
||||||
|
fcalli.nodes[1]);
|
||||||
|
|
||||||
GenNode(fnInstructions, res2.nodes[1],
|
GenNode(fnInstructions, res2.nodes[1],
|
||||||
0, -1, -1, -1, -1);
|
0, -1, -1, -1, -1);
|
||||||
|
|||||||
+21
-1
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -482,6 +502,7 @@ int Lex(std::string filename, std::istream &strm,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
|
case '>':
|
||||||
case '?':
|
case '?':
|
||||||
if (peek == read) {
|
if (peek == read) {
|
||||||
Flush();
|
Flush();
|
||||||
@@ -532,7 +553,6 @@ int Lex(std::string filename, std::istream &strm,
|
|||||||
case '^':
|
case '^':
|
||||||
case '~':
|
case '~':
|
||||||
case '!':
|
case '!':
|
||||||
case '>':
|
|
||||||
case '*':
|
case '*':
|
||||||
case '%':
|
case '%':
|
||||||
//*
|
//*
|
||||||
|
|||||||
+45
-156
@@ -1,11 +1,41 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
AdvancedSyntaxNode AdvancedSyntaxNode::Create(std::string_view nodeName,
|
||||||
|
bool isExpression,
|
||||||
|
std::vector<SyntaxNode> nodes) {
|
||||||
|
AdvancedSyntaxNode asn;
|
||||||
|
asn.nodeName = std::string(nodeName);
|
||||||
|
asn.isExpression = isExpression;
|
||||||
|
asn.nodes = nodes;
|
||||||
|
return asn;
|
||||||
|
}
|
||||||
|
|
||||||
SyntaxNode TObject2SyntaxNode(TObject o) {
|
SyntaxNode TObject2SyntaxNode(TObject o) {
|
||||||
if (std::holds_alternative<Undefined>(o))
|
if (std::holds_alternative<Undefined>(o))
|
||||||
return Undefined();
|
return Undefined();
|
||||||
if (std::holds_alternative<std::nullptr_t>(o))
|
if (IsNull(o))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (std::holds_alternative<std::string>(o))
|
if (std::holds_alternative<std::string>(o))
|
||||||
return std::get<std::string>(o);
|
return std::get<std::string>(o);
|
||||||
@@ -115,58 +145,16 @@ bool Parser::IsIdentifier(std::string txt, bool pop) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::IsAnySymbol(std::initializer_list<std::string> idents, bool pop) {
|
bool Parser::IsAnySymbol(std::initializer_list<std::string> idents, bool pop) {
|
||||||
|
|
||||||
if (i < tokens.size()) {
|
if (i < tokens.size()) {
|
||||||
if (tokens[i].type != LexTokenType::Symbol)
|
if (tokens[i].type != LexTokenType::Symbol)
|
||||||
return false;
|
return false;
|
||||||
for (auto item : idents) {
|
for (auto item : idents) {
|
||||||
if (item == ">") {
|
if (item == tokens[i].text) {
|
||||||
if (i + 1 < tokens.size()) {
|
tkn = tokens[i];
|
||||||
if ((tokens[i + 1].text == ">" ||
|
if (pop)
|
||||||
tokens[i + 1].text == ">=") &&
|
i++;
|
||||||
tokens[i + 1].type == LexTokenType::Symbol)
|
return true;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (item == tokens[i].text) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
if (pop)
|
|
||||||
i++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (item == ">>=") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">=" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
tkn.text = ">>=";
|
|
||||||
if (pop)
|
|
||||||
i += 2;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (item == ">>") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
tkn.text = ">>";
|
|
||||||
if (pop)
|
|
||||||
i += 2;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (item == tokens[i].text) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
if (pop)
|
|
||||||
i++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,45 +164,7 @@ bool Parser::IsSymbol(std::string txt, bool pop) {
|
|||||||
if (i < tokens.size()) {
|
if (i < tokens.size()) {
|
||||||
if (tokens[i].type != LexTokenType::Symbol)
|
if (tokens[i].type != LexTokenType::Symbol)
|
||||||
return false;
|
return false;
|
||||||
if (txt == ">") {
|
if (tokens[i].text == txt) {
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if ((tokens[i + 1].text == ">" || tokens[i + 1].text == ">=") &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (txt == tokens[i].text) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
if (pop)
|
|
||||||
i++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (txt == ">>=") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">=" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
tkn.text = ">>=";
|
|
||||||
if (pop)
|
|
||||||
i += 2;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (txt == ">>") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
tkn = tokens[i];
|
|
||||||
tkn.text = ">>";
|
|
||||||
if (pop)
|
|
||||||
i += 2;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (tokens[i].text == txt) {
|
|
||||||
tkn = tokens[i];
|
tkn = tokens[i];
|
||||||
if (pop)
|
if (pop)
|
||||||
i++;
|
i++;
|
||||||
@@ -233,7 +183,6 @@ static std::string EnsureSafeVariable(LexToken token) {
|
|||||||
}
|
}
|
||||||
void Parser::EnsureSymbol(std::string txt) {
|
void Parser::EnsureSymbol(std::string txt) {
|
||||||
if (i < tokens.size()) {
|
if (i < tokens.size()) {
|
||||||
|
|
||||||
if (tokens[i].type != LexTokenType::Symbol) {
|
if (tokens[i].type != LexTokenType::Symbol) {
|
||||||
throw SyntaxException(
|
throw SyntaxException(
|
||||||
tokens[i].lineInfo,
|
tokens[i].lineInfo,
|
||||||
@@ -241,69 +190,7 @@ void Parser::EnsureSymbol(std::string txt) {
|
|||||||
LexTokenType_ToString(tokens[i].type) + " \"" +
|
LexTokenType_ToString(tokens[i].type) + " \"" +
|
||||||
tokens[i].text + "\" which is not a symbol at all.");
|
tokens[i].text + "\" which is not a symbol at all.");
|
||||||
}
|
}
|
||||||
if (txt == ">") {
|
if (tokens[i].text != txt) {
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if ((tokens[i + 1].text == ">" || tokens[i + 1].text == ">=") &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol)
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
|
||||||
"expected the symbol \"" + txt +
|
|
||||||
"\" but got the symbol \"" +
|
|
||||||
tokens[i].text +
|
|
||||||
tokens[i + 1].text + "\"");
|
|
||||||
;
|
|
||||||
}
|
|
||||||
if (txt == tokens[i].text) {
|
|
||||||
|
|
||||||
tkn = tokens[i];
|
|
||||||
i++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (txt == ">>=") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">=" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
|
|
||||||
tkn = tokens[i];
|
|
||||||
i += 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
|
||||||
"expected the symbol \"" + txt +
|
|
||||||
"\" but got the symbol \"" +
|
|
||||||
tokens[i].text + tokens[i + 1].text +
|
|
||||||
"\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
|
||||||
"expected the symbol \"" + txt +
|
|
||||||
"\" but got the symbol \"" +
|
|
||||||
tokens[i].text + "\"");
|
|
||||||
} else if (txt == ">>") {
|
|
||||||
if (i + 1 < tokens.size()) {
|
|
||||||
if (tokens[i].text == ">" && tokens[i + 1].text == ">" &&
|
|
||||||
tokens[i].type == LexTokenType::Symbol &&
|
|
||||||
tokens[i + 1].type == LexTokenType::Symbol) {
|
|
||||||
|
|
||||||
tkn = tokens[i];
|
|
||||||
i += 2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
|
||||||
"expected the symbol \"" + txt +
|
|
||||||
"\" but got the symbol \"" +
|
|
||||||
tokens[i].text + tokens[i + 1].text +
|
|
||||||
"\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
|
||||||
"expected the symbol \"" + txt +
|
|
||||||
"\" but got the symbol \"" +
|
|
||||||
tokens[i].text + "\"");
|
|
||||||
} else if (tokens[i].text != txt) {
|
|
||||||
|
|
||||||
throw SyntaxException(tokens[i].lineInfo,
|
throw SyntaxException(tokens[i].lineInfo,
|
||||||
"expected the symbol \"" + txt +
|
"expected the symbol \"" + txt +
|
||||||
@@ -633,6 +520,10 @@ void Parser::ParseHtml(std::vector<SyntaxNode> &nodes, std::string var) {
|
|||||||
EnsureSymbol(")");
|
EnsureSymbol(")");
|
||||||
EnsureSymbol(">");
|
EnsureSymbol(">");
|
||||||
|
|
||||||
|
if (std::holds_alternative<std::nullptr_t>(item))
|
||||||
|
item = AdvancedSyntaxNode::Create(DeclareExpression, true,
|
||||||
|
{"item"});
|
||||||
|
|
||||||
std::vector<SyntaxNode> _nodes;
|
std::vector<SyntaxNode> _nodes;
|
||||||
parseFn(_nodes, "each");
|
parseFn(_nodes, "each");
|
||||||
body = AdvancedSyntaxNode::Create(ScopeNode, false, _nodes);
|
body = AdvancedSyntaxNode::Create(ScopeNode, false, _nodes);
|
||||||
@@ -1411,7 +1302,7 @@ SyntaxNode Parser::ParseNode(bool isRoot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isRoot)
|
if (!isRoot)
|
||||||
i++;
|
EnsureSymbol("}");
|
||||||
return aSN;
|
return aSN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1517,10 +1408,8 @@ SyntaxNode Parser::ParseNode(bool isRoot) {
|
|||||||
body = ParseNode();
|
body = ParseNode();
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<std::nullptr_t>(item))
|
if (std::holds_alternative<std::nullptr_t>(item))
|
||||||
item = AdvancedSyntaxNode::Create(
|
item =
|
||||||
DeclareExpression, true,
|
AdvancedSyntaxNode::Create(DeclareExpression, true, {"item"});
|
||||||
{AdvancedSyntaxNode::Create(GetVariableExpression, true,
|
|
||||||
{"item"})});
|
|
||||||
|
|
||||||
return AdvancedSyntaxNode::Create(EachStatement, false,
|
return AdvancedSyntaxNode::Create(EachStatement, false,
|
||||||
{item, list, body});
|
{item, list, body});
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <TessesFramework/Common.hpp>
|
#include <TessesFramework/Common.hpp>
|
||||||
#include <TessesFramework/Filesystem/LocalFS.hpp>
|
#include <TessesFramework/Filesystem/LocalFS.hpp>
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
namespace Tesses::CrossLang::Programs {
|
namespace Tesses::CrossLang::Programs {
|
||||||
@@ -16,7 +36,7 @@ static void Help(std::string &filename) {
|
|||||||
printf(" -n: Set name (MyAppOrLibName defaults to out)\n");
|
printf(" -n: Set name (MyAppOrLibName defaults to out)\n");
|
||||||
printf(" -h, --help: Prints help\n");
|
printf(" -h, --help: Prints help\n");
|
||||||
printf("Options except for help have flag with arg like this: -F ARG\n");
|
printf("Options except for help have flag with arg like this: -F ARG\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CrossArchiveCreate(std::vector<std::string> &argv) {
|
int64_t CrossArchiveCreate(std::vector<std::string> &argv) {
|
||||||
@@ -53,7 +73,7 @@ int64_t CrossArchiveCreate(std::vector<std::string> &argv) {
|
|||||||
printf("Expected "
|
printf("Expected "
|
||||||
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-prod]"
|
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-prod]"
|
||||||
"]]]\n");
|
"]]]\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
namespace Tesses::CrossLang::Programs {
|
namespace Tesses::CrossLang::Programs {
|
||||||
@@ -94,7 +114,7 @@ void CrossLangDump(std::shared_ptr<Tesses::Framework::Streams::Stream> strm) {
|
|||||||
|
|
||||||
uint32_t ents = EnsureInt(strm);
|
uint32_t ents = EnsureInt(strm);
|
||||||
|
|
||||||
for (uint8_t k = 0; k < ents; k++) {
|
for (uint32_t k = 0; k < ents; k++) {
|
||||||
Ensure(strm, main_header, 1);
|
Ensure(strm, main_header, 1);
|
||||||
uint8_t flags = main_header[0];
|
uint8_t flags = main_header[0];
|
||||||
std::cout << "\t\t/^" << strs.at(EnsureInt(strm)) << "^/"
|
std::cout << "\t\t/^" << strs.at(EnsureInt(strm)) << "^/"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Platform/Environment.hpp"
|
#include "TessesFramework/Platform/Environment.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -85,7 +105,7 @@ TObject CrossLangShell(GCList &ls, std::vector<std::string> &argv) {
|
|||||||
"Tesses.CrossLang.ShellPackage-1.0.0.0-prod.crvm";
|
"Tesses.CrossLang.ShellPackage-1.0.0.0-prod.crvm";
|
||||||
if (argv.size() == 2 && argv[1] == "configdir") {
|
if (argv.size() == 2 && argv[1] == "configdir") {
|
||||||
std::cout << dir.ToString() << std::endl;
|
std::cout << dir.ToString() << std::endl;
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
}
|
}
|
||||||
if (argv.size() > 1 && argv[1] == "update-shell") {
|
if (argv.size() > 1 && argv[1] == "update-shell") {
|
||||||
|
|
||||||
@@ -101,15 +121,15 @@ TObject CrossLangShell(GCList &ls, std::vector<std::string> &argv) {
|
|||||||
auto strm = resp.ReadAsStream();
|
auto strm = resp.ReadAsStream();
|
||||||
CrossLang::CrossArchiveExtract(strm, subdir);
|
CrossLang::CrossArchiveExtract(strm, subdir);
|
||||||
|
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Error when fetching the script error: "
|
std::cout << "Error when fetching the script error: "
|
||||||
<< std::to_string(resp.statusCode) << " "
|
<< std::to_string(resp.statusCode) << " "
|
||||||
<< HttpUtils::StatusCodeString(resp.statusCode)
|
<< HttpUtils::StatusCodeString(resp.statusCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return 1;
|
return (int64_t)1;
|
||||||
}
|
}
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Tesses::Framework::Filesystem::LocalFS->RegularFileExists(filename)) {
|
if (!Tesses::Framework::Filesystem::LocalFS->RegularFileExists(filename)) {
|
||||||
@@ -125,12 +145,12 @@ TObject CrossLangShell(GCList &ls, std::vector<std::string> &argv) {
|
|||||||
CrossLang::CrossArchiveExtract(strm, subdir);
|
CrossLang::CrossArchiveExtract(strm, subdir);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return (int64_t)1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Download(filename, subdir))
|
if (!Download(filename, subdir))
|
||||||
return 1;
|
return (int64_t)1;
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -27,7 +47,7 @@ static void Help(std::string filename) {
|
|||||||
"for sane with file access to current directory and sub "
|
"for sane with file access to current directory and sub "
|
||||||
"directories, \"full\" has full runtime.\n");
|
"directories, \"full\" has full runtime.\n");
|
||||||
printf("Options except for help have flag with arg like this: -F ARG\n");
|
printf("Options except for help have flag with arg like this: -F ARG\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
void CrossLangCompiler(std::vector<std::string> &argv) {
|
void CrossLangCompiler(std::vector<std::string> &argv) {
|
||||||
/*std::ifstream strm(argv[1],std::ios_base::in|std::ios_base::binary);
|
/*std::ifstream strm(argv[1],std::ios_base::in|std::ios_base::binary);
|
||||||
@@ -107,14 +127,14 @@ void CrossLangCompiler(std::vector<std::string> &argv) {
|
|||||||
printf("Expected "
|
printf("Expected "
|
||||||
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-"
|
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-"
|
||||||
"prod]]]]\n");
|
"prod]]]]\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
dependencies.push_back(
|
dependencies.push_back(
|
||||||
std::pair<std::string, TVMVersion>(str1, v2));
|
std::pair<std::string, TVMVersion>(str1, v2));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("ERROR: Dependency must have version\n");
|
printf("ERROR: Dependency must have version\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argv[i] == "-t") {
|
} else if (argv[i] == "-t") {
|
||||||
@@ -137,14 +157,14 @@ void CrossLangCompiler(std::vector<std::string> &argv) {
|
|||||||
printf("Expected "
|
printf("Expected "
|
||||||
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-"
|
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-"
|
||||||
"prod]]]]\n");
|
"prod]]]]\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
tools.push_back(
|
tools.push_back(
|
||||||
std::pair<std::string, TVMVersion>(str1, v2));
|
std::pair<std::string, TVMVersion>(str1, v2));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("ERROR: Tool must have version\n");
|
printf("ERROR: Tool must have version\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argv[i] == "-n") {
|
} else if (argv[i] == "-n") {
|
||||||
@@ -161,7 +181,7 @@ void CrossLangCompiler(std::vector<std::string> &argv) {
|
|||||||
printf("Expected "
|
printf("Expected "
|
||||||
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-prod]"
|
"MAJOR[.MINOR[.PATCH[.BUILD[-dev,-alpha,-beta,-prod]"
|
||||||
"]]]\n");
|
"]]]\n");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (argv[i] == "-D" || argv[i] == "--debug") {
|
} else if (argv[i] == "-D" || argv[i] == "--debug") {
|
||||||
@@ -192,7 +212,7 @@ void CrossLangCompiler(std::vector<std::string> &argv) {
|
|||||||
|
|
||||||
if (comptime == "secure") {
|
if (comptime == "secure") {
|
||||||
TStd::RegisterConsole(gc, env);
|
TStd::RegisterConsole(gc, env);
|
||||||
TStd::RegisterClass(gc, env);
|
TStd::RegisterZeClass(gc, env);
|
||||||
TStd::RegisterCrypto(gc, env);
|
TStd::RegisterCrypto(gc, env);
|
||||||
TStd::RegisterDictionary(gc, env);
|
TStd::RegisterDictionary(gc, env);
|
||||||
TStd::RegisterJson(gc, env);
|
TStd::RegisterJson(gc, env);
|
||||||
@@ -201,7 +221,7 @@ void CrossLangCompiler(std::vector<std::string> &argv) {
|
|||||||
env->permissions.locked = true;
|
env->permissions.locked = true;
|
||||||
} else if (comptime == "secure_file") {
|
} else if (comptime == "secure_file") {
|
||||||
TStd::RegisterConsole(gc, env);
|
TStd::RegisterConsole(gc, env);
|
||||||
TStd::RegisterClass(gc, env);
|
TStd::RegisterZeClass(gc, env);
|
||||||
TStd::RegisterCrypto(gc, env);
|
TStd::RegisterCrypto(gc, env);
|
||||||
TStd::RegisterDictionary(gc, env);
|
TStd::RegisterDictionary(gc, env);
|
||||||
TStd::RegisterJson(gc, env);
|
TStd::RegisterJson(gc, env);
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
using namespace Tesses::Framework;
|
using namespace Tesses::Framework;
|
||||||
namespace Tesses::CrossLang::Programs {
|
namespace Tesses::CrossLang::Programs {
|
||||||
@@ -7,7 +27,7 @@ TObject CrossLangVM(GCList &ls, TRootEnvironment *env,
|
|||||||
std::cout << "USAGE: "
|
std::cout << "USAGE: "
|
||||||
<< (argv.empty() ? (std::string) "crossvm" : argv[0])
|
<< (argv.empty() ? (std::string) "crossvm" : argv[0])
|
||||||
<< " <filename.crvm> <args...>" << std::endl;
|
<< " <filename.crvm> <args...>" << std::endl;
|
||||||
return 1;
|
return (int64_t)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
env->LoadFileWithDependencies(
|
env->LoadFileWithDependencies(
|
||||||
@@ -33,7 +53,7 @@ TObject CrossLangVM(GCList &ls, TRootEnvironment *env,
|
|||||||
auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2});
|
auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2});
|
||||||
auto svr2 = Tesses::CrossLang::ToHttpServer(ls.GetGC(), res);
|
auto svr2 = Tesses::CrossLang::ToHttpServer(ls.GetGC(), res);
|
||||||
if (svr2 == nullptr)
|
if (svr2 == nullptr)
|
||||||
return 1;
|
return (int64_t)1;
|
||||||
Tesses::Framework::Http::HttpServer svr(port, svr2);
|
Tesses::Framework::Http::HttpServer svr(port, svr2);
|
||||||
svr.StartAccepting();
|
svr.StartAccepting();
|
||||||
TF_RunEventLoop();
|
TF_RunEventLoop();
|
||||||
@@ -46,7 +66,7 @@ TObject CrossLangVM(GCList &ls, TRootEnvironment *env,
|
|||||||
_co->CallMethod(ls, "", "Close", {});
|
_co->CallMethod(ls, "", "Close", {});
|
||||||
}
|
}
|
||||||
TF_Quit();
|
TF_Quit();
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
} else {
|
} else {
|
||||||
TList *args = TList::Create(ls);
|
TList *args = TList::Create(ls);
|
||||||
for (size_t arg = 1; arg < argv.size(); arg++)
|
for (size_t arg = 1; arg < argv.size(); arg++)
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Filesystem/VFS.hpp"
|
#include "TessesFramework/Filesystem/VFS.hpp"
|
||||||
using namespace Tesses::Framework;
|
using namespace Tesses::Framework;
|
||||||
@@ -162,6 +182,10 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (args[1] == "configdir") {
|
||||||
|
Tesses::Framework::Console::WriteLine(
|
||||||
|
GetCrossLangConfigDir().ToString());
|
||||||
|
return 0;
|
||||||
} else if (args[1] == "vm") {
|
} else if (args[1] == "vm") {
|
||||||
int64_t myi64 = 0;
|
int64_t myi64 = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -190,9 +210,9 @@ static TObject Class_GetInfo(TRootEnvironment *env, GCList &ls,
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
void TStd::RegisterClass(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
void TStd::RegisterZeClass(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
env->permissions.canRegisterClass = true;
|
env->permissions.canRegisterZeClass = true;
|
||||||
TDictionary *cls = env->EnsureDictionary(gc, "Class");
|
TDictionary *cls = env->EnsureDictionary(gc, "Class");
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,39 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#ifndef CROSSLANG_CUSTOM_CONSOLE
|
#ifndef CROSSLANG_CUSTOM_CONSOLE
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
TObject Console_setInvertedColors(GCList &ls, std::vector<TObject> args) {
|
||||||
|
bool inverted;
|
||||||
|
if (GetArgument(args, 0, inverted)) {
|
||||||
|
Tesses::Framework::Console::SetInvertedColors(inverted);
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
TObject Console_Reset(GCList &ls, std::vector<TObject> args) {
|
||||||
|
Tesses::Framework::Console::Reset();
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
TObject Console_getIsTTY(GCList &ls, std::vector<TObject> args) {
|
TObject Console_getIsTTY(GCList &ls, std::vector<TObject> args) {
|
||||||
|
|
||||||
return Tesses::Framework::Console::IsTTY();
|
return Tesses::Framework::Console::IsTTY();
|
||||||
@@ -62,18 +92,21 @@ TObject Console_Write(GCList &ls, std::vector<TObject> args) {
|
|||||||
TObject Console_Fatal(GCList &ls, std::vector<TObject> args) {
|
TObject Console_Fatal(GCList &ls, std::vector<TObject> args) {
|
||||||
if (args.size() < 1) {
|
if (args.size() < 1) {
|
||||||
Tesses::Framework::Console::ErrorLine("FATAL: <NO MESSAGE>");
|
Tesses::Framework::Console::ErrorLine("FATAL: <NO MESSAGE>");
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
Tesses::Framework::Console::ErrorLine("FATAL: " +
|
Tesses::Framework::Console::ErrorLine("FATAL: " +
|
||||||
ToString(ls.GetGC(), args[0]));
|
ToString(ls.GetGC(), args[0]));
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
TObject Console_WriteLine(GCList &ls, std::vector<TObject> args) {
|
TObject Console_WriteLine(GCList &ls, std::vector<TObject> args) {
|
||||||
|
|
||||||
if (args.size() < 1) {
|
if (args.size() < 1) {
|
||||||
Tesses::Framework::Console::WriteLineView("");
|
Tesses::Framework::Console::WriteLineView("");
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
Tesses::Framework::Console::WriteLine(ToString(ls.GetGC(), args[0]));
|
std::string text = ToString(ls.GetGC(), args[0]);
|
||||||
|
|
||||||
|
Tesses::Framework::Console::WriteLine(text);
|
||||||
|
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
@@ -143,7 +176,7 @@ TObject Console_List(GCList &ls, std::vector<TObject> args) {
|
|||||||
|
|
||||||
return (int64_t)Tesses::Framework::Console::List(items);
|
return (int64_t)Tesses::Framework::Console::List(items);
|
||||||
}
|
}
|
||||||
return 0;
|
return (int64_t)0;
|
||||||
}
|
}
|
||||||
void TStd::RegisterConsole(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
void TStd::RegisterConsole(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
||||||
env->permissions.canRegisterConsole = true;
|
env->permissions.canRegisterConsole = true;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
using namespace Tesses::Framework::Crypto;
|
using namespace Tesses::Framework::Crypto;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
using namespace Tesses::Framework::Platform::Environment;
|
using namespace Tesses::Framework::Platform::Environment;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,11 +1,30 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
using namespace Tesses::Framework::Serialization::Json;
|
using namespace Tesses::Framework::Serialization::Json;
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|
||||||
static bool IsValidForJson(TObject v) {
|
static bool IsValidForJson(TObject v) {
|
||||||
if (std::holds_alternative<std::nullptr_t>(v))
|
if (IsNull(v))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (std::holds_alternative<int64_t>(v))
|
if (std::holds_alternative<int64_t>(v))
|
||||||
@@ -20,10 +39,10 @@ static bool IsValidForJson(TObject v) {
|
|||||||
if (std::holds_alternative<std::string>(v))
|
if (std::holds_alternative<std::string>(v))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(v)) {
|
if (std::holds_alternative<THeapObject *>(v)) {
|
||||||
auto res = std::get<THeapObjectHolder>(v);
|
auto res = std::get<THeapObject *>(v);
|
||||||
auto ls = dynamic_cast<TList *>(res.obj);
|
auto ls = dynamic_cast<TList *>(res);
|
||||||
auto dict = dynamic_cast<TDictionary *>(res.obj);
|
auto dict = dynamic_cast<TDictionary *>(res);
|
||||||
if (ls != nullptr)
|
if (ls != nullptr)
|
||||||
return true;
|
return true;
|
||||||
if (dict != nullptr)
|
if (dict != nullptr)
|
||||||
@@ -32,7 +51,7 @@ static bool IsValidForJson(TObject v) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static JToken JsonSerialize(TObject v) {
|
static JToken JsonSerialize(TObject v) {
|
||||||
if (std::holds_alternative<std::nullptr_t>(v))
|
if (IsNull(v))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (std::holds_alternative<int64_t>(v))
|
if (std::holds_alternative<int64_t>(v))
|
||||||
return std::get<int64_t>(v);
|
return std::get<int64_t>(v);
|
||||||
@@ -42,8 +61,8 @@ static JToken JsonSerialize(TObject v) {
|
|||||||
return std::get<bool>(v);
|
return std::get<bool>(v);
|
||||||
if (std::holds_alternative<std::string>(v))
|
if (std::holds_alternative<std::string>(v))
|
||||||
return std::get<std::string>(v);
|
return std::get<std::string>(v);
|
||||||
if (std::holds_alternative<THeapObjectHolder>(v)) {
|
if (std::holds_alternative<THeapObject *>(v)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(v).obj;
|
auto obj = std::get<THeapObject *>(v);
|
||||||
auto ls = dynamic_cast<TList *>(obj);
|
auto ls = dynamic_cast<TList *>(obj);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
@@ -159,7 +178,7 @@ static TObject JsonDocDecode(GCList &ls2, std::vector<TObject> args) {
|
|||||||
std::string Json_Encode(TObject o, bool indent) {
|
std::string Json_Encode(TObject o, bool indent) {
|
||||||
return Json::Encode(JsonSerialize(o), indent);
|
return Json::Encode(JsonSerialize(o), indent);
|
||||||
}
|
}
|
||||||
TObject Json_Decode(GCList ls, std::string str) {
|
TObject Json_Decode(GCList &ls, std::string str) {
|
||||||
return JsonDeserialize(ls, Json::Decode(str));
|
return JsonDeserialize(ls, Json::Decode(str));
|
||||||
}
|
}
|
||||||
std::string Json_DocEncode(TObject o, bool indent) {
|
std::string Json_DocEncode(TObject o, bool indent) {
|
||||||
@@ -169,7 +188,7 @@ std::string Json_DocEncode(TObject o, bool indent) {
|
|||||||
return Json::DocEncode(ls, indent);
|
return Json::DocEncode(ls, indent);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
TObject Json_DocDecode(GCList ls, std::string str) {
|
TObject Json_DocDecode(GCList &ls, std::string str) {
|
||||||
return JsonDeserialize(ls, Json::DocDecode(str));
|
return JsonDeserialize(ls, Json::DocDecode(str));
|
||||||
}
|
}
|
||||||
void TStd::RegisterJson(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
void TStd::RegisterJson(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
||||||
|
|||||||
+396
-21
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <TessesFramework/Crypto/ClientTLSStream.hpp>
|
#include <TessesFramework/Crypto/ClientTLSStream.hpp>
|
||||||
#include <TessesFramework/Http/HttpClient.hpp>
|
#include <TessesFramework/Http/HttpClient.hpp>
|
||||||
@@ -150,6 +170,46 @@ class THttpDictionary : public TNativeObject {
|
|||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
} else if (key == "TryGetOnlyOne") {
|
||||||
|
std::string key;
|
||||||
|
std::string value;
|
||||||
|
if (GetArgument(args, 0, key) && dict->TryGetOnlyOne(key, value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
} else if (key == "TryGetOnlyOneBoolean") {
|
||||||
|
std::string key;
|
||||||
|
bool value;
|
||||||
|
if (GetArgument(args, 0, key) &&
|
||||||
|
dict->TryGetOnlyOneBoolean(key, value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
} else if (key == "TryGetOnlyOneDouble") {
|
||||||
|
std::string key;
|
||||||
|
double value;
|
||||||
|
if (GetArgument(args, 0, key) &&
|
||||||
|
dict->TryGetOnlyOneDouble(key, value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
} else if (key == "TryGetOnlyOneInt") {
|
||||||
|
std::string key;
|
||||||
|
int64_t value;
|
||||||
|
if (GetArgument(args, 0, key) &&
|
||||||
|
dict->TryGetOnlyOneInt(key, value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
} else if (key == "TryGetOnlyOneDate") {
|
||||||
|
std::string key;
|
||||||
|
Tesses::Framework::Date::DateTime value;
|
||||||
|
if (GetArgument(args, 0, key) &&
|
||||||
|
dict->TryGetOnlyOneDate(key, value)) {
|
||||||
|
return std::make_shared<Tesses::Framework::Date::DateTime>(
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
} else if (key == "ToList") {
|
} else if (key == "ToList") {
|
||||||
TList *_ls = TList::Create(ls);
|
TList *_ls = TList::Create(ls);
|
||||||
for (auto item : dict->kvp) {
|
for (auto item : dict->kvp) {
|
||||||
@@ -215,7 +275,7 @@ class TServerContext : public TNativeObjectThatReturnsHttpDictionary {
|
|||||||
else if (key == "getIP")
|
else if (key == "getIP")
|
||||||
return ctx->ip;
|
return ctx->ip;
|
||||||
else if (key == "getPort")
|
else if (key == "getPort")
|
||||||
return ctx->port;
|
return (int64_t)ctx->port;
|
||||||
else if (key == "getOriginalPath")
|
else if (key == "getOriginalPath")
|
||||||
return ctx->originalPath;
|
return ctx->originalPath;
|
||||||
else if (key == "getPath")
|
else if (key == "getPath")
|
||||||
@@ -235,10 +295,13 @@ class TServerContext : public TNativeObjectThatReturnsHttpDictionary {
|
|||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
} else if (key == "getStatusCode")
|
} else if (key == "getStatusCode")
|
||||||
return ctx->statusCode;
|
return (int64_t)ctx->statusCode;
|
||||||
else if (key == "getQueryParams")
|
else if (key == "getQueryParams")
|
||||||
return TNativeObject::Create<THttpDictionary>(ls, &ctx->queryParams,
|
return TNativeObject::Create<THttpDictionary>(ls, &ctx->queryParams,
|
||||||
this);
|
this);
|
||||||
|
else if (key == "getBodyParams")
|
||||||
|
return TNativeObject::Create<THttpDictionary>(ls, &ctx->bodyParams,
|
||||||
|
this);
|
||||||
else if (key == "getRequestHeaders")
|
else if (key == "getRequestHeaders")
|
||||||
return TNativeObject::Create<THttpDictionary>(
|
return TNativeObject::Create<THttpDictionary>(
|
||||||
ls, &ctx->requestHeaders, this);
|
ls, &ctx->requestHeaders, this);
|
||||||
@@ -780,18 +843,20 @@ static TObject Net_Http_ListenOnUnusedPort(GCList &ls,
|
|||||||
static TObject Net_Http_MimeType(GCList &ls, std::vector<TObject> args) {
|
static TObject Net_Http_MimeType(GCList &ls, std::vector<TObject> args) {
|
||||||
Tesses::Framework::Filesystem::VFSPath p;
|
Tesses::Framework::Filesystem::VFSPath p;
|
||||||
if (GetArgumentAsPath(args, 0, p)) {
|
if (GetArgumentAsPath(args, 0, p)) {
|
||||||
std::filesystem::path p2 = p.GetFileName();
|
|
||||||
return HttpUtils::MimeType(p2);
|
return HttpUtils::GetMimeTypePath(p);
|
||||||
}
|
}
|
||||||
return std::string("application/octet-stream");
|
return std::string("application/octet-stream");
|
||||||
}
|
}
|
||||||
class THttpRequestBody : public TNativeObject {
|
class THttpRequestBody : public TNativeObject {
|
||||||
HttpRequestBody *body;
|
std::shared_ptr<HttpRequestBody> body;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
THttpRequestBody(HttpRequestBody *body) { this->body = body; }
|
THttpRequestBody(std::shared_ptr<HttpRequestBody> body) {
|
||||||
|
this->body = body;
|
||||||
|
}
|
||||||
bool IsClosed() { return body == nullptr; }
|
bool IsClosed() { return body == nullptr; }
|
||||||
HttpRequestBody *GetBody() { return this->body; }
|
std::shared_ptr<HttpRequestBody> GetBody() { return this->body; }
|
||||||
|
|
||||||
std::string TypeName() { return "Net.Http.HttpRequestBody"; }
|
std::string TypeName() { return "Net.Http.HttpRequestBody"; }
|
||||||
|
|
||||||
@@ -799,10 +864,7 @@ class THttpRequestBody : public TNativeObject {
|
|||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close() {
|
void Close() { this->body = nullptr; }
|
||||||
delete this->body;
|
|
||||||
this->body = nullptr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class THttpResponse : public TNativeObjectThatReturnsHttpDictionary {
|
class THttpResponse : public TNativeObjectThatReturnsHttpDictionary {
|
||||||
@@ -907,7 +969,8 @@ static TObject Net_Http_MakeRequest(GCList &ls, std::vector<TObject> args,
|
|||||||
_obj = options->GetValue("Body");
|
_obj = options->GetValue("Body");
|
||||||
|
|
||||||
if (GetObjectHeap(_obj, body1)) {
|
if (GetObjectHeap(_obj, body1)) {
|
||||||
req.body = new TDictionaryHttpRequestBody(gc, body1);
|
req.body =
|
||||||
|
std::make_shared<TDictionaryHttpRequestBody>(gc, body1);
|
||||||
} else if (GetObjectHeap(_obj, body2) && !body2->IsClosed()) {
|
} else if (GetObjectHeap(_obj, body2) && !body2->IsClosed()) {
|
||||||
req.body = body2->GetBody();
|
req.body = body2->GetBody();
|
||||||
}
|
}
|
||||||
@@ -920,8 +983,6 @@ static TObject Net_Http_MakeRequest(GCList &ls, std::vector<TObject> args,
|
|||||||
if (req.body != nullptr) {
|
if (req.body != nullptr) {
|
||||||
if (body2 != nullptr) {
|
if (body2 != nullptr) {
|
||||||
body2->Close();
|
body2->Close();
|
||||||
} else if (body1 != nullptr) {
|
|
||||||
delete req.body;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1073,7 +1134,7 @@ static TObject Net_Http_WebSocketClient(GCList &ls, std::vector<TObject> args) {
|
|||||||
if (GetArgument(args, 0, url) && GetArgumentHeap(args, 1, headers) &&
|
if (GetArgument(args, 0, url) && GetArgumentHeap(args, 1, headers) &&
|
||||||
GetArgumentHeap(args, 2, dict)) {
|
GetArgumentHeap(args, 2, dict)) {
|
||||||
GetArgumentHeap(args, 3, callable);
|
GetArgumentHeap(args, 3, callable);
|
||||||
HttpDictionary hdict;
|
HttpDictionary hdict(false);
|
||||||
for (int64_t index = 0; index < headers->Count(); index++) {
|
for (int64_t index = 0; index < headers->Count(); index++) {
|
||||||
_obj = headers->Get(index);
|
_obj = headers->Get(index);
|
||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
@@ -1171,7 +1232,7 @@ static TObject Net_Http_WebSocketClient(GCList &ls, std::vector<TObject> args) {
|
|||||||
if (!GetObjectHeap(hobj, headers))
|
if (!GetObjectHeap(hobj, headers))
|
||||||
return Undefined();
|
return Undefined();
|
||||||
|
|
||||||
HttpDictionary hdict;
|
HttpDictionary hdict(false);
|
||||||
for (int64_t index = 0; index < headers->Count(); index++) {
|
for (int64_t index = 0; index < headers->Count(); index++) {
|
||||||
_obj = headers->Get(index);
|
_obj = headers->Get(index);
|
||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
@@ -1381,7 +1442,7 @@ static TObject New_StreamHttpRequestBody(GCList &ls,
|
|||||||
|
|
||||||
if (GetArgument(args, 0, strm) && GetArgument(args, 1, mimeType)) {
|
if (GetArgument(args, 0, strm) && GetArgument(args, 1, mimeType)) {
|
||||||
return TNativeObject::Create<THttpRequestBody>(
|
return TNativeObject::Create<THttpRequestBody>(
|
||||||
ls, new StreamHttpRequestBody(strm, mimeType));
|
ls, std::make_shared<StreamHttpRequestBody>(strm, mimeType));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -1390,7 +1451,7 @@ static TObject New_TextHttpRequestBody(GCList &ls, std::vector<TObject> args) {
|
|||||||
std::string mimeType;
|
std::string mimeType;
|
||||||
if (GetArgument(args, 0, text) && GetArgument(args, 1, mimeType)) {
|
if (GetArgument(args, 0, text) && GetArgument(args, 1, mimeType)) {
|
||||||
return TNativeObject::Create<THttpRequestBody>(
|
return TNativeObject::Create<THttpRequestBody>(
|
||||||
ls, new TextHttpRequestBody(text, mimeType));
|
ls, std::make_shared<TextHttpRequestBody>(text, mimeType));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -1398,8 +1459,8 @@ static TObject New_JsonHttpRequestBody(GCList &ls, std::vector<TObject> args) {
|
|||||||
|
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
return TNativeObject::Create<THttpRequestBody>(
|
return TNativeObject::Create<THttpRequestBody>(
|
||||||
ls,
|
ls, std::make_shared<TextHttpRequestBody>(Json_Encode(args[0]),
|
||||||
new TextHttpRequestBody(Json_Encode(args[0]), "application/json"));
|
"application/json"));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -1408,6 +1469,315 @@ static TObject New_ServerSentEvents(GCList &ls, std::vector<TObject> args) {
|
|||||||
return std::make_shared<Tesses::Framework::Http::ServerSentEvents>();
|
return std::make_shared<Tesses::Framework::Http::ServerSentEvents>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TAttributeEnumerator : public TEnumerator {
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node;
|
||||||
|
std::unordered_map<
|
||||||
|
std::string, std::optional<std::string>,
|
||||||
|
Tesses::Framework::Serialization::Html::CaseInsensitiveHash,
|
||||||
|
Tesses::Framework::Serialization::Html::CaseInsensitiveEqual>::iterator
|
||||||
|
ittr;
|
||||||
|
bool hasStarted;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TAttributeEnumerator(
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node)
|
||||||
|
: node(node), hasStarted(false) {}
|
||||||
|
bool MoveNext(std::shared_ptr<GC> ls) {
|
||||||
|
if (!node)
|
||||||
|
return false;
|
||||||
|
if (!this->hasStarted) {
|
||||||
|
this->hasStarted = true;
|
||||||
|
this->ittr = this->node->attributes.begin();
|
||||||
|
return !this->node->attributes.empty();
|
||||||
|
} else {
|
||||||
|
this->ittr++;
|
||||||
|
return this->ittr != this->node->attributes.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TObject GetCurrent(GCList &ls) {
|
||||||
|
if (!this->hasStarted)
|
||||||
|
return Undefined();
|
||||||
|
if (this->ittr != this->node->attributes.end()) {
|
||||||
|
ls.GetGC()->BarrierBegin();
|
||||||
|
|
||||||
|
auto kvp = TDictionary::Create(ls);
|
||||||
|
kvp->SetValue("Key", this->ittr->first);
|
||||||
|
kvp->SetValue("Value",
|
||||||
|
this->ittr->second
|
||||||
|
? static_cast<TObject>(this->ittr->second.value())
|
||||||
|
: static_cast<TObject>(nullptr));
|
||||||
|
ls.GetGC()->BarrierEnd();
|
||||||
|
return kvp;
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TAttributeHolder : public TNativeObject {
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TAttributeHolder(
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node)
|
||||||
|
: node(node) {}
|
||||||
|
std::string TypeName() { return "Net.Http.HtmlAttributeList"; }
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args) {
|
||||||
|
if (!node)
|
||||||
|
return Undefined();
|
||||||
|
if (key == "GetAt") {
|
||||||
|
std::string key;
|
||||||
|
if (GetArgument(args, 0, key)) {
|
||||||
|
auto attr = node->attributes.find(key);
|
||||||
|
if (attr != node->attributes.end()) {
|
||||||
|
if (attr->second)
|
||||||
|
return attr->second.value();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "SetAt") {
|
||||||
|
std::string key;
|
||||||
|
if (args.size() == 2 && GetArgument(args, 0, key)) {
|
||||||
|
if (std::holds_alternative<Undefined>(args[1])) {
|
||||||
|
node->attributes.erase(key);
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (IsNull(args[1])) {
|
||||||
|
node->attributes[key] = std::nullopt;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
std::string str;
|
||||||
|
if (GetArgument(args, 1, str)) {
|
||||||
|
node->attributes[key] = str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == "GetEnumerator") {
|
||||||
|
return ls.Create<TAttributeEnumerator>(this->node);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == "ToString") {
|
||||||
|
std::string attr;
|
||||||
|
for (auto &item : node->attributes) {
|
||||||
|
attr += " ";
|
||||||
|
attr += item.first;
|
||||||
|
if (item.second) {
|
||||||
|
attr += "\"";
|
||||||
|
attr += HttpUtils::HtmlEncode(*item.second);
|
||||||
|
attr += "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
class TChildrenEnumerator : public TEnumerator {
|
||||||
|
int64_t index;
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TChildrenEnumerator(
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node)
|
||||||
|
: index(-1), node(node) {}
|
||||||
|
bool MoveNext(std::shared_ptr<GC> ls) {
|
||||||
|
if (!this->node)
|
||||||
|
return false;
|
||||||
|
this->index++;
|
||||||
|
return this->index >= 0 &&
|
||||||
|
static_cast<size_t>(this->index) < this->node->children.size();
|
||||||
|
}
|
||||||
|
TObject GetCurrent(GCList &ls);
|
||||||
|
};
|
||||||
|
class TChildrenHolder : public TNativeObject {
|
||||||
|
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TChildrenHolder(
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node)
|
||||||
|
: node(node) {}
|
||||||
|
std::string TypeName() { return "Net.Http.HtmlChildrenList"; }
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args);
|
||||||
|
};
|
||||||
|
|
||||||
|
class THtmlNode : public TNativeObject {
|
||||||
|
TAttributeHolder *attrHolder;
|
||||||
|
TChildrenHolder *childrenHolder;
|
||||||
|
|
||||||
|
public:
|
||||||
|
THtmlNode(
|
||||||
|
std::shared_ptr<GC> gc,
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node)
|
||||||
|
: node(node) {
|
||||||
|
GCList ls(gc);
|
||||||
|
attrHolder = ls.Create<TAttributeHolder>(node);
|
||||||
|
childrenHolder = ls.Create<TChildrenHolder>(node);
|
||||||
|
}
|
||||||
|
std::shared_ptr<Tesses::Framework::Serialization::Html::HtmlNode> node;
|
||||||
|
std::string TypeName() { return "HtmlNode"; }
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args) {
|
||||||
|
if (!node)
|
||||||
|
return Undefined();
|
||||||
|
if (key == "getInnerText") {
|
||||||
|
return node->InnerText();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == "getAttributes") {
|
||||||
|
return this->attrHolder;
|
||||||
|
}
|
||||||
|
if (key == "getChildren") {
|
||||||
|
return this->childrenHolder;
|
||||||
|
}
|
||||||
|
if (key == "FindNodes") {
|
||||||
|
std::string tag;
|
||||||
|
if (GetArgument(args, 0, tag)) {
|
||||||
|
ls.GetGC()->BarrierBegin();
|
||||||
|
TList *list = ls.Create<TList>();
|
||||||
|
for (auto &item : node->FindNodes(tag)) {
|
||||||
|
auto no = std::const_pointer_cast<
|
||||||
|
Tesses::Framework::Serialization::Html::HtmlNode>(item);
|
||||||
|
list->Add(ls.Create<THtmlNode>(ls.GetGC(), no));
|
||||||
|
}
|
||||||
|
ls.GetGC()->BarrierEnd();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "setIsText") {
|
||||||
|
if (GetArgument(args, 0, node->isText))
|
||||||
|
return node->isText;
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "getIsText") {
|
||||||
|
return node->isText;
|
||||||
|
}
|
||||||
|
if (key == "getText" || key == "getTag" || key == "getTextOrTag") {
|
||||||
|
return node->text_or_tag;
|
||||||
|
}
|
||||||
|
if (key == "setText" || key == "setTag" || key == "setTextOrTag") {
|
||||||
|
if (GetArgument(args, 0, node->text_or_tag))
|
||||||
|
return node->text_or_tag;
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == "ToString") {
|
||||||
|
return node->ToString();
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
void Mark() {
|
||||||
|
if (this->marked)
|
||||||
|
return;
|
||||||
|
this->marked = true;
|
||||||
|
attrHolder->Mark();
|
||||||
|
childrenHolder->Mark();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TObject TChildrenEnumerator::GetCurrent(GCList &ls) {
|
||||||
|
if (!this->node)
|
||||||
|
return nullptr;
|
||||||
|
if (this->index <= -1)
|
||||||
|
return nullptr;
|
||||||
|
if (this->node->children.empty())
|
||||||
|
return nullptr;
|
||||||
|
if (static_cast<size_t>(this->index) >= this->node->children.size())
|
||||||
|
return nullptr;
|
||||||
|
return ls.Create<THtmlNode>(
|
||||||
|
ls.GetGC(), this->node->children[static_cast<size_t>(this->index)]);
|
||||||
|
}
|
||||||
|
TObject TChildrenHolder::CallMethod(GCList &ls, std::string key,
|
||||||
|
std::vector<TObject> args) {
|
||||||
|
if (!this->node)
|
||||||
|
return Undefined();
|
||||||
|
if (key == "Clear") {
|
||||||
|
node->children.clear();
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "getCount" || key == "getLength" || key == "Count" ||
|
||||||
|
key == "Length") {
|
||||||
|
return static_cast<int64_t>(this->node->children.size());
|
||||||
|
}
|
||||||
|
if (key == "GetAt") {
|
||||||
|
int64_t n0;
|
||||||
|
if (GetArgument(args, 0, n0)) {
|
||||||
|
size_t num = static_cast<size_t>(n0);
|
||||||
|
if (num < this->node->children.size()) {
|
||||||
|
return ls.Create<THtmlNode>(ls.GetGC(),
|
||||||
|
this->node->children[num]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "SetAt") {
|
||||||
|
int64_t n0;
|
||||||
|
THtmlNode *htmlNode;
|
||||||
|
if (GetArgument(args, 0, n0) && GetArgumentHeap(args, 1, htmlNode)) {
|
||||||
|
size_t num = static_cast<size_t>(n0);
|
||||||
|
if (num < this->node->children.size() && htmlNode->node) {
|
||||||
|
this->node->children[num] = htmlNode->node;
|
||||||
|
ls.Add(htmlNode);
|
||||||
|
return htmlNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "RemoveAt") {
|
||||||
|
int64_t n0;
|
||||||
|
if (GetArgument(args, 0, n0)) {
|
||||||
|
size_t num = static_cast<size_t>(n0);
|
||||||
|
if (num < this->node->children.size()) {
|
||||||
|
this->node->children.erase(this->node->children.cbegin() + num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "Add") {
|
||||||
|
|
||||||
|
THtmlNode *htmlNode;
|
||||||
|
if (GetArgumentHeap(args, 0, htmlNode) && htmlNode->node) {
|
||||||
|
this->node->children.push_back(htmlNode->node);
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "GetEnumerator") {
|
||||||
|
return ls.Create<TChildrenEnumerator>(this->node);
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
static TObject New_HtmlNode(GCList &ls, std::vector<TObject> args) {
|
||||||
|
|
||||||
|
return ls.Create<THtmlNode>(
|
||||||
|
ls.GetGC(),
|
||||||
|
std::make_shared<Tesses::Framework::Serialization::Html::HtmlNode>());
|
||||||
|
}
|
||||||
|
static TObject Net_Http_ParseHtml(GCList &ls, std::vector<TObject> args) {
|
||||||
|
std::shared_ptr<Tesses::Framework::TextStreams::TextReader> textReader;
|
||||||
|
if (GetArgument(args, 0, textReader)) {
|
||||||
|
return ls.Create<THtmlNode>(
|
||||||
|
ls.GetGC(),
|
||||||
|
Tesses::Framework::Serialization::Html::Parse(textReader));
|
||||||
|
}
|
||||||
|
auto strReader =
|
||||||
|
std::make_shared<Tesses::Framework::TextStreams::StringReader>();
|
||||||
|
if (GetArgument(args, 0, strReader->GetString())) {
|
||||||
|
return ls.Create<THtmlNode>(
|
||||||
|
ls.GetGC(),
|
||||||
|
Tesses::Framework::Serialization::Html::Parse(strReader));
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
||||||
|
|
||||||
env->permissions.canRegisterNet = true;
|
env->permissions.canRegisterNet = true;
|
||||||
@@ -1423,7 +1793,7 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
"Create a text request body", {"text", "mimeType"},
|
"Create a text request body", {"text", "mimeType"},
|
||||||
New_TextHttpRequestBody);
|
New_TextHttpRequestBody);
|
||||||
_new->DeclareFunction(gc, "JsonHttpRequestBody",
|
_new->DeclareFunction(gc, "JsonHttpRequestBody",
|
||||||
"Create a text request body", {"json"},
|
"Create a json request body", {"json"},
|
||||||
New_JsonHttpRequestBody);
|
New_JsonHttpRequestBody);
|
||||||
_new->DeclareFunction(
|
_new->DeclareFunction(
|
||||||
gc, "HttpServer", "Create a http server (allows multiple)",
|
gc, "HttpServer", "Create a http server (allows multiple)",
|
||||||
@@ -1448,6 +1818,8 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
_new->DeclareFunction(gc, "ServerSentEvents",
|
_new->DeclareFunction(gc, "ServerSentEvents",
|
||||||
"Create server sent events object", {""},
|
"Create server sent events object", {""},
|
||||||
New_ServerSentEvents);
|
New_ServerSentEvents);
|
||||||
|
_new->DeclareFunction(gc, "HtmlNode", "Create an html node", {},
|
||||||
|
New_HtmlNode);
|
||||||
|
|
||||||
TDictionary *http = TDictionary::Create(ls);
|
TDictionary *http = TDictionary::Create(ls);
|
||||||
TDictionary *smtp = TDictionary::Create(ls);
|
TDictionary *smtp = TDictionary::Create(ls);
|
||||||
@@ -1533,6 +1905,9 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
gc, "MountableServer",
|
gc, "MountableServer",
|
||||||
"Create a server you can mount to, must mount parents before child",
|
"Create a server you can mount to, must mount parents before child",
|
||||||
{"root"}, New_MountableServer);
|
{"root"}, New_MountableServer);
|
||||||
|
|
||||||
|
http->DeclareFunction(gc, "ParseHtml", "Parse html document",
|
||||||
|
{"strOrTextReader"}, Net_Http_ParseHtml);
|
||||||
dict->DeclareFunction(gc, "NetworkStream", "Create a network stream",
|
dict->DeclareFunction(gc, "NetworkStream", "Create a network stream",
|
||||||
{"ipv6", "datagram"}, New_NetworkStream);
|
{"ipv6", "datagram"}, New_NetworkStream);
|
||||||
smtp->DeclareFunction(gc, "Send", "Send email via smtp server",
|
smtp->DeclareFunction(gc, "Send", "Send email via smtp server",
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
#if defined(GEKKO)
|
#if defined(GEKKO)
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
class ProcessObject : public TNativeObject {
|
class ProcessObject : public TNativeObject {
|
||||||
public:
|
public:
|
||||||
ProcessObject() {
|
|
||||||
arguments = nullptr;
|
|
||||||
environment = nullptr;
|
|
||||||
}
|
|
||||||
ProcessObject(GCList &ls) {
|
ProcessObject(GCList &ls) {
|
||||||
arguments = TList::Create(ls);
|
arguments = TList::Create(ls);
|
||||||
environment = TList::Create(ls);
|
environment = TList::Create(ls);
|
||||||
@@ -167,7 +183,7 @@ static TObject Process_Start(GCList &ls, std::vector<TObject> args,
|
|||||||
TDictionary *dict;
|
TDictionary *dict;
|
||||||
|
|
||||||
if (GetArgumentHeap(args, 0, dict)) {
|
if (GetArgumentHeap(args, 0, dict)) {
|
||||||
auto process = TNativeObject::Create<ProcessObject>(ls);
|
auto process = TNativeObject::Create<ProcessObject>(ls, ls);
|
||||||
auto name = dict->GetValue("FileName");
|
auto name = dict->GetValue("FileName");
|
||||||
auto inh = dict->GetValue("InheritParentEnvironment");
|
auto inh = dict->GetValue("InheritParentEnvironment");
|
||||||
auto rStdIn = dict->GetValue("RedirectStandardInput");
|
auto rStdIn = dict->GetValue("RedirectStandardInput");
|
||||||
@@ -280,6 +296,16 @@ void TStd::RegisterProcess(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
}
|
}
|
||||||
return Undefined();
|
return Undefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dict->DeclareFunction(
|
||||||
|
gc, "ShellFileOrUrl", "Launch file or url in shell", {"urlOrFilename"},
|
||||||
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
|
std::string fileOrUrl;
|
||||||
|
if (GetArgument(args, 0, fileOrUrl))
|
||||||
|
Tesses::Framework::Platform::ShellFileOrUrl(fileOrUrl);
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
});
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
} // namespace Tesses::CrossLang
|
} // namespace Tesses::CrossLang
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <TessesFramework/TessesFrameworkFeatures.h>
|
#include <TessesFramework/TessesFrameworkFeatures.h>
|
||||||
|
|
||||||
|
|||||||
+135
-64
@@ -1,4 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
#include "TessesFramework/Streams/Stream.hpp"
|
#include "TessesFramework/Streams/Stream.hpp"
|
||||||
@@ -6,28 +25,17 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if !defined(CROSSLANG_STATIC)
|
#if !defined(CROSSLANG_STATIC)
|
||||||
#if defined(CROSSLANG_ENABLE_FFI)
|
#if defined(CROSSLANG_ENABLE_FFI)
|
||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
#else
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -42,7 +50,7 @@ std::string SharedExtension = ".dylib";
|
|||||||
std::string SharedExtension = ".so";
|
std::string SharedExtension = ".so";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class TMuxex : public TNativeObject {
|
class TMutex : public TNativeObject {
|
||||||
public:
|
public:
|
||||||
Tesses::Framework::Threading::Mutex mtx;
|
Tesses::Framework::Threading::Mutex mtx;
|
||||||
|
|
||||||
@@ -60,6 +68,33 @@ class TMuxex : public TNativeObject {
|
|||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
class TCond : public TNativeObject {
|
||||||
|
public:
|
||||||
|
Tesses::Framework::Threading::Cond cond;
|
||||||
|
std::string TypeName() { return "Cond"; }
|
||||||
|
|
||||||
|
TObject CallMethod(GCList &ls, std::string key, std::vector<TObject> args) {
|
||||||
|
if (key == "Broadcast") {
|
||||||
|
cond.Broadcast();
|
||||||
|
} else if (key == "Signal") {
|
||||||
|
cond.Signal();
|
||||||
|
} else if (key == "Wait") {
|
||||||
|
TMutex *mtx;
|
||||||
|
if (GetArgumentHeap(args, 0, mtx)) {
|
||||||
|
std::shared_ptr<Tesses::Framework::Date::TimeSpan> ts;
|
||||||
|
int64_t num;
|
||||||
|
if (GetArgument(args, 1, ts)) {
|
||||||
|
if (ts)
|
||||||
|
return cond.Wait(&mtx->mtx, *ts);
|
||||||
|
} else if (GetArgument(args, 1, num)) {
|
||||||
|
return cond.Wait(&mtx->mtx, static_cast<uint32_t>(num));
|
||||||
|
} else
|
||||||
|
cond.Wait(&mtx->mtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#if !defined(CROSSLANG_STATIC)
|
#if !defined(CROSSLANG_STATIC)
|
||||||
class DL {
|
class DL {
|
||||||
@@ -70,15 +105,18 @@ class DL {
|
|||||||
Tesses::Framework::Filesystem::LocalFilesystem lfs;
|
Tesses::Framework::Filesystem::LocalFilesystem lfs;
|
||||||
std::string str = lfs.VFSPathToSystem(p);
|
std::string str = lfs.VFSPathToSystem(p);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
handle =
|
|
||||||
LoadLibraryExA(str.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
throw std::runtime_error("I removed support on this platform");
|
||||||
|
// handle =LoadLibraryExA(str.c_str(), NULL,
|
||||||
|
// LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||||
#else
|
#else
|
||||||
handle = dlopen(str.c_str(), RTLD_LAZY);
|
handle = dlopen(str.c_str(), RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
template <typename T> T Resolve(std::string name) {
|
template <typename T> T Resolve(std::string name) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return (T)GetProcAddress((HMODULE)handle, name.c_str());
|
throw std::runtime_error("I removed support on this platform");
|
||||||
|
// return (T)GetProcAddress((HMODULE)handle, name.c_str());
|
||||||
#else
|
#else
|
||||||
return (T)dlsym(handle, name.c_str());
|
return (T)dlsym(handle, name.c_str());
|
||||||
|
|
||||||
@@ -86,7 +124,9 @@ class DL {
|
|||||||
}
|
}
|
||||||
~DL() {
|
~DL() {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
FreeLibrary((HMODULE)handle);
|
|
||||||
|
throw std::runtime_error("I removed support on this platform");
|
||||||
|
// FreeLibrary((HMODULE)handle);
|
||||||
#else
|
#else
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
#endif
|
#endif
|
||||||
@@ -149,8 +189,8 @@ ffi_tmp_type_t FFI_ConvertTObjectToFFIType(TObject &arg, std::string t) {
|
|||||||
return (ffi_tmp_type_t){
|
return (ffi_tmp_type_t){
|
||||||
.v_ptr = (void *)std::get<std::string>(arg).c_str()};
|
.v_ptr = (void *)std::get<std::string>(arg).c_str()};
|
||||||
}
|
}
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(arg)) {
|
} else if (std::holds_alternative<THeapObject *>(arg)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(arg).obj;
|
auto obj = std::get<THeapObject *>(arg);
|
||||||
auto bA = dynamic_cast<TByteArray *>(obj);
|
auto bA = dynamic_cast<TByteArray *>(obj);
|
||||||
auto nat = dynamic_cast<TNative *>(obj);
|
auto nat = dynamic_cast<TNative *>(obj);
|
||||||
if (bA != nullptr) {
|
if (bA != nullptr) {
|
||||||
@@ -441,13 +481,7 @@ static TObject TypeIsClass(GCList &ls, std::vector<TObject> args) {
|
|||||||
static TObject TypeIsDefined(GCList &ls, std::vector<TObject> args) {
|
static TObject TypeIsDefined(GCList &ls, std::vector<TObject> args) {
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return (!std::holds_alternative<std::nullptr_t>(args[0]) &&
|
return (!IsNull(args[0]) && !std::holds_alternative<Undefined>(args[0]));
|
||||||
!std::holds_alternative<Undefined>(args[0]));
|
|
||||||
}
|
|
||||||
static TObject TypeIsHeap(GCList &ls, std::vector<TObject> args) {
|
|
||||||
if (args.empty())
|
|
||||||
return nullptr;
|
|
||||||
return std::holds_alternative<THeapObjectHolder>(args[0]);
|
|
||||||
}
|
}
|
||||||
static TObject TypeIsNumber(GCList &ls, std::vector<TObject> args) {
|
static TObject TypeIsNumber(GCList &ls, std::vector<TObject> args) {
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
@@ -455,6 +489,7 @@ static TObject TypeIsNumber(GCList &ls, std::vector<TObject> args) {
|
|||||||
return std::holds_alternative<int64_t>(args[0]) ||
|
return std::holds_alternative<int64_t>(args[0]) ||
|
||||||
std::holds_alternative<double>(args[0]);
|
std::holds_alternative<double>(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TObject TypeIsLong(GCList &ls, std::vector<TObject> args) {
|
static TObject TypeIsLong(GCList &ls, std::vector<TObject> args) {
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -550,6 +585,16 @@ static TObject TypeIsQueryable(GCList &ls, std::vector<TObject> args) {
|
|||||||
TQueryable *queryable;
|
TQueryable *queryable;
|
||||||
return GetArgumentHeap(args, 0, queryable);
|
return GetArgumentHeap(args, 0, queryable);
|
||||||
}
|
}
|
||||||
|
static TObject TypeIsException(GCList &ls, std::vector<TObject> args) {
|
||||||
|
TException *ex;
|
||||||
|
TNativeException *nex;
|
||||||
|
return GetArgumentHeap(args, 0, ex) || GetArgumentHeap(args, 0, nex);
|
||||||
|
}
|
||||||
|
static TObject TypeIsNativeException(GCList &ls, std::vector<TObject> args) {
|
||||||
|
|
||||||
|
TNativeException *nex;
|
||||||
|
return GetArgumentHeap(args, 0, nex);
|
||||||
|
}
|
||||||
static TObject New_SubdirFilesystem(GCList &ls, std::vector<TObject> args) {
|
static TObject New_SubdirFilesystem(GCList &ls, std::vector<TObject> args) {
|
||||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
|
||||||
|
|
||||||
@@ -674,7 +719,7 @@ std::string GetObjectTypeString(TObject _obj) {
|
|||||||
return "Regex";
|
return "Regex";
|
||||||
if (std::holds_alternative<Undefined>(_obj))
|
if (std::holds_alternative<Undefined>(_obj))
|
||||||
return "Undefined";
|
return "Undefined";
|
||||||
if (std::holds_alternative<std::nullptr_t>(_obj))
|
if (IsNull(_obj))
|
||||||
return "Null";
|
return "Null";
|
||||||
if (std::holds_alternative<bool>(_obj))
|
if (std::holds_alternative<bool>(_obj))
|
||||||
return "Boolean";
|
return "Boolean";
|
||||||
@@ -826,8 +871,8 @@ std::string GetObjectTypeString(TObject _obj) {
|
|||||||
}
|
}
|
||||||
return "VFS";
|
return "VFS";
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<THeapObjectHolder>(_obj)) {
|
if (std::holds_alternative<THeapObject *>(_obj)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(_obj).obj;
|
auto obj = std::get<THeapObject *>(_obj);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
|
|
||||||
@@ -929,14 +974,10 @@ TObject ParseLong(GCList &ls, std::vector<TObject> args) {
|
|||||||
|
|
||||||
std::string str = ToString(ls.GetGC(), args[0]);
|
std::string str = ToString(ls.GetGC(), args[0]);
|
||||||
|
|
||||||
try {
|
int64_t d;
|
||||||
int64_t v = std::stoll(str, &pos, base);
|
if (Tesses::Framework::Serialization::BitConverter::TryParseSigned(
|
||||||
if (pos < str.size())
|
str, d, base))
|
||||||
return nullptr;
|
return d;
|
||||||
return v;
|
|
||||||
} catch (std::exception &ex) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -948,14 +989,10 @@ TObject ParseDouble(GCList &ls, std::vector<TObject> args) {
|
|||||||
|
|
||||||
std::string str = ToString(ls.GetGC(), args[0]);
|
std::string str = ToString(ls.GetGC(), args[0]);
|
||||||
|
|
||||||
try {
|
double d;
|
||||||
double v = std::stod(str, &pos);
|
if (Tesses::Framework::Serialization::BitConverter::TryParseDouble(str,
|
||||||
if (pos < str.size())
|
d))
|
||||||
return nullptr;
|
return d;
|
||||||
return v;
|
|
||||||
} catch (std::exception &ex) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -1004,11 +1041,7 @@ static TObject YieldEnumerableFunc(GCList &ls, std::vector<TObject> args) {
|
|||||||
static TObject DateTime_Sleep(GCList &ls, std::vector<TObject> args) {
|
static TObject DateTime_Sleep(GCList &ls, std::vector<TObject> args) {
|
||||||
int64_t msec;
|
int64_t msec;
|
||||||
if (GetArgument(args, 0, msec)) {
|
if (GetArgument(args, 0, msec)) {
|
||||||
#if defined(_WIN32)
|
Tesses::Framework::TF_Sleep(msec);
|
||||||
Sleep((int)msec);
|
|
||||||
#else
|
|
||||||
usleep(1000 * msec);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -1228,6 +1261,26 @@ static TObject New_Queryable(GCList &ls, std::vector<TObject> args) {
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
static TObject New_Exception(GCList &ls, std::vector<TObject> args) {
|
||||||
|
// TException(message,$type,$extrafields,$innerException);
|
||||||
|
|
||||||
|
std::string message;
|
||||||
|
|
||||||
|
if (GetArgument(args, 0, message)) {
|
||||||
|
std::string type = "Exception";
|
||||||
|
TDictionary *extraFields = nullptr;
|
||||||
|
TObject innerException = Undefined();
|
||||||
|
GetArgument(args, 1, type);
|
||||||
|
GetArgumentHeap(args, 2, extraFields);
|
||||||
|
if (args.size() > 3)
|
||||||
|
innerException = args[3];
|
||||||
|
|
||||||
|
return ls.Create<TException>(message, type, extraFields,
|
||||||
|
innerException);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
@@ -1390,10 +1443,7 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
env->DeclareFunction(gc, "TypeIsDefined",
|
env->DeclareFunction(gc, "TypeIsDefined",
|
||||||
"Get whether object is not null or undefined",
|
"Get whether object is not null or undefined",
|
||||||
{"object"}, TypeIsDefined);
|
{"object"}, TypeIsDefined);
|
||||||
env->DeclareFunction(
|
|
||||||
gc, "TypeIsHeap",
|
|
||||||
"Get whether object is susceptible to garbage collection", {"object"},
|
|
||||||
TypeIsHeap);
|
|
||||||
env->DeclareFunction(gc, "TypeIsNumber", "Get whether object is a number",
|
env->DeclareFunction(gc, "TypeIsNumber", "Get whether object is a number",
|
||||||
{"object"}, TypeIsNumber);
|
{"object"}, TypeIsNumber);
|
||||||
env->DeclareFunction(gc, "TypeIsLong",
|
env->DeclareFunction(gc, "TypeIsLong",
|
||||||
@@ -1445,7 +1495,13 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
env->DeclareFunction(gc, "TypeIsQueryable",
|
env->DeclareFunction(gc, "TypeIsQueryable",
|
||||||
"Get whether object is a Queryable", {"object"},
|
"Get whether object is a Queryable", {"object"},
|
||||||
TypeIsQueryable);
|
TypeIsQueryable);
|
||||||
|
env->DeclareFunction(
|
||||||
|
gc, "TypeIsException",
|
||||||
|
"Get whether object is either an Exception or a NativeException",
|
||||||
|
{"object"}, TypeIsException);
|
||||||
|
env->DeclareFunction(gc, "TypeIsNativeException",
|
||||||
|
"Get whether object is a NativeException", {"object"},
|
||||||
|
TypeIsNativeException);
|
||||||
newTypes->DeclareFunction(
|
newTypes->DeclareFunction(
|
||||||
gc, "Regex", "Create regex object", {"regex"},
|
gc, "Regex", "Create regex object", {"regex"},
|
||||||
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
@@ -1457,17 +1513,22 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
});
|
});
|
||||||
newTypes->DeclareFunction(
|
newTypes->DeclareFunction(
|
||||||
gc, "Mutex", "Create mutex", {},
|
gc, "Mutex", "Create a mutex", {},
|
||||||
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
return TNativeObject::Create<TMuxex>(ls);
|
return TNativeObject::Create<TMutex>(ls);
|
||||||
|
});
|
||||||
|
newTypes->DeclareFunction(
|
||||||
|
gc, "Cond", "Create a conditional variable", {},
|
||||||
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
|
return TNativeObject::Create<TCond>(ls);
|
||||||
});
|
});
|
||||||
newTypes->DeclareFunction(
|
newTypes->DeclareFunction(
|
||||||
gc, "Thread", "Create thread", {"callback"},
|
gc, "Thread", "Create thread", {"callback"},
|
||||||
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
if (args.size() == 1 &&
|
if (args.size() == 1 &&
|
||||||
std::holds_alternative<THeapObjectHolder>(args[0])) {
|
std::holds_alternative<THeapObject *>(args[0])) {
|
||||||
auto cb = dynamic_cast<TCallable *>(
|
auto cb =
|
||||||
std::get<THeapObjectHolder>(args[0]).obj);
|
dynamic_cast<TCallable *>(std::get<THeapObject *>(args[0]));
|
||||||
if (cb != nullptr) {
|
if (cb != nullptr) {
|
||||||
return CreateThread(ls, cb, false);
|
return CreateThread(ls, cb, false);
|
||||||
}
|
}
|
||||||
@@ -1500,6 +1561,10 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
|
|||||||
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
return TAssociativeArray::Create(ls);
|
return TAssociativeArray::Create(ls);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
newTypes->DeclareFunction(
|
||||||
|
gc, "Exception", "Create an Exception",
|
||||||
|
{"message", "$type", "$extraFields", "$innerException"}, New_Exception);
|
||||||
newTypes->DeclareFunction(
|
newTypes->DeclareFunction(
|
||||||
gc, "ByteArray",
|
gc, "ByteArray",
|
||||||
"Create bytearray, with optional either size (to size it) or string "
|
"Create bytearray, with optional either size (to size it) or string "
|
||||||
@@ -1587,7 +1652,7 @@ void TStd::RegisterStd(
|
|||||||
RegisterCrypto(gc, env);
|
RegisterCrypto(gc, env);
|
||||||
RegisterOGC(gc, env);
|
RegisterOGC(gc, env);
|
||||||
RegisterProcess(gc, env);
|
RegisterProcess(gc, env);
|
||||||
RegisterClass(gc, env);
|
RegisterZeClass(gc, env);
|
||||||
|
|
||||||
gc->RegisterEverything(env);
|
gc->RegisterEverything(env);
|
||||||
|
|
||||||
@@ -1613,7 +1678,13 @@ void TStd::RegisterStd(
|
|||||||
gc_dict->DeclareFunction(
|
gc_dict->DeclareFunction(
|
||||||
gc, "Collect", "Collect garbage", {},
|
gc, "Collect", "Collect garbage", {},
|
||||||
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
[](GCList &ls, std::vector<TObject> args) -> TObject {
|
||||||
ls.GetGC()->Collect();
|
std::vector<THeapObject *> to_delete;
|
||||||
|
ls.GetGC()->BarrierBegin();
|
||||||
|
ls.GetGC()->Collect(to_delete);
|
||||||
|
ls.GetGC()->BarrierEnd();
|
||||||
|
|
||||||
|
for (auto item : to_delete)
|
||||||
|
delete item;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
});
|
});
|
||||||
gc_dict->DeclareFunction(
|
gc_dict->DeclareFunction(
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "TessesFramework/Uuid.hpp"
|
#include "TessesFramework/Uuid.hpp"
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -67,6 +87,8 @@ static TObject VM_SourceToAst(GCList &ls, std::vector<TObject> args) {
|
|||||||
static TObject VM_Eval(GCList &ls, std::vector<TObject> args) {
|
static TObject VM_Eval(GCList &ls, std::vector<TObject> args) {
|
||||||
std::string str;
|
std::string str;
|
||||||
if (GetArgument(args, 0, str)) {
|
if (GetArgument(args, 0, str)) {
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
if (current_function != nullptr) {
|
if (current_function != nullptr) {
|
||||||
return current_function->env->Eval(ls, str);
|
return current_function->env->Eval(ls, str);
|
||||||
}
|
}
|
||||||
@@ -90,6 +112,8 @@ static TObject Success(GCList &ls) {
|
|||||||
}
|
}
|
||||||
static TObject VM_getCurrentEnvironment(GCList &ls2,
|
static TObject VM_getCurrentEnvironment(GCList &ls2,
|
||||||
std::vector<TObject> args) {
|
std::vector<TObject> args) {
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
if (current_function != nullptr)
|
if (current_function != nullptr)
|
||||||
return current_function->env;
|
return current_function->env;
|
||||||
return Undefined();
|
return Undefined();
|
||||||
@@ -261,6 +285,7 @@ static TObject VM_Compile(GCList &ls, std::vector<TObject> args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
static TObject VM_GetStacktrace(GCList &ls, std::vector<TObject> args) {
|
static TObject VM_GetStacktrace(GCList &ls, std::vector<TObject> args) {
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
if (current_function != nullptr) {
|
if (current_function != nullptr) {
|
||||||
if (current_function->thread != nullptr) {
|
if (current_function->thread != nullptr) {
|
||||||
TList *list = TList::Create(ls);
|
TList *list = TList::Create(ls);
|
||||||
|
|||||||
+22
-16
@@ -1,22 +1,28 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
TAny *TAny::Create(GCList &ls) {
|
TAny *TAny::Create(GCList &ls) { return ls.Create<TAny>(); }
|
||||||
TAny *anyObj = new TAny();
|
TAny *TAny::Create(GCList *ls) { return ls->Create<TAny>(); }
|
||||||
|
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
|
||||||
ls.Add(anyObj);
|
|
||||||
gc->Watch(anyObj);
|
|
||||||
return anyObj;
|
|
||||||
}
|
|
||||||
TAny *TAny::Create(GCList *ls) {
|
|
||||||
TAny *anyObj = new TAny();
|
|
||||||
|
|
||||||
std::shared_ptr<GC> gc = ls->GetGC();
|
|
||||||
ls->Add(anyObj);
|
|
||||||
gc->Watch(anyObj);
|
|
||||||
return anyObj;
|
|
||||||
}
|
|
||||||
void TAny::Mark() {
|
void TAny::Mark() {
|
||||||
if (this->marked)
|
if (this->marked)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,20 +1,32 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|
||||||
TAssociativeArray *TAssociativeArray::Create(GCList &ls) {
|
TAssociativeArray *TAssociativeArray::Create(GCList &ls) {
|
||||||
TAssociativeArray *list = new TAssociativeArray();
|
return ls.Create<TAssociativeArray>();
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
TAssociativeArray *TAssociativeArray::Create(GCList *ls) {
|
TAssociativeArray *TAssociativeArray::Create(GCList *ls) {
|
||||||
TAssociativeArray *list = new TAssociativeArray();
|
return ls->Create<TAssociativeArray>();
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
void TAssociativeArray::Set(std::shared_ptr<GC> gc, TObject key,
|
void TAssociativeArray::Set(std::shared_ptr<GC> gc, TObject key,
|
||||||
TObject value) {
|
TObject value) {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
// THANKS TO https://www.youtube.com/watch?v=R-z2Hv-7nxk
|
// THANKS TO https://www.youtube.com/watch?v=R-z2Hv-7nxk
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
+21
-7
@@ -1,12 +1,26 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
std::string TClassObject::TypeName() {
|
std::string TClassObject::TypeName() { return this->name; }
|
||||||
std::string type = "class ";
|
|
||||||
type += this->name;
|
|
||||||
for (auto &item : this->inherit_tree)
|
|
||||||
type += " : " + item;
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
TObject TClassObject::CallMethod(GCList &ls, std::string className,
|
TObject TClassObject::CallMethod(GCList &ls, std::string className,
|
||||||
std::string name, std::vector<TObject> args) {
|
std::string name, std::vector<TObject> args) {
|
||||||
auto value = this->GetValue(className, name);
|
auto value = this->GetValue(className, name);
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
bool TClassEnvironment::HasConstForSet(std::string key) {
|
bool TClassEnvironment::HasConstForSet(std::string key) {
|
||||||
@@ -9,22 +29,12 @@ bool TClassEnvironment::HasConstForSet(std::string key) {
|
|||||||
TClassEnvironment *TClassEnvironment::Create(GCList *gc, TEnvironment *env,
|
TClassEnvironment *TClassEnvironment::Create(GCList *gc, TEnvironment *env,
|
||||||
TClassObject *obj) {
|
TClassObject *obj) {
|
||||||
|
|
||||||
TClassEnvironment *env2 = new TClassEnvironment(env, obj);
|
return gc->Create<TClassEnvironment>(env, obj);
|
||||||
|
|
||||||
std::shared_ptr<GC> _gc = gc->GetGC();
|
|
||||||
gc->Add(env2);
|
|
||||||
_gc->Watch(env2);
|
|
||||||
return env2;
|
|
||||||
}
|
}
|
||||||
TClassEnvironment *TClassEnvironment::Create(GCList &gc, TEnvironment *env,
|
TClassEnvironment *TClassEnvironment::Create(GCList &gc, TEnvironment *env,
|
||||||
TClassObject *obj) {
|
TClassObject *obj) {
|
||||||
|
|
||||||
TClassEnvironment *env2 = new TClassEnvironment(env, obj);
|
return gc.Create<TClassEnvironment>(env, obj);
|
||||||
|
|
||||||
std::shared_ptr<GC> _gc = gc.GetGC();
|
|
||||||
gc.Add(env2);
|
|
||||||
_gc->Watch(env2);
|
|
||||||
return env2;
|
|
||||||
}
|
}
|
||||||
TClassEnvironment::TClassEnvironment(TEnvironment *env, TClassObject *obj) {
|
TClassEnvironment::TClassEnvironment(TEnvironment *env, TClassObject *obj) {
|
||||||
this->env = env;
|
this->env = env;
|
||||||
@@ -33,6 +43,7 @@ TClassEnvironment::TClassEnvironment(TEnvironment *env, TClassObject *obj) {
|
|||||||
bool TClassEnvironment::HasVariable(std::string key) {
|
bool TClassEnvironment::HasVariable(std::string key) {
|
||||||
if (key == "this")
|
if (key == "this")
|
||||||
return true;
|
return true;
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
if (this->clsObj->HasValue(current_function == nullptr
|
if (this->clsObj->HasValue(current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className,
|
: current_function->callable->className,
|
||||||
@@ -49,6 +60,8 @@ bool TClassEnvironment::HasVariableOrFieldRecurse(std::string key,
|
|||||||
bool setting) {
|
bool setting) {
|
||||||
if (key == "this")
|
if (key == "this")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
std::string clsName = current_function == nullptr
|
std::string clsName = current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className;
|
: current_function->callable->className;
|
||||||
@@ -63,6 +76,7 @@ TObject TClassEnvironment::GetVariable(std::string key) {
|
|||||||
if (key == "this")
|
if (key == "this")
|
||||||
return this->clsObj;
|
return this->clsObj;
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
std::string clsName = current_function == nullptr
|
std::string clsName = current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className;
|
: current_function->callable->className;
|
||||||
@@ -75,6 +89,7 @@ void TClassEnvironment::SetVariable(std::string key, TObject value) {
|
|||||||
if (key == "this")
|
if (key == "this")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
std::string clsName = current_function == nullptr
|
std::string clsName = current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className;
|
: current_function->callable->className;
|
||||||
@@ -90,6 +105,7 @@ TObject TClassEnvironment::GetVariable(GCList &ls, std::string key) {
|
|||||||
if (key == "this")
|
if (key == "this")
|
||||||
return this->clsObj;
|
return this->clsObj;
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
std::string clsName = current_function == nullptr
|
std::string clsName = current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className;
|
: current_function->callable->className;
|
||||||
@@ -107,6 +123,7 @@ TObject TClassEnvironment::SetVariable(GCList &ls, std::string key, TObject v) {
|
|||||||
if (key == "this")
|
if (key == "this")
|
||||||
return this->clsObj;
|
return this->clsObj;
|
||||||
|
|
||||||
|
auto current_function = GC::GetCurrentFunction();
|
||||||
std::string clsName = current_function == nullptr
|
std::string clsName = current_function == nullptr
|
||||||
? ""
|
? ""
|
||||||
: current_function->callable->className;
|
: current_function->callable->className;
|
||||||
|
|||||||
+43
-45
@@ -1,27 +1,38 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
TArgWrapper::TArgWrapper(TCallable *callable) : callable(callable) {}
|
||||||
TArgWrapper *TArgWrapper::Create(GCList &ls, TCallable *callable) {
|
TArgWrapper *TArgWrapper::Create(GCList &ls, TCallable *callable) {
|
||||||
TArgWrapper *argWrapper = new TArgWrapper();
|
return ls.Create<TArgWrapper>(callable);
|
||||||
argWrapper->callable = callable;
|
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
|
||||||
ls.Add(argWrapper);
|
|
||||||
gc->Watch(argWrapper);
|
|
||||||
return argWrapper;
|
|
||||||
}
|
}
|
||||||
TArgWrapper *TArgWrapper::Create(GCList *ls, TCallable *callable) {
|
TArgWrapper *TArgWrapper::Create(GCList *ls, TCallable *callable) {
|
||||||
TArgWrapper *argWrapper = new TArgWrapper();
|
return ls->Create<TArgWrapper>(callable);
|
||||||
argWrapper->callable = callable;
|
|
||||||
std::shared_ptr<GC> gc = ls->GetGC();
|
|
||||||
ls->Add(argWrapper);
|
|
||||||
gc->Watch(argWrapper);
|
|
||||||
return argWrapper;
|
|
||||||
}
|
}
|
||||||
TObject TArgWrapper::Call(GCList &ls, std::vector<TObject> args) {
|
TObject TArgWrapper::Call(GCList &ls, std::vector<TObject> args) {
|
||||||
auto cse = current_function;
|
auto cse = GC::GetCurrentFunction();
|
||||||
TList *argList = TList::Create(ls);
|
TList *argList = TList::Create(ls);
|
||||||
argList->items = args;
|
argList->items = args;
|
||||||
TObject v = this->callable->Call(ls, {argList});
|
TObject v = this->callable->Call(ls, {argList});
|
||||||
current_function = cse;
|
GC::SetCurrentFunction(cse);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
void TArgWrapper::Mark() {
|
void TArgWrapper::Mark() {
|
||||||
@@ -46,52 +57,39 @@ void TClosure::Mark() {
|
|||||||
this->closure->Mark();
|
this->closure->Mark();
|
||||||
GC::Mark(this->tag);
|
GC::Mark(this->tag);
|
||||||
}
|
}
|
||||||
TClosure *TClosure::Create(GCList &ls, TEnvironment *env, TFile *file,
|
TClosure::TClosure(TEnvironment *env, TFile *file, uint32_t chunkId,
|
||||||
uint32_t chunkId, bool ownScope) {
|
bool ownScope) {
|
||||||
TClosure *closure = new TClosure();
|
this->className = "";
|
||||||
closure->className = "";
|
this->ownScope = ownScope;
|
||||||
closure->ownScope = ownScope;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
this->chunkId = chunkId;
|
||||||
ls.Add(closure);
|
|
||||||
_gc->Watch(closure);
|
|
||||||
closure->chunkId = chunkId;
|
|
||||||
if (chunkId < file->chunks.size())
|
if (chunkId < file->chunks.size())
|
||||||
closure->closure = file->chunks[chunkId];
|
this->closure = file->chunks[chunkId];
|
||||||
else
|
else
|
||||||
throw VMException("ChunkId out of bounds.");
|
throw VMException("ChunkId out of bounds.");
|
||||||
closure->env = env;
|
this->env = env;
|
||||||
closure->file = file;
|
this->file = file;
|
||||||
|
}
|
||||||
return closure;
|
TClosure *TClosure::Create(GCList &ls, TEnvironment *env, TFile *file,
|
||||||
|
uint32_t chunkId, bool ownScope) {
|
||||||
|
return ls.Create<TClosure>(env, file, chunkId, ownScope);
|
||||||
}
|
}
|
||||||
TClosure *TClosure::Create(GCList *ls, TEnvironment *env, TFile *file,
|
TClosure *TClosure::Create(GCList *ls, TEnvironment *env, TFile *file,
|
||||||
uint32_t chunkId, bool ownScope) {
|
uint32_t chunkId, bool ownScope) {
|
||||||
TClosure *closure = new TClosure();
|
return ls->Create<TClosure>(env, file, chunkId, ownScope);
|
||||||
closure->className = "";
|
|
||||||
closure->ownScope = ownScope;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(closure);
|
|
||||||
_gc->Watch(closure);
|
|
||||||
closure->chunkId = chunkId;
|
|
||||||
if (chunkId < file->chunks.size())
|
|
||||||
closure->closure = file->chunks[chunkId];
|
|
||||||
else
|
|
||||||
throw VMException("ChunkId out of bounds.");
|
|
||||||
closure->env = env;
|
|
||||||
closure->file = file;
|
|
||||||
|
|
||||||
return closure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TObject TClosure::Call(GCList &ls, std::vector<TObject> args) {
|
TObject TClosure::Call(GCList &ls, std::vector<TObject> args) {
|
||||||
auto cse = current_function;
|
auto cse = GC::GetCurrentFunction();
|
||||||
InterperterThread *thrd = InterperterThread::Create(ls);
|
InterperterThread *thrd = InterperterThread::Create(ls);
|
||||||
thrd->AddCallStackEntry(ls, this, args);
|
thrd->AddCallStackEntry(ls, this, args);
|
||||||
|
|
||||||
thrd->Execute(ls.GetGC());
|
thrd->Execute(ls.GetGC());
|
||||||
|
|
||||||
TObject v = thrd->call_stack_entries[0]->Pop(ls);
|
TObject v = thrd->call_stack_entries[0]->Pop(ls);
|
||||||
current_function = cse;
|
GC::SetCurrentFunction(cse);
|
||||||
|
// current_function = cse;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
} // namespace Tesses::CrossLang
|
} // namespace Tesses::CrossLang
|
||||||
+28
-24
@@ -1,24 +1,35 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
TDynamicDictionary::TDynamicDictionary(TCallable *callable) : cb(callable) {}
|
||||||
TDynamicDictionary *TDynamicDictionary::Create(GCList &ls,
|
TDynamicDictionary *TDynamicDictionary::Create(GCList &ls,
|
||||||
TCallable *callable) {
|
TCallable *callable) {
|
||||||
|
|
||||||
TDynamicDictionary *dict = new TDynamicDictionary();
|
return ls.Create<TDynamicDictionary>(callable);
|
||||||
dict->cb = callable;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(dict);
|
|
||||||
_gc->Watch(dict);
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
TDynamicDictionary *TDynamicDictionary::Create(GCList *ls,
|
TDynamicDictionary *TDynamicDictionary::Create(GCList *ls,
|
||||||
TCallable *callable) {
|
TCallable *callable) {
|
||||||
TDynamicDictionary *dict = new TDynamicDictionary();
|
return ls->Create<TDynamicDictionary>(callable);
|
||||||
dict->cb = callable;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(dict);
|
|
||||||
_gc->Watch(dict);
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDynamicDictionary::Mark() {
|
void TDynamicDictionary::Mark() {
|
||||||
@@ -165,8 +176,9 @@ void TDictionary::DeclareFunction(
|
|||||||
TObject TDictionary::GetValue(std::string key) {
|
TObject TDictionary::GetValue(std::string key) {
|
||||||
if (this->items.empty())
|
if (this->items.empty())
|
||||||
return Undefined();
|
return Undefined();
|
||||||
if (this->items.count(key) > 0)
|
auto item = this->items.find(key);
|
||||||
return this->items[key];
|
if (item != this->items.end())
|
||||||
|
return item->second;
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
void TDictionary::SetValue(std::string key, TObject value) {
|
void TDictionary::SetValue(std::string key, TObject value) {
|
||||||
@@ -189,18 +201,10 @@ void TDictionary::Mark() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TDictionary *TDictionary::Create(GCList *gc) {
|
TDictionary *TDictionary::Create(GCList *gc) {
|
||||||
TDictionary *dict = new TDictionary();
|
return gc->Create<TDictionary>();
|
||||||
std::shared_ptr<GC> _gc = gc->GetGC();
|
|
||||||
gc->Add(dict);
|
|
||||||
_gc->Watch(dict);
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
TDictionary *TDictionary::Create(GCList &gc) {
|
TDictionary *TDictionary::Create(GCList &gc) {
|
||||||
TDictionary *dict = new TDictionary();
|
return gc.Create<TDictionary>();
|
||||||
std::shared_ptr<GC> _gc = gc.GetGC();
|
|
||||||
gc.Add(dict);
|
|
||||||
_gc->Watch(dict);
|
|
||||||
return dict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace Tesses::CrossLang
|
}; // namespace Tesses::CrossLang
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
|
namespace Tesses::CrossLang {
|
||||||
|
|
||||||
|
TException::TException(std::string message, std::string type,
|
||||||
|
TDictionary *extraFields, TObject innerException)
|
||||||
|
: message(message), type(type), extraFields(extraFields),
|
||||||
|
innerException(innerException) {}
|
||||||
|
TObject TException::CallMethod(GCList &ls, std::string key,
|
||||||
|
std::vector<TObject> args) {
|
||||||
|
|
||||||
|
if (key == "getMessage" ||
|
||||||
|
key == "getText") // Text is for compatibility reasons
|
||||||
|
return this->message;
|
||||||
|
if (key == "getInnerException")
|
||||||
|
return this->innerException;
|
||||||
|
if (key == "getType")
|
||||||
|
return this->type;
|
||||||
|
if (key == "getLine")
|
||||||
|
return static_cast<int64_t>(this->line.value_or(0));
|
||||||
|
if (key == "getOffset")
|
||||||
|
return static_cast<int64_t>(this->offset.value_or(0));
|
||||||
|
if (key == "getColumn")
|
||||||
|
return static_cast<int64_t>(this->column.value_or(0));
|
||||||
|
if (key == "getFileName")
|
||||||
|
return this->filename.value_or("");
|
||||||
|
|
||||||
|
if (key == "setLine") {
|
||||||
|
int64_t v;
|
||||||
|
if (!this->line && GetArgument(args, 0, v))
|
||||||
|
this->line = static_cast<uint32_t>(v);
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "setColumn") {
|
||||||
|
int64_t v;
|
||||||
|
if (!this->column && GetArgument(args, 0, v))
|
||||||
|
this->column = static_cast<uint32_t>(v);
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "setOffset") {
|
||||||
|
int64_t v;
|
||||||
|
if (!this->offset && GetArgument(args, 0, v))
|
||||||
|
this->offset = static_cast<uint32_t>(v);
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
if (key == "setFileName") {
|
||||||
|
std::string v;
|
||||||
|
if (!this->filename && GetArgument(args, 0, v))
|
||||||
|
this->filename = v;
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == "ToString") {
|
||||||
|
std::string text;
|
||||||
|
text.reserve(this->type.size() + this->message.size() + 3);
|
||||||
|
text.append(this->type);
|
||||||
|
text.append(": ");
|
||||||
|
text.append(this->message);
|
||||||
|
text.push_back('\n');
|
||||||
|
if (this->filename) {
|
||||||
|
auto &filename = *this->filename;
|
||||||
|
text.reserve(text.size() + filename.size() + 4);
|
||||||
|
text.append("At: ");
|
||||||
|
text.append(filename);
|
||||||
|
|
||||||
|
if (this->line) {
|
||||||
|
text.push_back(':');
|
||||||
|
text.append(std::to_string(*this->line));
|
||||||
|
if (this->column) {
|
||||||
|
|
||||||
|
text.push_back(':');
|
||||||
|
text.append(std::to_string(*this->column));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text.push_back('\n');
|
||||||
|
|
||||||
|
if (!this->line && this->column) {
|
||||||
|
text.append("Column: ");
|
||||||
|
text.append(std::to_string(*this->column));
|
||||||
|
text.push_back('\n');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this->line) {
|
||||||
|
text.append("Line: ");
|
||||||
|
text.append(std::to_string(*this->line));
|
||||||
|
text.push_back('\n');
|
||||||
|
}
|
||||||
|
if (this->column) {
|
||||||
|
text.append("Column: ");
|
||||||
|
text.append(std::to_string(*this->column));
|
||||||
|
text.push_back('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->offset) {
|
||||||
|
text.append("Offset: ");
|
||||||
|
text.append(std::to_string(*this->offset));
|
||||||
|
text.push_back('\n');
|
||||||
|
}
|
||||||
|
if (!std::holds_alternative<Undefined>(this->innerException)) {
|
||||||
|
text.append("InnerException:");
|
||||||
|
|
||||||
|
std::string textInner = ToString(ls.GetGC(), this->innerException);
|
||||||
|
|
||||||
|
for (auto item : Tesses::Framework::Http::HttpUtils::SplitString(
|
||||||
|
textInner, "\n")) {
|
||||||
|
if (item.empty()) {
|
||||||
|
text.push_back('\n');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
text.append("\n\t");
|
||||||
|
text.append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
if (extraFields != nullptr) {
|
||||||
|
GCList ls2(ls.GetGC());
|
||||||
|
if (extraFields->MethodExists(ls2, key)) {
|
||||||
|
return extraFields->CallMethod(ls, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key.size() > 3 && key[0] == 'g' && key[1] == 'e' && key[2] == 't') {
|
||||||
|
ls.GetGC()->BarrierBegin();
|
||||||
|
auto val = extraFields->GetValue(key.substr(3));
|
||||||
|
ls.GetGC()->BarrierEnd();
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
std::string TException::TypeName() { return this->type; }
|
||||||
|
bool TException::ToBool() { return true; }
|
||||||
|
void TException::Mark() {
|
||||||
|
if (marked)
|
||||||
|
return;
|
||||||
|
marked = true;
|
||||||
|
|
||||||
|
if (this->extraFields)
|
||||||
|
this->extraFields->Mark();
|
||||||
|
|
||||||
|
GC::Mark(this->innerException);
|
||||||
|
}
|
||||||
|
|
||||||
|
TNativeException::TNativeException(const char *what, std::exception_ptr ptr)
|
||||||
|
: what(what != nullptr ? what : ""), ptr(ptr) {}
|
||||||
|
TObject TNativeException::CallMethod(GCList &ls, std::string key,
|
||||||
|
std::vector<TObject> args) {
|
||||||
|
if (key == "getMessage" || key == "getText")
|
||||||
|
return this->what;
|
||||||
|
if (key == "getType")
|
||||||
|
return "NativeException";
|
||||||
|
|
||||||
|
if (key == "ToString") {
|
||||||
|
return "NativeException: " + this->what;
|
||||||
|
}
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
std::string TNativeException::TypeName() { return "NativeException"; }
|
||||||
|
std::string TNativeException::What() { return this->what; }
|
||||||
|
std::exception_ptr TNativeException::GetPointer() { return this->ptr; }
|
||||||
|
void TNativeException::ThrowIt() { std::rethrow_exception(this->ptr); }
|
||||||
|
} // namespace Tesses::CrossLang
|
||||||
@@ -1,8 +1,28 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
TExternalMethod::TExternalMethod(
|
TExternalMethod::TExternalMethod(
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
|
||||||
std::string documentation, std::vector<std::string> argNames,
|
std::string documentation, std::vector<std::string> argNames,
|
||||||
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
std::function<void()> destroy) {
|
std::function<void()> destroy) {
|
||||||
|
|
||||||
this->cb = cb;
|
this->cb = cb;
|
||||||
@@ -14,43 +34,24 @@ TExternalMethod *TExternalMethod::Create(
|
|||||||
GCList &ls, std::string documentation, std::vector<std::string> argNames,
|
GCList &ls, std::string documentation, std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
std::function<void()> destroy) {
|
std::function<void()> destroy) {
|
||||||
auto gc = ls.GetGC();
|
return ls.Create<TExternalMethod>(documentation, argNames, cb, destroy);
|
||||||
TExternalMethod *method =
|
|
||||||
new TExternalMethod(cb, documentation, argNames, destroy);
|
|
||||||
ls.Add(method);
|
|
||||||
gc->Watch(method);
|
|
||||||
return method;
|
|
||||||
}
|
}
|
||||||
TExternalMethod *TExternalMethod::Create(
|
TExternalMethod *TExternalMethod::Create(
|
||||||
GCList *ls, std::string documentation, std::vector<std::string> argNames,
|
GCList *ls, std::string documentation, std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb,
|
||||||
std::function<void()> destroy) {
|
std::function<void()> destroy) {
|
||||||
auto gc = ls->GetGC();
|
return ls->Create<TExternalMethod>(documentation, argNames, cb, destroy);
|
||||||
TExternalMethod *method =
|
|
||||||
new TExternalMethod(cb, documentation, argNames, destroy);
|
|
||||||
ls->Add(method);
|
|
||||||
gc->Watch(method);
|
|
||||||
return method;
|
|
||||||
}
|
}
|
||||||
TExternalMethod *TExternalMethod::Create(
|
TExternalMethod *TExternalMethod::Create(
|
||||||
GCList &ls, std::string documentation, std::vector<std::string> argNames,
|
GCList &ls, std::string documentation, std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb) {
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb) {
|
||||||
auto gc = ls.GetGC();
|
return ls.Create<TExternalMethod>(documentation, argNames, cb);
|
||||||
TExternalMethod *method =
|
|
||||||
new TExternalMethod(cb, documentation, argNames, []() -> void {});
|
|
||||||
ls.Add(method);
|
|
||||||
gc->Watch(method);
|
|
||||||
return method;
|
|
||||||
}
|
}
|
||||||
TExternalMethod *TExternalMethod::Create(
|
TExternalMethod *TExternalMethod::Create(
|
||||||
GCList *ls, std::string documentation, std::vector<std::string> argNames,
|
GCList *ls, std::string documentation, std::vector<std::string> argNames,
|
||||||
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb) {
|
std::function<TObject(GCList &ls, std::vector<TObject> args)> cb) {
|
||||||
auto gc = ls->GetGC();
|
|
||||||
TExternalMethod *method =
|
return ls->Create<TExternalMethod>(documentation, argNames, cb);
|
||||||
new TExternalMethod(cb, documentation, argNames, []() -> void {});
|
|
||||||
ls->Add(method);
|
|
||||||
gc->Watch(method);
|
|
||||||
return method;
|
|
||||||
}
|
}
|
||||||
TObject TExternalMethod::Call(GCList &ls, std::vector<TObject> args) {
|
TObject TExternalMethod::Call(GCList &ls, std::vector<TObject> args) {
|
||||||
if (cb == nullptr)
|
if (cb == nullptr)
|
||||||
|
|||||||
+56
-115
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -44,28 +64,15 @@ void TYieldEnumerator::Mark() {
|
|||||||
GC::Mark(this->current);
|
GC::Mark(this->current);
|
||||||
GC::Mark(this->enumerator);
|
GC::Mark(this->enumerator);
|
||||||
}
|
}
|
||||||
TYieldEnumerator *TYieldEnumerator::Create(GCList &ls, TObject v) {
|
|
||||||
TYieldEnumerator *yieldEnum = new TYieldEnumerator();
|
|
||||||
yieldEnum->current = nullptr;
|
|
||||||
yieldEnum->hasStarted = false;
|
|
||||||
yieldEnum->enumerator = v;
|
|
||||||
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
TYieldEnumerator::TYieldEnumerator(TObject v)
|
||||||
ls.Add(yieldEnum);
|
: current(nullptr), hasStarted(false), enumerator(v) {}
|
||||||
_gc->Watch(yieldEnum);
|
|
||||||
return yieldEnum;
|
TYieldEnumerator *TYieldEnumerator::Create(GCList &ls, TObject v) {
|
||||||
|
return ls.Create<TYieldEnumerator>(v);
|
||||||
}
|
}
|
||||||
TYieldEnumerator *TYieldEnumerator::Create(GCList *ls, TObject v) {
|
TYieldEnumerator *TYieldEnumerator::Create(GCList *ls, TObject v) {
|
||||||
|
return ls->Create<TYieldEnumerator>(v);
|
||||||
TYieldEnumerator *yieldEnum = new TYieldEnumerator();
|
|
||||||
yieldEnum->current = nullptr;
|
|
||||||
yieldEnum->hasStarted = false;
|
|
||||||
yieldEnum->enumerator = v;
|
|
||||||
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(yieldEnum);
|
|
||||||
_gc->Watch(yieldEnum);
|
|
||||||
return yieldEnum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TCustomEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TCustomEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
@@ -97,21 +104,12 @@ void TCustomEnumerator::Mark() {
|
|||||||
return;
|
return;
|
||||||
this->dict->Mark();
|
this->dict->Mark();
|
||||||
}
|
}
|
||||||
|
TCustomEnumerator::TCustomEnumerator(TDictionary *dict) : dict(dict) {}
|
||||||
TCustomEnumerator *TCustomEnumerator::Create(GCList *ls, TDictionary *dict) {
|
TCustomEnumerator *TCustomEnumerator::Create(GCList *ls, TDictionary *dict) {
|
||||||
TCustomEnumerator *customEnum = new TCustomEnumerator();
|
return ls->Create<TCustomEnumerator>(dict);
|
||||||
customEnum->dict = dict;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(customEnum);
|
|
||||||
_gc->Watch(customEnum);
|
|
||||||
return customEnum;
|
|
||||||
}
|
}
|
||||||
TCustomEnumerator *TCustomEnumerator::Create(GCList &ls, TDictionary *dict) {
|
TCustomEnumerator *TCustomEnumerator::Create(GCList &ls, TDictionary *dict) {
|
||||||
TCustomEnumerator *customEnum = new TCustomEnumerator();
|
return ls.Create<TCustomEnumerator>(dict);
|
||||||
customEnum->dict = dict;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(customEnum);
|
|
||||||
_gc->Watch(customEnum);
|
|
||||||
return customEnum;
|
|
||||||
}
|
}
|
||||||
TEnumerator *TEnumerator::CreateFromObject(GCList &ls, TObject obj) {
|
TEnumerator *TEnumerator::CreateFromObject(GCList &ls, TObject obj) {
|
||||||
std::string str;
|
std::string str;
|
||||||
@@ -141,23 +139,16 @@ TEnumerator *TEnumerator::CreateFromObject(GCList &ls, TObject obj) {
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
TVFSPathEnumerator::TVFSPathEnumerator(
|
||||||
|
Tesses::Framework::Filesystem::VFSPathEnumerator enumerator)
|
||||||
|
: enumerator(enumerator) {}
|
||||||
TVFSPathEnumerator *TVFSPathEnumerator::Create(
|
TVFSPathEnumerator *TVFSPathEnumerator::Create(
|
||||||
GCList &ls, Tesses::Framework::Filesystem::VFSPathEnumerator enumerator) {
|
GCList &ls, Tesses::Framework::Filesystem::VFSPathEnumerator enumerator) {
|
||||||
TVFSPathEnumerator *vfspathe = new TVFSPathEnumerator();
|
return ls.Create<TVFSPathEnumerator>(enumerator);
|
||||||
vfspathe->enumerator = enumerator;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(vfspathe);
|
|
||||||
_gc->Watch(vfspathe);
|
|
||||||
return vfspathe;
|
|
||||||
}
|
}
|
||||||
TVFSPathEnumerator *TVFSPathEnumerator::Create(
|
TVFSPathEnumerator *TVFSPathEnumerator::Create(
|
||||||
GCList *ls, Tesses::Framework::Filesystem::VFSPathEnumerator enumerator) {
|
GCList *ls, Tesses::Framework::Filesystem::VFSPathEnumerator enumerator) {
|
||||||
TVFSPathEnumerator *vfspathe = new TVFSPathEnumerator();
|
return ls->Create<TVFSPathEnumerator>(enumerator);
|
||||||
vfspathe->enumerator = enumerator;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(vfspathe);
|
|
||||||
_gc->Watch(vfspathe);
|
|
||||||
return vfspathe;
|
|
||||||
}
|
}
|
||||||
bool TVFSPathEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TVFSPathEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
return enumerator.MoveNext();
|
return enumerator.MoveNext();
|
||||||
@@ -165,25 +156,15 @@ bool TVFSPathEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
|||||||
TObject TVFSPathEnumerator::GetCurrent(GCList &ls) {
|
TObject TVFSPathEnumerator::GetCurrent(GCList &ls) {
|
||||||
return enumerator.Current;
|
return enumerator.Current;
|
||||||
}
|
}
|
||||||
|
TDictionaryEnumerator::TDictionaryEnumerator(TDictionary *dict)
|
||||||
|
: dict(dict), hasStarted(false) {}
|
||||||
TDictionaryEnumerator *TDictionaryEnumerator::Create(GCList &ls,
|
TDictionaryEnumerator *TDictionaryEnumerator::Create(GCList &ls,
|
||||||
TDictionary *dict) {
|
TDictionary *dict) {
|
||||||
TDictionaryEnumerator *dicte = new TDictionaryEnumerator();
|
return ls.Create<TDictionaryEnumerator>(dict);
|
||||||
dicte->dict = dict;
|
|
||||||
dicte->hasStarted = false;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(dicte);
|
|
||||||
_gc->Watch(dicte);
|
|
||||||
return dicte;
|
|
||||||
}
|
}
|
||||||
TDictionaryEnumerator *TDictionaryEnumerator::Create(GCList *ls,
|
TDictionaryEnumerator *TDictionaryEnumerator::Create(GCList *ls,
|
||||||
TDictionary *dict) {
|
TDictionary *dict) {
|
||||||
TDictionaryEnumerator *dicte = new TDictionaryEnumerator();
|
return ls->Create<TDictionaryEnumerator>(dict);
|
||||||
dicte->dict = dict;
|
|
||||||
dicte->hasStarted = false;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(dicte);
|
|
||||||
_gc->Watch(dicte);
|
|
||||||
return dicte;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDictionaryEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TDictionaryEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
@@ -217,24 +198,13 @@ void TDictionaryEnumerator::Mark() {
|
|||||||
this->marked = true;
|
this->marked = true;
|
||||||
this->dict->Mark();
|
this->dict->Mark();
|
||||||
}
|
}
|
||||||
|
TListEnumerator::TListEnumerator(TList *list) : ls(list), index(-1) {}
|
||||||
|
|
||||||
TListEnumerator *TListEnumerator::Create(GCList &ls, TList *list) {
|
TListEnumerator *TListEnumerator::Create(GCList &ls, TList *list) {
|
||||||
TListEnumerator *liste = new TListEnumerator();
|
return ls.Create<TListEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
TListEnumerator *TListEnumerator::Create(GCList *ls, TList *list) {
|
TListEnumerator *TListEnumerator::Create(GCList *ls, TList *list) {
|
||||||
TListEnumerator *liste = new TListEnumerator();
|
return ls->Create<TListEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
bool TListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
this->index++;
|
this->index++;
|
||||||
@@ -242,7 +212,7 @@ bool TListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
|||||||
}
|
}
|
||||||
TObject TListEnumerator::GetCurrent(GCList &ls) {
|
TObject TListEnumerator::GetCurrent(GCList &ls) {
|
||||||
|
|
||||||
if (this->index < -1)
|
if (this->index <= -1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (this->ls->Count() == 0)
|
if (this->ls->Count() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -260,25 +230,17 @@ void TListEnumerator::Mark() {
|
|||||||
this->ls->Mark();
|
this->ls->Mark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAssociativeArrayEnumerator::TAssociativeArrayEnumerator(
|
||||||
|
TAssociativeArray *list)
|
||||||
|
: ls(list), index(-1) {}
|
||||||
|
|
||||||
TAssociativeArrayEnumerator *
|
TAssociativeArrayEnumerator *
|
||||||
TAssociativeArrayEnumerator::Create(GCList &ls, TAssociativeArray *list) {
|
TAssociativeArrayEnumerator::Create(GCList &ls, TAssociativeArray *list) {
|
||||||
TAssociativeArrayEnumerator *liste = new TAssociativeArrayEnumerator();
|
return ls.Create<TAssociativeArrayEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
TAssociativeArrayEnumerator *
|
TAssociativeArrayEnumerator *
|
||||||
TAssociativeArrayEnumerator::Create(GCList *ls, TAssociativeArray *list) {
|
TAssociativeArrayEnumerator::Create(GCList *ls, TAssociativeArray *list) {
|
||||||
TAssociativeArrayEnumerator *liste = new TAssociativeArrayEnumerator();
|
return ls->Create<TAssociativeArrayEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
bool TAssociativeArrayEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TAssociativeArrayEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
this->index++;
|
this->index++;
|
||||||
@@ -305,26 +267,16 @@ void TAssociativeArrayEnumerator::Mark() {
|
|||||||
this->marked = true;
|
this->marked = true;
|
||||||
this->ls->Mark();
|
this->ls->Mark();
|
||||||
}
|
}
|
||||||
|
TDynamicListEnumerator::TDynamicListEnumerator(TDynamicList *list)
|
||||||
|
: ls(list), index(-1) {}
|
||||||
|
|
||||||
TDynamicListEnumerator *TDynamicListEnumerator::Create(GCList &ls,
|
TDynamicListEnumerator *TDynamicListEnumerator::Create(GCList &ls,
|
||||||
TDynamicList *list) {
|
TDynamicList *list) {
|
||||||
TDynamicListEnumerator *liste = new TDynamicListEnumerator();
|
return ls.Create<TDynamicListEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
TDynamicListEnumerator *TDynamicListEnumerator::Create(GCList *ls,
|
TDynamicListEnumerator *TDynamicListEnumerator::Create(GCList *ls,
|
||||||
TDynamicList *list) {
|
TDynamicList *list) {
|
||||||
TDynamicListEnumerator *liste = new TDynamicListEnumerator();
|
return ls->Create<TDynamicListEnumerator>(list);
|
||||||
liste->ls = list;
|
|
||||||
liste->index = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(liste);
|
|
||||||
_gc->Watch(liste);
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
bool TDynamicListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TDynamicListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
this->index++;
|
this->index++;
|
||||||
@@ -351,24 +303,13 @@ void TDynamicListEnumerator::Mark() {
|
|||||||
this->marked = true;
|
this->marked = true;
|
||||||
this->ls->Mark();
|
this->ls->Mark();
|
||||||
}
|
}
|
||||||
|
TStringEnumerator::TStringEnumerator(std::string str)
|
||||||
|
: str(str), hasStarted(false) {}
|
||||||
TStringEnumerator *TStringEnumerator::Create(GCList &ls, std::string str) {
|
TStringEnumerator *TStringEnumerator::Create(GCList &ls, std::string str) {
|
||||||
TStringEnumerator *stre = new TStringEnumerator();
|
return ls.Create<TStringEnumerator>(str);
|
||||||
stre->str = str;
|
|
||||||
stre->hasStarted = false;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(stre);
|
|
||||||
_gc->Watch(stre);
|
|
||||||
return stre;
|
|
||||||
}
|
}
|
||||||
TStringEnumerator *TStringEnumerator::Create(GCList *ls, std::string str) {
|
TStringEnumerator *TStringEnumerator::Create(GCList *ls, std::string str) {
|
||||||
TStringEnumerator *stre = new TStringEnumerator();
|
return ls->Create<TStringEnumerator>(str);
|
||||||
stre->str = str;
|
|
||||||
stre->hasStarted = false;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(stre);
|
|
||||||
_gc->Watch(stre);
|
|
||||||
return stre;
|
|
||||||
}
|
}
|
||||||
bool TStringEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
bool TStringEnumerator::MoveNext(std::shared_ptr<GC> ls) {
|
||||||
if (!this->hasStarted) {
|
if (!this->hasStarted) {
|
||||||
|
|||||||
+28
-41
@@ -1,20 +1,31 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
TDynamicList::TDynamicList(TCallable *callable) : cb(callable) {}
|
||||||
TDynamicList *TDynamicList::Create(GCList &ls, TCallable *callable) {
|
TDynamicList *TDynamicList::Create(GCList &ls, TCallable *callable) {
|
||||||
TDynamicList *list = new TDynamicList();
|
return ls.Create<TDynamicList>(callable);
|
||||||
list->cb = callable;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
TDynamicList *TDynamicList::Create(GCList *ls, TCallable *callable) {
|
TDynamicList *TDynamicList::Create(GCList *ls, TCallable *callable) {
|
||||||
TDynamicList *list = new TDynamicList();
|
return ls->Create<TDynamicList>(callable);
|
||||||
list->cb = callable;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDynamicList::Mark() {
|
void TDynamicList::Mark() {
|
||||||
@@ -120,35 +131,11 @@ TObject TDynamicList::SetAt(GCList &ls, int64_t index, TObject val) {
|
|||||||
|
|
||||||
TDynamicList::~TDynamicList() {}
|
TDynamicList::~TDynamicList() {}
|
||||||
|
|
||||||
TByteArray *TByteArray::Create(GCList &ls) {
|
TByteArray *TByteArray::Create(GCList &ls) { return ls.Create<TByteArray>(); }
|
||||||
TByteArray *arr = new TByteArray();
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(arr);
|
|
||||||
_gc->Watch(arr);
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
TByteArray *TByteArray::Create(GCList *ls) {
|
TByteArray *TByteArray::Create(GCList *ls) { return ls->Create<TByteArray>(); }
|
||||||
TByteArray *arr = new TByteArray();
|
TList *TList::Create(GCList *gc) { return gc->Create<TList>(); }
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
TList *TList::Create(GCList &gc) { return gc.Create<TList>(); }
|
||||||
ls->Add(arr);
|
|
||||||
_gc->Watch(arr);
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
TList *TList::Create(GCList *gc) {
|
|
||||||
TList *list = new TList();
|
|
||||||
std::shared_ptr<GC> _gc = gc->GetGC();
|
|
||||||
gc->Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
TList *TList::Create(GCList &gc) {
|
|
||||||
TList *list = new TList();
|
|
||||||
std::shared_ptr<GC> _gc = gc.GetGC();
|
|
||||||
gc.Add(list);
|
|
||||||
_gc->Watch(list);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
void TList::Add(TObject value) { this->items.push_back(value); }
|
void TList::Add(TObject value) { this->items.push_back(value); }
|
||||||
void TList::Set(int64_t index, TObject value) {
|
void TList::Set(int64_t index, TObject value) {
|
||||||
if (index >= 0 && index < this->Count()) {
|
if (index >= 0 && index < this->Count()) {
|
||||||
@@ -161,7 +148,7 @@ TObject TList::Get(int64_t index) {
|
|||||||
}
|
}
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
int64_t TList::Count() { return (int64_t)this->items.size(); }
|
int64_t TList::Count() { return this->items.size(); }
|
||||||
void TList::Insert(int64_t index, TObject value) {
|
void TList::Insert(int64_t index, TObject value) {
|
||||||
if (index >= 0 && index <= this->Count()) {
|
if (index >= 0 && index <= this->Count()) {
|
||||||
this->items.insert(this->items.begin() + index, value);
|
this->items.insert(this->items.begin() + index, value);
|
||||||
|
|||||||
+24
-13
@@ -1,7 +1,26 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
TNativeObject::~TNativeObject() {}
|
|
||||||
|
|
||||||
TNative::TNative(void *ptr, std::function<void(void *)> destroy) {
|
TNative::TNative(void *ptr, std::function<void(void *)> destroy) {
|
||||||
this->ptr = ptr;
|
this->ptr = ptr;
|
||||||
@@ -27,26 +46,18 @@ void TNative::Destroy() {
|
|||||||
}
|
}
|
||||||
bool TNativeObject::ToBool() { return true; }
|
bool TNativeObject::ToBool() { return true; }
|
||||||
bool TNativeObject::Equals(std::shared_ptr<GC> gc, TObject right) {
|
bool TNativeObject::Equals(std::shared_ptr<GC> gc, TObject right) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(right)) {
|
if (std::holds_alternative<THeapObject *>(right)) {
|
||||||
return this == std::get<THeapObjectHolder>(right).obj;
|
return this == std::get<THeapObject *>(right);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TNative *TNative::Create(GCList &ls, void *ptr,
|
TNative *TNative::Create(GCList &ls, void *ptr,
|
||||||
std::function<void(void *)> destroy) {
|
std::function<void(void *)> destroy) {
|
||||||
TNative *native = new TNative(ptr, destroy);
|
return ls.Create<TNative>(ptr, destroy);
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
|
||||||
ls.Add(native);
|
|
||||||
gc->Watch(native);
|
|
||||||
return native;
|
|
||||||
}
|
}
|
||||||
TNative *TNative::Create(GCList *ls, void *ptr,
|
TNative *TNative::Create(GCList *ls, void *ptr,
|
||||||
std::function<void(void *)> destroy) {
|
std::function<void(void *)> destroy) {
|
||||||
TNative *native = new TNative(ptr, destroy);
|
return ls->Create<TNative>(ptr, destroy);
|
||||||
std::shared_ptr<GC> gc = ls->GetGC();
|
|
||||||
ls->Add(native);
|
|
||||||
gc->Watch(native);
|
|
||||||
return native;
|
|
||||||
}
|
}
|
||||||
TNative::~TNative() { this->Destroy(); }
|
TNative::~TNative() { this->Destroy(); }
|
||||||
|
|
||||||
|
|||||||
+22
-10
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -41,19 +61,11 @@ TList *TQueryable::ToList(GCList &ls) {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
TQueryable *TQueryable::Create(GCList &ls, TObject parent) {
|
TQueryable *TQueryable::Create(GCList &ls, TObject parent) {
|
||||||
TQueryable *queryable = new TQueryable(parent);
|
return ls.Create<TQueryable>(parent);
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
|
||||||
ls.Add(queryable);
|
|
||||||
gc->Watch(queryable);
|
|
||||||
return queryable;
|
|
||||||
}
|
}
|
||||||
TQueryable *TQueryable::Create(GCList &ls, TObject parent, TQueryableMode mode,
|
TQueryable *TQueryable::Create(GCList &ls, TObject parent, TQueryableMode mode,
|
||||||
std::vector<TObject> args) {
|
std::vector<TObject> args) {
|
||||||
TQueryable *queryable = new TQueryable(parent, mode, args);
|
return ls.Create<TQueryable>(parent, mode, args);
|
||||||
std::shared_ptr<GC> gc = ls.GetGC();
|
|
||||||
ls.Add(queryable);
|
|
||||||
gc->Watch(queryable);
|
|
||||||
return queryable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TQueryable::Mark() {
|
void TQueryable::Mark() {
|
||||||
|
|||||||
+26
-2
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -16,8 +36,12 @@ TObject TRandom::CallMethod(GCList &ls, std::string name,
|
|||||||
|
|
||||||
return (int64_t)random.Next((uint32_t)first);
|
return (int64_t)random.Next((uint32_t)first);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
return random.Next();
|
uint64_t num = random.Next();
|
||||||
|
int64_t val2 = 0;
|
||||||
|
memcpy(&val2, &num, sizeof(int64_t));
|
||||||
|
return val2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == "NextByte") {
|
if (name == "NextByte") {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -9,12 +29,11 @@ void ThrowConstError(std::string key) {
|
|||||||
|
|
||||||
void TEnvironment::DeclareConstVariable(std::string key, TObject value) {
|
void TEnvironment::DeclareConstVariable(std::string key, TObject value) {
|
||||||
this->DeclareVariable(key, value);
|
this->DeclareVariable(key, value);
|
||||||
this->consts.push_back(key);
|
this->decls[key] = TEnvironmentDeclType::TEDT_CONST;
|
||||||
}
|
}
|
||||||
bool TEnvironment::HasConstForDeclare(std::string key) {
|
bool TEnvironment::HasConstForDeclare(std::string key) {
|
||||||
for (auto item : this->consts)
|
if (this->decls.count(key) > 0)
|
||||||
if (item == key)
|
return this->decls[key] == TEnvironmentDeclType::TEDT_CONST;
|
||||||
return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool TEnvironment::HasConstForSet(std::string key) {
|
bool TEnvironment::HasConstForSet(std::string key) {
|
||||||
@@ -172,9 +191,8 @@ void TEnvironment::DeclareVariable(std::shared_ptr<GC> gc,
|
|||||||
|
|
||||||
TObject v = this->GetVariable(name[0]);
|
TObject v = this->GetVariable(name[0]);
|
||||||
TDictionary *dict = nullptr;
|
TDictionary *dict = nullptr;
|
||||||
if (std::holds_alternative<THeapObjectHolder>(v)) {
|
if (std::holds_alternative<THeapObject *>(v)) {
|
||||||
dict =
|
dict = dynamic_cast<TDictionary *>(std::get<THeapObject *>(v));
|
||||||
dynamic_cast<TDictionary *>(std::get<THeapObjectHolder>(v).obj);
|
|
||||||
if (dict == nullptr) {
|
if (dict == nullptr) {
|
||||||
dict = TDictionary::Create(ls);
|
dict = TDictionary::Create(ls);
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
@@ -192,9 +210,9 @@ void TEnvironment::DeclareVariable(std::shared_ptr<GC> gc,
|
|||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
auto v = dict->GetValue(name[i]);
|
auto v = dict->GetValue(name[i]);
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
if (std::holds_alternative<THeapObjectHolder>(v)) {
|
if (std::holds_alternative<THeapObject *>(v)) {
|
||||||
auto dict2 = dynamic_cast<TDictionary *>(
|
auto dict2 =
|
||||||
std::get<THeapObjectHolder>(v).obj);
|
dynamic_cast<TDictionary *>(std::get<THeapObject *>(v));
|
||||||
if (dict2 == nullptr) {
|
if (dict2 == nullptr) {
|
||||||
dict2 = TDictionary::Create(ls);
|
dict2 = TDictionary::Create(ls);
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
@@ -308,13 +326,15 @@ void TRootEnvironment::SetVariable(std::string key, TObject value) {
|
|||||||
this->dict->SetValue(key, value);
|
this->dict->SetValue(key, value);
|
||||||
}
|
}
|
||||||
void TRootEnvironment::DeclareVariable(std::string key, TObject value) {
|
void TRootEnvironment::DeclareVariable(std::string key, TObject value) {
|
||||||
|
if (this->decls.count(key) == 0)
|
||||||
|
this->decls[key] = TEnvironmentDeclType::TEDT_VAR;
|
||||||
return this->dict->SetValue(key, value);
|
return this->dict->SetValue(key, value);
|
||||||
}
|
}
|
||||||
bool TRootEnvironment::HasVariable(std::string key) {
|
bool TRootEnvironment::HasVariable(std::string key) {
|
||||||
return this->dict->HasValue(key);
|
return this->dict->HasValue(key) || this->decls.count(key) > 0;
|
||||||
}
|
}
|
||||||
bool TRootEnvironment::HasVariableRecurse(std::string key) {
|
bool TRootEnvironment::HasVariableRecurse(std::string key) {
|
||||||
return this->dict->HasValue(key);
|
return this->dict->HasValue(key) || this->decls.count(key) > 0;
|
||||||
}
|
}
|
||||||
TEnvironment *TRootEnvironment::GetParentEnvironment() { return this; }
|
TEnvironment *TRootEnvironment::GetParentEnvironment() { return this; }
|
||||||
TRootEnvironment *TRootEnvironment::GetRootEnvironment() { return this; }
|
TRootEnvironment *TRootEnvironment::GetRootEnvironment() { return this; }
|
||||||
@@ -338,18 +358,10 @@ void TRootEnvironment::Mark() {
|
|||||||
cls.first->Mark();
|
cls.first->Mark();
|
||||||
}
|
}
|
||||||
TRootEnvironment *TRootEnvironment::Create(GCList *gc, TDictionary *dict) {
|
TRootEnvironment *TRootEnvironment::Create(GCList *gc, TDictionary *dict) {
|
||||||
TRootEnvironment *env = new TRootEnvironment(dict);
|
return gc->Create<TRootEnvironment>(dict);
|
||||||
std::shared_ptr<GC> _gc = gc->GetGC();
|
|
||||||
gc->Add(env);
|
|
||||||
_gc->Watch(env);
|
|
||||||
return env;
|
|
||||||
}
|
}
|
||||||
TRootEnvironment *TRootEnvironment::Create(GCList &gc, TDictionary *dict) {
|
TRootEnvironment *TRootEnvironment::Create(GCList &gc, TDictionary *dict) {
|
||||||
TRootEnvironment *env = new TRootEnvironment(dict);
|
return gc.Create<TRootEnvironment>(dict);
|
||||||
std::shared_ptr<GC> _gc = gc.GetGC();
|
|
||||||
gc.Add(env);
|
|
||||||
_gc->Watch(env);
|
|
||||||
return env;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TRootEnvironment::HandleException(std::shared_ptr<GC> gc,
|
bool TRootEnvironment::HandleException(std::shared_ptr<GC> gc,
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -82,16 +102,24 @@ TObject TSubEnvironment::GetVariable(std::string key) {
|
|||||||
if (this->dict->HasValue(key)) {
|
if (this->dict->HasValue(key)) {
|
||||||
return this->dict->GetValue(key);
|
return this->dict->GetValue(key);
|
||||||
}
|
}
|
||||||
|
if (this->decls.count(key) > 0 &&
|
||||||
|
this->decls[key] == TEnvironmentDeclType::TEDT_VAR) {
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
if (this->env->HasVariableRecurse(key)) {
|
if (this->env->HasVariableRecurse(key)) {
|
||||||
return this->env->GetVariable(key);
|
return this->env->GetVariable(key);
|
||||||
}
|
}
|
||||||
return Undefined();
|
return Undefined();
|
||||||
}
|
}
|
||||||
void TSubEnvironment::DeclareVariable(std::string key, TObject value) {
|
void TSubEnvironment::DeclareVariable(std::string key, TObject value) {
|
||||||
|
if (this->decls.count(key) == 0)
|
||||||
|
this->decls[key] = TEnvironmentDeclType::TEDT_VAR;
|
||||||
|
|
||||||
this->dict->SetValue(key, value);
|
this->dict->SetValue(key, value);
|
||||||
}
|
}
|
||||||
void TSubEnvironment::SetVariable(std::string key, TObject value) {
|
void TSubEnvironment::SetVariable(std::string key, TObject value) {
|
||||||
if (this->dict->HasValue(key)) {
|
|
||||||
|
if (this->dict->HasValue(key) || this->decls.count(key) > 0) {
|
||||||
this->dict->SetValue(key, value);
|
this->dict->SetValue(key, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -102,10 +130,10 @@ void TSubEnvironment::SetVariable(std::string key, TObject value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool TSubEnvironment::HasVariable(std::string key) {
|
bool TSubEnvironment::HasVariable(std::string key) {
|
||||||
return this->dict->HasValue(key);
|
return this->dict->HasValue(key) || this->decls.count(key) > 0;
|
||||||
}
|
}
|
||||||
bool TSubEnvironment::HasVariableRecurse(std::string key) {
|
bool TSubEnvironment::HasVariableRecurse(std::string key) {
|
||||||
if (this->dict->HasValue(key))
|
if (this->dict->HasValue(key) || this->decls.count(key) > 0)
|
||||||
return true;
|
return true;
|
||||||
return this->env->HasVariableRecurse(key);
|
return this->env->HasVariableRecurse(key);
|
||||||
}
|
}
|
||||||
@@ -159,19 +187,11 @@ TSubEnvironment *TEnvironment::GetSubEnvironment(GCList &gc) {
|
|||||||
}
|
}
|
||||||
TSubEnvironment *TSubEnvironment::Create(GCList *gc, TEnvironment *env,
|
TSubEnvironment *TSubEnvironment::Create(GCList *gc, TEnvironment *env,
|
||||||
TDictionary *dict) {
|
TDictionary *dict) {
|
||||||
TSubEnvironment *senv = new TSubEnvironment(env, dict);
|
return gc->Create<TSubEnvironment>(env, dict);
|
||||||
std::shared_ptr<GC> _gc = gc->GetGC();
|
|
||||||
gc->Add(senv);
|
|
||||||
_gc->Watch(senv);
|
|
||||||
return senv;
|
|
||||||
}
|
}
|
||||||
TSubEnvironment *TSubEnvironment::Create(GCList &gc, TEnvironment *env,
|
TSubEnvironment *TSubEnvironment::Create(GCList &gc, TEnvironment *env,
|
||||||
TDictionary *dict) {
|
TDictionary *dict) {
|
||||||
TSubEnvironment *senv = new TSubEnvironment(env, dict);
|
return gc.Create<TSubEnvironment>(env, dict);
|
||||||
std::shared_ptr<GC> _gc = gc.GetGC();
|
|
||||||
gc.Add(senv);
|
|
||||||
_gc->Watch(senv);
|
|
||||||
return senv;
|
|
||||||
}
|
}
|
||||||
TEnvironment *TSubEnvironment::GetParentEnvironment() { return this->env; }
|
TEnvironment *TSubEnvironment::GetParentEnvironment() { return this->env; }
|
||||||
TRootEnvironment *TSubEnvironment::GetRootEnvironment() {
|
TRootEnvironment *TSubEnvironment::GetRootEnvironment() {
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|||||||
+22
-2
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -119,8 +139,8 @@ bool InterperterThread::Add(std::shared_ptr<GC> gc) {
|
|||||||
str.append(std::get<std::string>(left));
|
str.append(std::get<std::string>(left));
|
||||||
str.push_back(std::get<char>(right));
|
str.push_back(std::get<char>(right));
|
||||||
cse.back()->Push(gc, str);
|
cse.back()->Push(gc, str);
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
auto natObj = dynamic_cast<TNativeObject *>(obj);
|
auto natObj = dynamic_cast<TNativeObject *>(obj);
|
||||||
|
|||||||
+38
-21
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -14,8 +34,7 @@ namespace Tesses::CrossLang {
|
|||||||
|
|
||||||
bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
if (std::holds_alternative<std::nullptr_t>(left) &&
|
if (IsNull(left) && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -92,8 +111,8 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
auto r = std::get<Tesses::Framework::Uuid>(right);
|
auto r = std::get<Tesses::Framework::Uuid>(right);
|
||||||
|
|
||||||
return l == r;
|
return l == r;
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -109,12 +128,12 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
if (GetObjectHeap(obj, callable)) {
|
if (GetObjectHeap(obj, callable)) {
|
||||||
return ToBool(callable->Call(ls, {right}));
|
return ToBool(callable->Call(ls, {right}));
|
||||||
|
|
||||||
} else if (std::holds_alternative<std::nullptr_t>(right)) {
|
} else if (IsNull(right)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(right)) {
|
} else if (std::holds_alternative<THeapObject *>(right)) {
|
||||||
return cls == std::get<THeapObjectHolder>(right).obj;
|
return cls == std::get<THeapObject *>(right);
|
||||||
}
|
}
|
||||||
} else if (natObj != nullptr) {
|
} else if (natObj != nullptr) {
|
||||||
return natObj->Equals(gc, right);
|
return natObj->Equals(gc, right);
|
||||||
@@ -124,10 +143,10 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
TObject fn = dict->GetValue("operator==");
|
TObject fn = dict->GetValue("operator==");
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
if (!std::holds_alternative<Undefined>(fn)) {
|
if (!std::holds_alternative<Undefined>(fn)) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn)) {
|
if (std::holds_alternative<THeapObject *>(fn)) {
|
||||||
|
|
||||||
auto obj = dynamic_cast<TCallable *>(
|
auto obj =
|
||||||
std::get<THeapObjectHolder>(fn).obj);
|
dynamic_cast<TCallable *>(std::get<THeapObject *>(fn));
|
||||||
if (obj != nullptr) {
|
if (obj != nullptr) {
|
||||||
auto closure = dynamic_cast<TClosure *>(obj);
|
auto closure = dynamic_cast<TClosure *>(obj);
|
||||||
if (closure != nullptr) {
|
if (closure != nullptr) {
|
||||||
@@ -144,17 +163,17 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return dict == std::get<THeapObjectHolder>(right).obj;
|
return dict == std::get<THeapObject *>(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return dict == std::get<THeapObjectHolder>(right).obj;
|
return dict == std::get<THeapObject *>(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return dict == std::get<THeapObjectHolder>(right).obj;
|
return dict == std::get<THeapObject *>(right);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -162,21 +181,19 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
|
|
||||||
else if (dynDict != nullptr) {
|
else if (dynDict != nullptr) {
|
||||||
auto res = dynDict->CallMethod(ls, "operator==", {right});
|
auto res = dynDict->CallMethod(ls, "operator==", {right});
|
||||||
if (!std::holds_alternative<std::nullptr_t>(res) &&
|
if (!IsNull(res) && std::holds_alternative<Undefined>(res)) {
|
||||||
std::holds_alternative<Undefined>(res)) {
|
|
||||||
return ToBool(res);
|
return ToBool(res);
|
||||||
}
|
}
|
||||||
} else if (native != nullptr &&
|
} else if (native != nullptr && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
return native->GetDestroyed();
|
return native->GetDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(right)) {
|
if (std::holds_alternative<THeapObject *>(right)) {
|
||||||
return obj == std::get<THeapObjectHolder>(right).obj;
|
return obj == std::get<THeapObject *>(right);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<std::nullptr_t>(right)) {
|
else if (IsNull(right)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
|
|
||||||
@@ -187,7 +204,7 @@ bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<std::nullptr_t>(right)) {
|
else if (IsNull(right)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -24,7 +44,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
std::regex regex;
|
std::regex regex;
|
||||||
TVMVersion version;
|
TVMVersion version;
|
||||||
if (std::holds_alternative<std::nullptr_t>(instance)) {
|
if (IsNull(instance)) {
|
||||||
if (key == "ToString") {
|
if (key == "ToString") {
|
||||||
cse.back()->Push(gc, "null");
|
cse.back()->Push(gc, "null");
|
||||||
return false;
|
return false;
|
||||||
@@ -1490,12 +1510,12 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
pattern,
|
pattern,
|
||||||
callable->ToRouteServerRequestHandler(gc));
|
callable->ToRouteServerRequestHandler(gc));
|
||||||
}
|
}
|
||||||
} else if (key == "Trace") {
|
} else if (key == "Query") {
|
||||||
std::string pattern;
|
std::string pattern;
|
||||||
TCallable *callable;
|
TCallable *callable;
|
||||||
if (GetArgument(args, 0, pattern) &&
|
if (GetArgument(args, 0, pattern) &&
|
||||||
GetArgumentHeap(args, 1, callable)) {
|
GetArgumentHeap(args, 1, callable)) {
|
||||||
routable->Trace(
|
routable->Query(
|
||||||
pattern,
|
pattern,
|
||||||
callable->ToRouteServerRequestHandler(gc));
|
callable->ToRouteServerRequestHandler(gc));
|
||||||
}
|
}
|
||||||
@@ -1964,8 +1984,8 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
}
|
}
|
||||||
cse.back()->Push(gc, Undefined());
|
cse.back()->Push(gc, Undefined());
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(instance)) {
|
} else if (std::holds_alternative<THeapObject *>(instance)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(instance).obj;
|
auto obj = std::get<THeapObject *>(instance);
|
||||||
auto list = dynamic_cast<TList *>(obj);
|
auto list = dynamic_cast<TList *>(obj);
|
||||||
auto dynList = dynamic_cast<TDynamicList *>(obj);
|
auto dynList = dynamic_cast<TDynamicList *>(obj);
|
||||||
auto bArray = dynamic_cast<TByteArray *>(obj);
|
auto bArray = dynamic_cast<TByteArray *>(obj);
|
||||||
@@ -2292,9 +2312,9 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
}
|
}
|
||||||
if (key == "RegisterClass") {
|
if (key == "RegisterClass") {
|
||||||
if ((myEnv->permissions.canRegisterEverything ||
|
if ((myEnv->permissions.canRegisterEverything ||
|
||||||
myEnv->permissions.canRegisterClass) &&
|
myEnv->permissions.canRegisterZeClass) &&
|
||||||
!rootEnv->permissions.locked)
|
!rootEnv->permissions.locked)
|
||||||
TStd::RegisterClass(gc, rootEnv);
|
TStd::RegisterZeClass(gc, rootEnv);
|
||||||
cse.back()->Push(gc, nullptr);
|
cse.back()->Push(gc, nullptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3195,7 +3215,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
if (GetArgument(args, 0, index) &&
|
if (GetArgument(args, 0, index) &&
|
||||||
(size_t)index < bArray->data.size() &&
|
(size_t)index < bArray->data.size() &&
|
||||||
(size_t)index + 8 <= bArray->data.size()) {
|
(size_t)index + 8 <= bArray->data.size()) {
|
||||||
uint64_t value = BitConverter::ToDoubleLE(
|
double value = BitConverter::ToDoubleLE(
|
||||||
bArray->data[(size_t)index]);
|
bArray->data[(size_t)index]);
|
||||||
|
|
||||||
cse.back()->Push(gc, value);
|
cse.back()->Push(gc, value);
|
||||||
@@ -3218,7 +3238,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
|
|||||||
if (GetArgument(args, 0, index) &&
|
if (GetArgument(args, 0, index) &&
|
||||||
(size_t)index < bArray->data.size() &&
|
(size_t)index < bArray->data.size() &&
|
||||||
(size_t)index + 8 <= bArray->data.size()) {
|
(size_t)index + 8 <= bArray->data.size()) {
|
||||||
uint64_t value = BitConverter::ToDoubleBE(
|
double value = BitConverter::ToDoubleBE(
|
||||||
bArray->data[(size_t)index]);
|
bArray->data[(size_t)index]);
|
||||||
|
|
||||||
cse.back()->Push(gc, value);
|
cse.back()->Push(gc, value);
|
||||||
|
|||||||
+26
-6
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -188,7 +208,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
if (netStrm != nullptr) {
|
if (netStrm != nullptr) {
|
||||||
if (key == "Port") {
|
if (key == "Port") {
|
||||||
cse.back()->Push(gc, netStrm->GetPort());
|
cse.back()->Push(gc, (int64_t)netStrm->GetPort());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,8 +343,8 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
|
|||||||
stk->Push(gc, Undefined());
|
stk->Push(gc, Undefined());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<THeapObjectHolder>(instance)) {
|
if (std::holds_alternative<THeapObject *>(instance)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(instance).obj;
|
auto obj = std::get<THeapObject *>(instance);
|
||||||
auto bA = dynamic_cast<TByteArray *>(obj);
|
auto bA = dynamic_cast<TByteArray *>(obj);
|
||||||
auto list = dynamic_cast<TList *>(obj);
|
auto list = dynamic_cast<TList *>(obj);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
@@ -669,9 +689,9 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
|
|||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
TObject fn = dict->GetValue("get" + key);
|
TObject fn = dict->GetValue("get" + key);
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn) &&
|
if (std::holds_alternative<THeapObject *>(fn) &&
|
||||||
dynamic_cast<TCallable *>(
|
dynamic_cast<TCallable *>(std::get<THeapObject *>(fn)) !=
|
||||||
std::get<THeapObjectHolder>(fn).obj) != nullptr) {
|
nullptr) {
|
||||||
return InvokeOne(ls, fn, dict);
|
return InvokeOne(ls, fn, dict);
|
||||||
} else {
|
} else {
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -15,10 +35,9 @@ namespace Tesses::CrossLang {
|
|||||||
bool InterperterThread::InvokeMethod(GCList &ls, TObject fn, TObject instance,
|
bool InterperterThread::InvokeMethod(GCList &ls, TObject fn, TObject instance,
|
||||||
std::vector<TObject> args) {
|
std::vector<TObject> args) {
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn)) {
|
if (std::holds_alternative<THeapObject *>(fn)) {
|
||||||
|
|
||||||
auto obj =
|
auto obj = dynamic_cast<TCallable *>(std::get<THeapObject *>(fn));
|
||||||
dynamic_cast<TCallable *>(std::get<THeapObjectHolder>(fn).obj);
|
|
||||||
if (obj != nullptr) {
|
if (obj != nullptr) {
|
||||||
auto closure = dynamic_cast<TClosure *>(obj);
|
auto closure = dynamic_cast<TClosure *>(obj);
|
||||||
if (closure != nullptr) {
|
if (closure != nullptr) {
|
||||||
|
|||||||
+22
-3
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -12,10 +32,9 @@
|
|||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
bool InterperterThread::InvokeTwo(GCList &ls, TObject fn, TObject left,
|
bool InterperterThread::InvokeTwo(GCList &ls, TObject fn, TObject left,
|
||||||
TObject right) {
|
TObject right) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn)) {
|
if (std::holds_alternative<THeapObject *>(fn)) {
|
||||||
|
|
||||||
auto obj =
|
auto obj = dynamic_cast<TCallable *>(std::get<THeapObject *>(fn));
|
||||||
dynamic_cast<TCallable *>(std::get<THeapObjectHolder>(fn).obj);
|
|
||||||
if (obj != nullptr) {
|
if (obj != nullptr) {
|
||||||
auto closure = dynamic_cast<TClosure *>(obj);
|
auto closure = dynamic_cast<TClosure *>(obj);
|
||||||
if (closure != nullptr) {
|
if (closure != nullptr) {
|
||||||
|
|||||||
+25
-5
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -257,8 +277,8 @@ bool InterperterThread::SetField(std::shared_ptr<GC> gc) {
|
|||||||
stk->Push(gc, Undefined());
|
stk->Push(gc, Undefined());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<THeapObjectHolder>(instance)) {
|
if (std::holds_alternative<THeapObject *>(instance)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(instance).obj;
|
auto obj = std::get<THeapObject *>(instance);
|
||||||
|
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -313,9 +333,9 @@ bool InterperterThread::SetField(std::shared_ptr<GC> gc) {
|
|||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
TObject fn = dict->GetValue("set" + key);
|
TObject fn = dict->GetValue("set" + key);
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn) &&
|
if (std::holds_alternative<THeapObject *>(fn) &&
|
||||||
dynamic_cast<TCallable *>(
|
dynamic_cast<TCallable *>(std::get<THeapObject *>(fn)) !=
|
||||||
std::get<THeapObjectHolder>(fn).obj) != nullptr) {
|
nullptr) {
|
||||||
return InvokeTwo(ls, fn, dict, value);
|
return InvokeTwo(ls, fn, dict, value);
|
||||||
} else {
|
} else {
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
|
|||||||
+22
-2
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -65,8 +85,8 @@ bool InterperterThread::Sub(std::shared_ptr<GC> gc) {
|
|||||||
cse.back()->Push(
|
cse.back()->Push(
|
||||||
gc,
|
gc,
|
||||||
std::make_shared<Tesses::Framework::Date::DateTime>((*l) - (*r)));
|
std::make_shared<Tesses::Framework::Date::DateTime>((*l) - (*r)));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
|
|
||||||
|
|||||||
+22
-2
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -44,8 +64,8 @@ bool ToBool(TObject obj) {
|
|||||||
} else if (std::holds_alternative<Tesses::Framework::Uuid>(obj)) {
|
} else if (std::holds_alternative<Tesses::Framework::Uuid>(obj)) {
|
||||||
auto &uuid = std::get<Tesses::Framework::Uuid>(obj);
|
auto &uuid = std::get<Tesses::Framework::Uuid>(obj);
|
||||||
return !uuid.IsEmpty();
|
return !uuid.IsEmpty();
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
} else if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto o = std::get<THeapObjectHolder>(obj).obj;
|
auto o = std::get<THeapObject *>(obj);
|
||||||
auto ls = dynamic_cast<TList *>(o);
|
auto ls = dynamic_cast<TList *>(o);
|
||||||
auto aarray = dynamic_cast<TAssociativeArray *>(o);
|
auto aarray = dynamic_cast<TAssociativeArray *>(o);
|
||||||
auto dict = dynamic_cast<TDictionary *>(o);
|
auto dict = dynamic_cast<TDictionary *>(o);
|
||||||
|
|||||||
+23
-3
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -31,7 +51,7 @@ std::string ToString(std::shared_ptr<GC> gc, TObject o) {
|
|||||||
if (std::holds_alternative<char>(o)) {
|
if (std::holds_alternative<char>(o)) {
|
||||||
return std::string{std::get<char>(o)};
|
return std::string{std::get<char>(o)};
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<std::nullptr_t>(o)) {
|
if (IsNull(o)) {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<Undefined>(o)) {
|
if (std::holds_alternative<Undefined>(o)) {
|
||||||
@@ -54,8 +74,8 @@ std::string ToString(std::shared_ptr<GC> gc, TObject o) {
|
|||||||
return std::get<Tesses::Framework::Uuid>(o).ToString(
|
return std::get<Tesses::Framework::Uuid>(o).ToString(
|
||||||
Framework::UuidStringifyConfig::LowercaseNoCurly);
|
Framework::UuidStringifyConfig::LowercaseNoCurly);
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<THeapObjectHolder>(o)) {
|
if (std::holds_alternative<THeapObject *>(o)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(o).obj;
|
auto obj = std::get<THeapObject *>(o);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto list = dynamic_cast<TList *>(obj);
|
auto list = dynamic_cast<TList *>(obj);
|
||||||
auto bArray = dynamic_cast<TByteArray *>(obj);
|
auto bArray = dynamic_cast<TByteArray *>(obj);
|
||||||
|
|||||||
+24
-4
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -58,13 +78,13 @@ void ThrowFatalError(std::exception &ex) {
|
|||||||
error.WriteLine(text);
|
error.WriteLine(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
if (clrtexcept != nullptr) {
|
if (clrtexcept != nullptr) {
|
||||||
error.WriteLine("CrossLang has encountered a fatal runtime exception");
|
error.WriteLine("CrossLang has encountered a fatal runtime exception");
|
||||||
error.WriteLine();
|
error.WriteLine();
|
||||||
error.WriteLine(clrtexcept->what());
|
error.WriteLine(clrtexcept->what());
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
if (compiler != nullptr) {
|
if (compiler != nullptr) {
|
||||||
error.WriteLine("CrossLang has encountered a compiler error");
|
error.WriteLine("CrossLang has encountered a compiler error");
|
||||||
@@ -81,13 +101,13 @@ void ThrowFatalError(std::exception &ex) {
|
|||||||
error.Write(":");
|
error.Write(":");
|
||||||
error.WriteLine((int64_t)li.offset);
|
error.WriteLine((int64_t)li.offset);
|
||||||
|
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
error.WriteLine("CrossLang has encountered a fatal C++ exception");
|
error.WriteLine("CrossLang has encountered a fatal C++ exception");
|
||||||
error.WriteLine();
|
error.WriteLine();
|
||||||
error.Write("what(): ");
|
error.Write("what(): ");
|
||||||
error.WriteLine(ex2->what());
|
error.WriteLine(ex2->what());
|
||||||
exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
} // namespace Tesses::CrossLang
|
} // namespace Tesses::CrossLang
|
||||||
+24
-30
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -5,22 +25,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|
||||||
TFile *TFile::Create(GCList &ls) {
|
TFile *TFile::Create(GCList &ls) { return ls.Create<TFile>(); }
|
||||||
TFile *f = new TFile();
|
TFile *TFile::Create(GCList *ls) { return ls->Create<TFile>(); }
|
||||||
f->icon = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(f);
|
|
||||||
_gc->Watch(f);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
TFile *TFile::Create(GCList *ls) {
|
|
||||||
TFile *f = new TFile();
|
|
||||||
f->icon = -1;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(f);
|
|
||||||
_gc->Watch(f);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
void TFileChunk::Mark() {
|
void TFileChunk::Mark() {
|
||||||
if (this->marked)
|
if (this->marked)
|
||||||
return;
|
return;
|
||||||
@@ -28,20 +34,8 @@ void TFileChunk::Mark() {
|
|||||||
this->file->Mark();
|
this->file->Mark();
|
||||||
}
|
}
|
||||||
|
|
||||||
TFileChunk *TFileChunk::Create(GCList &ls) {
|
TFileChunk *TFileChunk::Create(GCList &ls) { return ls.Create<TFileChunk>(); }
|
||||||
TFileChunk *chk = new TFileChunk();
|
TFileChunk *TFileChunk::Create(GCList *ls) { return ls->Create<TFileChunk>(); }
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(chk);
|
|
||||||
_gc->Watch(chk);
|
|
||||||
return chk;
|
|
||||||
}
|
|
||||||
TFileChunk *TFileChunk::Create(GCList *ls) {
|
|
||||||
TFileChunk *chk = new TFileChunk();
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(chk);
|
|
||||||
_gc->Watch(chk);
|
|
||||||
return chk;
|
|
||||||
}
|
|
||||||
void TFile::Mark() {
|
void TFile::Mark() {
|
||||||
if (this->marked)
|
if (this->marked)
|
||||||
return;
|
return;
|
||||||
|
|||||||
+135
-89
@@ -1,17 +1,46 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Tesses::Framework::Threading;
|
using namespace Tesses::Framework::Threading;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
#if defined(GEKKO) || defined(_EE)
|
||||||
|
|
||||||
|
struct PthreadCmp {
|
||||||
|
bool operator()(const pthread_t &a, const pthread_t &b) const {
|
||||||
|
return pthread_equal(a, b) != 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static std::map<pthread_t, CallStackEntry *, PthreadCmp> current_funcs;
|
||||||
|
static Tesses::Framework::Threading::Mutex current_funcs_mtx;
|
||||||
|
#else
|
||||||
|
thread_local CallStackEntry *current_function;
|
||||||
|
#endif
|
||||||
bool GC::IsRunning() {
|
bool GC::IsRunning() {
|
||||||
|
|
||||||
bool run = this->running;
|
bool run = this->running;
|
||||||
@@ -74,7 +103,13 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached) {
|
|||||||
TObject cb = th->callable->Call(ls, {});
|
TObject cb = th->callable->Call(ls, {});
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
th->returnValue = cb;
|
th->returnValue = cb;
|
||||||
|
#if defined(GEKKO) || defined(_EE)
|
||||||
|
current_funcs_mtx.Lock();
|
||||||
|
current_funcs.erase(pthread_self());
|
||||||
|
current_funcs_mtx.Unlock();
|
||||||
|
#endif
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
|
|
||||||
th->hasReturned = true;
|
th->hasReturned = true;
|
||||||
});
|
});
|
||||||
while (!th->hasInit)
|
while (!th->hasInit)
|
||||||
@@ -82,6 +117,23 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached) {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
void GC::Start() {
|
void GC::Start() {
|
||||||
|
using namespace Tesses::Framework::Serialization::Json;
|
||||||
|
auto prefsFile = GetCrossLangConfigDir() / "prefs.json";
|
||||||
|
if (Tesses::Framework::Filesystem::LocalFS->FileExists(prefsFile)) {
|
||||||
|
try {
|
||||||
|
JToken tkn = Json::Decode(
|
||||||
|
Tesses::Framework::Filesystem::Helpers::ReadAllText(
|
||||||
|
Tesses::Framework::Filesystem::LocalFS, prefsFile));
|
||||||
|
JObject root;
|
||||||
|
int64_t ittrs;
|
||||||
|
if (TryGetJToken(tkn, root) &&
|
||||||
|
root.TryGetValueAsType("alloc_threshold", ittrs)) {
|
||||||
|
this->threshold = static_cast<uint32_t>(ittrs);
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
this->threshold = ALLOC_THRESHOLD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->tpool = new Tesses::Framework::Lazy<
|
this->tpool = new Tesses::Framework::Lazy<
|
||||||
Tesses::Framework::Threading::ThreadPool *>(
|
Tesses::Framework::Threading::ThreadPool *>(
|
||||||
@@ -93,121 +145,93 @@ void GC::Start() {
|
|||||||
return new Tesses::Framework::Threading::ThreadPool(threads);
|
return new Tesses::Framework::Threading::ThreadPool(threads);
|
||||||
},
|
},
|
||||||
[](Tesses::Framework::Threading::ThreadPool *p) -> void { delete p; });
|
[](Tesses::Framework::Threading::ThreadPool *p) -> void { delete p; });
|
||||||
this->mtx = new Mutex();
|
|
||||||
this->running = true;
|
this->running = true;
|
||||||
this->thrd = new Thread([this]() -> void {
|
this->thrd = new Thread([this]() -> void {
|
||||||
std::chrono::time_point<std::chrono::system_clock> last_frame,
|
|
||||||
this_frame;
|
|
||||||
|
|
||||||
this_frame = system_clock::now();
|
|
||||||
last_frame = this_frame;
|
|
||||||
|
|
||||||
while (this->IsRunning()) {
|
while (this->IsRunning()) {
|
||||||
this_frame = system_clock::now();
|
this->BarrierBegin();
|
||||||
if ((this_frame - last_frame) > 10s) {
|
while (this->IsRunning() && (this->allocs < this->threshold))
|
||||||
|
this->cond.Wait(&this->mtx);
|
||||||
|
this->allocs = 0;
|
||||||
|
std::vector<THeapObject *> to_delete;
|
||||||
|
this->Collect(to_delete);
|
||||||
|
this->BarrierEnd();
|
||||||
|
|
||||||
last_frame = this_frame;
|
for (auto o : to_delete)
|
||||||
this->Collect();
|
delete o;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::vector<THeapObject *> to_delete;
|
||||||
|
this->BarrierBegin();
|
||||||
|
this->Collect(to_delete);
|
||||||
|
this->BarrierEnd();
|
||||||
|
|
||||||
#if defined(_WIN32)
|
for (auto item : to_delete)
|
||||||
Sleep(100);
|
delete item;
|
||||||
#else
|
|
||||||
usleep(100000);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
GC::Collect();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GC::UsingNullThreads() { return false; }
|
bool GC::UsingNullThreads() { return false; }
|
||||||
|
|
||||||
void GC::BarrierBegin() { this->mtx->Lock(); }
|
void GC::BarrierBegin() { this->mtx.Lock(); }
|
||||||
void GC::BarrierEnd() { this->mtx->Unlock(); }
|
void GC::BarrierEnd() { this->mtx.Unlock(); }
|
||||||
void GC::Watch(TObject obj) {
|
void GC::Watch(TObject obj) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
auto _item = std::get<THeapObject *>(obj);
|
||||||
|
if (_item == nullptr)
|
||||||
|
return;
|
||||||
this->BarrierBegin();
|
this->BarrierBegin();
|
||||||
|
this->objects.insert(_item);
|
||||||
for (auto item : this->objects) {
|
auto nowAllocs = ++this->allocs;
|
||||||
if (item == _item) {
|
|
||||||
this->BarrierEnd();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->objects.push_back(_item);
|
|
||||||
this->BarrierEnd();
|
this->BarrierEnd();
|
||||||
|
if (nowAllocs >= this->threshold)
|
||||||
|
this->cond.Signal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GC::Mark(TObject obj) {
|
void GC::Mark(TObject obj) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
auto _item = std::get<THeapObject *>(obj);
|
||||||
_item->Mark();
|
if (_item)
|
||||||
|
_item->Mark();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GC::Unwatch(TObject obj) {
|
void GC::Unwatch(TObject obj) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
auto _item = std::get<THeapObject *>(obj);
|
||||||
|
if (_item == nullptr)
|
||||||
|
return;
|
||||||
this->BarrierBegin();
|
this->BarrierBegin();
|
||||||
for (auto index = this->objects.begin();
|
this->objects.erase(_item);
|
||||||
index != this->objects.end();) {
|
|
||||||
if (*index == _item) {
|
|
||||||
index = this->objects.erase(index);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
this->BarrierEnd();
|
this->BarrierEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GC::SetRoot(TObject obj) {
|
void GC::SetRoot(GCList *_item) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (_item == nullptr)
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
return;
|
||||||
this->BarrierBegin();
|
this->BarrierBegin();
|
||||||
|
|
||||||
for (auto item : this->roots) {
|
this->roots.insert(_item);
|
||||||
if (item == _item) {
|
this->BarrierEnd();
|
||||||
this->BarrierEnd();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->roots.push_back(_item);
|
|
||||||
this->BarrierEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Tesses::Framework::Threading::ThreadPool *GC::GetPool() {
|
Tesses::Framework::Threading::ThreadPool *GC::GetPool() {
|
||||||
return this->tpool->GetValue();
|
return this->tpool->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GC::UnsetRoot(TObject obj) {
|
void GC::UnsetRoot(GCList *_item) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (_item == nullptr)
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
return;
|
||||||
this->BarrierBegin();
|
this->BarrierBegin();
|
||||||
for (auto index = this->roots.begin(); index != this->roots.end();) {
|
this->roots.erase(_item);
|
||||||
if (*index == _item) {
|
this->BarrierEnd();
|
||||||
index = this->roots.erase(index);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
this->BarrierEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GC::~GC() {
|
GC::~GC() {
|
||||||
GC::BarrierBegin();
|
|
||||||
|
|
||||||
this->roots.clear();
|
|
||||||
GC::BarrierEnd();
|
|
||||||
|
|
||||||
this->running = false;
|
this->running = false;
|
||||||
|
this->cond.Signal();
|
||||||
this->thrd->Join();
|
this->thrd->Join();
|
||||||
delete this->thrd;
|
delete this->thrd;
|
||||||
for (auto item : objects)
|
|
||||||
delete item;
|
|
||||||
|
|
||||||
delete this->tpool;
|
delete this->tpool;
|
||||||
delete this->mtx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GC::RegisterEverythingCallback(
|
void GC::RegisterEverythingCallback(
|
||||||
@@ -218,23 +242,45 @@ void GC::RegisterEverything(TRootEnvironment *env) {
|
|||||||
for (auto item : this->register_everything)
|
for (auto item : this->register_everything)
|
||||||
item(this->shared_from_this(), env);
|
item(this->shared_from_this(), env);
|
||||||
}
|
}
|
||||||
void GC::Collect() {
|
|
||||||
this->BarrierBegin();
|
CallStackEntry *GC::GetCurrentFunction() {
|
||||||
|
#if defined(GEKKO) || defined(_EE)
|
||||||
|
current_funcs_mtx.Lock();
|
||||||
|
auto val = current_funcs[pthread_self()];
|
||||||
|
current_funcs_mtx.Unlock();
|
||||||
|
|
||||||
|
return val;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return current_function;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void GC::SetCurrentFunction(CallStackEntry *cse) {
|
||||||
|
#if defined(GEKKO) || defined(_EE)
|
||||||
|
current_funcs_mtx.Lock();
|
||||||
|
current_funcs[pthread_self()] = cse;
|
||||||
|
current_funcs_mtx.Unlock();
|
||||||
|
#else
|
||||||
|
current_function = cse;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GC::Collect(std::vector<THeapObject *> &to_delete) {
|
||||||
|
|
||||||
for (auto item : this->objects) {
|
for (auto item : this->objects) {
|
||||||
item->marked = false;
|
item->marked = false;
|
||||||
}
|
}
|
||||||
for (auto item : this->roots) {
|
for (auto item : this->roots) {
|
||||||
item->Mark();
|
item->Mark();
|
||||||
}
|
}
|
||||||
for (auto index = this->objects.begin(); index != this->objects.end();
|
for (auto index = this->objects.begin(); index != this->objects.end();) {
|
||||||
index++) {
|
|
||||||
THeapObject *o = *index;
|
THeapObject *o = *index;
|
||||||
if (!o->marked) {
|
if (!o->marked) {
|
||||||
delete o;
|
to_delete.push_back(o);
|
||||||
this->objects.erase(index);
|
index = this->objects.erase(index);
|
||||||
index--;
|
} else {
|
||||||
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->BarrierEnd();
|
|
||||||
}
|
}
|
||||||
}; // namespace Tesses::CrossLang
|
}; // namespace Tesses::CrossLang
|
||||||
|
|||||||
+29
-6
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
@@ -8,10 +28,12 @@ GCList::GCList(std::shared_ptr<GC> gc) {
|
|||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<GC> GCList::GetGC() { return this->gc; }
|
std::shared_ptr<GC> GCList::GetGC() const { return this->gc; }
|
||||||
void GCList::Remove(TObject obj) {
|
void GCList::Remove(TObject obj) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
auto _item = std::get<THeapObject *>(obj);
|
||||||
|
if (_item == nullptr)
|
||||||
|
return;
|
||||||
this->gc->BarrierBegin();
|
this->gc->BarrierBegin();
|
||||||
for (auto index = this->items.begin(); index != this->items.end();
|
for (auto index = this->items.begin(); index != this->items.end();
|
||||||
index++) {
|
index++) {
|
||||||
@@ -25,8 +47,10 @@ void GCList::Remove(TObject obj) {
|
|||||||
}
|
}
|
||||||
void GCList::Add(TObject obj) {
|
void GCList::Add(TObject obj) {
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(obj)) {
|
if (std::holds_alternative<THeapObject *>(obj)) {
|
||||||
auto _item = std::get<THeapObjectHolder>(obj).obj;
|
auto _item = std::get<THeapObject *>(obj);
|
||||||
|
if (_item == nullptr)
|
||||||
|
return;
|
||||||
this->gc->BarrierBegin();
|
this->gc->BarrierBegin();
|
||||||
|
|
||||||
for (auto item : this->items) {
|
for (auto item : this->items) {
|
||||||
@@ -40,7 +64,6 @@ void GCList::Add(TObject obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GCList::Mark() {
|
void GCList::Mark() {
|
||||||
this->marked = true;
|
|
||||||
for (auto item : this->items) {
|
for (auto item : this->items) {
|
||||||
item->Mark();
|
item->Mark();
|
||||||
}
|
}
|
||||||
|
|||||||
+178
-128
@@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
CrossLang is a dynamically-typed scripting language built on
|
||||||
|
TessesFramework, named in honor of Jesus's sacrifice.
|
||||||
|
|
||||||
|
Copyright (C) 2026 Mike Nolan
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later WITH TessesFramework-Exception-1.0
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include "CrossLang.hpp"
|
#include "CrossLang.hpp"
|
||||||
#include "TessesFramework/Serialization/BitConverter.hpp"
|
#include "TessesFramework/Serialization/BitConverter.hpp"
|
||||||
#include "TessesFramework/Streams/ByteReader.hpp"
|
#include "TessesFramework/Streams/ByteReader.hpp"
|
||||||
@@ -12,8 +32,6 @@
|
|||||||
|
|
||||||
namespace Tesses::CrossLang {
|
namespace Tesses::CrossLang {
|
||||||
|
|
||||||
thread_local CallStackEntry *current_function = nullptr;
|
|
||||||
|
|
||||||
TObject ExecuteFunction(GCList &ls, TCallable *callable,
|
TObject ExecuteFunction(GCList &ls, TCallable *callable,
|
||||||
std::vector<TObject> args) {
|
std::vector<TObject> args) {
|
||||||
return callable->Call(ls, args);
|
return callable->Call(ls, args);
|
||||||
@@ -81,8 +99,8 @@ bool InterperterThread::Times(std::shared_ptr<GC> gc) {
|
|||||||
} else if (std::holds_alternative<int64_t>(left) &&
|
} else if (std::holds_alternative<int64_t>(left) &&
|
||||||
std::holds_alternative<double>(right)) {
|
std::holds_alternative<double>(right)) {
|
||||||
cse.back()->Push(gc, std::get<int64_t>(left) * std::get<double>(right));
|
cse.back()->Push(gc, std::get<int64_t>(left) * std::get<double>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -182,8 +200,8 @@ bool InterperterThread::Divide(std::shared_ptr<GC> gc) {
|
|||||||
cse.back()->Push(gc, std::get<int64_t>(left) / std::get<double>(right));
|
cse.back()->Push(gc, std::get<int64_t>(left) / std::get<double>(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -258,8 +276,8 @@ bool InterperterThread::Mod(std::shared_ptr<GC> gc) {
|
|||||||
gc, fmod(std::get<int64_t>(left), std::get<double>(right)));
|
gc, fmod(std::get<int64_t>(left), std::get<double>(right)));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -314,8 +332,8 @@ bool InterperterThread::Neg(std::shared_ptr<GC> gc) {
|
|||||||
cse.back()->Push(gc, -std::get<int64_t>(left));
|
cse.back()->Push(gc, -std::get<int64_t>(left));
|
||||||
} else if (std::holds_alternative<double>(left)) {
|
} else if (std::holds_alternative<double>(left)) {
|
||||||
cse.back()->Push(gc, -std::get<double>(left));
|
cse.back()->Push(gc, -std::get<double>(left));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
|
|
||||||
@@ -367,7 +385,7 @@ bool InterperterThread::LNot(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
if (std::holds_alternative<Undefined>(left)) {
|
if (std::holds_alternative<Undefined>(left)) {
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
} else if (std::holds_alternative<std::nullptr_t>(left)) {
|
} else if (IsNull(left)) {
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,8 +395,8 @@ bool InterperterThread::LNot(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
else if (std::holds_alternative<bool>(left)) {
|
else if (std::holds_alternative<bool>(left)) {
|
||||||
cse.back()->Push(gc, !std::get<bool>(left));
|
cse.back()->Push(gc, !std::get<bool>(left));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -433,8 +451,8 @@ bool InterperterThread::BNot(std::shared_ptr<GC> gc) {
|
|||||||
cse.back()->Push(gc, ~std::get<int64_t>(left));
|
cse.back()->Push(gc, ~std::get<int64_t>(left));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -540,8 +558,8 @@ bool InterperterThread::Lt(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() < r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() < r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -646,8 +664,8 @@ bool InterperterThread::Gt(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() > r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() > r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -753,8 +771,8 @@ bool InterperterThread::Lte(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() <= r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() <= r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -865,8 +883,8 @@ bool InterperterThread::Gte(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() >= r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() >= r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -919,8 +937,7 @@ bool InterperterThread::Eq(std::shared_ptr<GC> gc) {
|
|||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
auto right = cse.back()->Pop(ls);
|
auto right = cse.back()->Pop(ls);
|
||||||
auto left = cse.back()->Pop(ls);
|
auto left = cse.back()->Pop(ls);
|
||||||
if (std::holds_alternative<std::nullptr_t>(left) &&
|
if (IsNull(left) && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1002,8 +1019,8 @@ bool InterperterThread::Eq(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() == r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() == r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1041,25 +1058,23 @@ bool InterperterThread::Eq(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
else if (dynDict != nullptr) {
|
else if (dynDict != nullptr) {
|
||||||
auto res = dynDict->CallMethod(ls, "operator==", {right});
|
auto res = dynDict->CallMethod(ls, "operator==", {right});
|
||||||
if (!std::holds_alternative<std::nullptr_t>(res) &&
|
if (!IsNull(res) && std::holds_alternative<Undefined>(res)) {
|
||||||
std::holds_alternative<Undefined>(res)) {
|
|
||||||
cse.back()->Push(gc, res);
|
cse.back()->Push(gc, res);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (native != nullptr &&
|
else if (native != nullptr && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
cse.back()->Push(gc, native->GetDestroyed());
|
cse.back()->Push(gc, native->GetDestroyed());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(right)) {
|
if (std::holds_alternative<THeapObject *>(right)) {
|
||||||
cse.back()->Push(gc, obj == std::get<THeapObjectHolder>(right).obj);
|
cse.back()->Push(gc, obj == std::get<THeapObject *>(right));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<std::nullptr_t>(right)) {
|
else if (IsNull(right)) {
|
||||||
cse.back()->Push(gc, false);
|
cse.back()->Push(gc, false);
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
@@ -1071,7 +1086,7 @@ bool InterperterThread::Eq(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (std::holds_alternative<std::nullptr_t>(right)) {
|
else if (IsNull(right)) {
|
||||||
cse.back()->Push(gc, false);
|
cse.back()->Push(gc, false);
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
@@ -1089,8 +1104,7 @@ bool InterperterThread::NEq(std::shared_ptr<GC> gc) {
|
|||||||
auto right = cse.back()->Pop(ls);
|
auto right = cse.back()->Pop(ls);
|
||||||
auto left = cse.back()->Pop(ls);
|
auto left = cse.back()->Pop(ls);
|
||||||
|
|
||||||
if (std::holds_alternative<std::nullptr_t>(left) &&
|
if (IsNull(left) && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
cse.back()->Push(gc, false);
|
cse.back()->Push(gc, false);
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(left) &&
|
} else if (std::holds_alternative<Undefined>(left) &&
|
||||||
@@ -1160,8 +1174,8 @@ bool InterperterThread::NEq(std::shared_ptr<GC> gc) {
|
|||||||
auto &r =
|
auto &r =
|
||||||
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
std::get<std::shared_ptr<Tesses::Framework::Date::TimeSpan>>(right);
|
||||||
cse.back()->Push(gc, l->TotalSeconds() != r->TotalSeconds());
|
cse.back()->Push(gc, l->TotalSeconds() != r->TotalSeconds());
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
auto native = dynamic_cast<TNative *>(obj);
|
auto native = dynamic_cast<TNative *>(obj);
|
||||||
auto natObj = dynamic_cast<TNativeObject *>(obj);
|
auto natObj = dynamic_cast<TNativeObject *>(obj);
|
||||||
@@ -1198,22 +1212,20 @@ bool InterperterThread::NEq(std::shared_ptr<GC> gc) {
|
|||||||
else if (dynDict != nullptr) {
|
else if (dynDict != nullptr) {
|
||||||
|
|
||||||
auto res = dynDict->CallMethod(ls, "operator!=", {right});
|
auto res = dynDict->CallMethod(ls, "operator!=", {right});
|
||||||
if (!std::holds_alternative<std::nullptr_t>(res) &&
|
if (!IsNull(res) && std::holds_alternative<Undefined>(res)) {
|
||||||
std::holds_alternative<Undefined>(res)) {
|
|
||||||
cse.back()->Push(gc, res);
|
cse.back()->Push(gc, res);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (native != nullptr &&
|
else if (native != nullptr && IsNull(right)) {
|
||||||
std::holds_alternative<std::nullptr_t>(right)) {
|
|
||||||
cse.back()->Push(gc, !native->GetDestroyed());
|
cse.back()->Push(gc, !native->GetDestroyed());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (std::holds_alternative<THeapObjectHolder>(right)) {
|
if (std::holds_alternative<THeapObject *>(right)) {
|
||||||
cse.back()->Push(gc, obj != std::get<THeapObjectHolder>(right).obj);
|
cse.back()->Push(gc, obj != std::get<THeapObject *>(right));
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<std::nullptr_t>(right)) {
|
} else if (IsNull(right)) {
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
@@ -1226,7 +1238,7 @@ bool InterperterThread::NEq(std::shared_ptr<GC> gc) {
|
|||||||
} else if (std::holds_alternative<Undefined>(right)) {
|
} else if (std::holds_alternative<Undefined>(right)) {
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
return false;
|
return false;
|
||||||
} else if (std::holds_alternative<std::nullptr_t>(right)) {
|
} else if (IsNull(right)) {
|
||||||
cse.back()->Push(gc, true);
|
cse.back()->Push(gc, true);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -1245,8 +1257,8 @@ bool InterperterThread::LShift(std::shared_ptr<GC> gc) {
|
|||||||
std::holds_alternative<int64_t>(right)) {
|
std::holds_alternative<int64_t>(right)) {
|
||||||
cse.back()->Push(gc, std::get<int64_t>(left)
|
cse.back()->Push(gc, std::get<int64_t>(left)
|
||||||
<< (int)std::get<int64_t>(right));
|
<< (int)std::get<int64_t>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1303,8 +1315,8 @@ bool InterperterThread::RShift(std::shared_ptr<GC> gc) {
|
|||||||
std::holds_alternative<int64_t>(right)) {
|
std::holds_alternative<int64_t>(right)) {
|
||||||
cse.back()->Push(gc, std::get<int64_t>(left) >>
|
cse.back()->Push(gc, std::get<int64_t>(left) >>
|
||||||
(int)std::get<int64_t>(right));
|
(int)std::get<int64_t>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1361,8 +1373,8 @@ bool InterperterThread::BOr(std::shared_ptr<GC> gc) {
|
|||||||
std::holds_alternative<int64_t>(right)) {
|
std::holds_alternative<int64_t>(right)) {
|
||||||
cse.back()->Push(gc,
|
cse.back()->Push(gc,
|
||||||
std::get<int64_t>(left) | std::get<int64_t>(right));
|
std::get<int64_t>(left) | std::get<int64_t>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1419,8 +1431,8 @@ bool InterperterThread::XOr(std::shared_ptr<GC> gc) {
|
|||||||
std::holds_alternative<int64_t>(right)) {
|
std::holds_alternative<int64_t>(right)) {
|
||||||
cse.back()->Push(gc,
|
cse.back()->Push(gc,
|
||||||
std::get<int64_t>(left) ^ std::get<int64_t>(right));
|
std::get<int64_t>(left) ^ std::get<int64_t>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1476,8 +1488,8 @@ bool InterperterThread::BAnd(std::shared_ptr<GC> gc) {
|
|||||||
std::holds_alternative<int64_t>(right)) {
|
std::holds_alternative<int64_t>(right)) {
|
||||||
cse.back()->Push(gc,
|
cse.back()->Push(gc,
|
||||||
std::get<int64_t>(left) & std::get<int64_t>(right));
|
std::get<int64_t>(left) & std::get<int64_t>(right));
|
||||||
} else if (std::holds_alternative<THeapObjectHolder>(left)) {
|
} else if (std::holds_alternative<THeapObject *>(left)) {
|
||||||
auto obj = std::get<THeapObjectHolder>(left).obj;
|
auto obj = std::get<THeapObject *>(left);
|
||||||
auto dict = dynamic_cast<TDictionary *>(obj);
|
auto dict = dynamic_cast<TDictionary *>(obj);
|
||||||
|
|
||||||
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
|
||||||
@@ -1522,10 +1534,9 @@ bool InterperterThread::BAnd(std::shared_ptr<GC> gc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool InterperterThread::InvokeOne(GCList &ls, TObject fn, TObject arg) {
|
bool InterperterThread::InvokeOne(GCList &ls, TObject fn, TObject arg) {
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn)) {
|
if (std::holds_alternative<THeapObject *>(fn)) {
|
||||||
|
|
||||||
auto obj =
|
auto obj = dynamic_cast<TCallable *>(std::get<THeapObject *>(fn));
|
||||||
dynamic_cast<TCallable *>(std::get<THeapObjectHolder>(fn).obj);
|
|
||||||
if (obj != nullptr) {
|
if (obj != nullptr) {
|
||||||
auto closure = dynamic_cast<TClosure *>(obj);
|
auto closure = dynamic_cast<TClosure *>(obj);
|
||||||
if (closure != nullptr) {
|
if (closure != nullptr) {
|
||||||
@@ -1570,10 +1581,10 @@ bool InterperterThread::ExecuteFunction(std::shared_ptr<GC> gc) {
|
|||||||
if (args.size() == 3) {
|
if (args.size() == 3) {
|
||||||
|
|
||||||
if (std::holds_alternative<std::string>(args[1]) &&
|
if (std::holds_alternative<std::string>(args[1]) &&
|
||||||
std::holds_alternative<THeapObjectHolder>(args[2])) {
|
std::holds_alternative<THeapObject *>(args[2])) {
|
||||||
std::string key = std::get<std::string>(args[1]);
|
std::string key = std::get<std::string>(args[1]);
|
||||||
TList *ls = dynamic_cast<TList *>(
|
TList *ls = dynamic_cast<TList *>(
|
||||||
std::get<THeapObjectHolder>(args[2]).obj);
|
std::get<THeapObject *>(args[2]));
|
||||||
if (ls != nullptr)
|
if (ls != nullptr)
|
||||||
return ExecuteMethod2(gc, args[0], key, ls->items);
|
return ExecuteMethod2(gc, args[0], key, ls->items);
|
||||||
}
|
}
|
||||||
@@ -1582,10 +1593,10 @@ bool InterperterThread::ExecuteFunction(std::shared_ptr<GC> gc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::holds_alternative<THeapObjectHolder>(fn)) {
|
if (std::holds_alternative<THeapObject *>(fn)) {
|
||||||
|
|
||||||
auto obj = dynamic_cast<TCallable *>(
|
auto obj =
|
||||||
std::get<THeapObjectHolder>(fn).obj);
|
dynamic_cast<TCallable *>(std::get<THeapObject *>(fn));
|
||||||
if (obj != nullptr) {
|
if (obj != nullptr) {
|
||||||
auto closure = dynamic_cast<TClosure *>(obj);
|
auto closure = dynamic_cast<TClosure *>(obj);
|
||||||
if (closure != nullptr) {
|
if (closure != nullptr) {
|
||||||
@@ -2113,8 +2124,14 @@ bool InterperterThread::Throw(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
if (!std::holds_alternative<Undefined>(_res2)) {
|
if (!std::holds_alternative<Undefined>(_res2)) {
|
||||||
auto env = cse.back()->env;
|
auto env = cse.back()->env;
|
||||||
if (!env->GetRootEnvironment()->HandleException(gc, env, _res2))
|
if (!env->GetRootEnvironment()->HandleException(gc, env, _res2)) {
|
||||||
|
TNativeException *nex;
|
||||||
|
if (GetObjectHeap(_res2, nex)) {
|
||||||
|
nex->ThrowIt();
|
||||||
|
}
|
||||||
|
|
||||||
throw VMByteCodeException(gc, _res2, cse.back());
|
throw VMByteCodeException(gc, _res2, cse.back());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2143,8 +2160,7 @@ bool InterperterThread::JumpIfDefined(std::shared_ptr<GC> gc) {
|
|||||||
auto _res2 = stk->Pop(ls);
|
auto _res2 = stk->Pop(ls);
|
||||||
|
|
||||||
stk->ip = stk->ip + 4;
|
stk->ip = stk->ip + 4;
|
||||||
if (!std::holds_alternative<Undefined>(_res2) &&
|
if (!std::holds_alternative<Undefined>(_res2) && !IsNull(_res2)) {
|
||||||
!std::holds_alternative<std::nullptr_t>(_res2)) {
|
|
||||||
stk->ip = n;
|
stk->ip = n;
|
||||||
stk->Push(gc, _res2);
|
stk->Push(gc, _res2);
|
||||||
}
|
}
|
||||||
@@ -2223,6 +2239,7 @@ bool InterperterThread::JumpUndefined(std::shared_ptr<GC> gc) {
|
|||||||
bool InterperterThread::Jump(std::shared_ptr<GC> gc) {
|
bool InterperterThread::Jump(std::shared_ptr<GC> gc) {
|
||||||
|
|
||||||
std::vector<CallStackEntry *> &cse = this->call_stack_entries;
|
std::vector<CallStackEntry *> &cse = this->call_stack_entries;
|
||||||
|
|
||||||
auto stk = cse.back();
|
auto stk = cse.back();
|
||||||
|
|
||||||
if (stk->ip + 4 <= stk->callable->closure->code.size()) {
|
if (stk->ip + 4 <= stk->callable->closure->code.size()) {
|
||||||
@@ -2316,9 +2333,8 @@ bool InterperterThread::AppendList(std::shared_ptr<GC> gc) {
|
|||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
auto obj = stk->Pop(ls);
|
auto obj = stk->Pop(ls);
|
||||||
auto objhold = stk->Pop(ls);
|
auto objhold = stk->Pop(ls);
|
||||||
if (std::holds_alternative<THeapObjectHolder>(objhold)) {
|
if (std::holds_alternative<THeapObject *>(objhold)) {
|
||||||
auto list =
|
auto list = dynamic_cast<TList *>(std::get<THeapObject *>(objhold));
|
||||||
dynamic_cast<TList *>(std::get<THeapObjectHolder>(objhold).obj);
|
|
||||||
if (list != nullptr) {
|
if (list != nullptr) {
|
||||||
list->Add(obj);
|
list->Add(obj);
|
||||||
}
|
}
|
||||||
@@ -2348,12 +2364,12 @@ bool InterperterThread::AppendDictionary(std::shared_ptr<GC> gc) {
|
|||||||
auto value = stk->Pop(ls);
|
auto value = stk->Pop(ls);
|
||||||
auto k = stk->Pop(ls);
|
auto k = stk->Pop(ls);
|
||||||
auto objhold = stk->Pop(ls);
|
auto objhold = stk->Pop(ls);
|
||||||
if (std::holds_alternative<THeapObjectHolder>(objhold) &&
|
if (std::holds_alternative<THeapObject *>(objhold) &&
|
||||||
std::holds_alternative<std::string>(k)) {
|
std::holds_alternative<std::string>(k)) {
|
||||||
auto dict = dynamic_cast<TDictionary *>(
|
auto dict =
|
||||||
std::get<THeapObjectHolder>(objhold).obj);
|
dynamic_cast<TDictionary *>(std::get<THeapObject *>(objhold));
|
||||||
auto cls = dynamic_cast<TClassObject *>(
|
auto cls =
|
||||||
std::get<THeapObjectHolder>(objhold).obj);
|
dynamic_cast<TClassObject *>(std::get<THeapObject *>(objhold));
|
||||||
|
|
||||||
if (dict != nullptr) {
|
if (dict != nullptr) {
|
||||||
dict->SetValue(std::get<std::string>(k), value);
|
dict->SetValue(std::get<std::string>(k), value);
|
||||||
@@ -2409,23 +2425,39 @@ bool InterperterThread::TryCatch(std::shared_ptr<GC> gc) {
|
|||||||
if (GetObjectHeap(tryFn, tryC) && GetObjectHeap(catchFn, catchC)) {
|
if (GetObjectHeap(tryFn, tryC) && GetObjectHeap(catchFn, catchC)) {
|
||||||
try {
|
try {
|
||||||
stk->Push(gc, tryC->Call(ls, {}));
|
stk->Push(gc, tryC->Call(ls, {}));
|
||||||
}
|
|
||||||
|
|
||||||
catch (std::exception &ex) {
|
} catch (std::bad_alloc &ex) {
|
||||||
TDictionary *dict = TDictionary::Create(ls);
|
std::cerr
|
||||||
auto gc = ls.GetGC();
|
<< "CrossLang has failed to allocate, sorry for termination."
|
||||||
auto myEx = dynamic_cast<VMByteCodeException *>(&ex);
|
<< std::endl;
|
||||||
if (myEx != nullptr) {
|
std::exit(1);
|
||||||
stk->Push(gc, catchC->Call(ls, {myEx->exception}));
|
} catch (const std::string &ex) {
|
||||||
} else {
|
stk->Push(gc, catchC->Call(ls, {ex}));
|
||||||
gc->BarrierBegin();
|
} catch (const char *ex) {
|
||||||
|
|
||||||
dict->SetValue("Type", "NativeException");
|
stk->Push(gc,
|
||||||
dict->SetValue("Text", ex.what());
|
catchC->Call(ls, {std::string{ex != nullptr ? ex : ""}}));
|
||||||
gc->BarrierEnd();
|
} catch (std::runtime_error &ex) {
|
||||||
|
|
||||||
stk->Push(gc, catchC->Call(ls, {dict}));
|
stk->Push(
|
||||||
}
|
gc, catchC->Call(ls, {TNativeObject::Create<TException>(
|
||||||
|
ls, ex.what(), "RuntimeException")}));
|
||||||
|
} catch (VMException &ex) {
|
||||||
|
stk->Push(
|
||||||
|
gc, catchC->Call(ls, {TNativeObject::Create<TException>(
|
||||||
|
ls, ex.GetMessage(), "VMException")}));
|
||||||
|
} catch (VMByteCodeException &ex) {
|
||||||
|
stk->Push(gc, catchC->Call(ls, {ex.exception}));
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
stk->Push(gc,
|
||||||
|
catchC->Call(
|
||||||
|
ls, {TNativeObject::Create<TNativeException>(
|
||||||
|
ls, ex.what(), std::current_exception())}));
|
||||||
|
} catch (...) {
|
||||||
|
stk->Push(gc,
|
||||||
|
catchC->Call(ls, {TNativeObject::Create<TNativeException>(
|
||||||
|
ls, "<No Message>",
|
||||||
|
std::current_exception())}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2693,14 +2725,14 @@ void InterperterThread::Execute(std::shared_ptr<GC> gc) {
|
|||||||
|
|
||||||
std::vector<CallStackEntry *> &cse = this->call_stack_entries;
|
std::vector<CallStackEntry *> &cse = this->call_stack_entries;
|
||||||
#define VM_OPCODE_TABLE_INLINE
|
#define VM_OPCODE_TABLE_INLINE
|
||||||
#include "vm_opcode_table.h"
|
#include "vm_opcode_table.def"
|
||||||
#undef VM_OPCODE_TABLE_INLINE
|
#undef VM_OPCODE_TABLE_INLINE
|
||||||
|
|
||||||
execute:
|
execute:
|
||||||
|
|
||||||
if (!cse.empty()) {
|
if (!cse.empty()) {
|
||||||
auto stk = cse.back();
|
auto stk = cse.back();
|
||||||
current_function = stk;
|
GC::SetCurrentFunction(stk);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (stk->ip < 0xFFFFFFFF &&
|
while (stk->ip < 0xFFFFFFFF &&
|
||||||
@@ -2715,13 +2747,38 @@ execute:
|
|||||||
if (stk->mustReturn) {
|
if (stk->mustReturn) {
|
||||||
|
|
||||||
stk->mustReturn = false;
|
stk->mustReturn = false;
|
||||||
|
|
||||||
|
gc->BarrierBegin();
|
||||||
|
GCList ls(gc);
|
||||||
|
std::vector<TCallable *> callable;
|
||||||
|
while (!cse.empty()) {
|
||||||
|
auto r = cse.back();
|
||||||
|
auto e = r->env;
|
||||||
|
for (uint32_t i = 0; i < r->scopes; i++) {
|
||||||
|
if (!e->defers.empty()) {
|
||||||
|
ls.Add(e);
|
||||||
|
callable.insert(callable.end(),
|
||||||
|
e->defers.begin(),
|
||||||
|
e->defers.end());
|
||||||
|
}
|
||||||
|
e = e->GetParentEnvironment();
|
||||||
|
}
|
||||||
|
cse.erase(cse.end() - 1);
|
||||||
|
}
|
||||||
|
gc->BarrierEnd();
|
||||||
|
|
||||||
|
for (auto item : callable) {
|
||||||
|
GCList ls2(gc);
|
||||||
|
item->Call(ls2, {});
|
||||||
|
}
|
||||||
|
|
||||||
if (cse.size() > 1) {
|
if (cse.size() > 1) {
|
||||||
GCList ls(gc);
|
GCList ls(gc);
|
||||||
TObject o = cse[cse.size() - 1]->Pop(ls);
|
TObject o = cse[cse.size() - 1]->Pop(ls);
|
||||||
cse[cse.size() - 2]->Push(gc, o);
|
cse[cse.size() - 2]->Push(gc, o);
|
||||||
|
|
||||||
cse.erase(cse.end() - 1);
|
cse.erase(cse.end() - 1);
|
||||||
current_function = cse.back();
|
GC::SetCurrentFunction(cse.back());
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
goto execute;
|
goto execute;
|
||||||
} else {
|
} else {
|
||||||
@@ -2729,8 +2786,13 @@ execute:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc->UsingNullThreads())
|
if (gc->UsingNullThreads()) {
|
||||||
gc->Collect();
|
std::vector<THeapObject *> objs;
|
||||||
|
gc->Collect(objs);
|
||||||
|
for (auto &item : objs) {
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stk->mustReturn = false;
|
stk->mustReturn = false;
|
||||||
@@ -2764,7 +2826,7 @@ execute:
|
|||||||
}
|
}
|
||||||
if (cse.size() == 1) {
|
if (cse.size() == 1) {
|
||||||
|
|
||||||
current_function = nullptr;
|
GC::SetCurrentFunction(nullptr);
|
||||||
{
|
{
|
||||||
|
|
||||||
gc->BarrierBegin();
|
gc->BarrierBegin();
|
||||||
@@ -2817,7 +2879,7 @@ execute:
|
|||||||
cse[cse.size() - 2]->Push(gc, o);
|
cse[cse.size() - 2]->Push(gc, o);
|
||||||
|
|
||||||
cse.erase(cse.end() - 1);
|
cse.erase(cse.end() - 1);
|
||||||
current_function = cse.back();
|
GC::SetCurrentFunction(cse.back());
|
||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
|
|
||||||
for (auto item : callable) {
|
for (auto item : callable) {
|
||||||
@@ -2846,7 +2908,7 @@ void CallStackEntry::Push(std::shared_ptr<GC> gc, TObject o) {
|
|||||||
gc->BarrierEnd();
|
gc->BarrierEnd();
|
||||||
}
|
}
|
||||||
TObject CallStackEntry::Resume(GCList &ls) {
|
TObject CallStackEntry::Resume(GCList &ls) {
|
||||||
auto cse = current_function;
|
auto cse = GC::GetCurrentFunction();
|
||||||
InterperterThread *thrd = InterperterThread::Create(ls);
|
InterperterThread *thrd = InterperterThread::Create(ls);
|
||||||
ls.GetGC()->BarrierBegin();
|
ls.GetGC()->BarrierBegin();
|
||||||
thrd->call_stack_entries.push_back(this);
|
thrd->call_stack_entries.push_back(this);
|
||||||
@@ -2855,7 +2917,7 @@ TObject CallStackEntry::Resume(GCList &ls) {
|
|||||||
thrd->Execute(ls.GetGC());
|
thrd->Execute(ls.GetGC());
|
||||||
|
|
||||||
TObject v = thrd->call_stack_entries[0]->Pop(ls);
|
TObject v = thrd->call_stack_entries[0]->Pop(ls);
|
||||||
current_function = cse;
|
GC::SetCurrentFunction(cse);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
TObject CallStackEntry::Pop(GCList &gc) {
|
TObject CallStackEntry::Pop(GCList &gc) {
|
||||||
@@ -2870,41 +2932,17 @@ TObject CallStackEntry::Pop(GCList &gc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InterperterThread *InterperterThread::Create(GCList &ls) {
|
InterperterThread *InterperterThread::Create(GCList &ls) {
|
||||||
InterperterThread *it = new InterperterThread();
|
return ls.Create<InterperterThread>();
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(it);
|
|
||||||
_gc->Watch(it);
|
|
||||||
return it;
|
|
||||||
}
|
}
|
||||||
InterperterThread *InterperterThread::Create(GCList *ls) {
|
InterperterThread *InterperterThread::Create(GCList *ls) {
|
||||||
InterperterThread *it = new InterperterThread();
|
return ls->Create<InterperterThread>();
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(it);
|
|
||||||
_gc->Watch(it);
|
|
||||||
return it;
|
|
||||||
}
|
}
|
||||||
CallStackEntry *CallStackEntry::Create(GCList &ls) {
|
CallStackEntry *CallStackEntry::Create(GCList &ls) {
|
||||||
CallStackEntry *cse = new CallStackEntry();
|
return ls.Create<CallStackEntry>();
|
||||||
cse->mustReturn = false;
|
|
||||||
cse->srcline = -1;
|
|
||||||
cse->srcfile = "";
|
|
||||||
cse->thread = nullptr;
|
|
||||||
std::shared_ptr<GC> _gc = ls.GetGC();
|
|
||||||
ls.Add(cse);
|
|
||||||
_gc->Watch(cse);
|
|
||||||
return cse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CallStackEntry *CallStackEntry::Create(GCList *ls) {
|
CallStackEntry *CallStackEntry::Create(GCList *ls) {
|
||||||
CallStackEntry *cse = new CallStackEntry();
|
return ls->Create<CallStackEntry>();
|
||||||
cse->mustReturn = false;
|
|
||||||
cse->srcline = -1;
|
|
||||||
cse->srcfile = "";
|
|
||||||
cse->thread = nullptr;
|
|
||||||
std::shared_ptr<GC> _gc = ls->GetGC();
|
|
||||||
ls->Add(cse);
|
|
||||||
_gc->Watch(cse);
|
|
||||||
return cse;
|
|
||||||
}
|
}
|
||||||
void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
|
void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
|
||||||
std::vector<TObject> args) {
|
std::vector<TObject> args) {
|
||||||
@@ -2963,6 +3001,18 @@ void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
|
|||||||
cse->env->DeclareVariable(trimStart(closure->closure->args[i]),
|
cse->env->DeclareVariable(trimStart(closure->closure->args[i]),
|
||||||
args[i]);
|
args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (; i < closure->closure->args.size(); i++) {
|
||||||
|
auto &a = closure->closure->args[i];
|
||||||
|
if (a.size() > 1 && a[0] == '$') {
|
||||||
|
if (a[1] == '$') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cse->env->DeclareVariable(trimStart(a), Undefined());
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
std::string back = closure->closure->args.empty()
|
std::string back = closure->closure->args.empty()
|
||||||
? std::string()
|
? std::string()
|
||||||
: closure->closure->args.back();
|
: closure->closure->args.back();
|
||||||
@@ -2979,7 +3029,7 @@ void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
|
|||||||
throw VMException("Too many arguments");
|
throw VMException("Too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
current_function = cse;
|
GC::SetCurrentFunction(cse);
|
||||||
|
|
||||||
this->call_stack_entries.push_back(cse);
|
this->call_stack_entries.push_back(cse);
|
||||||
ls.GetGC()->BarrierEnd();
|
ls.GetGC()->BarrierEnd();
|
||||||
|
|||||||
Reference in New Issue
Block a user