Skip to content

An open-source XojoScript compiler and virtual machine for the Xojo language. Run XojoScript at native C++ speed on any device ๐Ÿ™

License

Notifications You must be signed in to change notification settings

simulanics/XojoScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

/simulanics/XojoScript

An open-source XojoScript compiler and virtual machine for the Xojo language. Compile and Run XojoScript at native C++ speed, on any system supporting C++ (99.9% of devices - even the web! ๐Ÿ™)

XojoScript Bytecode Compiler and Virtual Machine ๐Ÿš€

Welcome to the XojoScript Bytecode Compiler and Virtual Machine! This project is a lightweight bytecode compiler and virtual machine written in C++ that handles XojoScript executionโ€”including functions, classes, and more - entirely cross- platform. It compiles XojoScript into bytecode and executes it on a custom virtual machine. ๐Ÿคฏ

Features โœจ

  • Function Support: Compile and execute user-defined functions and built-in ones. Overloading of functions is permitted.
  • Module Support: Create XojoScript Modules. (โ— "extends" is in the works).
  • Class & Instance Support: Create classes, define methods, and instantiate objects.
  • Intrinsic Types: Handles types like Color, Integer, Double, Boolean, Variant and String.
  • Bytecode Execution: Runs compiled bytecode on a custom VM.
  • Debug Logging: Step-by-step debug logs to trace lexing, parsing, compiling, and execution.
  • 100%: Matches Xojo language syntax
  • Open Source: Released under the MIT License.

Getting Started ๐Ÿ

Prerequisites

  • A C++ compiler with C++17 support (e.g. g++, clang++)
  • Git

Installation

  1. Clone the Repository:

    git clone https://github.com/yourusername/XojoScript
    cd XojoScript
  2. Compile the Project:

For example, using g++:

g++ -std=c++17 -o xojoscript xojoscript.cpp -lffi

With speed optimizations:

g++ -o xojoscript xojoscript.cpp -lffi -O3 -march=native -mtune=native -flto
  1. Prepare Your Script:

Create a file named test.txt with your XojoScript code. For example:

Function addtwonumbers(num1 As Integer, num2 As Integer) As Integer
    Return num1 + num2
End Function

Public Sub Main()
    Dim result As Integer = addtwonumbers(2, 3)
    Print(str(result))
End Sub
  1. Run the Compiler on a script:
./xojoscript --s filename
(*currently compiles test.txt file and immediately runs it in the VM if no source file is specified.)

Debugging ๐Ÿ”

Debug logging is enabled via the DEBUG_MODE flag. Set it to true or false at the top of the code:

bool DEBUG_MODE = true;

This will output detailed logs for lexing, parsing, compiling, and execution.

Contributing ๐Ÿค

Contributions are welcome! Please feel free to open issues or submit pull requests. Your help is appreciated! ๐ŸŽ‰

License ๐Ÿ“„

This project is licensed under the MIT License. See the LICENSE file for details.

**This is currently a working proof-of-concept to be expanded upon.

Happy coding! ๐Ÿ˜„

About

An open-source XojoScript compiler and virtual machine for the Xojo language. Run XojoScript at native C++ speed on any device ๐Ÿ™

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages