Added basic threading support, changed license back to Apache-2.0 and many fixes. (0.15.0)
This commit is contained in:
parent
6bd13f6e96
commit
299771f091
158 changed files with 909 additions and 323 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(fun VERSION 0.14.0 LANGUAGES C)
|
project(fun VERSION 0.15.0 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
|
||||||
22
LICENSE
22
LICENSE
|
|
@ -1,13 +1,13 @@
|
||||||
Copyright 2025 Johannes Findeisen
|
Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
you may not use this file except in compliance with the License.
|
||||||
copyright notice and this permission notice appear in all copies.
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
See the License for the specific language governing permissions and
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
limitations under the License.
|
||||||
|
|
|
||||||
146
README.md
146
README.md
|
|
@ -1,5 +1,147 @@
|
||||||
# Fun
|
# Fun
|
||||||
|
|
||||||
Fun Uses Nothing — Life is too short not to code with fun... ;)
|
## What is Fun?
|
||||||
|
|
||||||
Go here for more information: [https://hanez.org/project/fun](https://hanez.org/project/fun)
|
Fun is a highly strict programming language, but also highly simple. It looks like Python (My favorite language), but there are differences.
|
||||||
|
|
||||||
|
Influenced by Bash, **[C](https://en.wikipedia.org/wiki/The_C_Programming_Language)**, Go, **[Lua](https://www.lua.org/)**, **[Python](https://www.python.org/)**, and Rust (Most influences came from linked languages).
|
||||||
|
|
||||||
|
Fun is and will ever be 100% free under the terms of the [ISC-License](https://opensource.org/license/isc-license-txt).
|
||||||
|
|
||||||
|
## Idea
|
||||||
|
|
||||||
|
* Simplicity
|
||||||
|
* Consistency
|
||||||
|
* Joy in coding
|
||||||
|
* Fun!
|
||||||
|
|
||||||
|
## Characteristics
|
||||||
|
|
||||||
|
* Dynamic and optionally statically typed
|
||||||
|
* Type safety
|
||||||
|
* Written in C
|
||||||
|
* Internal libs are written with no_camel_case even when written in Fun
|
||||||
|
* Only a minimal function set is written in C and most other core libraries are implemented in Fun
|
||||||
|
|
||||||
|
## The Fun Manifesto
|
||||||
|
|
||||||
|
Fun is a programming language built on a simple idea:
|
||||||
|
Coding should be enjoyable, elegant, and consistent.
|
||||||
|
|
||||||
|
### Philosophy
|
||||||
|
|
||||||
|
- **Fun is Fun**<br>
|
||||||
|
Programming should spark creativity, not frustration. Code in Fun feels light, playful, and rewarding.
|
||||||
|
- **Fun Uses Nothing**<br>
|
||||||
|
Minimalism is power. No unnecessary features, no endless syntax variations, no formatting debates. Just clean, uniform code.
|
||||||
|
- **Indentation is Truth**<br>
|
||||||
|
Two spaces, always. No tabs, no four-space wars. Code should look the same everywhere, from your laptop to /usr/bin/fun.
|
||||||
|
- **One Way to Do It**<br>
|
||||||
|
No clutter, no 15 ways of writing the same thing. Simplicity means clarity.
|
||||||
|
- **Hackable by Nature**<br>
|
||||||
|
Fun should be small and embeddable, like Lua. Easy to understand, extend, and tinker with — true to the hacker spirit.
|
||||||
|
- **Beautiful Defaults**<br>
|
||||||
|
A language that doesn’t need linters, formatters, or style guides. Beauty is built in.
|
||||||
|
|
||||||
|
## The Community
|
||||||
|
|
||||||
|
Fun is not about being the fastest or the most feature-rich. It’s about sharing joy in coding. The community should be:
|
||||||
|
|
||||||
|
- Respectful
|
||||||
|
- Curious
|
||||||
|
- Creative
|
||||||
|
|
||||||
|
Like the name says: Fun Unites Nerds.
|
||||||
|
|
||||||
|
## The Goal
|
||||||
|
|
||||||
|
A language that feels like home for developers who:
|
||||||
|
|
||||||
|
- Love minimal, elegant tools
|
||||||
|
- Believe consistency is freedom
|
||||||
|
- Want to write code that looks good and feels good
|
||||||
|
|
||||||
|
Fun may not change the world — but it will make programming a little more fun.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Actually there does not exist any documenation. In the [examples/](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"} directory should be an example of most Fun features.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
This section is a work in progress... Please excuse the lack of more information. There are daily updates here.
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
A C compiler, a libc and [Git](https://git-scm.com/).
|
||||||
|
|
||||||
|
Actually Fun requires both CMake and Make as build utils. You always can build Fun only using CMake. Make is just used as a wrapper around CMake.
|
||||||
|
|
||||||
|
#### FreeBSD
|
||||||
|
|
||||||
|
- [CMake](https://cmake.org/)
|
||||||
|
- [Clang](https://clang.llvm.org/)
|
||||||
|
- [GNU Make](https://www.gnu.org/software/make) (gmake)
|
||||||
|
|
||||||
|
#### Linux
|
||||||
|
|
||||||
|
- [CMake](https://cmake.org/)
|
||||||
|
- [GCC](https://gcc.gnu.org/) (Clang should work here too, not tested!)
|
||||||
|
- [GNU make](https://www.gnu.org/software/make) (make)
|
||||||
|
|
||||||
|
#### Windows
|
||||||
|
|
||||||
|
This requires Cygwin to be installed and configured. I will not cover this here.
|
||||||
|
|
||||||
|
- [CMake](https://cmake.org/)
|
||||||
|
- [GNU make](https://www.gnu.org/software/make) (make)
|
||||||
|
- [MinGW](https://en.wikipedia.org/wiki/MinGW)
|
||||||
|
|
||||||
|
### Rules
|
||||||
|
|
||||||
|
- Every commit requires a version incremantion in CMakeLists.txt before committing
|
||||||
|
- Every commit message must contain the version at the end in the following format (1.2.3)
|
||||||
|
- Version numbering follows "[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html)"
|
||||||
|
|
||||||
|
### Developement systems
|
||||||
|
|
||||||
|
- [GNU](https://gnu.org/)/[Linux](https://kernel.org/) ([Arch](https://archlinux.org/)/[Artix](https://artixlinux.org/), [Debian](https://www.debian.org/)) using [GCC](https://gcc.gnu.org/) and the [GNU C library](https://www.gnu.org/software/libc/) ([glibc](https://en.wikipedia.org/wiki/Glibc))
|
||||||
|
- GNU/Linux ([Alpine](https://alpinelinux.org/)) using GCC and the [musl libc](https://musl.libc.org/)
|
||||||
|
- [FreeBSD](https://www.freebsd.org/) using [Clang](https://clang.llvm.org/) and the [BSD libc](https://en.wikipedia.org/wiki/C_standard_library#BSD_libc)
|
||||||
|
- [Windows](https://en.wikipedia.org/wiki/Microsoft_Windows) using [MinGW](https://en.wikipedia.org/wiki/MinGW)
|
||||||
|
|
||||||
|
### Other systems
|
||||||
|
|
||||||
|
- [macOS](https://en.wikipedia.org/wiki/MacOS), [NetBSD](https://netbsd.org/), [OpenBSD](https://www.openbsd.org/), etc. should fully work, but I don't know. I do not use these systems actually. You wanna try and report?
|
||||||
|
|
||||||
|
### To Do
|
||||||
|
|
||||||
|
Everything... ;) No, a lot of stuff works already, but only a tiny set of functionality is available in the Fun programming language. It grows from day to day...
|
||||||
|
|
||||||
|
### Build Fun
|
||||||
|
|
||||||
|
Linux/UNIX only covered here for now.
|
||||||
|
|
||||||
|
Clone repository:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://git.xw3.org/fun/fun.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Change directory:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd fun
|
||||||
|
```
|
||||||
|
|
||||||
|
Build:
|
||||||
|
|
||||||
|
```
|
||||||
|
make # gmake on FeeBSD
|
||||||
|
```
|
||||||
|
|
||||||
|
That's it! For testing it run:
|
||||||
|
|
||||||
|
```
|
||||||
|
./build/fun ./demo.fun
|
||||||
|
```
|
||||||
|
|
|
||||||
4
demo.fun
4
demo.fun
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-30
|
* Added: 2025-09-30
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen
|
* Copyright 2025 Johannes Findeisen
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -49,7 +49,7 @@ print(sum3(1, 2, 3)) // expect 6
|
||||||
print(add(add(1, 2), 3)) // expect 6
|
print(add(add(1, 2), 3)) // expect 6
|
||||||
print(id(42)) // expect 42
|
print(id(42)) // expect 42
|
||||||
|
|
||||||
// Call as statement (result discarded)
|
// Call as statement (result dApache-2.0arded)
|
||||||
add(100, 23)
|
add(100, 23)
|
||||||
|
|
||||||
// Globals interacting with functions
|
// Globals interacting with functions
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Have fun in Fun
|
// Have fun in Fun
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Demonstrates system library includes after installation to /usr/lib/fun
|
// Demonstrates system library includes after installation to /usr/lib/fun
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// To test this you need to go to ./examples/ and test includes running ../build/fun include_local.fun
|
// To test this you need to go to ./examples/ and test includes running ../build/fun include_local.fun
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Simple utility module to be included locally with: #include "include_local_util.fun"
|
// Simple utility module to be included locally with: #include "include_local_util.fun"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-30
|
* Added: 2025-09-30
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-30
|
* Added: 2025-09-30
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Nested loops: break and continue behavior
|
// Nested loops: break and continue behavior
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Objects via maps: bracket access and method calls with explicit self
|
// Objects via maps: bracket access and method calls with explicit self
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Objects as maps: nested fields, methods with explicit self
|
// Objects as maps: nested fields, methods with explicit self
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Environment variables via env(name):
|
// Environment variables via env(name):
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Short-circuit demo for || and &&
|
// Short-circuit demo for || and &&
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Signed integer type examples with two's complement wrapping
|
// Signed integer type examples with two's complement wrapping
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Strings test: concatenation with variables and literals, functions returning strings
|
// Strings test: concatenation with variables and literals, functions returning strings
|
||||||
|
|
|
||||||
62
examples/threads_demo.fun
Normal file
62
examples/threads_demo.fun
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env fun
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Fun programming language.
|
||||||
|
* https://hanez.org/project/fun/
|
||||||
|
*
|
||||||
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
|
* https://opensource.org/license/apache-2-0
|
||||||
|
*
|
||||||
|
* Added: 2025-09-30
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Threading demo for Fun
|
||||||
|
// Run without installing:
|
||||||
|
// FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/threads_demo.fun
|
||||||
|
// (Windows PowerShell) $env:FUN_LIB_DIR="$PWD\lib"; .\build\fun.exe examples\threads_demo.fun
|
||||||
|
|
||||||
|
print("=== Threads demo ===")
|
||||||
|
|
||||||
|
// A worker function that does some work and returns a value
|
||||||
|
fun square(n)
|
||||||
|
// simulate work
|
||||||
|
sleep(100)
|
||||||
|
return n * n
|
||||||
|
|
||||||
|
// Spawn several workers
|
||||||
|
ids = []
|
||||||
|
for x in [1, 2, 3, 4, 5]
|
||||||
|
id = thread_spawn(square, x) // pass a single argument
|
||||||
|
push(ids, id)
|
||||||
|
print("spawned thread id=" + to_string(id) + " for x=" + to_string(x))
|
||||||
|
|
||||||
|
print("Joining threads...")
|
||||||
|
results = []
|
||||||
|
for id in ids
|
||||||
|
r = thread_join(id)
|
||||||
|
push(results, r)
|
||||||
|
|
||||||
|
print("Squares: " + to_string(results))
|
||||||
|
|
||||||
|
// Example: pass multiple args via array
|
||||||
|
fun add3(a, b, c)
|
||||||
|
return a + b + c
|
||||||
|
|
||||||
|
tid = thread_spawn(add3, [10, 20, 30])
|
||||||
|
print("join add3 -> " + to_string(thread_join(tid)))
|
||||||
|
|
||||||
|
print("=== Threads demo done ===")
|
||||||
|
|
||||||
|
/* Expected output:
|
||||||
|
=== Threads demo ===
|
||||||
|
spawned thread id=1 for x=1
|
||||||
|
spawned thread id=2 for x=2
|
||||||
|
spawned thread id=3 for x=3
|
||||||
|
spawned thread id=4 for x=4
|
||||||
|
spawned thread id=5 for x=5
|
||||||
|
Joining threads...
|
||||||
|
Squares: [array n=5]
|
||||||
|
join add3 -> 60
|
||||||
|
=== Threads demo done ===
|
||||||
|
*/
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Type Safety demonstration in Fun
|
// Type Safety demonstration in Fun
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print("Reassigning typed variables to another type should fail")
|
print("Reassigning typed variables to another type should fail")
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print("=== Typeof test start ===")
|
print("=== Typeof test start ===")
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Demonstration of enhanced typeof behavior:
|
// Demonstration of enhanced typeof behavior:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Integer (number) and boolean usage examples
|
// Integer (number) and boolean usage examples
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print("=== Dynamic (untyped) ===")
|
print("=== Dynamic (untyped) ===")
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Unsigned integer type examples with wrapping behavior
|
// Unsigned integer type examples with wrapping behavior
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// While loops feature test: simple loops, nested with if/else, and functions
|
// While loops feature test: simple loops, nested with if/else, and functions
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Basic math helpers to be included from system lib:
|
// Basic math helpers to be included from system lib:
|
||||||
|
|
|
||||||
4
play.fun
4
play.fun
|
|
@ -5,8 +5,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun foo()
|
fun foo()
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ This file is part of the Fun programming language.
|
||||||
https://hanez.org/project/fun/
|
https://hanez.org/project/fun/
|
||||||
|
|
||||||
Copyright 2025 Johannes Findeisen <you@hanez.org>
|
Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
Licensed under the terms of the ISC license.
|
Licensed under the terms of the Apache-2.0 license.
|
||||||
https://opensource.org/license/isc-license-txt
|
https://opensource.org/license/apache-2-0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ set -euo pipefail
|
||||||
# https://hanez.org/project/fun/
|
# https://hanez.org/project/fun/
|
||||||
#
|
#
|
||||||
# Copyright 2025 Johannes Findeisen <you@hanez.org>
|
# Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
# Licensed under the terms of the ISC license.
|
# Licensed under the terms of the Apache-2.0 license.
|
||||||
# https://opensource.org/license/isc-license-txt
|
# https://opensource.org/license/apache-2-0
|
||||||
|
|
||||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
|
||||||
EX_DIR="$ROOT/examples"
|
EX_DIR="$ROOT/examples"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
implementation or programming. Just a compiled version of many ideas... ;)
|
implementation or programming. Just a compiled version of many ideas... ;)
|
||||||
|
|
||||||
Copyright 2025 Johannes Findeisen <you@hanez.org>
|
Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
License: ISC License, https://opensource.org/license/isc-license-txt
|
License: Apache-2.0 License, https://opensource.org/license/apache-2-0
|
||||||
|
|
||||||
Birthdate: 2025-09-10
|
Birthdate: 2025-09-10
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -306,4 +306,4 @@ print "Current time: " + now
|
||||||
|
|
||||||
## 12. License
|
## 12. License
|
||||||
|
|
||||||
This document and the Fun language reference are licensed under the ISC License.
|
This document and the Fun language reference are licensed under the Apache-2.0 License.
|
||||||
|
|
|
||||||
|
|
@ -413,4 +413,4 @@ print("Current time: " + now)
|
||||||
|
|
||||||
## 15. License
|
## 15. License
|
||||||
|
|
||||||
This document and the Fun language reference are licensed under the ISC License.
|
This document and the Fun language reference are licensed under the Apache-2.0 License.
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bytecode.h"
|
#include "bytecode.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FUN_BYTECODE_H
|
#ifndef FUN_BYTECODE_H
|
||||||
|
|
@ -35,7 +35,7 @@ typedef enum {
|
||||||
OP_EQ, // a == b -> push 1/0
|
OP_EQ, // a == b -> push 1/0
|
||||||
OP_NEQ, // a != b -> push 1/0
|
OP_NEQ, // a != b -> push 1/0
|
||||||
|
|
||||||
OP_POP, // discard top of stack
|
OP_POP, // dApache-2.0ard top of stack
|
||||||
OP_JUMP, // unconditional jump
|
OP_JUMP, // unconditional jump
|
||||||
OP_JUMP_IF_FALSE, // jump if top of stack is false (0)
|
OP_JUMP_IF_FALSE, // jump if top of stack is false (0)
|
||||||
|
|
||||||
|
|
@ -115,6 +115,11 @@ typedef enum {
|
||||||
// OS
|
// OS
|
||||||
OP_ENV, // pops name string; pushes value string (or "")
|
OP_ENV, // pops name string; pushes value string (or "")
|
||||||
|
|
||||||
|
// Threads
|
||||||
|
OP_THREAD_SPAWN, // operand: 0=no args, 1=has args; pops [args?], fn; pushes thread id (int>0)
|
||||||
|
OP_THREAD_JOIN, // pops thread id; waits; pushes result value (or Nil)
|
||||||
|
OP_SLEEP_MS, // pops milliseconds; sleeps; pushes Nil (for statement POP safety)
|
||||||
|
|
||||||
// Bitwise (32-bit) and shifts/rotates
|
// Bitwise (32-bit) and shifts/rotates
|
||||||
OP_BAND, // pops b, a; pushes (uint32_t)(a & b)
|
OP_BAND, // pops b, a; pushes (uint32_t)(a & b)
|
||||||
OP_BOR, // pops b, a; pushes (uint32_t)(a | b)
|
OP_BOR, // pops b, a; pushes (uint32_t)(a | b)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bytecode.h"
|
#include "bytecode.h"
|
||||||
|
|
@ -118,7 +118,7 @@ int main(void) {
|
||||||
bytecode_add_instruction(bc, OP_PRINT, 0); // top=1
|
bytecode_add_instruction(bc, OP_PRINT, 0); // top=1
|
||||||
|
|
||||||
bytecode_add_instruction(bc, OP_LOAD_CONST, c1);
|
bytecode_add_instruction(bc, OP_LOAD_CONST, c1);
|
||||||
bytecode_add_instruction(bc, OP_POP, 0); // discard 1 (stack now empty)
|
bytecode_add_instruction(bc, OP_POP, 0); // dApache-2.0ard 1 (stack now empty)
|
||||||
|
|
||||||
// ---------- HALT ----------
|
// ---------- HALT ----------
|
||||||
bytecode_add_instruction(bc, OP_HALT, 0);
|
bytecode_add_instruction(bc, OP_HALT, 0);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
43
src/parser.c
43
src/parser.c
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -798,7 +798,7 @@ static int emit_primary(Bytecode *bc, const char *src, size_t len, size_t *pos)
|
||||||
|
|
||||||
/* Append via insert: res.insert(index=len(res), value) */
|
/* Append via insert: res.insert(index=len(res), value) */
|
||||||
bytecode_add_instruction(bc, OP_INSERT, 0);
|
bytecode_add_instruction(bc, OP_INSERT, 0);
|
||||||
/* discard returned new length */
|
/* dApache-2.0ard returned new length */
|
||||||
bytecode_add_instruction(bc, OP_POP, 0);
|
bytecode_add_instruction(bc, OP_POP, 0);
|
||||||
|
|
||||||
/* i++ */
|
/* i++ */
|
||||||
|
|
@ -877,7 +877,7 @@ static int emit_primary(Bytecode *bc, const char *src, size_t len, size_t *pos)
|
||||||
|
|
||||||
/* Append via insert: res.insert(index=len(res), value) */
|
/* Append via insert: res.insert(index=len(res), value) */
|
||||||
bytecode_add_instruction(bc, OP_INSERT, 0);
|
bytecode_add_instruction(bc, OP_INSERT, 0);
|
||||||
/* discard returned new length */
|
/* dApache-2.0ard returned new length */
|
||||||
bytecode_add_instruction(bc, OP_POP, 0);
|
bytecode_add_instruction(bc, OP_POP, 0);
|
||||||
|
|
||||||
int c1 = bytecode_add_constant(bc, make_int(1));
|
int c1 = bytecode_add_constant(bc, make_int(1));
|
||||||
|
|
@ -1029,6 +1029,39 @@ static int emit_primary(Bytecode *bc, const char *src, size_t len, size_t *pos)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* threading */
|
||||||
|
if (strcmp(name, "thread_spawn") == 0) {
|
||||||
|
(*pos)++; /* '(' */
|
||||||
|
/* thread_spawn(fn [, args]) */
|
||||||
|
if (!emit_expression(bc, src, len, pos)) { parser_fail(*pos, "thread_spawn expects function as first arg"); free(name); return 0; }
|
||||||
|
int hasArgs = 0;
|
||||||
|
skip_spaces(src, len, pos);
|
||||||
|
if (*pos < len && src[*pos] == ',') {
|
||||||
|
(*pos)++;
|
||||||
|
skip_spaces(src, len, pos);
|
||||||
|
if (!emit_expression(bc, src, len, pos)) { parser_fail(*pos, "thread_spawn second arg must be array or value"); free(name); return 0; }
|
||||||
|
hasArgs = 1;
|
||||||
|
}
|
||||||
|
if (!consume_char(src, len, pos, ')')) { parser_fail(*pos, "Expected ')' after thread_spawn args"); free(name); return 0; }
|
||||||
|
bytecode_add_instruction(bc, OP_THREAD_SPAWN, hasArgs ? 1 : 0);
|
||||||
|
free(name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strcmp(name, "thread_join") == 0) {
|
||||||
|
(*pos)++; /* '(' */
|
||||||
|
if (!emit_expression(bc, src, len, pos) || !consume_char(src, len, pos, ')')) { parser_fail(*pos, "thread_join expects 1 arg (thread id)"); free(name); return 0; }
|
||||||
|
bytecode_add_instruction(bc, OP_THREAD_JOIN, 0);
|
||||||
|
free(name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (strcmp(name, "sleep") == 0) {
|
||||||
|
(*pos)++; /* '(' */
|
||||||
|
if (!emit_expression(bc, src, len, pos) || !consume_char(src, len, pos, ')')) { parser_fail(*pos, "sleep expects 1 arg (milliseconds)"); free(name); return 0; }
|
||||||
|
bytecode_add_instruction(bc, OP_SLEEP_MS, 0);
|
||||||
|
free(name);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* bitwise ops (32-bit) */
|
/* bitwise ops (32-bit) */
|
||||||
if (strcmp(name, "band") == 0) {
|
if (strcmp(name, "band") == 0) {
|
||||||
(*pos)++; /* '(' */
|
(*pos)++; /* '(' */
|
||||||
|
|
@ -2317,7 +2350,7 @@ static void parse_simple_statement(Bytecode *bc, const char *src, size_t len, si
|
||||||
/* rewind to statement start and emit as expression */
|
/* rewind to statement start and emit as expression */
|
||||||
local_pos = *pos;
|
local_pos = *pos;
|
||||||
if (emit_expression(bc, src, len, &local_pos)) {
|
if (emit_expression(bc, src, len, &local_pos)) {
|
||||||
bytecode_add_instruction(bc, OP_POP, 0); /* discard return value */
|
bytecode_add_instruction(bc, OP_POP, 0); /* dApache-2.0ard return value */
|
||||||
}
|
}
|
||||||
*pos = local_pos;
|
*pos = local_pos;
|
||||||
skip_to_eol(src, len, pos);
|
skip_to_eol(src, len, pos);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* - Optional shebang on the first line.
|
* - Optional shebang on the first line.
|
||||||
* - Optional single function wrapper: fun <ident>() { ... }
|
* - Optional single function wrapper: fun <ident>() { ... }
|
||||||
* - print("...") statements inside function or at top-level.
|
* - print("...") statements inside function or at top-level.
|
||||||
* Produces bytecode that executes all discovered print statements and halts.
|
* Produces bytecode that executes all dApache-2.0overed print statements and halts.
|
||||||
*
|
*
|
||||||
* Returns: newly allocated Bytecode*, or NULL on error.
|
* Returns: newly allocated Bytecode*, or NULL on error.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
21
src/vm.c
21
src/vm.c
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Bring in split-out built-ins without changing the build system yet */
|
/* Bring in split-out built-ins without changing the build system yet */
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
/* Threading internals (registry and platform glue) */
|
||||||
|
#include "vm/os/thread_common.c"
|
||||||
|
|
||||||
/* Track the currently running VM to annotate error messages */
|
/* Track the currently running VM to annotate error messages */
|
||||||
static VM *g_active_vm = NULL;
|
static VM *g_active_vm = NULL;
|
||||||
|
|
||||||
|
|
@ -268,7 +271,7 @@ void vm_run(VM *vm, Bytecode *entry) {
|
||||||
#include "vm/bitwise/shr.c"
|
#include "vm/bitwise/shr.c"
|
||||||
#include "vm/bitwise/rol.c"
|
#include "vm/bitwise/rol.c"
|
||||||
#include "vm/bitwise/ror.c"
|
#include "vm/bitwise/ror.c"
|
||||||
|
|
||||||
#include "vm/core/call.c"
|
#include "vm/core/call.c"
|
||||||
#include "vm/core/dup.c"
|
#include "vm/core/dup.c"
|
||||||
#include "vm/core/halt.c"
|
#include "vm/core/halt.c"
|
||||||
|
|
@ -283,11 +286,10 @@ void vm_run(VM *vm, Bytecode *entry) {
|
||||||
#include "vm/core/store_global.c"
|
#include "vm/core/store_global.c"
|
||||||
#include "vm/core/store_local.c"
|
#include "vm/core/store_local.c"
|
||||||
#include "vm/core/swap.c"
|
#include "vm/core/swap.c"
|
||||||
|
|
||||||
#include "vm/io/read_file.c"
|
#include "vm/io/read_file.c"
|
||||||
#include "vm/io/write_file.c"
|
#include "vm/io/write_file.c"
|
||||||
#include "vm/os/env.c"
|
|
||||||
|
|
||||||
#include "vm/logic/and.c"
|
#include "vm/logic/and.c"
|
||||||
#include "vm/logic/eq.c"
|
#include "vm/logic/eq.c"
|
||||||
#include "vm/logic/gt.c"
|
#include "vm/logic/gt.c"
|
||||||
|
|
@ -302,7 +304,7 @@ void vm_run(VM *vm, Bytecode *entry) {
|
||||||
#include "vm/maps/keys.c"
|
#include "vm/maps/keys.c"
|
||||||
#include "vm/maps/make_map.c"
|
#include "vm/maps/make_map.c"
|
||||||
#include "vm/maps/values.c"
|
#include "vm/maps/values.c"
|
||||||
|
|
||||||
#include "vm/math/abs.c"
|
#include "vm/math/abs.c"
|
||||||
#include "vm/math/clamp.c"
|
#include "vm/math/clamp.c"
|
||||||
#include "vm/math/max.c"
|
#include "vm/math/max.c"
|
||||||
|
|
@ -312,6 +314,11 @@ void vm_run(VM *vm, Bytecode *entry) {
|
||||||
#include "vm/math/random_int.c"
|
#include "vm/math/random_int.c"
|
||||||
#include "vm/math/random_seed.c"
|
#include "vm/math/random_seed.c"
|
||||||
|
|
||||||
|
#include "vm/os/env.c"
|
||||||
|
#include "vm/os/sleep_ms.c"
|
||||||
|
#include "vm/os/thread_join.c"
|
||||||
|
#include "vm/os/thread_spawn.c"
|
||||||
|
|
||||||
#include "vm/strings/find.c"
|
#include "vm/strings/find.c"
|
||||||
#include "vm/strings/split.c"
|
#include "vm/strings/split.c"
|
||||||
#include "vm/strings/substr.c"
|
#include "vm/strings/substr.c"
|
||||||
|
|
|
||||||
5
src/vm.h
5
src/vm.h
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FUN_VM_H
|
#ifndef FUN_VM_H
|
||||||
|
|
@ -34,6 +34,7 @@ static const char *opcode_names[] = {
|
||||||
"MIN","MAX","CLAMP","ABS","POW","RANDOM_SEED","RANDOM_INT",
|
"MIN","MAX","CLAMP","ABS","POW","RANDOM_SEED","RANDOM_INT",
|
||||||
"MAKE_MAP","KEYS","VALUES","HAS_KEY",
|
"MAKE_MAP","KEYS","VALUES","HAS_KEY",
|
||||||
"READ_FILE","WRITE_FILE","ENV",
|
"READ_FILE","WRITE_FILE","ENV",
|
||||||
|
"THREAD_SPAWN","THREAD_JOIN","SLEEP_MS",
|
||||||
"BAND","BOR","BXOR","BNOT","SHL","SHR","ROTL","ROTR"
|
"BAND","BOR","BXOR","BNOT","SHL","SHR","ROTL","ROTR"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* https://hanez.org/project/fun/
|
* https://hanez.org/project/fun/
|
||||||
*
|
*
|
||||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
* Licensed under the terms of the ISC license.
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
* https://opensource.org/license/isc-license-txt
|
* https://opensource.org/license/apache-2-0
|
||||||
*
|
*
|
||||||
* Added: 2025-09-29
|
* Added: 2025-09-29
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue