6 Commits
87 changed files with 3018 additions and 2278 deletions
+10 -5
View File
@@ -5,7 +5,7 @@ on:
- 'v*'
env:
TF_VERSION: 0.0.7
TF_VERSION: 0.0.9
PACKAGE_AND_BREW: ${{ secrets.PACKAGE_AND_BREW }}
VERSION: ${{ gitea.ref_name }}
RESULT_IMAGE_NAME: tesses50/crosslang
@@ -15,7 +15,7 @@ env:
jobs:
build-ppc:
name: "🔨 Build for PowerPC"
runs-on: ubuntu-latest
runs-on: asrock
container:
image: git.tesses.org/tesses50/linux-ppc:latest
steps:
@@ -31,27 +31,31 @@ jobs:
build-packages:
name: "🔨 Build for everything else"
runs-on: fw13-ubuntu-latest
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:
@@ -67,7 +71,8 @@ jobs:
update-tap:
runs-on: global-container-mingw
runs-on: msi-walmart
container: git.tesses.org/tesses50/global-containers-mingw:latest
steps:
- uses: actions/checkout@v4
- run: |
+5 -3
View File
@@ -8,8 +8,11 @@
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/builds/l/crossint",
"args": ["queryable.tcross"],
"program": "${workspaceFolder}/build/crosslang",
"args": [
"webapp",
"tytd2025"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/builds/l",
"environment": [],
@@ -28,6 +31,5 @@
}
]
}
]
}
+633
View File
@@ -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
View File
@@ -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>.
+2 -2
View File
@@ -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}'`
echo "class Crosslang < Formula" > "Formula/crosslang.rb"
echo " desc \"\"" >> "Formula/crosslang.rb"
echo " homepage \"\"" >> "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 \"https://crosslang.tesseslanguage.com/\"" >> "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 " license \"GPLv3\"" >> "Formula/crosslang.rb"
+14 -9
View File
@@ -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.
![CrossImage](crosslang.png)
[WebSite](https://crosslang.tesseslanguage.com/)
## 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
## Use in docker (use my container)
```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)
@@ -23,16 +24,15 @@ Tesses Cross Language
```
## 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)
- Follow the commands bellow
Pick one depending on what you need
## Run these commands to install crosslang (with plugin support)
### Run these commands to install crosslang (with plugin support)
```bash
git clone https://git.tesses.org/tesses50/tessesframework
cd tessesframework
mkdir build
cd build
cmake -S .. -B . -DTESSESFRAMEWORK_FETCHCONTENT=OFF
cmake -S .. -B .
make
sudo make install
cd ../..
@@ -45,13 +45,18 @@ make
sudo make install
```
## Build with shared libs only (self contained dependencies)
### Build with shared libs only (self contained dependencies)
```bash
cmake -S ../.. -B .
make -j`nproc`
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)
```
+5 -2
View File
@@ -1,5 +1,8 @@
# 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
@@ -10,7 +13,7 @@ Fixed Process.ShellFileOrUrl was broken New.ShellFileOrUrl
Use new build setup
## 0.0.7
Fix a security vulerability in crossdump that is supposed to use uint32_t but accidently used uint8_t, set to tessesframework=0.0.5
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
Fix bug with classes, use slim exclusively, add package private data and change rehaul cmake configs
@@ -22,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
## 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
Add uuids, bytestreams and single file runtime binaries
+1 -1
View File
@@ -1,6 +1,6 @@
include(InstallRequiredSystemLibraries)
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_MINOR "${TessesCrossLang_VERSION_MINOR}")
+1 -1
View File
@@ -5,7 +5,7 @@ set(CROSSLANG_STATIC ${TESSESFRAMEWORK_STATIC} CACHE INTERNAL "For CrossLang" FO
FetchContent_Declare(
TessesFramework
GIT_REPOSITORY https://git.tesses.org/tesses50/tessesframework.git
GIT_TAG 5b54af1728907559999e446e56497055297a3696
GIT_TAG e4ca34aa597c9b0955aa23c18c500048af697c92
)
set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF)
FetchContent_MakeAvailable(TessesFramework)
-1
View File
@@ -12,7 +12,6 @@ src/vm/bc/tobool.cpp
src/compiler/codegen.cpp
src/compiler/lexer.cpp
src/compiler/parser.cpp
src/compiler/ast.cpp
src/runtime_methods/uuid.cpp
src/runtime_methods/class.cpp
src/runtime_methods/console.cpp
+1 -1
View File
@@ -1,3 +1,3 @@
set(CROSSLANG_MAJOR_VERSION 0)
set(CROSSLANG_MINOR_VERSION 0)
set(CROSSLANG_PATCH_VERSION 10)
set(CROSSLANG_PATCH_VERSION 11)
+89 -332
View File
@@ -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
#include <TessesFramework/TessesFramework.hpp>
#include <any>
@@ -84,33 +104,31 @@ class TVMVersion {
*
* @return uint8_t The major
*/
uint8_t Major() const { return major; }
uint8_t Major() { return major; }
/**
* @brief Minor
*
* @return uint8_t The minor
*/
uint8_t Minor() const { return minor; }
uint8_t Minor() { return minor; }
/**
* @brief Patch
*
* @return uint8_t The patch
*/
uint8_t Patch() const { return patch; }
uint8_t Patch() { return patch; }
/**
* @brief Build
*
* @return uint16_t The build
*/
uint16_t Build() const { return build >> 2; }
uint16_t Build() { return build >> 2; }
/**
* @brief Stage (dev, alpha, beta or prod)
*
* @return TVMVersionStage The stage
*/
TVMVersionStage VersionStage() const {
return static_cast<TVMVersionStage>(build & 3);
}
TVMVersionStage VersionStage() { return (TVMVersionStage)(build & 3); }
/**
* @brief Set the Major
*
@@ -217,7 +235,7 @@ class TVMVersion {
*
* @param versionData an array that is 5 bytes long
*/
void ToArray(uint8_t *versionData) const {
void ToArray(uint8_t *versionData) {
versionData[0] = major;
versionData[1] = minor;
versionData[2] = patch;
@@ -269,7 +287,7 @@ class TVMVersion {
* @return int returns 1 if this is newer than other version, 0 if same, -1
* if this is older than other version
*/
int CompareTo(const TVMVersion &version) const {
int CompareTo(TVMVersion &version) {
if (this->major > version.major)
return 1;
if (this->major < version.major)
@@ -293,7 +311,7 @@ class TVMVersion {
*
* @return uint64_t serialized as a long
*/
uint64_t AsLong() const {
uint64_t AsLong() {
uint64_t v = (uint64_t)major << 32;
v |= (uint64_t)minor << 24;
v |= (uint64_t)patch << 16;
@@ -306,7 +324,7 @@ class TVMVersion {
* @return int CompareTo(RuntimeVersion) where RuntimeVersion is the runtime
* version
*/
int CompareToRuntime() const {
int CompareToRuntime() {
TVMVersion version(CROSSLANG_BYTECODE_MAJOR, CROSSLANG_BYTECODE_MINOR,
CROSSLANG_BYTECODE_PATCH, CROSSLANG_BYTECODE_BUILD,
CROSSLANG_BYTECODE_VERSIONSTAGE);
@@ -321,10 +339,9 @@ class TVMVersion {
* @return true the parsing succeeded
* @return false the parsing failed
*/
static bool TryParse(const std::string &versionStr, TVMVersion &version) {
static bool TryParse(std::string versionStr, TVMVersion &version) {
if (versionStr.empty())
return false;
size_t sep = versionStr.find_last_of('-');
std::string left = versionStr;
@@ -402,7 +419,7 @@ class TVMVersion {
* @return std::string the version string like 1.0.0.0-prod (or dev, alpha,
* beta)
*/
std::string ToString() const {
std::string ToString() {
std::string str = {};
str.append(std::to_string((int)this->Major()));
str.push_back('.');
@@ -411,20 +428,14 @@ class TVMVersion {
str.append(std::to_string((int)this->Patch()));
str.push_back('.');
str.append(std::to_string((int)this->Build()));
switch (this->VersionStage()) {
case TVMVersionStage::DevVersion:
if (this->VersionStage() == TVMVersionStage::DevVersion) {
str.append("-dev");
break;
case TVMVersionStage::AlphaVersion:
} else if (this->VersionStage() == TVMVersionStage::AlphaVersion) {
str.append("-alpha");
break;
case TVMVersionStage::BetaVersion:
} else if (this->VersionStage() == TVMVersionStage::BetaVersion) {
str.append("-beta");
break;
case TVMVersionStage::ProductionVersion:
} else if (this->VersionStage() == TVMVersionStage::ProductionVersion) {
str.append("-prod");
break;
}
return str;
}
@@ -1288,9 +1299,6 @@ class AdvancedSyntaxNode {
std::vector<SyntaxNode> n);
};
SyntaxNode Deserialize(std::string astData);
std::string Serialize(SyntaxNode node);
class GC;
class TRootEnvironment;
/**
@@ -1356,67 +1364,14 @@ class Parser {
class THeapObject;
class CallStackEntry;
class InterperterThread;
class TString;
class THeapObject {
protected:
virtual bool opAdd(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opSub(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opTimes(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opDiv(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opMod(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opLessThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opGreaterThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opLessThanEqual(InterperterThread *thrd,
std::shared_ptr<GC> gc, TObject rhs);
virtual bool opGreaterThanEqual(InterperterThread *thrd,
std::shared_ptr<GC> gc, TObject rhs);
virtual bool opLeftShift(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opRightShift(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opBitwiseOr(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opBitwiseAnd(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opXor(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
virtual bool opNeg(InterperterThread *thrd, std::shared_ptr<GC> gc);
virtual bool opBitwiseNot(InterperterThread *thrd, std::shared_ptr<GC> gc);
virtual bool opLogicalNot(InterperterThread *thrd, std::shared_ptr<GC> gc);
virtual bool opExecuteMethod(InterperterThread *thrd,
std::shared_ptr<GC> gc,
const std::string &name,
const std::vector<TObject> &args);
virtual bool opSetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name, TObject value);
virtual bool opGetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name);
public:
bool marked;
virtual void Mark() { marked = true; }
THeapObject() = default;
THeapObject(const THeapObject &) = delete;
THeapObject &operator=(const THeapObject &) = delete;
virtual ~THeapObject() = default;
virtual std::string TypeName() = 0;
virtual TString *ToString(GCList &ls);
virtual bool ToBool();
virtual bool IsEqualTo(std::shared_ptr<GC> gc, TObject rhs);
virtual bool IsNotEqualTo(std::shared_ptr<GC> gc, TObject rhs);
friend class InterperterThread;
};
// this is a dummy type with
@@ -1430,12 +1385,13 @@ class TContinue {};
*/
using TObject =
std::variant<Undefined, int64_t, double, char, bool, std::regex,
Tesses::Framework::Filesystem::VFSPath, MethodInvoker,
THeapObject *, TVMVersion,
std::variant<Undefined, int64_t, double, char, bool, std::string,
std::regex, Tesses::Framework::Filesystem::VFSPath,
MethodInvoker, THeapObject *, TVMVersion,
std::shared_ptr<Tesses::Framework::Date::DateTime>,
std::shared_ptr<Tesses::Framework::Date::TimeSpan>, TBreak,
TContinue, std::shared_ptr<Tesses::Framework::Filesystem::VFS>,
TContinue, std::shared_ptr<Tesses::Framework::Streams::Stream>,
std::shared_ptr<Tesses::Framework::Filesystem::VFS>,
std::shared_ptr<Tesses::Framework::Http::IHttpServer>,
std::shared_ptr<Tesses::Framework::Http::HttpRequestBody>,
std::shared_ptr<Tesses::Framework::TextStreams::TextReader>,
@@ -1454,6 +1410,7 @@ class GC : public std::enable_shared_from_this<GC> {
Tesses::Framework::Threading::Mutex mtx;
Tesses::Framework::Threading::Cond cond;
uint32_t allocs = 0;
uint32_t threshold = ALLOC_THRESHOLD;
volatile std::atomic<bool> running;
std::unordered_set<GCList *> roots;
std::unordered_set<THeapObject *> objects;
@@ -1493,7 +1450,7 @@ class GC : public std::enable_shared_from_this<GC> {
};
std::string GetObjectTypeString(TObject obj);
std::string ObjectToString(std::shared_ptr<GC> gc, TObject obj);
std::string ToString(std::shared_ptr<GC> gc, TObject obj);
class GCList {
std::vector<THeapObject *> items;
@@ -1513,8 +1470,6 @@ class GCList {
return obj;
}
TString *FromString(std::string_view str);
void Add(TObject v);
void Remove(TObject v);
void Mark();
@@ -1533,164 +1488,36 @@ class TFileChunk : public THeapObject {
static TFileChunk *Create(GCList &gc);
TFile *file;
std::vector<uint8_t> code;
std::vector<TString *> args;
std::optional<TString *> name;
std::vector<std::string> args;
std::optional<std::string> name;
void Mark();
};
class TMutByteView;
class TByteView : public THeapObject {
class TByteArray : public THeapObject {
public:
virtual std::pair<const uint8_t *, size_t> GetBounds() const = 0;
TString *ToString(GCList &ls);
void CopyTo(TMutByteView *view);
void CopyTo(TMutByteView *view, size_t srcOffset, size_t destOffset,
size_t length);
std::pair<const uint8_t *, size_t>
GetBoundsConstrained(size_t offset = 0, size_t length = (size_t)-1) {
auto bounds = GetBounds();
if (bounds.first == nullptr || offset >= bounds.second || length == 0)
return std::pair<const uint8_t *, size_t>(nullptr, 0);
length = std::min(length, bounds.second - offset);
return std::pair<const uint8_t *, size_t>(bounds.first + offset,
length);
}
std::string TypeName();
bool opExecuteMethod(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name,
const std::vector<TObject> &args);
bool opGetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name);
int64_t GetAt(size_t index) {
auto res = GetBoundsConstrained(index, 1);
if (res.first == nullptr || res.second != 1)
return -1;
return *res.first;
}
};
class TMutByteView : public TByteView {
public:
std::pair<const uint8_t *, size_t> GetBounds() const;
virtual std::pair<uint8_t *, size_t> GetMutableBounds() = 0;
std::pair<uint8_t *, size_t>
GetMutableBoundsConstrained(size_t offset = 0, size_t length = (size_t)-1) {
auto bounds = GetMutableBounds();
if (bounds.first == nullptr || offset >= bounds.second || length == 0)
return std::pair<uint8_t *, size_t>(nullptr, 0);
length = std::min(length, bounds.second - offset);
return std::pair<uint8_t *, size_t>(bounds.first + offset, length);
}
};
class TMemoryStreamMutByteView : public TMutByteView {
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm;
public:
TMemoryStreamMutByteView(
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm);
std::pair<uint8_t *, size_t> GetMutableBounds();
};
class TString : public TByteView {
private:
std::string text;
protected:
bool opAdd(InterperterThread *thrd, std::shared_ptr<GC> gc, TObject rhs);
bool opLessThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
bool opGreaterThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
bool opLessThanEqual(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
bool opGreaterThanEqual(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs);
public:
TString();
explicit TString(std::string_view str);
TString(std::string_view lhs, std::string_view rhs);
TString(const char *text, size_t len);
template <typename Itterator>
TString(Itterator begin, Itterator end) : text(begin, end) {}
TString(std::string &&str);
const std::string &GetString() const;
std::pair<const uint8_t *, size_t> GetBounds() const;
TString *ToString(GCList &ls);
std::string TypeName();
bool IsEqualTo(std::shared_ptr<GC> gc, TObject rhs);
bool IsNotEqualTo(std::shared_ptr<GC> gc, TObject rhs);
};
class TResource : public TByteView {
std::vector<uint8_t> bytes;
public:
TResource(std::vector<uint8_t> &&bytes);
std::pair<const uint8_t *, size_t> GetBounds() const;
std::string TypeName();
};
class TByteArray : public TMutByteView {
std::vector<uint8_t> data;
public:
TByteArray(size_t length);
TByteArray(TByteView *view);
void Resize(size_t length);
std::pair<uint8_t *, size_t> GetMutableBounds();
std::string TypeName();
[[deprecated("Use GCList::Create<T>() instead")]]
static TByteArray *Create(GCList *gc);
[[deprecated("Use GCList::Create<T>() instead")]]
static TByteArray *Create(GCList &gc);
};
class TMutSpan : public TMutByteView {
TMutByteView *view;
int64_t offset;
int64_t length;
public:
TMutSpan(TMutByteView *view, int64_t offset, int64_t length);
std::pair<uint8_t *, size_t> GetMutableBounds();
std::string TypeName();
void Mark();
};
class TSpan : public TByteView {
TByteView *view;
int64_t offset;
int64_t length;
public:
TSpan(TByteView *view, int64_t offset, int64_t length);
std::pair<const uint8_t *, size_t> GetBounds() const;
std::string TypeName();
void Mark();
};
enum class TClassModifier { Private, Protected, Public, Static };
class TClassEntry {
public:
TClassModifier modifier;
bool isFunction;
bool isAbstract;
std::vector<TString *> args;
TString *documentation;
TString *name;
std::vector<std::string> args;
std::string documentation;
std::string name;
uint32_t chunkId;
};
class TClass {
public:
TString *documentation;
std::vector<TString *> name;
std::vector<TString *> inherits;
std::string documentation;
std::vector<std::string> name;
std::vector<std::string> inherits;
std::vector<TClassEntry> entry;
};
class TClassObjectEntry {
@@ -1710,19 +1537,19 @@ class TFile : public THeapObject {
static TFile *Create(GCList &gc);
std::vector<TFileChunk *> chunks;
std::vector<TString *> strings;
std::vector<std::pair<TString *, TString *>> vms;
std::vector<std::pair<std::vector<TString *>, uint32_t>> functions;
std::vector<std::pair<TString *, TVMVersion>> dependencies;
std::vector<std::pair<TString *, TVMVersion>> tools;
std::vector<std::string> strings;
std::vector<std::pair<std::string, std::string>> vms;
std::vector<std::pair<std::vector<std::string>, uint32_t>> functions;
std::vector<std::pair<std::string, TVMVersion>> dependencies;
std::vector<std::pair<std::string, TVMVersion>> tools;
std::vector<std::pair<std::string, std::vector<uint8_t>>> sections;
std::vector<std::pair<TString *, std::vector<uint8_t>>> metadata;
std::vector<TResource *> resources;
std::vector<std::pair<std::string, std::vector<uint8_t>>> metadata;
std::vector<std::vector<uint8_t>> resources;
std::vector<TClass> classes;
TString *name;
std::string name;
TVMVersion version;
TString *info;
TResource *icon = nullptr;
std::string info;
int32_t icon = -1;
void Load(std::shared_ptr<GC> gc,
std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
@@ -1732,10 +1559,10 @@ class TFile : public THeapObject {
uint8_t *buffer, size_t len);
uint32_t
EnsureInt(std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
void EnsureString(GCList &ls,
std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
std::string
EnsureString(std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
TString *
std::string
GetString(std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
void Mark();
@@ -1761,13 +1588,6 @@ class TAssociativeArray : public THeapObject {
};
class TList : public THeapObject {
protected:
bool opExecuteMethod(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name,
const std::vector<TObject> &args);
bool opGetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name);
public:
TList() = default;
template <typename Itterator>
@@ -1775,7 +1595,10 @@ class TList : public THeapObject {
TList(std::initializer_list<TObject> il) : items(il) {}
TList(int64_t capacity) { items.reserve(capacity); }
std::vector<TObject> items;
[[deprecated("Use GCList::Create<T>() instead")]]
static TList *Create(GCList *gc);
[[deprecated("Use GCList::Create<T>() instead")]]
static TList *Create(GCList &gc);
template <typename Itterator>
[[deprecated("Use GCList::Create<T>() instead")]]
static TList *Create(GCList *gc, Itterator begin, Itterator end) {
@@ -1794,7 +1617,6 @@ class TList : public THeapObject {
static TList *Create(GCList &gc, std::initializer_list<TObject> il) {
return gc.Create<TList>(il);
}
std::string TypeName();
virtual int64_t Count();
virtual TObject Get(int64_t index);
virtual void Set(int64_t index, TObject value);
@@ -2431,7 +2253,7 @@ class TDynamicList : public THeapObject {
TObject Remove(GCList &ls, TObject v);
TObject RemoveAt(GCList &ls, int64_t v);
TObject Clear(GCList &ls);
TString *ToString(GCList &ls);
TObject ToString(GCList &ls);
~TDynamicList();
};
@@ -2645,64 +2467,12 @@ class TNativeObject : public THeapObject {
return ls->Create<T>(std::forward<TArgs>(args)...);
}
virtual TObject CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args) = 0;
virtual TObject CallMethod(GCList &ls, std::string name,
std::vector<TObject> args) = 0;
virtual std::string TypeName() = 0;
virtual bool ToBool();
virtual bool Equals(std::shared_ptr<GC> gc, TObject right);
};
class ITStream : public TNativeObject {
protected:
bool Exists(std::string_view str);
public:
TObject CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args);
std::string TypeName();
virtual std::shared_ptr<Tesses::Framework::Streams::Stream> GetStream() = 0;
};
class TObjectStreamWrapper : public ITStream {
std::shared_ptr<TObjectStream> strm;
public:
TObjectStreamWrapper(std::shared_ptr<TObjectStream> strm);
TObject CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args);
std::string TypeName();
std::shared_ptr<Tesses::Framework::Streams::Stream> GetStream();
};
class TStream : public ITStream {
std::shared_ptr<Tesses::Framework::Streams::Stream> strm;
public:
TStream(std::shared_ptr<Tesses::Framework::Streams::Stream> strm);
std::shared_ptr<Tesses::Framework::Streams::Stream> GetStream();
};
class TMemoryStream : public ITStream {
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm;
public:
TMemoryStream(
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm);
std::shared_ptr<Tesses::Framework::Streams::Stream> GetStream();
TObject CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args);
std::string TypeName();
};
class TNetworkStream : public ITStream {
std::shared_ptr<Tesses::Framework::Streams::NetworkStream> strm;
TNetworkStream(
std::shared_ptr<Tesses::Framework::Streams::NetworkStream> strm);
std::shared_ptr<Tesses::Framework::Streams::Stream> GetStream();
TObject CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args);
std::string TypeName();
};
class TRandom : public TNativeObject {
public:
Tesses::Framework::Random random;
@@ -2813,7 +2583,7 @@ class SyntaxException : public std::exception {
LexTokenLineInfo LineInfo() { return line; }
};
template <typename T> bool GetObject(const TObject &obj, T &res) {
template <typename T> bool GetObject(TObject &obj, T &res) {
if (!std::holds_alternative<T>(obj))
return false;
res = std::get<T>(obj);
@@ -2828,34 +2598,20 @@ inline bool IsNull(const TObject &obj) {
}
[[deprecated("Use GetObjectHeap() with TString instead")]]
inline bool GetObject(const TObject &obj, std::string &str) {
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,
std::enable_if_t<std::is_base_of_v<Tesses::Framework::Streams::Stream, T>,
int> = 0>
bool GetObject(const TObject &obj, std::shared_ptr<T> &ptr) {
ITStream *strm;
if (!GetObjectHeap(obj, strm))
return false;
auto res = std::dynamic_pointer_cast<T>(strm->GetStream());
if (!res)
return false;
ptr = res;
return true;
}
template <typename T>
bool GetArgument(const std::vector<TObject> &args, size_t index, T &obj) {
bool GetArgument(std::vector<TObject> &args, size_t index, T &obj) {
if (index >= args.size())
return false;
return GetObject(args[index], obj);
}
template <typename T> bool GetObjectHeap(TObject &obj, T &res) {
THeapObject *h;
if (!GetObject<THeapObject *>(obj, h))
@@ -2868,7 +2624,7 @@ template <typename T> bool GetObjectHeap(TObject &obj, T &res) {
}
template <typename T>
bool GetArgumentHeap(const std::vector<TObject> &args, size_t index, T &obj) {
bool GetArgumentHeap(std::vector<TObject> &args, size_t index, T &obj) {
if (index >= args.size())
return false;
return GetObjectHeap(args[index], obj);
@@ -2878,8 +2634,8 @@ bool GetObjectAsPath(TObject &obj, Tesses::Framework::Filesystem::VFSPath &path,
bool GetArgumentAsPath(std::vector<TObject> &args, size_t index,
Tesses::Framework::Filesystem::VFSPath &path,
bool allowString = true);
bool ObjectToBool(TObject obj);
bool ObjectEquals(std::shared_ptr<GC> gc, TObject left, TObject right);
bool ToBool(TObject obj);
bool Equals(std::shared_ptr<GC> gc, TObject left, TObject right);
typedef void (*PluginFunction)(std::shared_ptr<GC> gc, TRootEnvironment *env);
#if !defined(_WIN32)
#define DLLEXPORT
@@ -2924,10 +2680,11 @@ ToHttpServer(std::shared_ptr<GC> gc, TObject obj);
class EmbedStream : public Tesses::Framework::Streams::Stream {
size_t offset;
MarkedTObject resource;
MarkedTObject file;
uint32_t resource;
public:
EmbedStream(std::shared_ptr<GC> gc, TResource *res);
EmbedStream(std::shared_ptr<GC> gc, TFile *file, uint32_t resource);
bool CanRead();
bool CanSeek();
bool EndOfStream();
+1 -1
View File
@@ -80,7 +80,7 @@ maintainer: Mike Nolan <tesses@tesses.net>
# 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: TessesFramework a library to make C++ easier for me, used in CrossLang
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}
+2
View File
@@ -10,6 +10,8 @@ else()
set(PKGCONFIG_DEPS "")
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)
install(FILES
+20
View File
@@ -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 <iostream>
namespace Tesses::CrossLang {
-139
View File
@@ -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 (IsNull(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
+27 -8
View File
@@ -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 <array>
#include <cstring>
@@ -1085,16 +1105,15 @@ void CodeGen::GenNode(std::vector<ByteCodeInstruction *> &instructions,
GenNode(instructions, adv.nodes[0], scope, contscope, brkscope,
contI, brkI);
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,
contI, brkI);
}
GenNode(instructions, adv.nodes[2], scope, contscope, brkscope,
contI, brkI);
instructions.push_back(new JumpStyleInstruction(JMP, ifIdEnd));
instructions.push_back(new LabelInstruction(ifIdTrue));
if (!std::holds_alternative<std::nullptr_t>(adv.nodes[1])) {
GenNode(instructions, adv.nodes[1], scope, contscope, brkscope,
contI, brkI);
}
GenNode(instructions, adv.nodes[1], scope, contscope, brkscope,
contI, brkI);
instructions.push_back(new LabelInstruction(ifIdEnd));
} else if (adv.nodeName == CompoundAssignExpression &&
+20
View File
@@ -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 <iostream>
#include <sstream>
+30 -2
View File
@@ -1,7 +1,37 @@
/*
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 <iostream>
#include <stdexcept>
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) {
if (std::holds_alternative<Undefined>(o))
return Undefined();
@@ -1865,8 +1895,6 @@ SyntaxNode Parser::ParseBAnd() {
SyntaxNode Parser::ParseExpression() {
SyntaxNode expr = ParseAssignment();
while (IsSymbol(",")) {
if (IsAnySymbol({"]", "}"}, false))
break;
expr = AdvancedSyntaxNode::Create(CommaExpression, true,
{expr, ParseAssignment()});
}
+20
View File
@@ -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 <TessesFramework/Common.hpp>
#include <TessesFramework/Filesystem/LocalFS.hpp>
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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 <iostream>
namespace Tesses::CrossLang::Programs {
+20
View File
@@ -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 <iostream>
+20
View File
@@ -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 <iostream>
namespace Tesses::CrossLang::Programs {
+21 -1
View File
@@ -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 "TessesFramework/Platform/Environment.hpp"
#include <iostream>
@@ -142,7 +162,7 @@ TObject CrossLangShell(GCList &ls, std::vector<std::string> &argv) {
env->LoadFileWithDependencies(
ls.GetGC(), Tesses::Framework::Filesystem::LocalFS, filename);
TList *args = ls.Create<TList>();
TList *args = TList::Create(ls);
args->Add(filename.ToString());
+20
View File
@@ -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 <fstream>
#include <iostream>
+21 -1
View File
@@ -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 <fstream>
#include <iostream>
@@ -39,7 +59,7 @@ TObject CrossLangInterperter(GCList &ls, TRootEnvironment *env,
}
}
TList *args = ls.Create<TList>();
TList *args = TList::Create(ls);
for (int arg = 1; arg < argv.size(); arg++)
args->Add(std::string(argv[arg]));
+22 -2
View File
@@ -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"
using namespace Tesses::Framework;
namespace Tesses::CrossLang::Programs {
@@ -25,7 +45,7 @@ TObject CrossLangVM(GCList &ls, TRootEnvironment *env,
env->EnsureDictionary(ls.GetGC(), "Net")
->SetValue("WebServerPort", (int64_t)port);
TList *args2 = ls.Create<TList>();
TList *args2 = TList::Create(ls);
for (auto &item : args.positional) {
args2->Add(item);
}
@@ -48,7 +68,7 @@ TObject CrossLangVM(GCList &ls, TRootEnvironment *env,
TF_Quit();
return (int64_t)0;
} else {
TList *args = ls.Create<TList>();
TList *args = TList::Create(ls);
for (size_t arg = 1; arg < argv.size(); arg++)
args->Add(std::string(argv[arg]));
+24
View File
@@ -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 "TessesFramework/Filesystem/VFS.hpp"
using namespace Tesses::Framework;
@@ -162,6 +182,10 @@ int main(int argc, char **argv) {
}
}
return 0;
} else if (args[1] == "configdir") {
Tesses::Framework::Console::WriteLine(
GetCrossLangConfigDir().ToString());
return 0;
} else if (args[1] == "vm") {
int64_t myi64 = 0;
+24 -4
View File
@@ -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"
namespace Tesses::CrossLang {
static TList *VectorOfStringToList(GCList &ls, std::vector<std::string> &strs) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for (auto &item : strs)
list->Add(item);
@@ -10,7 +30,7 @@ static TList *VectorOfStringToList(GCList &ls, std::vector<std::string> &strs) {
return list;
}
static TList *EntriesToList(GCList &ls, std::vector<TClassEntry> &ents) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for (auto &item : ents) {
std::string modifier = "public";
@@ -42,7 +62,7 @@ static TList *EntriesToList(GCList &ls, std::vector<TClassEntry> &ents) {
return list;
}
static TList *ClassInstanceToList(GCList &ls, TClassObject *co) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for (auto &item : co->entries) {
if (item.modifier == TClassModifier::Public) {
@@ -126,7 +146,7 @@ static TObject Class_CreateInstance(TRootEnvironment *env, GCList &ls,
}
static TObject Class_GetClassNames(TRootEnvironment *env, GCList &ls,
std::vector<TObject> args) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for (auto &item : env->classes) {
list->Add(JoinPeriod(item.first->classes.at(item.second).name));
+20
View File
@@ -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/>.
*/
#ifndef CROSSLANG_CUSTOM_CONSOLE
#include "CrossLang.hpp"
#include <iostream>
+20
View File
@@ -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"
using namespace Tesses::Framework::Crypto;
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
TObject Dictionary_FindByKey(GCList &ls, std::vector<TObject> args) {
TList *dest = ls.Create<TList>();
TList *dest = TList::Create(ls);
ls.GetGC()->BarrierBegin();
std::string key;
if (GetArgument(args, 1, key)) {
+21 -1
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
@@ -91,7 +111,7 @@ static TObject Env_GetRealExecutablePath(GCList &ls,
}
static TObject Env_GetAll(GCList &ls, std::vector<TObject> args) {
ls.GetGC()->BarrierBegin();
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
std::vector<std::pair<std::string, std::string>> env;
Tesses::Framework::Platform::Environment::GetEnvironmentVariables(env);
for (auto &item : env) {
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
@@ -63,7 +83,7 @@ static TObject FS_ReadAllLines(GCList &ls, std::vector<TObject> args) {
Tesses::Framework::Filesystem::Helpers::ReadAllLines(vfs, path, lines);
ls.GetGC()->BarrierBegin();
auto items = ls.Create<TList>();
auto items = TList::Create(ls);
for (auto &l : lines) {
items->Add(l);
}
+20 -1
View File
@@ -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"
using namespace Tesses::Framework::Serialization::Json;
@@ -114,7 +133,7 @@ static TObject JsonDeserialize(GCList &ls2, JToken json) {
if (TryGetJToken(json, str))
return str;
if (TryGetJToken(json, arr)) {
TList *ls = ls2.Create<TList>();
TList *ls = TList::Create(ls2);
for (auto &item : arr) {
auto itemRes = JsonDeserialize(ls2, item);
+339 -5
View File
@@ -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 <TessesFramework/Crypto/ClientTLSStream.hpp>
#include <TessesFramework/Http/HttpClient.hpp>
@@ -17,13 +37,13 @@ static std::shared_ptr<SMTPBody>
TObjectToSMTPBody(GCList &ls, std::string mimeType, TObject obj) {
std::shared_ptr<SMTPBody> body;
std::string text;
TByteView *ba;
TByteArray *ba;
std::shared_ptr<Tesses::Framework::Streams::Stream> sho;
if (GetObject(obj, text)) {
body = std::make_shared<SMTPStringBody>(text, mimeType);
} else if (GetObjectHeap(obj, ba)) {
std::shared_ptr<MemoryStream> ms = std::make_shared<MemoryStream>(true);
ms->WriteBlock(ba->GetData(), ba->GetSize());
ms->WriteBlock(ba->data.data(), ba->data.size());
ms->Seek(0L, SeekOrigin::Begin);
body = std::make_shared<SMTPStreamBody>(mimeType, ms);
@@ -191,7 +211,7 @@ class THttpDictionary : public TNativeObject {
}
return nullptr;
} else if (key == "ToList") {
TList *_ls = ls.Create<TList>();
TList *_ls = TList::Create(ls);
for (auto item : dict->kvp) {
for (auto i : item.second) {
auto d = TDictionary::Create(ls);
@@ -334,7 +354,7 @@ class TServerContext : public TNativeObjectThatReturnsHttpDictionary {
return strm;
});
return ls.Create<TList>(response.begin(), response.end());
return TList::Create(ls, response.begin(), response.end());
}
} else if (key == "getNeedToParseFormData")
return ctx->NeedToParseFormData();
@@ -1449,6 +1469,315 @@ static TObject New_ServerSentEvents(GCList &ls, std::vector<TObject> args) {
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) {
env->permissions.canRegisterNet = true;
@@ -1489,6 +1818,8 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
_new->DeclareFunction(gc, "ServerSentEvents",
"Create server sent events object", {""},
New_ServerSentEvents);
_new->DeclareFunction(gc, "HtmlNode", "Create an html node", {},
New_HtmlNode);
TDictionary *http = TDictionary::Create(ls);
TDictionary *smtp = TDictionary::Create(ls);
@@ -1574,6 +1905,9 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
gc, "MountableServer",
"Create a server you can mount to, must mount parents before child",
{"root"}, New_MountableServer);
http->DeclareFunction(gc, "ParseHtml", "Parse html document",
{"strOrTextReader"}, Net_Http_ParseHtml);
dict->DeclareFunction(gc, "NetworkStream", "Create a network stream",
{"ipv6", "datagram"}, New_NetworkStream);
smtp->DeclareFunction(gc, "Send", "Send email via smtp server",
@@ -1581,7 +1915,7 @@ void TStd::RegisterNet(std::shared_ptr<GC> gc, TRootEnvironment *env) {
dict->DeclareFunction(
gc, "getIPAddresses", "Get the ip addresses of this machine", {"$ipv6"},
[](GCList &ls, std::vector<TObject> args) -> TObject {
TList *a = ls.Create<TList>();
TList *a = TList::Create(ls);
bool ipv6 = false;
GetArgument(args, 0, ipv6);
ls.GetGC()->BarrierBegin();
+20
View File
@@ -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"
#if defined(GEKKO)
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+22 -2
View File
@@ -1,11 +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"
namespace Tesses::CrossLang {
class ProcessObject : public TNativeObject {
public:
ProcessObject(GCList &ls) {
arguments = ls.Create<TList>();
environment = ls.Create<TList>();
arguments = TList::Create(ls);
environment = TList::Create(ls);
process.includeThisEnv = true;
process.redirectStdIn = false;
+21 -1
View File
@@ -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 <TessesFramework/TessesFrameworkFeatures.h>
@@ -100,7 +120,7 @@ class SQLiteObject : public TNativeObject {
this->db->Exec(arg, res);
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
for (auto &item : res) {
TDictionary *dict = TDictionary::Create(ls);
+104 -20
View File
@@ -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 "TessesFramework/Streams/ByteReader.hpp"
#include "TessesFramework/Streams/Stream.hpp"
@@ -31,7 +50,7 @@ std::string SharedExtension = ".dylib";
std::string SharedExtension = ".so";
#endif
class TMuxex : public TNativeObject {
class TMutex : public TNativeObject {
public:
Tesses::Framework::Threading::Mutex mtx;
@@ -49,6 +68,33 @@ class TMuxex : public TNativeObject {
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)
class DL {
@@ -443,6 +489,7 @@ static TObject TypeIsNumber(GCList &ls, std::vector<TObject> args) {
return std::holds_alternative<int64_t>(args[0]) ||
std::holds_alternative<double>(args[0]);
}
static TObject TypeIsLong(GCList &ls, std::vector<TObject> args) {
if (args.empty())
return nullptr;
@@ -538,6 +585,16 @@ static TObject TypeIsQueryable(GCList &ls, std::vector<TObject> args) {
TQueryable *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) {
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs;
@@ -917,14 +974,10 @@ TObject ParseLong(GCList &ls, std::vector<TObject> args) {
std::string str = ToString(ls.GetGC(), args[0]);
try {
int64_t v = std::stoll(str, &pos, base);
if (pos < str.size())
return nullptr;
return v;
} catch (std::exception &ex) {
return nullptr;
}
int64_t d;
if (Tesses::Framework::Serialization::BitConverter::TryParseSigned(
str, d, base))
return d;
}
return nullptr;
}
@@ -936,14 +989,10 @@ TObject ParseDouble(GCList &ls, std::vector<TObject> args) {
std::string str = ToString(ls.GetGC(), args[0]);
try {
double v = std::stod(str, &pos);
if (pos < str.size())
return nullptr;
return v;
} catch (std::exception &ex) {
return nullptr;
}
double d;
if (Tesses::Framework::Serialization::BitConverter::TryParseDouble(str,
d))
return d;
}
return nullptr;
}
@@ -1212,6 +1261,26 @@ static TObject New_Queryable(GCList &ls, std::vector<TObject> args) {
}
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) {
GCList ls(gc);
@@ -1426,7 +1495,13 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
env->DeclareFunction(gc, "TypeIsQueryable",
"Get whether object is a Queryable", {"object"},
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(
gc, "Regex", "Create regex object", {"regex"},
[](GCList &ls, std::vector<TObject> args) -> TObject {
@@ -1438,9 +1513,14 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
return nullptr;
});
newTypes->DeclareFunction(
gc, "Mutex", "Create mutex", {},
gc, "Mutex", "Create a mutex", {},
[](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(
gc, "Thread", "Create thread", {"callback"},
@@ -1481,6 +1561,10 @@ void TStd::RegisterRoot(std::shared_ptr<GC> gc, TRootEnvironment *env) {
[](GCList &ls, std::vector<TObject> args) -> TObject {
return TAssociativeArray::Create(ls);
});
newTypes->DeclareFunction(
gc, "Exception", "Create an Exception",
{"message", "$type", "$extraFields", "$innerException"}, New_Exception);
newTypes->DeclareFunction(
gc, "ByteArray",
"Create bytearray, with optional either size (to size it) or string "
+20
View File
@@ -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 "CrossLang.hpp"
#include "TessesFramework/Serialization/BitConverter.hpp"
+22 -2
View File
@@ -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 <fstream>
#include <iostream>
@@ -39,7 +59,7 @@ static TObject AstToTObject(GCList &ls, SyntaxNode node) {
ls.GetGC()->BarrierBegin();
r->SetValue("Type", asn.nodeName);
r->SetValue("IsExpression", asn.isExpression);
TList *ls2 = ls.Create<TList>();
TList *ls2 = TList::Create(ls);
for (auto item : asn.nodes) {
ls2->Add(AstToTObject(ls, item));
}
@@ -268,7 +288,7 @@ static TObject VM_GetStacktrace(GCList &ls, std::vector<TObject> args) {
auto current_function = GC::GetCurrentFunction();
if (current_function != nullptr) {
if (current_function->thread != nullptr) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
ls.GetGC()->BarrierBegin();
for (auto item : current_function->thread->call_stack_entries) {
auto dict = TDictionary::Create(ls);
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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"
// THANKS TO https://www.youtube.com/watch?v=R-z2Hv-7nxk
namespace Tesses::CrossLang {
-83
View File
@@ -1,83 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
std::string TByteView::TypeName() { return "ByteView"; }
TString *TByteView::ToString(GCList &ls) {
auto bounds = GetBounds();
if (bounds.first == nullptr || bounds.second == 0)
return ls.FromString("");
return ls.Create<TString>(reinterpret_cast<const char *>(bounds.first),
bounds.second);
}
bool TByteView::opExecuteMethod(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name,
const std::vector<TObject> &args) {
if (name == "Slice") {
int64_t offset = 0;
int64_t length = -1;
GetArgument(args, 0, offset);
GetArgument(args, 1, length);
GCList ls(gc);
thrd->call_stack_entries.back()->Push(
gc, ls.Create<TSpan>(this, offset, length));
return false;
}
if (name == "Count" || name == "Length") {
thrd->call_stack_entries.back()->Push(
gc, static_cast<int64_t>(this->GetBounds().second));
return false;
}
if (name == "GetAt") {
int64_t i64;
if (GetArgument(args, 0, i64)) {
auto res = this->GetAt(static_cast<size_t>(i64));
thrd->call_stack_entries.back()->Push(
gc, res == -1 ? static_cast<TObject>(nullptr)
: static_cast<TObject>(res));
return false;
}
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TByteView::opGetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name) {
if (name == "Count" || name == "Length") {
thrd->call_stack_entries.back()->Push(
gc, static_cast<int64_t>(this->GetBounds().second));
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
void TByteView::CopyTo(TMutByteView *view) {
auto myBounds = this->GetBounds();
if (myBounds.first == nullptr || myBounds.second == 0)
return;
auto theirBounds = view->GetMutableBoundsConstrained(0, myBounds.second);
if (theirBounds.first == nullptr || theirBounds.second == 0)
return;
memcpy(theirBounds.first, myBounds.first, theirBounds.second);
}
void TByteView::CopyTo(TMutByteView *view, size_t srcOffset, size_t destOffset,
size_t length) {
auto myBounds = this->GetBoundsConstrained(srcOffset, length);
if (myBounds.first == nullptr || myBounds.second == 0)
return;
auto theirBounds =
view->GetMutableBoundsConstrained(destOffset, myBounds.second);
if (theirBounds.first == nullptr || theirBounds.second == 0)
return;
memcpy(theirBounds.first, myBounds.first, theirBounds.second);
}
} // namespace Tesses::CrossLang
View File
-10
View File
@@ -1,10 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
TResource::TResource(std::vector<uint8_t> &&bytes) : bytes(std::move(bytes)) {}
std::pair<const uint8_t *, size_t> TResource::GetBounds() const {
return std::pair<const uint8_t *, size_t>(bytes.data(), bytes.size());
}
std::string TResource::TypeName() { return "Resource"; }
} // namespace Tesses::CrossLang
-123
View File
@@ -1,123 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
TString::TString() {}
TString::TString(std::string_view str) : text(str) {}
TString::TString(const char *text, size_t len) : text(text, len) {}
TString::TString(std::string_view left, std::string_view right) {
text.reserve(left.size() + right.size());
text.append(left.begin(), left.end());
text.append(right.begin(), right.end());
}
TString::TString(std::string &&str) : text(std::move(str)) {}
const std::string &TString::GetString() const { return this->text; }
std::pair<const uint8_t *, size_t> TString::GetBounds() const {
return std::pair<const uint8_t *, size_t>(
reinterpret_cast<const uint8_t *>(text.data()), text.size());
}
std::string TString::TypeName() { return "String"; }
TString *TString::ToString(GCList &ls) {
ls.Add(this);
return this;
}
bool TString::opAdd(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs) {
TString *rStr;
char rChr;
if (GetObjectHeap(rhs, rStr)) {
GCList ls(gc);
thrd->call_stack_entries.back()->Push(
gc, ls.Create<TString>(this->GetString(), rStr->GetString()));
return false;
}
if (GetObject(rhs, rChr)) {
GCList ls(gc);
thrd->call_stack_entries.back()->Push(
gc,
ls.Create<TString>(this->GetString(), std::string_view(&rChr, 1)));
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TString::opLessThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
thrd->call_stack_entries.back()->Push(gc, this->GetString() <
rStr->GetString());
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TString::opGreaterThan(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
thrd->call_stack_entries.back()->Push(gc, this->GetString() >
rStr->GetString());
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TString::opLessThanEqual(InterperterThread *thrd, std::shared_ptr<GC> gc,
TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
thrd->call_stack_entries.back()->Push(gc, this->GetString() <=
rStr->GetString());
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TString::opGreaterThanEqual(InterperterThread *thrd,
std::shared_ptr<GC> gc, TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
thrd->call_stack_entries.back()->Push(gc, this->GetString() >=
rStr->GetString());
return false;
}
thrd->call_stack_entries.back()->Push(gc, Undefined());
return false;
}
bool TString::IsEqualTo(std::shared_ptr<GC> gc, TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
if (this == rStr)
return true;
return this->GetString() == rStr->GetString();
}
return false;
}
bool TString::IsNotEqualTo(std::shared_ptr<GC> gc, TObject rhs) {
TString *rStr;
if (GetObjectHeap(rhs, rStr)) {
if (this == rStr)
return false;
return this->GetString() != rStr->GetString();
}
return true;
}
} // namespace Tesses::CrossLang
+21 -7
View File
@@ -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"
namespace Tesses::CrossLang {
std::string TClassObject::TypeName() {
std::string type = "class ";
type += this->name;
for (auto &item : this->inherit_tree)
type += " : " + item;
return type;
}
std::string TClassObject::TypeName() { return this->name; }
TObject TClassObject::CallMethod(GCList &ls, std::string className,
std::string name, std::vector<TObject> args) {
auto value = this->GetValue(className, name);
+20
View File
@@ -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"
namespace Tesses::CrossLang {
bool TClassEnvironment::HasConstForSet(std::string key) {
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
TArgWrapper::TArgWrapper(TCallable *callable) : callable(callable) {}
@@ -9,7 +29,7 @@ TArgWrapper *TArgWrapper::Create(GCList *ls, TCallable *callable) {
}
TObject TArgWrapper::Call(GCList &ls, std::vector<TObject> args) {
auto cse = GC::GetCurrentFunction();
TList *argList = ls.Create<TList>();
TList *argList = TList::Create(ls);
argList->items = args;
TObject v = this->callable->Call(ls, {argList});
GC::SetCurrentFunction(cse);
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
@@ -45,7 +65,7 @@ TObject TDynamicDictionary::CallMethod(GCList &ls, std::string name,
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", "CallMethod");
dict->SetValue("Name", name);
auto argVal = ls.Create<TList>();
auto argVal = TList::Create(ls);
argVal->items = args;
dict->SetValue("Arguments", argVal);
ls.GetGC()->BarrierEnd();
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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"
namespace Tesses::CrossLang {
TExternalMethod::TExternalMethod(
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
@@ -192,7 +212,7 @@ bool TListEnumerator::MoveNext(std::shared_ptr<GC> ls) {
}
TObject TListEnumerator::GetCurrent(GCList &ls) {
if (this->index < -1)
if (this->index <= -1)
return nullptr;
if (this->ls->Count() == 0)
return nullptr;
+32 -208
View File
@@ -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"
namespace Tesses::CrossLang {
TDynamicList::TDynamicList(TCallable *callable) : cb(callable) {}
@@ -19,7 +39,7 @@ int64_t TDynamicList::Count(GCList &ls) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("Count"));
dict->SetValue("Type", "Count");
ls.GetGC()->BarrierEnd();
auto res = cb->Call(ls, {dict});
int64_t n;
@@ -31,7 +51,7 @@ TObject TDynamicList::Add(GCList &ls, TObject v) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("Add"));
dict->SetValue("Type", "Add");
dict->SetValue("Value", v);
ls.GetGC()->BarrierEnd();
return cb->Call(ls, {dict});
@@ -40,7 +60,7 @@ TObject TDynamicList::Insert(GCList &ls, int64_t index, TObject v) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("Insert"));
dict->SetValue("Type", "Insert");
dict->SetValue("Index", index);
dict->SetValue("Value", v);
ls.GetGC()->BarrierEnd();
@@ -49,14 +69,14 @@ TObject TDynamicList::Insert(GCList &ls, int64_t index, TObject v) {
TObject TDynamicList::Clear(GCList &ls) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("Clear"));
dict->SetValue("Type", "Clear");
ls.GetGC()->BarrierEnd();
return cb->Call(ls, {dict});
}
TObject TDynamicList::Remove(GCList &ls, TObject obj) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("Remove"));
dict->SetValue("Type", "Remove");
dict->SetValue("Value", obj);
ls.GetGC()->BarrierEnd();
@@ -65,7 +85,7 @@ TObject TDynamicList::Remove(GCList &ls, TObject obj) {
TObject TDynamicList::RemoveAllEqual(GCList &ls, TObject obj) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("RemoveAllEqual"));
dict->SetValue("Type", "RemoveAllEqual");
dict->SetValue("Value", obj);
ls.GetGC()->BarrierEnd();
@@ -74,7 +94,7 @@ TObject TDynamicList::RemoveAllEqual(GCList &ls, TObject obj) {
TObject TDynamicList::RemoveAt(GCList &ls, int64_t index) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("RemoveAt"));
dict->SetValue("Type", "RemoveAt");
dict->SetValue("Index", index);
ls.GetGC()->BarrierEnd();
@@ -83,7 +103,7 @@ TObject TDynamicList::RemoveAt(GCList &ls, int64_t index) {
TObject TDynamicList::ToString(GCList &ls) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("ToString"));
dict->SetValue("Type", "ToString");
ls.GetGC()->BarrierEnd();
return cb->Call(ls, {dict});
@@ -93,7 +113,7 @@ TObject TDynamicList::GetAt(GCList &ls, int64_t index) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("GetAt"));
dict->SetValue("Type", "GetAt");
dict->SetValue("Index", index);
ls.GetGC()->BarrierEnd();
return cb->Call(ls, {dict});
@@ -102,7 +122,7 @@ TObject TDynamicList::GetAt(GCList &ls, int64_t index) {
TObject TDynamicList::SetAt(GCList &ls, int64_t index, TObject val) {
auto dict = TDictionary::Create(ls);
ls.GetGC()->BarrierBegin();
dict->SetValue("Type", ls.FromString("SetAt"));
dict->SetValue("Type", "SetAt");
dict->SetValue("Index", index);
dict->SetValue("Value", val);
ls.GetGC()->BarrierEnd();
@@ -114,7 +134,8 @@ TDynamicList::~TDynamicList() {}
TByteArray *TByteArray::Create(GCList &ls) { return ls.Create<TByteArray>(); }
TByteArray *TByteArray::Create(GCList *ls) { return ls->Create<TByteArray>(); }
TList *TList::Create(GCList *gc) { return gc->Create<TList>(); }
TList *TList::Create(GCList &gc) { return gc.Create<TList>(); }
void TList::Add(TObject value) { this->items.push_back(value); }
void TList::Set(int64_t index, TObject value) {
if (index >= 0 && index < this->Count()) {
@@ -147,201 +168,4 @@ void TList::Mark() {
GC::Mark(item);
}
}
std::string TList::TypeName() { return "List"; }
bool TList::opGetField(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name) {
auto &cse = thrd->call_stack_entries;
if (name == "Count" || name == "Length") {
int64_t len = this->Count();
if (len < 0)
len = 0;
cse.back()->Push(gc, len);
return false;
}
cse.back()->Push(gc, Undefined());
return false;
}
bool TList::opExecuteMethod(InterperterThread *thrd, std::shared_ptr<GC> gc,
const std::string &name,
const std::vector<TObject> &args) {
auto &cse = thrd->call_stack_entries;
GCList ls(gc);
if (name == "GetEnumerator") {
cse.back()->Push(gc, ls.Create<TListEnumerator>(this));
return false;
} else if (name == "ToString") {
cse.back()->Push(gc, Json_Encode(this));
return false;
} else if (name == "Insert") {
if (args.size() != 2) {
throw VMException("List.Insert must only accept two arguments");
}
int64_t index;
if (!GetArgument(args, 0, index)) {
throw VMException("List.Insert first argument must be Long");
}
gc->BarrierBegin();
this->Insert(index, args[1]);
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "Add") {
if (args.size() != 1) {
throw VMException("List.Add must only accept one argument");
}
gc->BarrierBegin();
this->Add(args[0]);
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "Contains") {
if (args.size() != 1) {
throw VMException("List.Contains must only accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < this->Count(); i++) {
auto item = this->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
cse.back()->Push(gc, true);
return false;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, false);
return false;
} else if (name == "IndexOf") {
// IndexOf(obj, $idx)
if (args.size() < 1 || args.size() > 2) {
throw VMException("List.IndexOf must either have one "
"or two arguments");
}
int64_t i = 0;
GetArgument(args, 1, i);
gc->BarrierBegin();
for (; i < this->Count(); i++) {
auto item = this->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
cse.back()->Push(gc, i);
return false;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, (int64_t)-1);
return false;
} else if (name == "RemoveAllEqual") {
if (args.size() != 1) {
throw VMException("List.RemoveAllEqual must only "
"accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < this->Count(); i++) {
auto item = this->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
gc->BarrierBegin();
this->RemoveAt(i);
i--;
} else
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "Remove") {
if (args.size() != 1) {
throw VMException("List.Remove must only accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < this->Count(); i++) {
auto item = this->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
gc->BarrierBegin();
this->RemoveAt(i);
gc->BarrierEnd();
break;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "RemoveAt") {
if (args.size() != 1) {
throw VMException("List.RemoveAt must only accept one argument");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException("List.RemoveAt must only accept a long");
}
gc->BarrierBegin();
this->RemoveAt(std::get<int64_t>(args[0]));
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "Clear") {
gc->BarrierBegin();
this->Clear();
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (name == "GetAt") {
if (args.size() != 1) {
throw VMException("List.GetAt must only accept one argument");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException("List.GetAt must only accept a long");
}
int64_t index = std::get<int64_t>(args[0]);
if (index >= 0 && index < this->Count()) {
cse.back()->Push(gc, this->Get(index));
return false;
}
} else if (name == "SetAt") {
if (args.size() != 2) {
throw VMException("List.SetAt must only accept two arguments");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException("List.SetAt first argument must only "
"accept a long");
}
int64_t index = std::get<int64_t>(args[0]);
if (index >= 0 && index < this->Count()) {
this->Set(index, args[1]);
return false;
}
}
else if (name == "Count" || name == "Length") {
gc->BarrierBegin();
cse.back()->Push(gc, this->Count());
gc->BarrierEnd();
return false;
}
cse.back()->Push(gc, Undefined());
return false;
}
}; // namespace Tesses::CrossLang
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+21 -1
View File
@@ -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"
namespace Tesses::CrossLang {
@@ -32,7 +52,7 @@ TList *TQueryable::ToList(GCList &ls) {
auto enumerator = this->GetEnumerator(ls);
if (enumerator == nullptr)
return nullptr;
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
while (enumerator->MoveNext(gc)) {
gc->BarrierBegin();
list->Add(enumerator->GetCurrent(ls));
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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 <iostream>
#include <sstream>
+20
View File
@@ -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"
namespace Tesses::CrossLang {
-30
View File
@@ -1,30 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
TMemoryStream::TMemoryStream(
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm)
: strm(strm) {}
std::shared_ptr<Tesses::Framework::Streams::Stream> TMemoryStream::GetStream() {
return this->strm;
}
TObject TMemoryStream::CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args) {
if (name == "GetBytes") {
return ls.Create<TMemoryStreamMutByteView>(strm);
}
return ITStream::CallMethod(thrd, ls, name, args);
}
TMemoryStreamMutByteView::TMemoryStreamMutByteView(
std::shared_ptr<Tesses::Framework::Streams::MemoryStream> strm)
: strm(strm) {}
std::pair<uint8_t *, size_t> TMemoryStreamMutByteView::GetMutableBounds() {
if (!strm)
return std::pair<uint8_t *, size_t>(nullptr, 0);
auto &buff = strm->GetBuffer();
return std::pair<uint8_t *, size_t>(buff.data(), buff.size());
}
std::string TMemoryStream::TypeName() { return "MemoryStream"; }
} // namespace Tesses::CrossLang
-165
View File
@@ -1,165 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
TNetworkStream::TNetworkStream(
std::shared_ptr<Tesses::Framework::Streams::NetworkStream> strm)
: strm(strm) {}
std::shared_ptr<Tesses::Framework::Streams::Stream>
TNetworkStream::GetStream() {
return this->strm;
}
TObject TNetworkStream::CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args) {
int64_t n0;
bool bc;
if (name == "setBroadcast" && GetArgument(args, 0, bc))
strm->SetBroadcast(bc);
if (name == "setNoDelay" && GetArgument(args, 0, bc))
strm->SetNoDelay(bc);
if (name == "setReuseAddress" && GetArgument(args, 0, bc))
strm->SetReuseAddress(bc);
if (name == "setReusePort" && GetArgument(args, 0, bc))
strm->SetReusePort(bc);
if (name == "MulticastTTL" && GetArgument(args, 0, n0))
strm->SetMulticastTTL((uint8_t)n0);
if (name == "getPort" || name == "GetPort") {
return (int64_t)strm->GetPort();
}
if (name == "SetMulticastMembership") {
std::string ma;
std::string ifaceIP = "0.0.0.0";
if (GetArgument(args, 0, ma)) {
GetArgument(args, 1, ifaceIP);
strm->SetMulticastMembership(ma, ifaceIP);
}
return Undefined();
}
if (name == "Bind") {
std::string ip;
int64_t port;
if (GetArgument(args, 0, ip) && GetArgument(args, 1, port))
strm->Bind(ip, (uint16_t)port);
return Undefined();
}
if (name == "Accept") {
std::string ip;
uint16_t port;
auto strm2 = strm->Accept(ip, port);
if (strm2 ==
nullptr) // just in case, so we don't get a bugged TNetworkStream
return nullptr;
std::array list = {
TDItem("IP", ls.FromString(ip)),
TDItem("Port", (int64_t)port),
TDItem("Stream", ls.Create<TNetworkStream>(strm2)),
};
return ls.Create<TDictionary>(list.begin(), list.end());
}
if (name == "Listen") {
int64_t backlog;
if (GetArgument(args, 0, backlog)) {
strm->Listen((int32_t)backlog);
} else {
strm->Listen(10);
}
return Undefined();
}
if (name == "ReadFrom") {
TByteArray *data;
int64_t offset;
int64_t length;
if (name == "Read") {
TMutByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
if (GetArgument(args, 1, offset) &&
GetArgument(args, 2, length)) {
auto safe = bytes->GetMutableBoundsConstrained(
(size_t)offset, (size_t)length);
if (safe.first != nullptr) {
std::string ip = {};
uint16_t port = 0;
auto read =
strm->ReadFrom(safe.first, safe.second, ip, port);
std::array list = {
TDItem("IP", ls.FromString(ip)),
TDItem("Port", (int64_t)port),
TDItem("Read", (int64_t)read),
};
return ls.Create<TDictionary>(list.begin(), list.end());
} else {
return nullptr;
}
}
auto bounds = bytes->GetMutableBounds();
if (bounds.first) {
std::string ip = {};
uint16_t port = 0;
auto read =
strm->ReadFrom(bounds.first, bounds.second, ip, port);
std::array list = {
TDItem("IP", ls.FromString(ip)),
TDItem("Port", (int64_t)port),
TDItem("Read", (int64_t)read),
};
return ls.Create<TDictionary>(list.begin(), list.end());
}
}
return Undefined();
}
}
if (name == "WriteTo") {
// strm->WriteTo(buff, ip, port)
// strm->WriteTo(buff, off, len, ip, port)
TByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
TString *ip;
int64_t port;
if (GetArgument(args, 1, offset) && GetArgument(args, 2, length)) {
if (!(GetArgumentHeap(args, 3, ip) &&
GetArgument(args, 4, port)))
return Undefined();
auto safe =
bytes->GetBoundsConstrained((size_t)offset, (size_t)length);
if (safe.first != nullptr) {
return strm->WriteTo(safe.first, safe.second,
ip->GetString(), (uint16_t)port);
} else
return nullptr;
}
if (!(GetArgumentHeap(args, 1, ip) && GetArgument(args, 2, port)))
return Undefined();
auto bounds = bytes->GetBounds();
if (bounds.first) {
return (int64_t)strm->WriteTo(bounds.first, bounds.second,
ip->GetString(), (uint16_t)port);
}
}
return Undefined();
}
return ITStream::CallMethod(thrd, ls, name, args);
}
std::string TNetworkStream::TypeName() { return "NetworkStream"; }
} // namespace Tesses::CrossLang
-251
View File
@@ -1,251 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
#define CROSSLANG_TSTREAM_NAMES \
CROSSLANG_TSTREAM_NAME_ENT(getCanRead) \
CROSSLANG_TSTREAM_NAME_ENT(getCanSeek) \
CROSSLANG_TSTREAM_NAME_ENT(getCanWrite) \
CROSSLANG_TSTREAM_NAME_ENT(getEndOfStream) \
CROSSLANG_TSTREAM_NAME_ENT(getLength) \
CROSSLANG_TSTREAM_NAME_ENT(getPosition) \
CROSSLANG_TSTREAM_NAME_ENT(setPosition) \
CROSSLANG_TSTREAM_NAME_ENT(Close) \
CROSSLANG_TSTREAM_NAME_ENT(Dispose) \
CROSSLANG_TSTREAM_NAME_ENT(CopyTo) \
CROSSLANG_TSTREAM_NAME_ENT(CopyToLimit) \
CROSSLANG_TSTREAM_NAME_ENT(Flush) \
CROSSLANG_TSTREAM_NAME_ENT(Read) \
CROSSLANG_TSTREAM_NAME_ENT(ReadBlock) \
CROSSLANG_TSTREAM_NAME_ENT(ReadByte) \
CROSSLANG_TSTREAM_NAME_ENT(Seek) \
CROSSLANG_TSTREAM_NAME_ENT(SetRecvTimeout) \
CROSSLANG_TSTREAM_NAME_ENT(SetSendTimeout) \
CROSSLANG_TSTREAM_NAME_ENT(Write) \
CROSSLANG_TSTREAM_NAME_ENT(WriteText) \
CROSSLANG_TSTREAM_NAME_ENT(WriteBlock) \
CROSSLANG_TSTREAM_NAME_ENT(WriteByte)
enum TStreamFuncNameEnum {
#define CROSSLANG_TSTREAM_NAME_ENT(name) TSF_##name,
CROSSLANG_TSTREAM_NAMES
#undef CROSSLANG_TSTREAM_NAME_ENT
}; // namespace Tesses::CrossLang
static std::unordered_map<std::string_view, TStreamFuncNameEnum>
stream_func_names = {
#define CROSSLANG_TSTREAM_NAME_ENT(name) {#name, TSF_##name},
CROSSLANG_TSTREAM_NAMES
#undef CROSSLANG_TSTREAM_NAME_ENT
};
bool ITStream::Exists(std::string_view str) {
return stream_func_names.count(str) != 0;
}
TObject ITStream::CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args) {
auto strm = GetStream();
if (strm == nullptr)
return Undefined();
auto result = stream_func_names.find(name);
if (result == stream_func_names.end())
return Undefined();
switch (result->second) {
case TSF_getCanRead:
return strm->CanRead();
case TSF_getCanSeek:
return strm->CanSeek();
case TSF_getCanWrite:
return strm->CanWrite();
case TSF_getEndOfStream:
return strm->EndOfStream();
case TSF_getLength:
return strm->GetLength();
case TSF_getPosition:
return strm->GetPosition();
case TSF_setPosition: {
int64_t n;
if (GetArgument(args, 0, n)) {
strm->Seek(n, Tesses::Framework::Streams::SeekOrigin::Begin);
return n;
}
return Undefined();
}
case TSF_Close:
case TSF_Dispose:
strm->Close();
return Undefined();
case TSF_CopyTo: {
ITStream *strmDest;
if (GetArgumentHeap(args, 0, strmDest)) {
int64_t n = 1024;
GetArgument(args, 1, n);
strm->CopyTo(strmDest->GetStream(), (size_t)n);
}
return Undefined();
}
case TSF_CopyToLimit: {
ITStream *strmDest;
int64_t len;
if (GetArgumentHeap(args, 0, strmDest) && GetArgument(args, 1, len)) {
int64_t n = 1024;
GetArgument(args, 2, n);
strm->CopyToLimit(strmDest->GetStream(), (uint64_t)len, (size_t)n);
}
return Undefined();
}
case TSF_Flush:
strm->Flush();
return Undefined();
case TSF_Read: {
TMutByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
if (GetArgument(args, 1, offset) && GetArgument(args, 2, length)) {
auto safe = bytes->GetMutableBoundsConstrained((size_t)offset,
(size_t)length);
if (safe.first != nullptr)
return strm->Read(safe.first, safe.second);
else
return 0;
}
auto bounds = bytes->GetMutableBounds();
if (bounds.first) {
return (int64_t)strm->Read(bounds.first, bounds.second);
}
}
return Undefined();
}
case TSF_ReadBlock: {
TMutByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
if (GetArgument(args, 1, offset) && GetArgument(args, 2, length)) {
auto safe = bytes->GetMutableBoundsConstrained((size_t)offset,
(size_t)length);
if (safe.first != nullptr)
return strm->ReadBlock(safe.first, safe.second);
else
return 0;
}
auto bounds = bytes->GetMutableBounds();
if (bounds.first) {
return (int64_t)strm->ReadBlock(bounds.first, bounds.second);
}
}
return Undefined();
}
case TSF_ReadByte: {
return (int64_t)strm->ReadByte();
}
case TSF_Seek: {
int64_t offset;
int64_t whence;
if (GetArgument(args, 0, offset) && GetArgument(args, 1, whence)) {
strm->Seek(offset, (Tesses::Framework::Streams::SeekOrigin)whence);
}
return Undefined();
}
case TSF_SetRecvTimeout: {
int64_t to;
if (GetArgument(args, 0, to)) {
strm->SetRecvTimeout((uint64_t)to);
}
return Undefined();
}
case TSF_SetSendTimeout: {
int64_t to;
if (GetArgument(args, 0, to)) {
strm->SetSendTimeout((uint64_t)to);
}
return Undefined();
}
case TSF_Write: {
TByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
if (GetArgument(args, 1, offset) && GetArgument(args, 2, length)) {
auto safe =
bytes->GetBoundsConstrained((size_t)offset, (size_t)length);
if (safe.first != nullptr)
return strm->Write(safe.first, safe.second);
else
return 0;
}
auto bounds = bytes->GetBounds();
if (bounds.first) {
return (int64_t)strm->Write(bounds.first, bounds.second);
}
}
return Undefined();
}
case TSF_WriteText: { // for compat
TByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
auto bounds = bytes->GetBounds();
if (bounds.first)
strm->WriteBlock(bounds.first, bounds.second);
}
return Undefined();
}
case TSF_WriteBlock: {
TByteView *bytes;
if (GetArgumentHeap(args, 0, bytes)) {
int64_t offset;
int64_t length;
if (GetArgument(args, 1, offset) && GetArgument(args, 2, length)) {
auto safe =
bytes->GetBoundsConstrained((size_t)offset, (size_t)length);
if (safe.first != nullptr)
strm->WriteBlock(safe.first, safe.second);
return Undefined();
}
auto bounds = bytes->GetBounds();
if (bounds.first) {
strm->WriteBlock(bounds.first, bounds.second);
}
}
return Undefined();
}
case TSF_WriteByte: {
int64_t b0;
if (GetArgument(args, 0, b0)) {
strm->WriteByte((uint8_t)b0);
}
return Undefined();
}
}
return Undefined();
}
std::string ITStream::TypeName() { return "Stream"; }
TStream::TStream(std::shared_ptr<Tesses::Framework::Streams::Stream> strm)
: strm(strm) {}
std::shared_ptr<Tesses::Framework::Streams::Stream> TStream::GetStream() {
return this->strm;
}
} // namespace Tesses::CrossLang
-56
View File
@@ -1,56 +0,0 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang {
TObjectStreamWrapper::TObjectStreamWrapper(std::shared_ptr<TObjectStream> strm)
: strm(strm) {}
TObject TObjectStreamWrapper::CallMethod(InterperterThread *thrd, GCList &ls,
const std::string &name,
const std::vector<TObject> &args) {
if (Exists(name)) {
return ITStream::CallMethod(thrd, ls, name, args);
}
TDictionary *dict;
if (GetObjectHeap(strm->obj, dict)) {
auto val = dict->GetValue(name);
TCallable *call;
if (GetObjectHeap(val, call)) {
auto closure = dynamic_cast<TClosure *>(call);
if (closure && !closure->closure->args.empty() &&
closure->closure->args[0]->GetString() == "this") {
std::vector<TObject> args_new;
args_new.reserve(args.size() + 1);
args_new.push_back(dict);
args_new.insert(args_new.cend(), args.begin(), args.end());
return closure->Call(ls, args_new);
} else {
return call->Call(ls, args);
}
}
if (name.size() > 3 && name[1] == 'e' && name[2] == 't') {
char c = name[0];
if (c == 'g') {
auto fieldName = name.substr(3);
return dict->GetValue(fieldName);
} else if (c == 's' && !args.empty()) {
auto fieldName = name.substr(3);
dict->SetValue(fieldName, args[0]);
ls.Add(args[0]);
return args[0];
}
}
}
return Undefined();
}
std::shared_ptr<Tesses::Framework::Streams::Stream>
TObjectStreamWrapper::GetStream() {
return this->strm;
}
std::string TObjectStreamWrapper::TypeName() { return "CustomStream"; }
} // namespace Tesses::CrossLang
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+20 -10
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -121,15 +141,6 @@ bool InterperterThread::Add(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, str);
} else if (std::holds_alternative<THeapObject *>(left)) {
auto obj = std::get<THeapObject *>(left);
if (obj == nullptr) {
cse.back()->Push(gc, Undefined());
return false;
}
return obj->opAdd(this, gc, right);
/*
auto dict = dynamic_cast<TDictionary *>(obj);
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
auto natObj = dynamic_cast<TNativeObject *>(obj);
@@ -165,7 +176,6 @@ bool InterperterThread::Add(std::shared_ptr<GC> gc) {
} else {
cse.back()->Push(gc, Undefined());
}
*/
} else {
cse.back()->Push(gc, Undefined());
+20
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
+338 -6
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -58,7 +78,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
if (GetArgument(args, 0, str)) {
std::smatch m;
if (std::regex_search(str, m, regex)) {
auto myLs = ls.Create<TList>();
auto myLs = TList::Create(ls);
gc->BarrierBegin();
for (auto item : m) {
auto itm = TDictionary::Create(ls);
@@ -288,7 +308,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
std::get<Tesses::Framework::Filesystem::VFSPath>(instance);
if (key == "GetEnumerator") {
TList *_ls = ls.Create<TList>();
TList *_ls = TList::Create(ls);
for (auto item : path.path) {
_ls->Add(item);
}
@@ -683,7 +703,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
auto res = Tesses::Framework::Http::HttpUtils::SplitString(
str, delimiter, count);
TList *mls = ls.Create<TList>();
TList *mls = TList::Create(ls);
for (auto item : res) {
if (!removeEmpty || !item.empty())
mls->Add(item);
@@ -825,7 +845,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
std::vector<std::string> lines;
textReader->ReadAllLines(lines);
gc->BarrierBegin();
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
for (auto &item : lines)
list->Add(item);
gc->BarrierEnd();
@@ -1072,6 +1092,8 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
std::get<std::shared_ptr<Tesses::Framework::Streams::Stream>>(
instance);
if (strm != nullptr) {
auto memStrm = std::dynamic_pointer_cast<
Tesses::Framework::Streams::MemoryStream>(strm);
auto netStrm = std::dynamic_pointer_cast<
Tesses::Framework::Streams::NetworkStream>(strm);
@@ -1088,8 +1110,134 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
return InvokeMethod(ls, o, dict2, args);
}
}
if (memStrm != nullptr) {
if (key == "GetBytes") {
auto res = TByteArray::Create(ls);
res->data = memStrm->GetBuffer();
cse.back()->Push(gc, res);
return false;
}
}
if (netStrm != nullptr) {
if (key == "SetMulticastMembership") {
std::string ma;
std::string ifaceIP = "0.0.0.0";
if (GetArgument(args, 0, ma)) {
GetArgument(args, 1, ifaceIP);
netStrm->SetMulticastMembership(ma, ifaceIP);
}
cse.back()->Push(gc, Undefined());
return false;
}
if (key == "GetPort") {
cse.back()->Push(gc, (int64_t)netStrm->GetPort());
return false;
}
if (key == "Bind") {
std::string ip;
int64_t port;
if (GetArgument(args, 0, ip) &&
GetArgument(args, 1, port))
netStrm->Bind(ip, (uint16_t)port);
cse.back()->Push(gc, nullptr);
return false;
}
if (key == "Accept") {
std::string ip;
uint16_t port;
auto strm = netStrm->Accept(ip, port);
TDictionary *dict = TDictionary::Create(ls);
gc->BarrierBegin();
dict->SetValue("IP", ip);
dict->SetValue("Port", (int64_t)port);
dict->SetValue("Stream", strm);
gc->BarrierEnd();
cse.back()->Push(gc, dict);
return false;
}
if (key == "Listen") {
int64_t backlog;
if (GetArgument(args, 0, backlog)) {
netStrm->Listen((int32_t)backlog);
} else {
netStrm->Listen(10);
}
cse.back()->Push(gc, nullptr);
return false;
}
if (key == "ReadFrom") {
TByteArray *data;
int64_t offset;
int64_t length;
if (GetArgumentHeap<TByteArray *>(args, 0, data) &&
GetArgument<int64_t>(args, 1, offset) &&
GetArgument<int64_t>(args, 2, length)) {
size_t off = (size_t)offset;
size_t len = (size_t)length;
std::string ip = {};
uint16_t port = 0;
if (off < len)
len = netStrm->ReadFrom(
data->data.data() + off,
std::min(len,
std::min(data->data.size() - off,
data->data.size())),
ip, port);
else
len = 0;
TDictionary *dict = TDictionary::Create(ls);
gc->BarrierBegin();
dict->SetValue("IP", ip);
dict->SetValue("Port", (int64_t)port);
dict->SetValue("Read", (int64_t)len);
gc->BarrierEnd();
cse.back()->Push(gc, dict);
return false;
}
cse.back()->Push(gc, nullptr);
return false;
}
if (key == "WriteTo") {
TByteArray *data;
int64_t offset;
int64_t length;
std::string ip;
int64_t port;
if (GetArgumentHeap<TByteArray *>(args, 0, data) &&
GetArgument<int64_t>(args, 1, offset) &&
GetArgument<int64_t>(args, 2, length) &&
GetArgument(args, 3, ip) &&
GetArgument(args, 4, port)) {
size_t off = (size_t)offset;
size_t len = (size_t)length;
if (off < len)
len = netStrm->WriteTo(
data->data.data() + off,
std::min(len,
std::min(data->data.size() - off,
data->data.size())),
ip, (int64_t)port);
else
len = 0;
cse.back()->Push(gc, (int64_t)len);
return false;
}
cse.back()->Push(gc, nullptr);
return false;
}
}
if (key == "Read") {
@@ -1838,7 +1986,7 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
return false;
} else if (std::holds_alternative<THeapObject *>(instance)) {
auto obj = std::get<THeapObject *>(instance);
auto list = dynamic_cast<TList *>(obj);
auto dynList = dynamic_cast<TDynamicList *>(obj);
auto bArray = dynamic_cast<TByteArray *>(obj);
auto dict = dynamic_cast<TDictionary *>(obj);
@@ -3208,6 +3356,190 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr<GC> gc, TObject instance,
}
cse.back()->Push(gc, Undefined());
return false;
} else if (list != nullptr) {
if (key == "GetEnumerator") {
cse.back()->Push(gc, TListEnumerator::Create(ls, list));
return false;
} else if (key == "ToString") {
cse.back()->Push(gc, Json_Encode(list));
return false;
} else if (key == "Insert") {
if (args.size() != 2) {
throw VMException(
"List.Insert must only accept two arguments");
}
int64_t index;
if (!GetArgument(args, 0, index)) {
throw VMException(
"List.Insert first argument must be Long");
}
gc->BarrierBegin();
list->Insert(index, args[1]);
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "Add") {
if (args.size() != 1) {
throw VMException(
"List.Add must only accept one argument");
}
gc->BarrierBegin();
list->Add(args[0]);
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "Contains") {
if (args.size() != 1) {
throw VMException(
"List.Contains must only accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < list->Count(); i++) {
auto item = list->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
cse.back()->Push(gc, true);
return false;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, false);
return false;
} else if (key == "IndexOf") {
// IndexOf(obj, $idx)
if (args.size() < 1 || args.size() > 2) {
throw VMException("List.IndexOf must either have one "
"or two arguments");
}
int64_t i = 0;
GetArgument(args, 1, i);
gc->BarrierBegin();
for (; i < list->Count(); i++) {
auto item = list->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
cse.back()->Push(gc, i);
return false;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, (int64_t)-1);
return false;
} else if (key == "RemoveAllEqual") {
if (args.size() != 1) {
throw VMException("List.RemoveAllEqual must only "
"accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < list->Count(); i++) {
auto item = list->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
gc->BarrierBegin();
list->RemoveAt(i);
i--;
} else
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "Remove") {
if (args.size() != 1) {
throw VMException(
"List.Remove must only accept one argument");
}
gc->BarrierBegin();
for (int64_t i = 0; i < list->Count(); i++) {
auto item = list->Get(i);
gc->BarrierEnd();
if (Equals(gc, args[0], item)) {
gc->BarrierBegin();
list->RemoveAt(i);
gc->BarrierEnd();
break;
}
gc->BarrierBegin();
}
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "RemoveAt") {
if (args.size() != 1) {
throw VMException(
"List.RemoveAt must only accept one argument");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException(
"List.RemoveAt must only accept a long");
}
gc->BarrierBegin();
list->RemoveAt(std::get<int64_t>(args[0]));
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "Clear") {
gc->BarrierBegin();
list->Clear();
gc->BarrierEnd();
cse.back()->Push(gc, Undefined());
return false;
} else if (key == "GetAt") {
if (args.size() != 1) {
throw VMException(
"List.GetAt must only accept one argument");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException("List.GetAt must only accept a long");
}
int64_t index = std::get<int64_t>(args[0]);
if (index >= 0 && index < list->Count()) {
cse.back()->Push(gc, list->Get(index));
return false;
}
} else if (key == "SetAt") {
if (args.size() != 2) {
throw VMException(
"List.SetAt must only accept two arguments");
}
if (!std::holds_alternative<int64_t>(args[0])) {
throw VMException("List.SetAt first argument must only "
"accept a long");
}
int64_t index = std::get<int64_t>(args[0]);
if (index >= 0 && index < list->Count()) {
list->Set(index, args[1]);
return false;
}
}
else if (key == "Count" || key == "Length") {
gc->BarrierBegin();
cse.back()->Push(gc, list->Count());
gc->BarrierEnd();
return false;
}
cse.back()->Push(gc, Undefined());
return false;
} else if (dynList != nullptr) {
if (key == "GetEnumerator") {
+95 -13
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -145,6 +165,59 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, Undefined());
return false;
}
if (std::holds_alternative<
std::shared_ptr<Tesses::Framework::Streams::Stream>>(
instance)) {
auto strm =
std::get<std::shared_ptr<Tesses::Framework::Streams::Stream>>(
instance);
if (strm != nullptr) {
auto netStrm = std::dynamic_pointer_cast<
Tesses::Framework::Streams::NetworkStream>(strm);
if (key == "CanRead") {
cse.back()->Push(gc, strm->CanRead());
return false;
}
if (key == "CanWrite") {
cse.back()->Push(gc, strm->CanWrite());
return false;
}
if (key == "CanSeek") {
cse.back()->Push(gc, strm->CanSeek());
return false;
}
if (key == "EndOfStream") {
cse.back()->Push(gc, strm->EndOfStream());
return false;
}
if (key == "Length") {
cse.back()->Push(gc, strm->GetLength());
return false;
}
if (key == "Position") {
cse.back()->Push(gc, strm->GetPosition());
return false;
}
if (netStrm != nullptr) {
if (key == "Port") {
cse.back()->Push(gc, (int64_t)netStrm->GetPort());
return false;
}
}
cse.back()->Push(gc, Undefined());
return false;
}
}
if (std::holds_alternative<TVMVersion>(instance)) {
TVMVersion &version = std::get<TVMVersion>(instance);
if (key == "Major") {
@@ -338,7 +411,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, file->info);
return false;
} else if (key == "Dependencies") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (auto item : file->dependencies) {
auto res = TDictionary::Create(ls);
@@ -350,7 +423,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, list);
return false;
} else if (key == "Tools") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (auto item : file->tools) {
auto res = TDictionary::Create(ls);
@@ -362,7 +435,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, list);
return false;
} else if (key == "Strings") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (auto item : file->name) {
list->Add(item);
@@ -376,7 +449,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, (int64_t)file->metadata.size());
return false;
} else if (key == "Metadata") {
TList *meta = ls.Create<TList>();
TList *meta = TList::Create(ls);
gc->BarrierBegin();
for (size_t i = 0; i < file->metadata.size(); i++) {
meta->Add(TDictionary::Create(
@@ -388,7 +461,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, meta);
return false;
} else if (key == "Sections") {
TList *sections = ls.Create<TList>();
TList *sections = TList::Create(ls);
gc->BarrierBegin();
for (auto &item : file->sections) {
TByteArray *ba = TByteArray::Create(ls);
@@ -402,7 +475,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, sections);
return false;
} else if (key == "SupportedVMs") {
TList *supported = ls.Create<TList>();
TList *supported = TList::Create(ls);
gc->BarrierBegin();
if (file->vms.empty()) {
supported->Add(TDictionary::Create(
@@ -418,7 +491,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, supported);
return false;
} else if (key == "Chunks") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (auto item : file->chunks) {
list->Add(item);
@@ -429,7 +502,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
cse.back()->Push(gc, list);
return false;
} else if (key == "Classes") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (uint32_t i = 0; i < (uint32_t)file->classes.size();
@@ -441,13 +514,13 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
gc->BarrierEnd();
return false;
} else if (key == "Functions") {
auto list = ls.Create<TList>();
auto list = TList::Create(ls);
gc->BarrierBegin();
for (auto &item : file->functions) {
TDictionary *dict = TDictionary::Create(ls);
if (!item.first.empty())
dict->SetValue("Documentation", item.first[0]);
TList *nameParts = ls.Create<TList>();
TList *nameParts = TList::Create(ls);
for (size_t i = 1; i < item.first.size(); i++) {
nameParts->Add(item.first[i]);
}
@@ -477,7 +550,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
}
if (chunk != nullptr) {
if (key == "Arguments") {
auto myargs = ls.Create<TList>();
auto myargs = TList::Create(ls);
gc->BarrierBegin();
for (auto item : chunk->args) {
myargs->Add(item);
@@ -533,7 +606,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
if (closure != nullptr) {
if (key == "Arguments") {
GCList ls2(gc);
TList *ls = ls2.Create<TList>();
TList *ls = TList::Create(ls2);
for (auto arg : closure->closure->args) {
ls->Add(arg);
}
@@ -548,7 +621,7 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
if (externalMethod != nullptr) {
if (key == "Arguments") {
GCList ls2(gc);
TList *ls = ls2.Create<TList>();
TList *ls = TList::Create(ls2);
for (auto arg : externalMethod->args) {
ls->Add(arg);
}
@@ -582,7 +655,16 @@ bool InterperterThread::GetField(std::shared_ptr<GC> gc) {
return false;
}
}
if (list != nullptr) {
if (key == "Count" || key == "Length") {
int64_t len = list->Count();
if (len < 0)
len = 0;
stk->Push(gc, len);
return false;
}
}
if (dynList != nullptr) {
if (key == "Count" || key == "Length") {
int64_t len = dynList->Count(ls);
+21 -1
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -23,7 +43,7 @@ bool InterperterThread::InvokeMethod(GCList &ls, TObject fn, TObject instance,
if (closure != nullptr) {
if (!closure->closure->args.empty() &&
closure->closure->args[0].GetString() == "this") {
closure->closure->args[0] == "this") {
std::vector<TObject> args2;
args2.push_back(instance);
args2.insert(args2.end(), args.begin(), args.end());
+20
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
+45
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -231,7 +251,32 @@ bool InterperterThread::SetField(std::shared_ptr<GC> gc) {
stk->Push(gc, Undefined());
return false;
}
if (std::holds_alternative<
std::shared_ptr<Tesses::Framework::Streams::Stream>>(
instance)) {
auto strm =
std::get<std::shared_ptr<Tesses::Framework::Streams::Stream>>(
instance);
auto netStrm = std::dynamic_pointer_cast<
Tesses::Framework::Streams::NetworkStream>(strm);
if (netStrm != nullptr) {
int64_t n0;
bool bc;
if (key == "Broadcast" && GetObject(value, bc))
netStrm->SetBroadcast(bc);
if (key == "NoDelay" && GetObject(value, bc))
netStrm->SetNoDelay(bc);
if (key == "ReuseAddress" && GetObject(value, bc))
netStrm->SetReuseAddress(bc);
if (key == "ReusePort" && GetObject(value, bc))
netStrm->SetReusePort(bc);
if (key == "MulticastTTL" && GetObject(value, n0))
netStrm->SetMulticastTTL((uint8_t)n0);
}
stk->Push(gc, Undefined());
return false;
}
if (std::holds_alternative<THeapObject *>(instance)) {
auto obj = std::get<THeapObject *>(instance);
+22 -10
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -67,15 +87,7 @@ bool InterperterThread::Sub(std::shared_ptr<GC> gc) {
std::make_shared<Tesses::Framework::Date::DateTime>((*l) - (*r)));
} else if (std::holds_alternative<THeapObject *>(left)) {
auto obj = std::get<THeapObject *>(left);
if (obj == nullptr) {
cse.back()->Push(gc, Undefined());
return false;
}
return obj->opSub(this, gc, right);
/*auto dict = dynamic_cast<TDictionary *>(obj);
auto dict = dynamic_cast<TDictionary *>(obj);
auto dynDict = dynamic_cast<TDynamicDictionary *>(obj);
auto natObj = dynamic_cast<TNativeObject *>(obj);
@@ -112,7 +124,7 @@ bool InterperterThread::Sub(std::shared_ptr<GC> gc) {
} else {
cse.back()->Push(gc, Undefined());
}
*/
} else {
cse.back()->Push(gc, Undefined());
}
+20
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
+20
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
+20
View File
@@ -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"
namespace Tesses::CrossLang {
+51 -64
View File
@@ -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 <cstring>
@@ -43,18 +63,15 @@ void TFile::Ensure(std::shared_ptr<Tesses::Framework::Streams::Stream> stream,
"End of file, could not read " + std::to_string((int64_t)len) +
" byte(s)., offset=" + std::to_string(stream->GetLength()));
}
void TFile::EnsureString(
GCList &ls, std::shared_ptr<Tesses::Framework::Streams::Stream> stream) {
std::string TFile::EnsureString(
std::shared_ptr<Tesses::Framework::Streams::Stream> stream) {
auto len = EnsureInt(stream);
if (len == 0) {
this->strings.push_back(ls.FromString(""));
return;
}
if (len == 0)
return {};
std::string str = {};
str.resize((size_t)len);
Ensure(stream, (uint8_t *)str.data(), str.size());
this->strings.push_back(ls.Create<TString>(std::move(str)));
return str;
}
uint32_t
@@ -63,7 +80,7 @@ TFile::EnsureInt(std::shared_ptr<Tesses::Framework::Streams::Stream> stream) {
Ensure(stream, buffer, 4);
return BitConverter::ToUint32BE(buffer[0]);
}
TString *
std::string
TFile::GetString(std::shared_ptr<Tesses::Framework::Streams::Stream> stream) {
uint32_t index = EnsureInt(stream);
if (index >= this->strings.size())
@@ -78,7 +95,7 @@ void TFile::EnsureCanRunInCrossLang() {
return;
for (auto item : this->vms) {
if (item.first->GetString() == VMName) {
if (item.first == VMName) {
return;
}
}
@@ -86,8 +103,7 @@ void TFile::EnsureCanRunInCrossLang() {
std::string errorMessage = "The virtual machines supported are:\n";
for (auto item : this->vms) {
errorMessage +=
item.first->GetString() + "\n\t" + item.second->GetString() + "\n";
errorMessage += item.first + "\n\t" + item.second + "\n";
}
throw VMException(errorMessage);
}
@@ -156,7 +172,7 @@ TDictionary *TFile::MetadataDecode(GCList &ls, size_t midx) {
items.push_back(parseEnt());
}
return ls.Create<TList>(items.begin(), items.end());
return TList::Create(ls, items.begin(), items.end());
} else
throw std::out_of_range("Abrupt end of metadata");
} break;
@@ -170,8 +186,8 @@ TDictionary *TFile::MetadataDecode(GCList &ls, size_t midx) {
if (index + 4 <= bytes.size()) {
auto val2 = BitConverter::ToUint32BE(bytes[index]);
index += 4;
TString *text = this->strings.at((size_t)val2);
items.emplace_back(text->GetString(), parseEnt());
std::string &text = this->strings.at((size_t)val2);
items.emplace_back(text, parseEnt());
} else
throw std::out_of_range("Abrupt end of metadata");
}
@@ -184,7 +200,9 @@ TDictionary *TFile::MetadataDecode(GCList &ls, size_t midx) {
if (index + 4 <= bytes.size()) {
auto val = BitConverter::ToUint32BE(bytes[index]);
index += 4;
return ls.Create<TByteArray>(this->resources.at((size_t)val));
auto ba = TByteArray::Create(ls);
ba->data = this->resources.at((size_t)val);
return ba;
} else
throw std::out_of_range("Abrupt end of metadata");
} break;
@@ -192,8 +210,7 @@ TDictionary *TFile::MetadataDecode(GCList &ls, size_t midx) {
if (index + 4 <= bytes.size()) {
auto val = BitConverter::ToUint32BE(bytes[index]);
index += 4;
return ls.Create<TStream>(
std::make_shared<EmbedStream>(ls.GetGC(), this, val));
return std::make_shared<EmbedStream>(ls.GetGC(), this, val);
} else
throw std::out_of_range("Abrupt end of metadata");
} break;
@@ -215,8 +232,8 @@ TDictionary *TFile::MetadataDecode(GCList &ls, size_t midx) {
ls, "", {},
[val, this](GCList &ls,
std::vector<TObject> args) -> TObject {
return ls.Create<TStream>(std::make_shared<EmbedStream>(
ls.GetGC(), this, val));
return std::make_shared<EmbedStream>(ls.GetGC(), this,
val);
});
em->watch.push_back(this);
ls.GetGC()->BarrierEnd();
@@ -264,36 +281,26 @@ void TFile::Load(std::shared_ptr<GC> gc,
this->info = GetString(stream);
} else if (strncmp(table_name, "DEPS", 4) == 0) // dependencies
{
TString *name = GetString(stream);
std::string name = GetString(stream);
uint8_t version_bytes[5];
Ensure(stream, version_bytes, sizeof(version_bytes));
TVMVersion depVersion(version_bytes);
gc->BarrierBegin();
this->dependencies.push_back(
std::pair<TString *, TVMVersion>(name, depVersion));
gc->BarrierEnd();
std::pair<std::string, TVMVersion>(name, depVersion));
} else if (strncmp(table_name, "TOOL", 4) ==
0) // compile tools (for package manager)
{
TString *name = GetString(stream);
std::string name = GetString(stream);
uint8_t version_bytes[5];
Ensure(stream, version_bytes, sizeof(version_bytes));
TVMVersion depVersion(version_bytes);
gc->BarrierBegin();
this->tools.push_back(
std::pair<TString *, TVMVersion>(name, depVersion));
gc->BarrierEnd();
std::pair<std::string, TVMVersion>(name, depVersion));
} else if (strncmp(table_name, "RESO", 4) ==
0) // resources (using embed)
{
std::vector<uint8_t> data;
data.resize(tableLen);
auto &data = this->resources.emplace_back(tableLen);
Ensure(stream, data.data(), data.size());
GCList ls(gc);
gc->BarrierBegin();
this->resources.push_back(ls.Create<TResource>(std::move(data)));
gc->BarrierEnd();
} else if (strncmp(table_name, "CHKS", 4) == 0 &&
gc != nullptr) // chunks
{
@@ -301,13 +308,11 @@ void TFile::Load(std::shared_ptr<GC> gc,
size_t chunkCount = (size_t)EnsureInt(stream);
for (size_t j = 0; j < chunkCount; j++) {
auto chunk = ls.Create<TFileChunk>();
auto chunk = TFileChunk::Create(ls);
chunk->file = this;
size_t argCount = (size_t)EnsureInt(stream);
for (size_t k = 0; k < argCount; k++) {
gc->BarrierBegin();
chunk->args.push_back(GetString(stream));
gc->BarrierEnd();
}
size_t len = (size_t)EnsureInt(stream);
chunk->code.resize(len);
@@ -322,45 +327,33 @@ void TFile::Load(std::shared_ptr<GC> gc,
size_t funLength = (size_t)EnsureInt(stream);
for (size_t j = 0; j < funLength; j++) {
std::vector<TString *> fnParts;
std::vector<std::string> fnParts;
uint32_t fnPartsC = EnsureInt(stream);
for (uint32_t k = 0; k < fnPartsC; k++) {
fnParts.push_back(GetString(stream));
}
uint32_t fnNumber = EnsureInt(stream);
gc->BarrierBegin();
this->functions.push_back(
std::pair<std::vector<TString *>, uint32_t>(fnParts,
fnNumber));
gc->BarrierEnd();
std::pair<std::vector<std::string>, uint32_t>(fnParts,
fnNumber));
}
} else if (strncmp(table_name, "STRS", 4) == 0) // strings
{
size_t strsLen = (size_t)EnsureInt(stream);
gc->BarrierBegin();
this->strings.reserve(strsLen);
gc->BarrierEnd();
GCList ls(gc);
for (size_t j = 0; j < strsLen; j++) {
gc->BarrierBegin();
EnsureString(ls, stream);
gc->BarrierEnd();
this->strings.push_back(EnsureString(stream));
}
} else if (strncmp(table_name, "ICON", 4) == 0) // icon
{
this->icon = this->resources.at(EnsureInt(stream));
this->icon = (int32_t)EnsureInt(stream);
} else if (strncmp(table_name, "MACH", 4) == 0) // machine
{
TString *name = GetString(stream);
TString *howToGet = GetString(stream);
gc->BarrierBegin();
std::string name = GetString(stream);
std::string howToGet = GetString(stream);
this->vms.push_back(
std::pair<TString *, TString *>(name, howToGet));
gc->BarrierEnd();
std::pair<std::string, std::string>(name, howToGet));
} else if (strncmp(table_name, "CLSS", 4) == 0) // classes
{
uint32_t clsCnt = EnsureInt(stream);
@@ -368,17 +361,14 @@ void TFile::Load(std::shared_ptr<GC> gc,
TClass cls;
cls.documentation = GetString(stream);
uint32_t name_cnt = EnsureInt(stream);
cls.name.reserve((size_t)name_cnt);
for (uint32_t k = 0; k < name_cnt; k++) {
cls.name.push_back(GetString(stream));
}
name_cnt = EnsureInt(stream);
cls.inherits.reserve((size_t)name_cnt);
for (uint32_t k = 0; k < name_cnt; k++) {
cls.inherits.push_back(GetString(stream));
}
name_cnt = EnsureInt(stream);
cls.entry.reserve((size_t)name_cnt);
for (uint32_t k = 0; k < name_cnt; k++) {
TClassEntry ent;
Ensure(stream, main_header, 1);
@@ -389,15 +379,12 @@ void TFile::Load(std::shared_ptr<GC> gc,
ent.documentation = GetString(stream);
ent.name = GetString(stream);
uint32_t arglen = EnsureInt(stream);
ent.args.reserve((size_t)arglen);
for (uint32_t l = 0; l < arglen; l++)
ent.args.push_back(GetString(stream));
ent.chunkId = EnsureInt(stream);
cls.entry.push_back(ent);
}
gc->BarrierBegin();
this->classes.push_back(cls);
gc->BarrierEnd();
}
} else if (strncmp(table_name, "META", 4) == 0) // structured metadata
{
+45 -3
View File
@@ -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 <chrono>
#include <iostream>
@@ -97,6 +117,23 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached) {
return dict;
}
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<
Tesses::Framework::Threading::ThreadPool *>(
@@ -113,7 +150,7 @@ void GC::Start() {
this->thrd = new Thread([this]() -> void {
while (this->IsRunning()) {
this->BarrierBegin();
while (this->IsRunning() && (this->allocs < ALLOC_THRESHOLD))
while (this->IsRunning() && (this->allocs < this->threshold))
this->cond.Wait(&this->mtx);
this->allocs = 0;
std::vector<THeapObject *> to_delete;
@@ -142,23 +179,28 @@ void GC::BarrierEnd() { this->mtx.Unlock(); }
void GC::Watch(TObject obj) {
if (std::holds_alternative<THeapObject *>(obj)) {
auto _item = std::get<THeapObject *>(obj);
if (_item == nullptr)
return;
this->BarrierBegin();
this->objects.insert(_item);
auto nowAllocs = ++this->allocs;
this->BarrierEnd();
if (nowAllocs >= ALLOC_THRESHOLD)
if (nowAllocs >= this->threshold)
this->cond.Signal();
}
}
void GC::Mark(TObject obj) {
if (std::holds_alternative<THeapObject *>(obj)) {
auto _item = std::get<THeapObject *>(obj);
_item->Mark();
if (_item)
_item->Mark();
}
}
void GC::Unwatch(TObject obj) {
if (std::holds_alternative<THeapObject *>(obj)) {
auto _item = std::get<THeapObject *>(obj);
if (_item == nullptr)
return;
this->BarrierBegin();
this->objects.erase(_item);
this->BarrierEnd();
+24
View File
@@ -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"
namespace Tesses::CrossLang {
@@ -12,6 +32,8 @@ std::shared_ptr<GC> GCList::GetGC() const { return this->gc; }
void GCList::Remove(TObject obj) {
if (std::holds_alternative<THeapObject *>(obj)) {
auto _item = std::get<THeapObject *>(obj);
if (_item == nullptr)
return;
this->gc->BarrierBegin();
for (auto index = this->items.begin(); index != this->items.end();
index++) {
@@ -27,6 +49,8 @@ void GCList::Add(TObject obj) {
if (std::holds_alternative<THeapObject *>(obj)) {
auto _item = std::get<THeapObject *>(obj);
if (_item == nullptr)
return;
this->gc->BarrierBegin();
for (auto item : this->items) {
+56 -10
View File
@@ -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 "TessesFramework/Serialization/BitConverter.hpp"
#include "TessesFramework/Streams/ByteReader.hpp"
@@ -2042,8 +2062,7 @@ bool InterperterThread::DeclareConstVariable(std::shared_ptr<GC> gc) {
throw VMException(
"[DECLARECONSTVARIABLE] Can't pop string, got type " +
GetObjectTypeString(key) + " = " + ObjectToString(gc, key) +
".");
GetObjectTypeString(key) + " = " + ToString(gc, key) + ".");
}
}
return false;
@@ -2061,8 +2080,10 @@ bool InterperterThread::PushResourceStream(std::shared_ptr<GC> gc) {
gc->BarrierBegin();
GCList ls(gc);
stk->Push(gc, ls.Create<TStream>(std::make_shared<EmbedStream>(
gc, stk->callable->file->resources[n])));
// TByteArray* arr = TByteArray::Create(ls);
// arr->data = stk->callable->file->resources[n];
stk->Push(
gc, std::make_shared<EmbedStream>(gc, stk->callable->file, n));
gc->BarrierEnd();
} else {
@@ -2085,9 +2106,9 @@ bool InterperterThread::PushResource(std::shared_ptr<GC> gc) {
gc->BarrierBegin();
GCList ls(gc);
stk->Push(gc,
ls.Create<TByteArray>(stk->callable->file->resources[n]));
TByteArray *arr = TByteArray::Create(ls);
arr->data = stk->callable->file->resources[n];
stk->Push(gc, arr);
gc->BarrierEnd();
} else {
@@ -2378,7 +2399,7 @@ bool InterperterThread::CreateArray(std::shared_ptr<GC> gc) {
std::vector<CallStackEntry *> &cse = this->call_stack_entries;
auto stk = cse.back();
GCList ls(gc);
TList *dict = ls.Create<TList>();
TList *dict = TList::Create(ls);
stk->Push(gc, dict);
return false;
}
@@ -2726,6 +2747,31 @@ execute:
if (stk->mustReturn) {
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) {
GCList ls(gc);
TObject o = cse[cse.size() - 1]->Pop(ls);
@@ -2909,7 +2955,7 @@ void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
: closure->env;
cse->ip = 0;
if (closure->closure->args.empty() && closure->chunkId != 0) {
TList *list = ls.Create<TList>();
TList *list = TList::Create(ls);
list->items = args;
cse->env->DeclareVariable("arguments", list);
@@ -2973,7 +3019,7 @@ void InterperterThread::AddCallStackEntry(GCList &ls, TClosure *closure,
if (i == closure->closure->args.size() - 1 && back.size() > 2 &&
back[0] == '$' && back[1] == '$') {
auto argName = closure->closure->args[i];
auto lsArgs = ls.Create<TList>();
auto lsArgs = TList::Create(ls);
for (; i < args.size(); i++)
lsArgs->Add(args[i]);
cse->env->DeclareVariable(trimStart(argName), lsArgs);