Introduction
UCodeLang is a Progaming language made for GameEngines.
This guide is an contains everything about the UCodeLang Project and it's tools,standard and C++ API.
The guide is meant to be read in any order. Depending on your use case.
If your a Game engine developer or framework developer go to Geting Started Implementers and Library API Reference.
If your a normal user go to Geting Started User.
If you just want to learn about the language go to SyntaxAndSemantics or Standard library.
Credits
The was Language was designed and developed by LostBlizzard On GitHub.
Who currently maintains the
- The UCodeLang cplusplus implementation of the language.
The UCodeGameEngine(being worked on) the primary reason The Language was made.
UCodeLang is mainly inspired by C++,Rust,C#,Go.
License
The UCodeLang source and documentation are released under the Mit License
Why Make another programming language.
UCode is a programming language designed to be embedded into existing software such as game engines while being a low-level language with modern and high-level features.
mainly
- does not require a garbage collector like C#.
- offers more functionality than Lua.
- is easier to use than C++.
- Uses Compile time power to reduce boilerplate.
Design Principles/Pillars
- Simple is better than complex.
- Zero-overhead abstractions
- You don't pay for what you don't use.
- What you do use is just as efficient as what you could reasonably write by hand.
- Productive
- Scalable compilation times
- Reliable Tooling.
- gradual learning curve
- Reuseable
- multi-paradigm
- Compile time power
QA
-
Q: UCodeLang is very similar to c++ and rust why not use Rust or C++?
A: C++ is too compilcaicated of a language and is unanalyzable after compiling(without hacking the compiler).rust memory features is not that usefull for my use cases and c++ Smart Pointer's is all i need.
-
Q: Why is it written in c++.
A: Most Game Engines and specificaly my game engine is written in c++.c++ is stil the best tool for makeing game engines.
-
Q:Why not use LLVM for your backend.
A:LLVM is too big of a dependency and writeing backends my self gives me a good excuse to learn about Computers(The Reason im makeing a game engine). Also you just output llvm assembly text.
-
Q:Why significant white space?
A:Just Seemed Interesting also just looks nicer.
-
Q:UCodeLang just seems takes ideas from other languages does not do anything new.
A:UCodeLang is not the next big thing it's just a tool made for my specific use case.It takes the best Parts from languages i like and attempts to remove excess.
-
Q:What does UCode mean?
A:The word UCode means nothing and has no history it just just a name I made up for a progaming language idea.if you realy want a meaning a meaning it when the idea was made it stand for Unsigned Code based on c/c++ unsigned keyword.
-
Q:Do you like c++?
A:I like it enough to spend a year makeing a new language useing it but not enough to make my users for my Game Engine Use it(Sorry unreal).
-
Q:what next and when will be Language be done.
-
A:When the repository Opens (preferably on 1/2/2023 The one year anniversary of makeing the jit project) most features would be done and dont really plan on adding more unless it Just too Good. I'll be around for an extra year to finsh up the other architectures and backends and stabitly.at that point the project will be done and i can go on working on that game engine and go to work on biger and better things.
Syntax
Here a basic run down of UCodeLang Syntax for People who already know how a programming language.
UCode uses Sugnificant Whitespace like python.
The syntax for declaring a function in UCode is as follows:
|function_name[parameter_list];//not being explicit with the return
|function_name[parameter_list] -> void;
For example, the following code declares a function named add that takes two integer parameters and returns an integer:
|add[int x, int y] -> int;
Variables are declared with a type and a name. For example, the following code declares an integer variable named x:
int x;
Member functions are just functions with a this parameter
use ULang;
$MyClass:
|SayHello[this&]:
Fmt::Print("Hello, World!");
|main[]:
var object = MyClass();
object.SayHello();
To access a static variable or function in UCode, you can use the class name and the scope resolution operator (::).
//no use of the ULang namespace;
|main[]:
ULang::Fmt::Print("Hello");
functions can be expressed in different ways.
|add[int x, int y] => x + y;
|add2[int x, int y] -> int:
ret x + y;
|add3[int x, int y]:
ret x + y;
enums are is as follows:
$Color enum:
Red,
Green,
Blue,
namespaces are is as follows:
MyNamespaces:
static int MyStaticValue = 10;
thread int MythreadLocalValue =10;
int Value = 10;//also my threadLocalValue
using namespaces is as follows:
use MyNamespaces;
alias is as follows:
$i64 = int64;
$u32 = uint32;
inheritance look like this
$Worker trait;//no members
$FasterWorker[Worker];//no members
Object protections look like this
$Worker;
$FasterWorker[Worker]:
public:
int Hp = 10;
private:
int Money = 10;
int Happiness = 10;
Standard Library Compiler alias
int? MaybeAnInt;//an optional int
int[] Ints;//an Vector<int>
int[5] MoreInts;//an Array<int,5> //an Array<int,(somevarable)>
int[(somevarable)] MoreInts; //an Array<int,(somevarable)> Map short hand takes precedent over array in this case so you need parentheses.
int[String] StringToIntMap;//an Map<String,int>
int[sometype] SomeTypeToIntMap;//an Map<sometype,int>
int[:] SpanOfInts;//an Span<int>
int^ UniqueInt;//an Unique_ptr<int>
int$ SharedInt;//an Shared_ptr<int>
int[^] UniqueIntsArray;//an Unique_Array<int>
int[$] SharedIntsArray;//an Shared_Array<int>
imut int ConstInt = 5;
imut ConstInt2 = 4;// or like this.
$MyClass:
|SayHello[umut this&]:
Fmt::Print("Hello, World!");
|main[]:
int x = 10;
int& r = x;
|Update_NumToChange[int& V]:
V = 10;
Thats the basics heres. Some links Explore More:
Geting Started Users
Despite that UCodeLang was designed to embed into applications. You can use Directly using uclang command line tool.
Download
You may use the Playground to try it without Downloading.
Run The following in your terminal to install on linux/MacOs.
curl -L https://github.com/LostbBlizzard/UCodeLang/releases/latest/download/install.sh | sh
Or Download the Installer on the latest release for Windows.
To test that it was installed in your command prompt try runing.
uclang help
Extension
lets also download the VsCode extension to make our lives easier.
just search up UCodeLang by Lost blizzard in your extension tab.
Hello main
after geting your extension. run
uclang new
This will ask you about the Project name and author's name.
You can put HelloMain as the ProjectName. and MySelf as the AuthorName.
Inside the new folder.You will Have this folder structure.
- HelloMain
- src
- main.uc
- ULangModule.ucm
- Build.uc
The 'src' Folder is were all your code is going to be. UCodeLang uses the .uc file extension for all source files.
main.uc is were your main funcion is.This is were your program will start executing.
Build.ucm Is your build script. this allows you to do stuff before and after you build your project. you can ignore this file or even delete it for now.
Lasly ULangModule.uc Is were you place your dependencies.
build and runing
Now lets build our Hello World Program by runing uclang build.
uclang build
And run to program by using uclang run
uclang run
You should see Hello World On your Screen.
Also See Syntax And Semantics
Also See Standardlibrary
UCodeCL command-line reference
The UCodeLang Command-line tool it serves as a Compiler,Runtime,build system and package manager for UCodeLang.
Syntax
uclang [command] <arguments>
Commands
Name | arguments | Description |
---|---|---|
help | none | Outputs all the all the available commands. |
new | none | makes a new UCodeLang Module Project. |
build | Path(optional),flags(optional) | Builds a UCodeLang File,Module,Folder. |
run | Path(optional),flags(optional) | Builds a UCodeLang File,Module,Folder or .ulib and runs it. See More |
get | Path(optional) | Downloads the Modules dependencies. |
dump | Path | Builds a UCodeLang File,Module,Folder or .ulib and attempts to convert the output into readable textworks with wasm,window,linux,macos,c89,.ulib,.uir outputs. |
clean | Path | clears a Module a intermediate and output files. |
cleanall | none | clears all Modules on the system intermediate and output files. |
cpptoulangvm | CppPath,CpplinkPath,ulangout | uses C++ source code to create bindings for UCodeVm |
cppdirtoulangvm | CppDir,CpplinkPath,ulangout | uses C++ source files code to create bindings for UCodeVm |
fmt | Path(optional) | Formats A UCodeLang Module or file. |
index | Path(optional) | Adds Module to to the Module Index so it can be used/referenced by other module in your system. |
test | Path(optional) | Runs Tests on your UCodeLang Module Project. |
update | Path(optional) | updates Module Dependencies uses Tests to avoid breaking changes and revert back if needed this may take Sometime. |
updatetools | none | updates UCodeLangTools. |
uninstalltools | none | uninstalls uclang and uclanglsp all downloaded modules will be left alone. |
install | Name | Installs a UCodeLangModule. |
addmod | Name,Path(optional) | runs a Installed and adds the Module to the project. |
runmod | Name | runs a Installed UCodeLangModule. |
uninstallmod | Name | uninstalls a Installed UCodeLangModule |
exits | none | exits ucodelang if opened without command line arguments. |
UCodeCL command-line reference
The UCodeLang Command-line tool it serves as a Compiler,Runtime,build system and package manager for UCodeLang.
Syntax
uclang [command] <arguments>
Commands
Name | arguments | Description |
---|---|---|
help | none | Outputs all the all the available commands. |
new | none | makes a new UCodeLang Module Project. |
build | Path(optional),flags(optional) | Builds a UCodeLang File,Module,Folder. |
run | Path(optional),flags(optional) | Builds a UCodeLang File,Module,Folder or .ulib and runs it. See More |
get | Path(optional) | Downloads the Modules dependencies. |
dump | Path | Builds a UCodeLang File,Module,Folder or .ulib and attempts to convert the output into readable textworks with wasm,window,linux,macos,c89,.ulib,.uir outputs. |
clean | Path | clears a Module a intermediate and output files. |
cleanall | none | clears all Modules on the system intermediate and output files. |
cpptoulangvm | CppPath,CpplinkPath,ulangout | uses C++ source code to create bindings for UCodeVm |
cppdirtoulangvm | CppDir,CpplinkPath,ulangout | uses C++ source files code to create bindings for UCodeVm |
fmt | Path(optional) | Formats A UCodeLang Module or file. |
index | Path(optional) | Adds Module to to the Module Index so it can be used/referenced by other module in your system. |
test | Path(optional) | Runs Tests on your UCodeLang Module Project. |
update | Path(optional) | updates Module Dependencies uses Tests to avoid breaking changes and revert back if needed this may take Sometime. |
updatetools | none | updates UCodeLangTools. |
uninstalltools | none | uninstalls uclang and uclanglsp all downloaded modules will be left alone. |
install | Name | Installs a UCodeLangModule. |
addmod | Name,Path(optional) | runs a Installed and adds the Module to the project. |
runmod | Name | runs a Installed UCodeLangModule. |
uninstallmod | Name | uninstalls a Installed UCodeLangModule |
exits | none | exits ucodelang if opened without command line arguments. |
Help Command
the list available commands is equivalent to reading the commands docs Example
uclang help
Possible output
Usage: uclang [command] [args]
new [Path] :Makes a new Module Project
build [Path] :Builds the UCode file,Module,folder
run [Path] <FunctionName(<Args>)> :run the UCode file,Module,folder,.ulib
test [Path] :Runs Tests the UCode file,Module,folder,.ulib
dump [Path] :Convert the UCode file,Module,folder,.ulib to Readable Text
New Command
Example
uclang new <ProjectName> <Author> <-[y/n]>
This command will make a new project in the working directory.
If not provided will ask the user for a ProjectName an Author and if should make a .gitnore file.
The exit code is 0.
Build Command
By default uclang build will compile to UCodeVM being 32 or 64 bit if the current cpu is 32 or 64.
if path not provided it will use the working directory as its input and use a UCodeModule Project in it to Compile.
The exit is 0 if compilation succeed or 1 for compilation fail.
Example
uclang build -c89
uclang build -uvm:x86_64
Flag | extra | Description |
---|---|---|
-01 | none | builds using using optimizations for Size. |
-02 | none | builds using using optimizations for Speed. |
-03 | none | builds using using optimizations for Maximum speed. |
-ndebug | none | disable debug mode and removes debug Symbols |
-32 | none | Sets build Target as 32bit Machine |
-64 | none | Sets build Target as 64bit Machine |
-c11 | none | build using C BackEnd. |
-wasm | none | build using the wasm BackEnd. |
-ir | none | Outputs the IR. |
-uvm | this,x86_64,x86,x86,arm_64,arm | Build Native Code for the UCodeVm the .ulib can run on any Operating system(Most of the time) for that cpu chip. |
-native | this,linux,windows,mac | Build Native Code Executable |
Run Command
By default uclang will try to call the main funcion.
uclang run
This can be overwritten and basic arguments can be passed.
uclang run func(4)
These flags only apply if path was UCodeLang File,Module,Folder or .ulib.
The exit code is 0 if compilation succeed or 1 for compilation fail or if it panic or returns an error if the return type is an result type.
after runing the console will look like the following
returned:
void
or
returned:
1
Flag | extra | Description |
---|---|---|
-jit | none | Uses the jit compiler compiler instead of the interpreter. |
-03 | none | Activates all optimization. |
-native | none | Compiles native code before running. |
Get Command
Example
uclang get <ProjectPath>
This command will download the project dependencies if they don't exist.
The exit code is 0 it did so successfully else its 1.
Dump Command
Example
uclang dump <path>
Its Disassembles a .ulib or a .wasm file or a project.
if path not provided it will use the working directory as its input and use a UCodeModule Project in it to Compile and dump its output.
note this is manly used for debuging.
The exit code is 0 it did so successfully else its 1.
Clean Command
Example
uclang clean <path>
Clears a Module a intermediate and output files if not provided will use the working directory.
exit code is 0 if it worked else 1.
Cleanall Command
Example
uclang cleanall <path>
Clears all modules on the system intermediate and output files if not provided will use the working directory.
exit code is 0 if it worked else 1.
Fmt Command
Example
uclang new <Path>
if path not provided it will use the working directory as its input.
Formats the UCodeLang Code in the Module or the file directly.
The exit code is 0 it did so successfully else its 1.
cpptoulangvm
Example
uclang cpptoulangvm [Cppfilepath] [UCodeLangBindingPath] [CppVMBindingPath]
Generates bindings for UCodeLang using c++ source code.
exit code is 0 if it worked else 1.
Heres our types and funcions we will like to export in our c++ file.
enum class Colors
{
Red,
Green,
Blue,
}
void SomeFuncionthatTakeinColor(Colors a)
{
//
}
The argument for the macros is the namespace inside of UCodeLang file.
namespace OurAPI
{
UCodeLangExportSymbol("YourFrameWorkNameSpace") enum class Colors
{
Red,
Green,
Blue,
}
UCodeLangExportSymbol("YourFrameWorkNameSpace") void SomeFuncionthatTakeinColor(Colors a)
{
//
}
}
next we need to add 'UCodeLangAutoLink' macros. when we add our Add_CPPCall.
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.OutPut);//initialize RunTimeLib useing our Compiled code.
//Adding Our PrintNumberConsole Funcion.
lib.Add_CPPCall("PrintNumberConsole", []( UCodeLang::InterpreterCPPinterface& Input)
{
int Par0 = Input.GetParameter<int>();
UAPI_PrintNumberConsole(Par0);
Input.Set_Return();
},UAPI_PrintNumberConsole);
//Our UCodeLangAutoLink
UCodeLangAutoLink(Lib, OurAPI);
Lets run our UCodeLang UCodeLang command line tool.
Open your command line in your ProjectRoot.
ProjectRoot >
then run uclang and type cpptoulangvm
- Then with for c++ file path
- then output ucodelang file(.uc) path
- then c++ output were 'UCodeLangAutoLink' macros is found
ProjectRoot > ./uclang cpptoulangvm [CppPath] [UCodeLangOut] [CppVMLinkPath]
now the UCodeLangOut will have all funcion and type boilerplate and CppVMLinkPath will have all the Add_CPPCall funcions.
and if you have your API in multiple C++ files you can use cppdirtoulangvm to search inside directories.it even automatically includes the .h/.hpp files.
cppdirtoulangvm
Example
uclang cppdirtoulangvm [Cppdirpath] [UCodeLangBindingPath] [CppVMBindingPath]
Works the same as cpptoulangvm but take input of c++ directory instead of a single file.
Test Command
Example
uclang test <path>
if path not provided it will use the working directory as its input.
Runs all the test in the module.
use ULang;
[Test]
|MyTest[]:
Assert(1 == 1);
The exit code is 0 it did so successfully and all the test pass else its 1.
Update Command
Example
uclang <path>
if path not provided it will use the working directory as its input.
Attempts the update the dependencieses and reverse the changes if the dependency update breaks the module build and the test fail.
this may take a while as it does a binary search to find the newest compatible dependeny without breaking the module for each dependency.
The exit code is 0 it did so successfully or all module are up too date else its 1.
Updatetools Command
Example
uclang updatetools
This command will update uclang and the lsp to the newest version.
exit code is 0 if it worked else 1.
Uninstalltools Command
Example
uclang uninstalltools
This command will update uninstall uclang and the lsp. all downloaded modules may be removed.
exit code is 0 if it worked else 1.
index Command
Example
uclang index <ModulePath>
readds if it doesn't already exist the module to system moduleindex so reference as a module dependency or be used in RunMod.
The exit code is 0 it did so successfully else its 1.
Install Command
Example
uclang Install [WebLink]
downloads a Module from the Web and added it the module system index. if it succeeds you should be able to use [modrun] or use it as a dependency.
The exit code is 0 it did so successfully else its 1.
runmod Command
runs a module on the system. By default uclang will try to call the main funcion.
uclang runmod [module]
This can be overwritten and basic arguments can be passed.
uclang runmod [module] func(4)
The exit code is 0 if compilation succeed or 1 for compilation fail or if it panic or returns an error if the return type is an result type.
after runing the console will look like the following
returned:
void
or
returned:
1
Flag | extra | Description |
---|---|---|
-jit | none | Uses the jit compiler compiler instead of the interpreter. |
-03 | none | Activates all optimization. |
-native | none | Compiles native code before running. |
addmod Command
Example
uclang addmod <WebLink> <module>
if path not provided it will use the working directory as its input.
downloads a Module from the Web and added it the module system index. then adds as a dependency to the module.
The exit code is 0 it did so successfully else its 1.
uninstallmod Command
Example
uclang uninstallmod [modulename]
Uninstall the module and it's unused dependencies.
The exit code is 0 it did so successfully else its 1.
Exit Command
exits ucodelang if opened without command line arguments.
ForImplementers
This section is about for People who are Implementing the UCodeLang in there C++ Projects such as GameEngines or Developer frameworks.
Requirements
- C++17 Compiler.
- Basic knowledge of linking and Include C++ Projects
Download
Simply Git Clone The project or download it inside your external librarys or dependency folder.
git clone https://github.com/LostbBlizzard/UCodeLang.git
Building Project
We will be using premake here but this will work with any build system.
To Build the Project we need to set up the local Project includes Directory.
-
The UCodeLang/UCodeLang is is intentional.It Just how the project is Structured.
-
[YourDependencyFolder] is the Directory you git clone to.
-
[GitDownload] is the Directory git clone produced containing UCodeLang Repository.
includedirs
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/include",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/include",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src",
}
Next we pick what files are part of the Library.
UCodeLang mainly uses .hpp and .cpp but with some exceptions so we also have to include them.
files
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.hpp",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.cpp",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.h",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.c",
}
We will also need to include zydis and zycore because UCodeLang needs them.
files {
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src/**.c",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/src/**.c",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src/**.inc",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/src/**.inc",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/include/**.h",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/include/**.h",
}
Try building this as a Static library. It may take 2-8 minutes to fully build.
90% of the Project is the Compiler.
If your haveing any problems try asking for help on the github discussions tab.
Using it
Now the hard part is over its now time to use this library.
Now in your Main project now add these two include Directorys and make sure you link your static library.
includedirs
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang"
}
If every thing is done correctly. your should be able to use these segment of c++ in your project.
#include <UCodeLang/UCodeLang.hpp>
int main()
{
const char* MyUCode = "|main[] => 1;";
UCodeLang::Compiler myCompiler;
auto comilerRet = myCompiler.CompileText(MyUCode);
if (!comilerRet.IsError())
{
//your ucode was Compiled
UCodeLang::RunTimeLangState State;
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.GetValue().OutPut.value());//initialize RunTimeLib using our Compiled code.
State.AddLib(&Lib);//Add RunTimeLib
State.LinkLibs();//Link libraries
UCodeLang::Interpreter interpreter;
interpreter.Init(&State);
interpreter.Call(StaticVariablesInitializeFunc);//initialize our Static Variables.
interpreter.Call(ThreadVariablesInitializeFunc);//initialize thread local/Interpreter local Variables.
int Value = interpreter.RCall<int>("main");//Call main
std::cout << " Got Value " << Value;
interpreter.Call(ThreadVariablesUnLoadFunc);//Call Thread local Variables destructors.
interpreter.Call(StaticVariablesUnLoadFunc);//Call Static Variables destructors.
}
else
{
//your code failed to compile
}
}
Here the C++ reference use this find out what usefull full classes,funcion and types are in UCodeLang.
Also see the Language Reference if you alread know C++ you can learn the Whole Language in a day.
ForImplementers
This section is about for People who are Implementing the UCodeLang in there C++ Projects such as GameEngines or Developer frameworks.
Requirements
- C++17 Compiler.
- Basic knowledge of linking and Include C++ Projects
Download
Simply Git Clone The project or download it inside your external librarys or dependency folder.
git clone https://github.com/LostbBlizzard/UCodeLang.git
Building Project
We will be using premake here but this will work with any build system.
To Build the Project we need to set up the local Project includes Directory.
-
The UCodeLang/UCodeLang is is intentional.It Just how the project is Structured.
-
[YourDependencyFolder] is the Directory you git clone to.
-
[GitDownload] is the Directory git clone produced containing UCodeLang Repository.
includedirs
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/include",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/include",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src",
}
Next we pick what files are part of the Library.
UCodeLang mainly uses .hpp and .cpp but with some exceptions so we also have to include them.
files
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.hpp",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.cpp",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.h",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang/**.c",
}
We will also need to include zydis and zycore because UCodeLang needs them.
files {
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src/**.c",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/src/**.c",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/src/**.inc",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/src/**.inc",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zydis/include/**.h",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/Dependencies/zycore/include/**.h",
}
Try building this as a Static library. It may take 2-8 minutes to fully build.
90% of the Project is the Compiler.
If your haveing any problems try asking for help on the github discussions tab.
Using it
Now the hard part is over its now time to use this library.
Now in your Main project now add these two include Directorys and make sure you link your static library.
includedirs
{
"[YourDependencyFolder]/[GitDownload]/UCodeLang",
"[YourDependencyFolder]/[GitDownload]/UCodeLang/UCodeLang"
}
If every thing is done correctly. your should be able to use these segment of c++ in your project.
#include <UCodeLang/UCodeLang.hpp>
int main()
{
const char* MyUCode = "|main[] => 1;";
UCodeLang::Compiler myCompiler;
auto comilerRet = myCompiler.CompileText(MyUCode);
if (!comilerRet.IsError())
{
//your ucode was Compiled
UCodeLang::RunTimeLangState State;
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.GetValue().OutPut.value());//initialize RunTimeLib using our Compiled code.
State.AddLib(&Lib);//Add RunTimeLib
State.LinkLibs();//Link libraries
UCodeLang::Interpreter interpreter;
interpreter.Init(&State);
interpreter.Call(StaticVariablesInitializeFunc);//initialize our Static Variables.
interpreter.Call(ThreadVariablesInitializeFunc);//initialize thread local/Interpreter local Variables.
int Value = interpreter.RCall<int>("main");//Call main
std::cout << " Got Value " << Value;
interpreter.Call(ThreadVariablesUnLoadFunc);//Call Thread local Variables destructors.
interpreter.Call(StaticVariablesUnLoadFunc);//Call Static Variables destructors.
}
else
{
//your code failed to compile
}
}
Here the C++ reference use this find out what usefull full classes,funcion and types are in UCodeLang.
Also see the Language Reference if you alread know C++ you can learn the Whole Language in a day.
Calling C++ from UCodeLang
Its Time to Make UCodeLang do something useful. By default UCodeLang has no Input or Output other than doing stuff with memory.
So UCodeLang has no way Opening Files,Networking or most importantly calling your framework.
To Fix this We have CPPCalls and dynamic external funcions.
Lets Say we have a UCodeLang funcion that we want to make Print a Number to the Console.
|PrintNumberConsole[int number] -> void;
First we will need to tell the UCodeLang compiler that the funcion will have its implementation be added at runtime by using the dynamic and extern Keywords.
extern dynamic |PrintNumberConsole[int number] -> void;
Next In our C++ file. Lets make a funcion that does that.
void UAPI_PrintNumberConsole(int num)
{
std::cout << std::tostring(num) << std::endl;
}
Then lets add that funcion to the RunTimeLib using Add_CPPCall.
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.OutPut);//initialize RunTimeLib useing our Compiled code.
//Adding Our PrintNumberConsole Funcion.
lib.Add_CPPCall("PrintNumberConsole", []( UCodeLang::InterpreterCPPinterface& Input)
{
int Par0 = Input.GetParameter<int>();
UAPI_PrintNumberConsole(Par0);
Input.Set_Return();
},UAPI_PrintNumberConsole);
Lets me explains whats going in Add_CPPCall.
First give the funcion the a name "PrintNumberConsole".
Next we make a lambda(funcion without a name) that allow us to talk to the Interpreter that called this funcion. then we ask for for our first function of parameter of type int.
Then we call UAPI_PrintNumberConsole with our parameter.
Then we ask the Interpreter to set Set_Return to nothing.
Lastly we pass a funcion pointer of UAPI_PrintNumberConsole.So the JitInterpreter and the NativeInterpreter will be to call the funcion.
now all you have to do is to call PrintNumberConsole in your UCodeLang Source Code.
extern dynamic |PrintNumberConsole[int number] -> void;
const char* MyUCode = "|main[] => PrintNumberConsole(10 + 5);";
When you call main you should should see that 15 was printed to the console.
but this would be tedious to do for every funcion and it doesn't account for.
- Funcion overloading.
- Namespaces.
- Structs.
- Enums.
- Constructors,Destructor copy Constructors.
- Changeing APIs
- Type marshaling
- Just having Hundreds of funcions to expose.
It Would be a architectural and dependency nightmare.
If only theres a way to generate these bindings and types using our c++ source code and all we have to do just mark the funcions and types we would like expose.
We could call it cpptoulangvm.
Automatic Binding Generation
To Solve this problem uclang or the UCodeLang command line tool is able to generate these bindings.
First step is geting the uclang command line tool. Theres two ways of geting by installing it or building from source.
For this example we will just steal it from the github releases and put it in our project root directory.
after that lets mark our c++ files with the funcions and types to export.
Heres our types and funcions we will like to export in our c++ file.
enum class Colors
{
Red,
Green,
Blue,
}
void SomeFuncionthatTakeinColor(Colors a)
{
//
}
Next add these c++ macros .The argument for the macros is the namespace inside of UCodeLang file.
namespace OurAPI
{
UCodeLangExportSymbol("YourFrameWorkNameSpace") enum class Colors
{
Red,
Green,
Blue,
}
UCodeLangExportSymbol("YourFrameWorkNameSpace") void SomeFuncionthatTakeinColor(Colors a)
{
//
}
}
These will tell uclang command line tool to generate bindings for these funcions and types.
next we need to add 'UCodeLangAutoLink' macros. when we add our Add_CPPCall.
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.OutPut);//initialize RunTimeLib useing our Compiled code.
//Adding Our PrintNumberConsole Funcion.
lib.Add_CPPCall("PrintNumberConsole", []( UCodeLang::InterpreterCPPinterface& Input)
{
int Par0 = Input.GetParameter<int>();
UAPI_PrintNumberConsole(Par0);
Input.Set_Return();
},UAPI_PrintNumberConsole);
//Our UCodeLangAutoLink
UCodeLangAutoLink(Lib, OurAPI);
now lets run our UCodeLang UCodeLang command line tool.
Open your command line in your ProjectRoot.
ProjectRoot >
then run uclang (or uclang.exe if your on windows) and type cpptoulangvm
- Then with for c++ file path
- then output ucodelang file(.uc) path
- then c++ output were 'UCodeLangAutoLink' macros is found
ProjectRoot > ./uclang cpptoulangvm [CppPath] [UCodeLangOut] [CppVMLinkPath]
now the UCodeLangOut will have all funcion and type boilerplate and CppVMLinkPath will have all the Add_CPPCall funcions.
and if you have your API in multiple C++ files you can use cppdirtoulangvm to search inside directories.it even automatically includes the .h/.hpp files.
ProjectRoot > ./uclang cppdirtoulangvm [CppDir] [UCodeLangOut] [CppVMLinkPath]
The Next Part is about using Module System to Add the Standad Library and other Modules(like your framwork API) and also allowing for intellisense for your code editor.
System IO
After Automatic Binding Generation the last thing we need to is to add the Standard Library and allowing Input And Output.
Let's take the easier one out of the way.
Allowing Input And Output.
Because CPPCalls and dynamic external funcions is the only for UCodeLang to talk to c++ and by extension the outside world.
Three Classes are made to add all of CPPCalls for you so you can get to work on makeing your framework.
Adds CppCalls for direct access to the file system,network and other IO.
Adds CppCalls for simulateing access in memory to the file system,network and other IO allowing the developer selectively allow access to these systems.
like pretending all files don't exist and except for selected few and those are read-only.
- UtilityLink
Adds CppCalls for everything else that doesn't fit in IO mostly relating to the CPU and Memory.
- Math
- SIMD
- Atomic
those classes can be used like so
UCodeLang::RunTimeLib Lib;
Lib.Init(comilerRet.OutPut);//initialize RunTimeLib useing our Compiled code.
//Link UtilityLinks
UtilityLink::Link(Lib);
SandBoxedIOLink::Link(Lib);
//IOLink::Link(Lib);
//You can only pick SandBoxedIOLink or IOLink because thay add the same funcions
Standard Library and Modules
To add the StandardLibrary we need to use the Module System.
First we need to change how we compile our UCodeLang Code to use the ModuleFile class.
The ModuleFile class allows us add dependencies to our UCodeLang code.
TODO
Now you know the basics to get started makeing your framework.
Use the API Reference to see what other useful funcions and classes are in UCodeLang.
Hot Reloading and Inspecting State
TODO
MultThreading
This part is not done because i have not finalized the MultThreading yet.
Debug Support
API Reference
The API Reference is spit into Three parts and Compiler and RunTime.
Every thing in UCodeLang in UCodeLang NameSpace
namespace UC = UCodeLang;
Compilation
Types related to compiling and its Output.
Name | Type | Description |
---|---|---|
Compiler | Class | The UCodeLang Compiler. |
ModuleFile | Class | The UCodeLang Compiler Module System. |
UClib | Class | The UCodeLang Compiler Output. |
UCodeBackEnd | Class | The BackEnd for the UCodeInterpreter. |
C11BackEnd | Class | The BackEnd to output C Code. |
WasmBackEnd | Class | The BackEnd targeting Wasm. |
RunTime
Types related to The UCodeVM/RunTime.
Name | Type | Description |
---|---|---|
RunTimeLib | Class | The BackEnd to output C Code. |
UCodeRunTime | Class | The Core UCodeLang Runtime. |
AnyInterpreter | Class | A wapper over Interpreter,JitInterpreter and NativeInterpreter. |
Interpreter | Class | The Default Interpreter. |
JitInterpreter | Class | The Jit Interpreter. |
NativeInterpreter | Class | Runs Precompiled Native Code. |
IOLink | Class | Adds CppCalls for direct access to the file system,network and other IO. |
SandBoxedIOLink | Class | Adds CppCalls for SandBoxed access to the file system,network and other IO. |
UtilityLink | Class | Adds CppCalls for everything else that doesn't fit in IO. |
Analysis
Types related to The Analyzing UCodeLang ,UCodeLang Output or its Runtime.
Name | Type | Description |
---|---|---|
ReflectionVector | Class | Lets you use UCodeLang Vectors in a Easy Way. |
ReflectionString | Class | Lets you use UCodeLang Strings in a Easy Way. |
Core
Basic types that UCodeLang Uses stop isn't part of C++17 standard Library.
Name | Type | Description |
---|---|---|
Result | Generic class | A type holding a returned value or an error code. |
NeverNullPtr | Generic class | A pointer that should never be null. |
NullablePtr | Generic class | A pointer that could be null. |
Variant | Generic class | A wapper over std::variant give it more functions. |
Span | Generic class | A contiguous sequence of objects |
C API
UCodeLang Has a C API for using UCodeLang in Programming Languages other than C++.
Notes
Many more classes and funcions can be found in UCodeLang but may change may change on a whim its recommended not to used those them if its not documented here.
C API
The C API is used to allow UCodeLang to be used in other programing language.
Definition
HeaderFile: UCodeLang/UCodeLangCAPI.h
Name | Type | Description |
---|
API Reference
The API Reference is spit into Three parts and Compiler and RunTime.
Every thing in UCodeLang in UCodeLang NameSpace
namespace UC = UCodeLang;
Compilation
Types related to compiling and its Output.
Name | Type | Description |
---|---|---|
Compiler | Class | The UCodeLang Compiler. |
ModuleFile | Class | The UCodeLang Compiler Module System. |
UClib | Class | The UCodeLang Compiler Output. |
UCodeBackEnd | Class | The BackEnd for the UCodeInterpreter. |
C11BackEnd | Class | The BackEnd to output C Code. |
WasmBackEnd | Class | The BackEnd targeting Wasm. |
RunTime
Types related to The UCodeVM/RunTime.
Name | Type | Description |
---|---|---|
RunTimeLib | Class | The BackEnd to output C Code. |
UCodeRunTime | Class | The Core UCodeLang Runtime. |
AnyInterpreter | Class | A wapper over Interpreter,JitInterpreter and NativeInterpreter. |
Interpreter | Class | The Default Interpreter. |
JitInterpreter | Class | The Jit Interpreter. |
NativeInterpreter | Class | Runs Precompiled Native Code. |
IOLink | Class | Adds CppCalls for direct access to the file system,network and other IO. |
SandBoxedIOLink | Class | Adds CppCalls for SandBoxed access to the file system,network and other IO. |
UtilityLink | Class | Adds CppCalls for everything else that doesn't fit in IO. |
Analysis
Types related to The Analyzing UCodeLang ,UCodeLang Output or its Runtime.
Name | Type | Description |
---|---|---|
ReflectionVector | Class | Lets you use UCodeLang Vectors in a Easy Way. |
ReflectionString | Class | Lets you use UCodeLang Strings in a Easy Way. |
Core
Basic types that UCodeLang Uses stop isn't part of C++17 standard Library.
Name | Type | Description |
---|---|---|
Result | Generic class | A type holding a returned value or an error code. |
NeverNullPtr | Generic class | A pointer that should never be null. |
NullablePtr | Generic class | A pointer that could be null. |
Variant | Generic class | A wapper over std::variant give it more functions. |
Span | Generic class | A contiguous sequence of objects |
C API
UCodeLang Has a C API for using UCodeLang in Programming Languages other than C++.
Notes
Many more classes and funcions can be found in UCodeLang but may change may change on a whim its recommended not to used those them if its not documented here.
Reference/Compiler
Definition
HeaderFile: UCodeLang/Compliation/Compiler.hpp
Is Included In UCodeLang.hpp: Yes
The UCodeLang Compiler.
class Compiler;
Example
#include <UCodeLang/UCodeLang.hpp>
void main()
{
const char* MyUCode = "|main[] => 1;";
UCodeLang::Compiler myCompiler;
auto comilerRet = myCompiler.CompileText(MyUCode);
if (!comilerRet.IsError())
{
//your ucode was Compiled
}
else
{
//your ucode fail to compile
}
}
Methods
Funcion | Parameters | Return | Description |
---|---|---|---|
CompileText | (const String_view& Text, const ExternalFiles& ExternalFiles = {}) | CompilerRet | Compiles UCodeLang Text and returns the Result. |
CompileFileToLib | (const Path& path, const ExternalFiles& ExternalFiles = {}) | CompilerRet | Compiles UCodeLang Text and returns the Result. |
CompilePathToObj | (const Path& path, const Path& OutLib, const ExternalFiles& ExternalFiles = {}) | CompilerRet | Compiles UCodeLang File at the Path and returns the Result and Outputs at the OutLib. |
CompileFiles | (const CompilerPathData& Data, const ExternalFiles& ExternalFiles = {}) | CompilerRet | Compiles UCodeLang using CompilerPathData and returns the Result. |
CompileFiles_UseIntDir | (const CompilerPathData& Data, const ExternalFiles& ExternalFiles = {}) | CompilerRet | Compiles UCodeLang using CompilerPathData and returns the Result and Outputs intermediates file. |
Set_FrontEnd | (FrontEndObject_Ptr Value) | void | Sets The FrontEnd. |
Set_BackEnd | (BackEndObject_Ptr Value) | void | Sets The BackEnd. |
GetBackEndName | None | String | Gets The BackEnd BackEnd Name. |
GetOutputExtWithDot | None | String | Gets The Output file extension. |
GetOutputBackEndInfo | None | CompliationBackEndInfo | Gets The Metadata about the BackEnd |
Types
CompilerPathData
struct CompilerPathData
{
Path FileDir;
Path IntDir;
Path OutFile;
}
ExternalFiles
struct ExternalFiles
{
Vector<Path> Files;
};
CompliationSuccess
struct CompliationSuccess
{
NeverNullPtr<UClib> OutPut;
Optional<BytesPtr> OutFile;
}
CompilerRet
using CompilerRet = Result<CompliationSuccess,NeverNullPtr<CompliationErrors>>;
Notes
Reference/ModuleFile
Definition
HeaderFile: UCodeLang/Compliation/ModuleFile.hpp
Is Included In UCodeLang.hpp: No
The UCodeLang Compiler Module System.
class ModuleFile;
Example
[!IMPORTANT] This Is section Is incomplete
Methods
Funcion | Parameters | Return | Description |
---|---|---|---|
BuildModule | (Compiler& Compiler,const ModuleIndex& Modules,bool IsSubModule = false, OptionalRef | ModuleRet | Builds The Module Project. |
BuildFile | (const String& filestring, Compiler& Compiler, const ModuleIndex& Modules) | ModuleRet | Builds The Module file using the filestring as a Build Script. |
DownloadModules | (const ModuleIndex& Modules,OptionalRef | bool | Downloads The Modules Dependencies. |
Static Funcions
Funcion | Parameters | Return | Description |
---|---|---|---|
ToFile | (const ModuleFile* Lib, const Path& path) | bool | Write the Module File to the path and returns true if it succeeded. |
FromFile | (ModuleFile* Lib, const Path& path) | bool | Get the Module File from the path and returns true if it succeeded |
Fields
Type | Name | Description |
---|---|---|
ModuleIdentifier | ModuleName | The Module identification. |
Path | ThisModuleDir | The working directory of this Module.Is set fom FromFile. |
bool | ForceImport | if true the Compiler will Force the Import System to be used |
bool | RemoveUnSafe | if true the Compiler will ban the use of unsafe in the Module. |
Vector<ModuleDependencie> | ModuleDependencies | Modules this Module needs to Compile. |
Static Members
Types
Notes
Reference/UClib
Definition
HeaderFile: UCodeLang/LangCore/UClib.hpp
Is Included In UCodeLang.hpp: Yes
The UCodeLang Compiler Output.
class UClib;
Example
[!IMPORTANT] This Is section Is incomplete
Methods
Funcion | Parameters | Return | Description |
---|---|---|---|
Get_Assembly | None | ClassAssembly& | Gets the ClassAssembly. |
WriteToFile | (const Path& path) | bool | Write the UClib File to the path and returns true if it succeeded. |
Static Funcions
Funcion | Parameters | Return | Description |
---|---|---|---|
ToFile | (const UClib* Lib, const Path& path) | bool | Write the UClib File to the path and returns true if it succeeded. |
FromFile | (UClib* Lib, const Path& path) | bool | Get the UClib File from the path and returns true if it succeeded |
OpenFile | (const Path& path) | Optional<UClib> | Get the UClib File from the path and returns Nothing if it failed |
Reference/UCodeBackEnd
Definition
HeaderFile: UCodeLang/Compliation/Back/UCodeBackEnd/UCodeBackEnd.hpp
Is Included In UCodeLang.hpp: No
The BackEnd for the Interpreter or Jit Interpreter.
class UCodeBackEnd;
Example
#include "UCodeLang.hpp"
#include "UCodeLang/Compliation/Back/UCodeBackEnd/UCodeBackEnd.hpp"
void main()
{
UCodeLang::Compiler _Compiler;
_Compiler.Set_BackEnd(UCodeLang::UCodeBackEnd::MakeObject);
//You set the backend to target the Interpreter or jit-Interpreter
}
MemberFuncions
Funcion | Parameters | Return | Description |
---|---|---|---|
Reset | None | void | Resets The BackEnd to be used again. |
Build | (const IRBuilder* Input) | void | Generates a UClib from Input. |
Static Members
Funcion | Parameters | Return | Description |
---|---|---|---|
MakeObject | None | BackEndObject* | Returns a pointer heap allocated to a BackEndObject.Must be freed. |
Notes
Like All BackEnds UCodeBackEnd is not meant to be directly but instead used from the Compiler.
Reference/C11Backend
Definition
HeaderFile: UCodeLang/Compliation/Back/C11/C89Backend.hpp
Is Included In UCodeLang.hpp: No
The BackEnd to output C11 Code.
class C11Backend;
Example
#include "UCodeLang.hpp"
#include "UCodeLang/Compliation/Back/C11/C11Backend.hpp"
void main()
{
UCodeLang::Compiler _Compiler;
_Compiler.Set_BackEnd(UCodeLang::C11Backend::MakeObject);
//You set the backend to output C11 Code.
}
MemberFuncions
Funcion | Parameters | Return | Description |
---|---|---|---|
Reset | None | void | Resets The BackEnd to be used again. |
Build | (const IRBuilder* Input) | void | Generates C89 Code from Input. |
Static Members
Funcion | Parameters | Return | Description |
---|---|---|---|
MakeObject | None | BackEndObject* | Returns a pointer heap allocated to a BackEndObject.Must be freed. |
UpdateToCindentifier | const String& Value | void | Converts a identifier to a valid C89 indentifier.can be used to find a funcion from the UClib ClassMethod using the DecorationName Field. |
Notes
Like All BackEnds UCodeBackEnd is not meant to be directly but instead used from the Compiler.
Reference/C11Backend
Definition
HeaderFile: UCodeLang/Compliation/Back/WebAssembly/WasmBackEnd.hpp
Is Included In UCodeLang.hpp: No
The BackEnd to output a WebAssembly Module.
class WasmBackEnd;
Example
#include "UCodeLang.hpp"
#include "UCodeLang/Compliation/Back/WebAssembly/WasmBackEnd.hpp"
void main()
{
UCodeLang::Compiler _Compiler;
_Compiler.Set_BackEnd(UCodeLang::WasmBackEnd::MakeObject);
//You set the backend to output a Wasm.
}
MemberFuncions
Funcion | Parameters | Return | Description |
---|---|---|---|
Reset | None | void | Resets The BackEnd to be used again. |
Build | (const IRBuilder* Input) | void | Generates a WebAssembly Module from Input. |
Static Members
Funcion | Parameters | Return | Description |
---|---|---|---|
MakeObject | None | BackEndObject* | Returns a pointer heap allocated to a BackEndObject.Must be freed. |
ToWebName | const String& Value | void | Converts a identifier to a valid Wasm indentifier.can be used to find a funcion from the UClib ClassMethod using the DecorationName Field. |
Notes
Like All BackEnds UCodeBackEnd is not meant to be directly but instead used from the Compiler.
API Reference
The API Reference is spit into Three parts and Compiler and RunTime.
Every thing in UCodeLang in UCodeLang NameSpace
namespace UC = UCodeLang;
Compilation
Types related to compiling and its Output.
Name | Type | Description |
---|---|---|
Compiler | Class | The UCodeLang Compiler. |
ModuleFile | Class | The UCodeLang Compiler Module System. |
UClib | Class | The UCodeLang Compiler Output. |
UCodeBackEnd | Class | The BackEnd for the UCodeInterpreter. |
C11BackEnd | Class | The BackEnd to output C Code. |
WasmBackEnd | Class | The BackEnd targeting Wasm. |
RunTime
Types related to The UCodeVM/RunTime.
Name | Type | Description |
---|---|---|
RunTimeLib | Class | The BackEnd to output C Code. |
UCodeRunTime | Class | The Core UCodeLang Runtime. |
AnyInterpreter | Class | A wapper over Interpreter,JitInterpreter and NativeInterpreter. |
Interpreter | Class | The Default Interpreter. |
JitInterpreter | Class | The Jit Interpreter. |
NativeInterpreter | Class | Runs Precompiled Native Code. |
IOLink | Class | Adds CppCalls for direct access to the file system,network and other IO. |
SandBoxedIOLink | Class | Adds CppCalls for SandBoxed access to the file system,network and other IO. |
UtilityLink | Class | Adds CppCalls for everything else that doesn't fit in IO. |
Analysis
Types related to The Analyzing UCodeLang ,UCodeLang Output or its Runtime.
Name | Type | Description |
---|---|---|
ReflectionVector | Class | Lets you use UCodeLang Vectors in a Easy Way. |
ReflectionString | Class | Lets you use UCodeLang Strings in a Easy Way. |
Core
Basic types that UCodeLang Uses stop isn't part of C++17 standard Library.
Name | Type | Description |
---|---|---|
Result | Generic class | A type holding a returned value or an error code. |
NeverNullPtr | Generic class | A pointer that should never be null. |
NullablePtr | Generic class | A pointer that could be null. |
Variant | Generic class | A wapper over std::variant give it more functions. |
Span | Generic class | A contiguous sequence of objects |
C API
UCodeLang Has a C API for using UCodeLang in Programming Languages other than C++.
Notes
Many more classes and funcions can be found in UCodeLang but may change may change on a whim its recommended not to used those them if its not documented here.
Reference/AnyInterpreter
Definition
HeaderFile: UCodeLang/Compliation/ModuleFile.hpp
Is Included In UCodeLang.hpp: No
The UCodeLang Compiler Module System.
class AnyInterpreter;
Example
Methods
Funcion | Parameters | Return | Description |
---|---|---|---|
BuildModule | (Compiler& Compiler,const ModuleIndex& Modules,bool IsSubModule = false, OptionalRef | ModuleRet | Builds The Module Project. |
BuildFile | (const String& filestring, Compiler& Compiler, const ModuleIndex& Modules) | ModuleRet | Builds The Module file using the filestring as a Build Script. |
DownloadModules | (const ModuleIndex& Modules,OptionalRef | bool | Downloads The Modules Dependencies. |
Static Funcions
Funcion | Parameters | Return | Description |
---|---|---|---|
ToFile | (const ModuleFile* Lib, const Path& path) | bool | Write the Module File to the path and returns true if it succeeded. |
FromFile | (ModuleFile* Lib, const Path& path) | bool | Get the Module File from the path and returns true if it succeeded |
Fields
Type | Name | Description |
---|---|---|
ModuleIdentifier | ModuleName | The Module identification. |
Path | ThisModuleDir | The working directory of this Module.Is set fom FromFile. |
bool | ForceImport | if true the Compiler will Force the Import System to be used |
bool | RemoveUnSafe | if true the Compiler will ban the use of unsafe in the Module. |
Vector<ModuleDependencie> | ModuleDependencies | Modules this Module needs to Compile. |
Static Members
Types
Notes
API Reference
The API Reference is spit into Three parts and Compiler and RunTime.
Every thing in UCodeLang in UCodeLang NameSpace
namespace UC = UCodeLang;
Compilation
Types related to compiling and its Output.
Name | Type | Description |
---|---|---|
Compiler | Class | The UCodeLang Compiler. |
ModuleFile | Class | The UCodeLang Compiler Module System. |
UClib | Class | The UCodeLang Compiler Output. |
UCodeBackEnd | Class | The BackEnd for the UCodeInterpreter. |
C11BackEnd | Class | The BackEnd to output C Code. |
WasmBackEnd | Class | The BackEnd targeting Wasm. |
RunTime
Types related to The UCodeVM/RunTime.
Name | Type | Description |
---|---|---|
RunTimeLib | Class | The BackEnd to output C Code. |
UCodeRunTime | Class | The Core UCodeLang Runtime. |
AnyInterpreter | Class | A wapper over Interpreter,JitInterpreter and NativeInterpreter. |
Interpreter | Class | The Default Interpreter. |
JitInterpreter | Class | The Jit Interpreter. |
NativeInterpreter | Class | Runs Precompiled Native Code. |
IOLink | Class | Adds CppCalls for direct access to the file system,network and other IO. |
SandBoxedIOLink | Class | Adds CppCalls for SandBoxed access to the file system,network and other IO. |
UtilityLink | Class | Adds CppCalls for everything else that doesn't fit in IO. |
Analysis
Types related to The Analyzing UCodeLang ,UCodeLang Output or its Runtime.
Name | Type | Description |
---|---|---|
ReflectionVector | Class | Lets you use UCodeLang Vectors in a Easy Way. |
ReflectionString | Class | Lets you use UCodeLang Strings in a Easy Way. |
Core
Basic types that UCodeLang Uses stop isn't part of C++17 standard Library.
Name | Type | Description |
---|---|---|
Result | Generic class | A type holding a returned value or an error code. |
NeverNullPtr | Generic class | A pointer that should never be null. |
NullablePtr | Generic class | A pointer that could be null. |
Variant | Generic class | A wapper over std::variant give it more functions. |
Span | Generic class | A contiguous sequence of objects |
C API
UCodeLang Has a C API for using UCodeLang in Programming Languages other than C++.
Notes
Many more classes and funcions can be found in UCodeLang but may change may change on a whim its recommended not to used those them if its not documented here.
API Reference
The API Reference is spit into Three parts and Compiler and RunTime.
Every thing in UCodeLang in UCodeLang NameSpace
namespace UC = UCodeLang;
Compilation
Types related to compiling and its Output.
Name | Type | Description |
---|---|---|
Compiler | Class | The UCodeLang Compiler. |
ModuleFile | Class | The UCodeLang Compiler Module System. |
UClib | Class | The UCodeLang Compiler Output. |
UCodeBackEnd | Class | The BackEnd for the UCodeInterpreter. |
C11BackEnd | Class | The BackEnd to output C Code. |
WasmBackEnd | Class | The BackEnd targeting Wasm. |
RunTime
Types related to The UCodeVM/RunTime.
Name | Type | Description |
---|---|---|
RunTimeLib | Class | The BackEnd to output C Code. |
UCodeRunTime | Class | The Core UCodeLang Runtime. |
AnyInterpreter | Class | A wapper over Interpreter,JitInterpreter and NativeInterpreter. |
Interpreter | Class | The Default Interpreter. |
JitInterpreter | Class | The Jit Interpreter. |
NativeInterpreter | Class | Runs Precompiled Native Code. |
IOLink | Class | Adds CppCalls for direct access to the file system,network and other IO. |
SandBoxedIOLink | Class | Adds CppCalls for SandBoxed access to the file system,network and other IO. |
UtilityLink | Class | Adds CppCalls for everything else that doesn't fit in IO. |
Analysis
Types related to The Analyzing UCodeLang ,UCodeLang Output or its Runtime.
Name | Type | Description |
---|---|---|
ReflectionVector | Class | Lets you use UCodeLang Vectors in a Easy Way. |
ReflectionString | Class | Lets you use UCodeLang Strings in a Easy Way. |
Core
Basic types that UCodeLang Uses stop isn't part of C++17 standard Library.
Name | Type | Description |
---|---|---|
Result | Generic class | A type holding a returned value or an error code. |
NeverNullPtr | Generic class | A pointer that should never be null. |
NullablePtr | Generic class | A pointer that could be null. |
Variant | Generic class | A wapper over std::variant give it more functions. |
Span | Generic class | A contiguous sequence of objects |
C API
UCodeLang Has a C API for using UCodeLang in Programming Languages other than C++.
Notes
Many more classes and funcions can be found in UCodeLang but may change may change on a whim its recommended not to used those them if its not documented here.
Syntax And Semantics
Syntax
Here a basic run down of UCodeLang Syntax for People who already know how a programming language.
UCode uses Sugnificant Whitespace like python.
The syntax for declaring a function in UCode is as follows:
|function_name[parameter_list];//not being explicit with the return
|function_name[parameter_list] -> void;
For example, the following code declares a function named add that takes two integer parameters and returns an integer:
|add[int x, int y] -> int;
Variables are declared with a type and a name. For example, the following code declares an integer variable named x:
int x;
Member functions are just functions with a this parameter
use ULang;
$MyClass:
|SayHello[this&]:
Fmt::Print("Hello, World!");
|main[]:
var object = MyClass();
object.SayHello();
To access a static variable or function in UCode, you can use the class name and the scope resolution operator (::).
//no use of the ULang namespace;
|main[]:
ULang::Fmt::Print("Hello");
functions can be expressed in different ways.
|add[int x, int y] => x + y;
|add2[int x, int y] -> int:
ret x + y;
|add3[int x, int y]:
ret x + y;
enums are is as follows:
$Color enum:
Red,
Green,
Blue,
namespaces are is as follows:
MyNamespaces:
static int MyStaticValue = 10;
thread int MythreadLocalValue =10;
int Value = 10;//also my threadLocalValue
using namespaces is as follows:
use MyNamespaces;
alias is as follows:
$i64 = int64;
$u32 = uint32;
inheritance look like this
$Worker trait;//no members
$FasterWorker[Worker];//no members
Object protections look like this
$Worker;
$FasterWorker[Worker]:
public:
int Hp = 10;
private:
int Money = 10;
int Happiness = 10;
Standard Library Compiler alias
int? MaybeAnInt;//an optional int
int[] Ints;//an Vector<int>
int[5] MoreInts;//an Array<int,5> //an Array<int,(somevarable)>
int[(somevarable)] MoreInts; //an Array<int,(somevarable)> Map short hand takes precedent over array in this case so you need parentheses.
int[String] StringToIntMap;//an Map<String,int>
int[sometype] SomeTypeToIntMap;//an Map<sometype,int>
int[:] SpanOfInts;//an Span<int>
int^ UniqueInt;//an Unique_ptr<int>
int$ SharedInt;//an Shared_ptr<int>
int[^] UniqueIntsArray;//an Unique_Array<int>
int[$] SharedIntsArray;//an Shared_Array<int>
imut int ConstInt = 5;
imut ConstInt2 = 4;// or like this.
$MyClass:
|SayHello[umut this&]:
Fmt::Print("Hello, World!");
|main[]:
int x = 10;
int& r = x;
|Update_NumToChange[int& V]:
V = 10;
Thats the basics heres. Some links Explore More:
MemoryManagement
[!IMPORTANT] This Is section Is incomplete.
UCode like C++ requires the programmer to manually allocate and deallocate memory useing the new and drop keywords.
like so:
int& MyMemory = unsafe new int();// allocate 4 bytes
unsafe drop(MyMemory);// deallocate 4 bytes
you can also allocate an array.
int[&] MyMemory = unsafe new int[5];// allocate 20 bytes
unsafe drop(MyMemory);// deallocate 20 bytes
because not deallocate memory can cause your Progarm to run out memory. You can use Smart Pointers in the Standardlibrary.Unique_ptr and Shared_ptr are both Smart Pointers and can deallocate memory when its not used.
Class(concept)
Classes are a data type that defines a custom structure with fields and methods. Classes work similarly to structs in C, but with some differences. For example:
Classes can inherit from other classes using the ‘[Type]’ operator. Classes can have constructors and destructors using the new and drop keywords.
$Person;//a class with no members.
$Worker[Person]://inherit from person
String name;
int age;
//constructors
|new[this&,string name,int age]:
this.name = name;
this.age = age;
//destructors
|drop[this&]:
Console::Log("Done Working for the Day.");
Classes can have access modifiers for their fields and methods using the public, private.
$Worker[Person]:
private:
String name;
public:
int age;
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
Address/pointers
[!IMPORTANT] This Is section Is wrong and out of date.
The syntax for addressing is &Value, where Value is the expression that needs to be pointed to. For example:
-&x obtains a pointer to the variable x
-&a[i] obtains a pointer to the i-th element of the array a
-&f() obtains a pointer to the return value of the function f
References can be used like normal variables, except they cannot be nullified.
The syntax for creating references is Type& Name = Value, where Type is the type of the value, Name is the name of the reference, and Value is the expression that needs to be referred to. For example:
int& r = x creates an int reference named r that refers to x.
char& c = s[0] creates a char reference named c that refers to the first character of the string.
float& f = g() creates a float reference named f that refers to the return value of the function.
Here is an example of how addressing and references are used in UCode:
int x = 10;
int& r = x; //Creates an int reference named r that refers to x
Console::Log(r); //Prints 10
r = 30; //Modifies the value at r
Console::Log(r); //Prints 30
Reassigning references
References can be reassigned by using an Address assignment statement. This changes what value the reference points to. For example:
int v = 10; //Assigns 10 to v
int& r = v; //Creates an int reference named r that refers to v
Console::Log(r); //Prints 10
int w = 5; //Assigns 5 to w
r &= w; //Reassigns r to refer to w
Console::Log(r); //Prints 5
Reassigning references should be done with caution, as it may cause unexpected behavior or errors if done incorrectly. For example:
r &= bitcast<int&>(0); //Reassigns r to refer to a null pointer.
Console::Log(r); //Prints garbage or causes an error
Reassigning references to nullptr or invalid memory addresses is not intended by UCode’s standard, as references are always assumed to be pointing to something valid.
If you need a nullable reference type, you can use Type? instead of Type&. Type? maps to optional
int? n = []; //Creates an optional int named n
Console::Log(n); //Prints nothing if null.
n = 10; //Assigns 10 to n
Console::Log(n); //Prints 10
n = []; //Assigns null (nothing) back again
Console::Log(n); //Prints nothing
Casting
Casting is a way of converting a value from one type to another. Casting can be used to change the representation or interpretation of a value, such as converting a float to an int or an int to a pointer. Casting can also be used to perform explicit conversions that are not allowed implicitly, such as converting an int64 to an int8 or an uint16 to an int16.
The syntax for casting is Value -> Type, where Value is the expression that needs to be converted and Type is the desired type. For example:
3.14 -> int converts the float 3.14 to the int 3 65 -> char converts the int 65 to the char ‘A’ x -> uint8 converts the variable x to an uint8 Casting can have different effects depending on the types involved. For example:
Casting between numeric types can cause truncation, rounding, or overflow if the value does not fit in the target type. Casting between pointer types can change the address or size of the pointed object. Casting between signed and unsigned types can change the sign bit or the value range of the integer. Here is an example of how casting is used in UCode:
float x = 1.23; //Assigns 1.23 to x
int y = x -> int; //Casts x to int and assigns it to y
Fmt::Print(y); //Prints 1
char c = 'a'; //Assigns 'a' to c
int z = c -> int; //Casts c to int and assigns it to z
Fmt::Print(z); //Prints 97
uintptr u = (uintptr) (x -> int&) -> uintptr; //Casts the address of x to uintptr and assigns it to u
Fmt::Print(u);
Lambda
a lambda expression is an anonymous function that can contain either an expression or a sequence of statements.
a lambda looks like this
|[x,y,z] => [expression]
or like this
|[x,y,z] : [statement/statements]
an example of shown below
var MyLambdaObject = |[x,y] => x * y;//expression
var MyLambdaObject2 = |[x,y]:
var Tep = x * y;
ret Tep;
;//Starements
lambdas also have a short-form syntax. shown below
var MyLambdaObject = [x,y] => x * y;//expression
Lambda Capturing
Lambda will automatically Capture varables by value from the outer scope.
int a = 10;
int b = 10;
var LambdaObject = |[] => a * b;
//both a and b are captured by value.
a = 0;
var Value = LambdaObject();
//the Value will be 100 and not 0 because its captured by value on were it was declared.
Sometimes it is needed to capture by reference to do this you can explicitly say it captured by reference.
int a = 10;
int b = 10;
//b is captured by value
//a is captured reference.
var LambdaObject = |[][&a] => a * b;
a = 0;
var Value = LambdaObject();
//the Value will be 0 because its captured by reference.
also note you can put expressions in the capture list.
int a = 10;
int b = 10;
var LambdaObject = |[][&a] => a * b;
var LambdaObject2 = |[][int& a = a] => a * b;
//both mean the same thing.
int a = 10;//outer scope 'a'
int b = 10;
var LambdaObject2 = |[][int& a = a] => a * b;
^ this 'a' is for capture
var LambdaObject2 = |[][int& a = a] => a * b;
^ is referring to the outer scope.
Note it is not possible to explicitly assigned the captures varable in the short-form syntax.
[!IMPORTANT]
Explicitly assigned Lambda Capturing has no implementation on the compiler yet.
Lambda inside Lambdas is not tested yet.
Funcion Pointer
TODO
Constructors And Destructors
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
Traits
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
Parameter Packs
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
Conditional compilation
conditional compilation In UCode is allows a way of including or omitting selected lines of source code depending on constant expressions.
unlike languages like C UCode uses constant expressions to determine what to include and what to remove useing special keywords.
the special keywords are:
- $if
- $else
- $for
- Obj.$Varable/Obj.$Func()
The eval keyword is used to make constant expressions.
$if and $else
the special variant of the if keyword allows forces the check comparison do be an constant expression and does not generate symbols in the if block until evaluated.also the newly added symbols are in the same scope as the if.
for example:
eval bool Mode = true; //constant expression varable
|Main[]:
$if Mode:
int A = 1;
$else if true://constant else if
int A = 2;
$else:
int A = 3;
Console::Log(A);
after evaluating the code gets simplified into.
|Main[]:
int A = 1;
Console::Log(A);
also works in file scope and namespace scope.
eval bool Mode = true; //constant expression varable
$if Mode:
$CoolInt = uint32;
$else
$CoolInt = uint64;
after evaluating the code gets simplified into.
$CoolInt = uint64;
$for
the special variant of the for keyword will unwap the list to their own scopes and is mostly used with parameter packs but can work with any object with constant expression for loop overload implementation.
note the list must also be a constant expression.
|Func<X:...>[ParameterPack X]:
$for [Item : X]:
var ItemT = typeof(Item);
bind(ItemT) Buffer = Item;
|main[]:
Func<int,uint32,uint64>(0,1,2);
after evaluating the code gets simplified into.
|Func<int,uint32,int64>[int X1,uint32 X2,int64 X3]:
|
var ItemT = typeof(X1);
bind(ItemT) Buffer = X1;
|
|
var ItemT = typeof(X2);
bind(ItemT) Buffer = X2;
|
|
var ItemT = typeof(X3);
bind(ItemT) Buffer = X3;
|
Obj.$Varable/Obj.$Func()
The special variant of the object member access allows to use Varable instead of a constant literal.
for example:
eval char[\] MemberName = "X";
$Vec2:
int X;
int Y;
|Main[]:
Vec2 Vec = Vec2();
Vec.$MemberName = 1;
after evaluating the code gets simplified into.
$Vec2:
int X;
int Y;
|Main[]:
Vec.X = 1;
this alows for simpler serialization and Deserialization and gives more tools for reduceing boilerplate.
-Note the special object member access must be a static char Array constant expression.
-Also using this allows for accessing operator overloading Funcions pointers or Funcions with keywords in them like new or drop.
for example:
$Vec2:
int X;
int Y;
|+[this&,this& Other] -> Vec2;
eval char[\] MemberName = "+";
$ItemFuncPointer = [Vec2&,Vec2&] -> Vec2;
|Main[]:
Vec2 Vec = Vec2();
Vec2 OtherVec = Vec2();
ItemFuncPointer Pointer = Vec2::$MemberName;
//Calls Vec2::+[Vec2&,Vec2& Other] -> Vec2;
Vec2 Value = Pointer(Vec,OtherVec);
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
NameSpaces
A allows scope to the Class,types,funcions in a scope to organize code.
A NameSpace can be use like so.
MyNameSpace:
$VeryColorClass:
int X;
int Y;
The Class can be accessed by useing '::'.
MyNameSpace:
$VeryColorClass:
int X;
int Y;
|main[]:
MyNameSpace::VeryColorClass Myclass = [];
NameSpace's can be also be Scoped like so.
MyNameSpace::EvenCoolorNameSpace:
$VeryColorClass:
int X;
int Y;
NameSpaces can only be used at the File or NameSpace Scope.
Name convention
Pascal case is a naming convention that is preferred by UCode’s standard for naming types, functions, and constants. Pascal case means that every word in the name starts with a capital letter and there are no separators between words. For example:
SomeType is a type name in Pascal case DoSomething is a function name in Pascal case PI is a constant name in Pascal case Pascal case makes the names easy to read and distinguish from other naming conventions. It also helps to avoid conflicts with keywords or built-in types that are usually lowercase. For example:
int is a keyword and a built-in type Int is a user-defined type in Pascal case Pascal case should be used consistently throughout the code to maintain clarity and readability. Here is an example of how Pascal case is used in UCode:
//A user-defined type that represents a point
$Point:
int X;
int Y;
//A function that takes two points and returns their distance
$Distance[Point p1, Point p2]:
return Math::Sqrt(
(p1.X - p2.X)+(p1.X - p2.X)
+ (p1.Y - p2.Y)+ (p1.Y - p2.Y)
);
//A constant that holds the value of pi
umut float PI = 3.14159;
//Creating two points and printing their distance
Point origin = [0, 0]; //Assigns 0 to both X and Y fields
Point target = [3, 4];
//Assigns 3 to X and 4 to Y fields
Console::Log(Distance(origin, target)); //Prints 5
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Array(Standardlibrary/Containers)
Not to be confused with AddressArray and NativeArrays.
The Array Type is a fixed-size collection of data items stored in contiguous memory with added safety features unlike NativeArrays.
The Array type Can be used like so.
int[10] Items;
Array<int,(10)> Items2;
Both being equivalent.
All the values in the array are stored on the stack as the size of the array is known at compile time.
Arrays mainly are used if you know how many elements you will need at compile time as thay are faster then Vectors in most cases.
int[] Items;
Items.Resize(3);//The Size Known at Compile Time.
Items[0] = 10;
Items[1] = 20;
Items[2] = Items[1];
Useing an array;
int[3] Items;
Items[0] = 10;
Items[1] = 20;
Items[2] = Items[1];
Member functions
Signature | Description |
---|---|
unsafe |Data[imut this&] -> imut T[&]; | Gets the Raw Data Pointer. |
unsafe |Data[this&] -> T[&]; | Gets the Raw Data Pointer. |
|Size[imut this&] -> uintptr; | Get the Size of the Array. |
|[][imut this&,uintptr index] -> imut T&; | Gets the address of an element. |
|[][this&,uintptr index] -> T&; | Gets the address of an element. |
Inherited traits
Trait | Description |
---|---|
Buffer_t<T> | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
Notes
The array type will always be the size of it elements it will use the generic constant expression to get the size.
Vector<T>(Standardlibrary/Containers)
Not to be confused with Vec2 and Vec3.
The Vector Type is dynamically resizeable collection of data items stored in contiguous memory.
The Vector type Can be used like so.
int[] Items;
Vector<int> Items2;
Both being equivalent.
Vector are dynamic so your able to add elements at runtime.
int[] Items;
Items.Push(5);
Items.Push(10);
Items.Push(30);
Fmt::Print(Items[0]); \\ 5
Fmt::Print(Items[1]); \\ 10
Fmt::Print(Items[2]); \\ 30
Fmt::Print(Items.Size()); \\ 3
Vector can also be can be initialized with starting elements.
int[] Items = [10,20,30];
Fmt::Print(Items[0]); \\ 5
Fmt::Print(Items[1]); \\ 10
Fmt::Print(Items[2]); \\ 30
Fmt::Print(Items.Size()); \\ 3
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Vector. |
|new[this&,imut this& Other] -> void; | Copys a Vector |
|new[this&,imut this& Other] -> void; | Moves a Vector |
|new<T...>[this&,imut T items] -> void; | Makes a New Vector with the added elements. |
|new<T...>[this&,moved T items] -> void; | Makes a New Vector with the added elements. |
unsafe |Data[imut this&] -> imut T[&]; | Gets the Raw Data Pointer. |
unsafe |Data[this&] -> T[&]; | Gets the Raw Data Pointer. |
|Size[imut this&] -> uintptr; | Get the Size of the Array. |
|Capacity[imut this&] -> uintptr; | Gets how much memory the string allocated to hold its contents |
|[][imut this&,uintptr index] -> imut T&; | Gets the address of an element. |
|[][this&,uintptr index] -> T&; | Gets the address of an element. |
|Push[this&,uintptr index] -> T&; | Adds the element to the end of the Vector. |
Inherited traits
Trait | Description |
---|---|
Buffer_t<T> | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
Notes
String_t(Standardlibrary/Containers)
Not to be confused with StringSpan. The String Type is used represent sequences of characters.
The String type Can be used like so.
String_t<char> mystr = "Hello World";
UCodeLang has many different char types which explains why the type is generic.
String_t<char> mystr = "Hello World";
String_t<uft8> mystr = "Hello World";
String_t<uft16> mystr = "Hello World";
String_t<uft32> mystr = "Hello World";
Most of type the you will be useing the alies String,String8,String16,String32. Instead of directly instantiating the type.
String mystr = "Hello World";
String8 mystr = "Hello World";
String16 mystr = "Hello World";
String32 mystr = "Hello World";
like most other languages you can concatenate strings togeter.
String mystr = "Hello";
mystr += " World";
Fmt::Print(mystr);
Member Aliases
$StrSpan = StringSpan_t<T>;
Member functions
Signature | Description |
---|---|
unsafe |Data[imut this&] -> imut T[&]; | Gets the Raw Data Pointer. |
unsafe |Data[this&] -> T[&]; | Gets the Raw Data Pointer. |
|Size[imut this&] -> uintptr; | Gets the Size of the Array. |
|Capacity[imut this&] -> uintptr; | Gets how much memory the string allocated to hold its contents |
|[][imut this&,uintptr index] -> imut T&; | Gets the address of an element. |
|[][this&,uintptr index] -> T&; | Gets the address of an element. |
|+[this&,imut this& other] -> this; | Concatenate a string to make a new string |
|+[this&,imut StrSpan& other] -> this; | Concatenate a Stringspan to make a new string |
|+=[this&,imut this& other] -> this; | Concatenate a string to a new string |
|+=[this&,imut StrSpan& other] -> this; | Concatenate a stringspan to a new string |
Inherited traits
Trait | Description |
---|---|
StringBuffer_t<T> | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Notes
Be aware that string literals like "hello" are StringSpans
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
String(Standardlibrary/Alias)
A String that contains ASCII characters.
$String = String_t<char>;
See String_t<T> for Member funcions and examples.
StringSpan(Standardlibrary/Type)
A Type Reference to a String that contains ASCII characters.
$StringSpan = String_t<char>;
See StringSpan<T> for Member funcions and examples.
String8(Standardlibrary/Alias)
A String that contains uft8 characters.
$String8 = String_t<utf8>;
See String_t for Member funcions and examples.
String8Span(Standardlibrary/Type)
A Type Reference to a String that contains uft8 characters.
$String16Span = String_t<uft8>;
See StringSpan<T> for Member funcions and examples.
String16(Standardlibrary/Alias)
A String that contains uft16 characters.
$String16 = String_t<utf8>;
See String_t<T> for Member funcions and examples.
String16Span(Standardlibrary/Type)
A Type Reference to a String that contains uft16 characters.
$String16Span = String_t<uft16>;
See StringSpan<T> for Member funcions and examples.
String32(Standardlibrary/Alias)
A String that contains uft32 characters.
$String32 = String_t<utf32>;
See String_t<T> for Member funcions and examples.
String32Span(Standardlibrary/Type)
A Type Reference to a String that contains uft32 characters.
$String16Span = String_t<uft32>;
See StringSpan<T> for Member funcions and examples.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
StringBuffer_t(Standardlibrary/ReferenceTypes)
Span(Standardlibrary/Type/Generic)
[!IMPORTANT] This Is section Is incomplete.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Math(Standardlibrary/Math)
Provides funcions for trigonometric, logarithmic, and other common mathematical functions.
|main[]:
Fmt::Print(Math::PI);//~3.14
Fmt::Print(Math::Abs(-1.5));//1.5
Fmt::Print(Math::Min(4.2,8.5));//4.2
Member functions
Signature | Description |
---|---|
Min<T>[T a,T b] -> T; | Returns the smaller of a int or a float. |
Max<T>[T a,T b] -> T; | Returns the larger of a int or a float. |
Abs<T>[T v] -> T; | Returns the absolute value of a int or a float. |
Notes
This Class is base on the C# Math Class
Vec2(Standardlibrary/Math)
A Vec2 that uses the float type.
$Vec2 = Vec2_t<float>;
See Vec2_t<T> for Member funcions and examples.
Vec3(Standardlibrary/Math)
A Vec3 that uses the float type.
$Vec3 = Vec3_t<float>;
See Vec3i_t<T> for Member funcions and examples.
Vec2i(Standardlibrary/Math)
A Vec2i that uses the int type.
$Vec2i = Vec2i_t<int>;
See Vec2i_t<T> for Member funcions and examples.
Vec3i(Standardlibrary/Math)
A Vec3i that uses the int type.
$Vec3i = Vec3i_t<int>;
See Vec3i_t<T> for Member funcions and examples.
Vec2_t(Standardlibrary/Math)
Not to be confused with Vector.
Vec2_t is the base type of a mathematical vector with an x and y value.
Vec2_t<float> pos = [5,4];
pos += [10,5];
Fmt::Print(pos);// [X:15,Y:9]
Vec2_t is mostly used for position,size and rotation others things that need an x and y value.
Fields functions
$Vec2_t<T>:
T X;
T Y;
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a Vec2 with 0,0 coordinate. |
|new[this&,T x,T y] -> void; | Makes a Vec2 with the coordinate. |
|+=[this&,imut this& other] -> void; | |
|+[imut this&,imut this& other] -> this; | |
|==[imut this&,imut this& other] -> bool; | |
|!=[imut this&,imut this& other] -> bool; |
Vec3_t(Standardlibrary/Math)
Not to be confused with Vector.
Vec2i_t is the base type of a mathematical vector with an x and y value.
Vec3_t<float> pos = [5,4,0];
pos += [10,5,3];
Fmt::Print(pos);// [X:15,Y:9,Z:3]
Vec2i_t is mostly used for position,size and rotation others things that need an x and y value.
Fields functions
$Vec3_t<T>:
T X;
T Y;
T Z;
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a Vec3 with 0,0,0 coordinate. |
|new[this&,T x,T y,T z] -> void; | Makes a Vec3 with the coordinates. |
|+=[this&,imut this& other] -> void; | |
|+[imut this&,imut this& other] -> this; | |
|==[imut this&,imut this& other] -> bool; | |
|!=[imut this&,imut this& other] -> bool; |
Vec2i_t(Standardlibrary/Math)
Not to be confused with Vector.
Vec2i_t is the base type of a mathematical vector with an x and y value.
Vec2i_t<int> pos = [5,4];
pos += [10,5];
Fmt::Print(pos);// [X:15,Y:9]
Vec2i_t is mostly used for position,size and rotation others things that need an x and y value.
Fields functions
$Vec2i_t<T>:
T X;
T Y;
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a Vec2 with 0,0 coordinate. |
|new[this&,T x,T y] -> void; | Makes a Vec2 with the coordinate. |
|+=[this&,imut this& other] -> void; | |
|+[imut this&,imut this& other] -> this; | |
|==[imut this&,imut this& other] -> bool; | |
|!=[imut this&,imut this& other] -> bool; |
Vec3i_t(Standardlibrary/Math)
Not to be confused with Vector.
Vec3i_t is the base type of a mathematical vector with an x and y value.
Vec3i_t<float> pos = [5,4,0];
pos += [10,5,3];
Fmt::Print(pos);// [X:15,Y:9,Z:3]
Vec3i_t is mostly used for position,size and rotation others things that need an x and y value.
Fields functions
$Vec3i_t<T>:
T X;
T Y;
T Z;
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a Vec3 with 0,0,0 coordinate. |
|new[this&,T x,T y,T z] -> void; | Makes a Vec3 with the coordinates. |
|+=[this&,imut this& other] -> void; | |
|+[imut this&,imut this& other] -> this; | |
|==[imut this&,imut this& other] -> bool; | |
|!=[imut this&,imut this& other] -> bool; |
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Optional<T>(Standardlibrary/ErrorHandleing)
Optional is a type that is part of the standard library. that can hold either a value of type T or nothing (Null).
The Optional type Can be used like so.
int? MayBeNull = Null;
Optional<int> MayBeNull2 = Null;
Both being equivalent.
The Optional is an enum and here its implementation.
$Optional<T>:
Opt(T opt),
Null
The Optional type allows you to have
- Optional struct fields
- Optional function arguments
- Nullable pointers
- default values
|divide[float numerator,float denominator] -> float?:
if denominator == 0:
ret Null;
else:
ret Opt(numerator / denominator);
|main[]:
var result = divide(2.0, 3.0);
match result:
Opt(out x):Fmt::Print("Result: {x}"),
Null:Fmt::Print("Cannot divide by 0"),
Question Mark Operator,
The question mark operator, ? allows for easier use of the optional type.
It lets.
|AddLastNumbers[int[]& stack] -> int?:
var a = stack.Pop();
var b = stack.Pop();
if Opt(a,out vala) && Opt(b,out valb):
ret Opt(vala + valb);
ret Null;
To become.
|AddLastNumbers[int[]& stack] -> int?:
ret Opt((?stack.Pop()) + (?stack.Pop()))
When starting an expression with ? UCodeLang will check if its Null and will do an early return if it is.
makeing your life easier.
Notes
All Examples is taken from Rust as UCodeLang was directly inspired by the Rust Programming Language.
Result<T>(Standardlibrary/ErrorHandleing)
Result is a type that is part of the standard library. that can hold either a value of type T or an error(Null).
The Result type Can be used like so.
$MyErrorType;
int!MyErrorType MayHaveError = Null;
Result<int,Result> MayHaveError = Null;
Both being equivalent.
The Result is an enum and here its implementation.
$Result<T,E>:
Val(T val),
Err(E err),
The Result type allows you to returning Error in a safe way and predictable.
Question Mark Operator,
The question mark operator, ? allows for easier use of the result type.
It lets.
|test[] -> Empty!OpenFileError:
var fileop = File::Open("somefile.txt");
if Val(fileop,out openedfile):
openedfile.Write("Hello");
ret Val(Empty());
else if Err(fileop,out err):
ret err;
To become.
|test[] -> Empty!OpenFileError:
var tep = (?File::Open("somefile.txt")).Write("Hello");
ret Emtpy()
When starting an expression with ? UCodeLang will check if its an Error and will do an early return if it is.
makeing your life easier.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Unique_ptr<T>(Standardlibrary/Memory)
A Unique_ptr is class that owns an object and free of that object when the unique_ptr goes out of scope.
int^ obj = unq int(10);
Unique_ptr<int> obj = Unique_ptr<int>::Make(10);
Both being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | default contructer. |
|new[this&,moved this other] -> void; | move contructer. |
|new[this&,imut this& other] -> invalid; | removed copy contructer. |
|drop[this&] -> void; | default destructer. |
|Get[imut this&] -> imut T& | gets owned object. |
|Get[this&] -> T&; | gets owned object. |
|Make[this&] -> this; | |
|Make<T...>[this&,imut T pars] -> this; | allocate memory for type. |
|Make<T...>[this&,moved T pars] -> this; | allocate memory for type. |
Shared_ptr(Standardlibrary/Memory)
A Shared_ptr is class that can share ownership of an object.useing reference counting to free the resource.
int$ obj = shr int(10);
Shared_ptr<int> obj = Shared_ptr<int>::Make(10);
Both being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | default contructer. |
|new[this&,moved this other] -> void; | move contructer. |
|new[this&,imut this& other] -> invalid; | removed copy contructer. |
|drop[this&] -> void; | default destructer. |
|Get[imut this&] -> imut T& | gets owned object. |
|Get[this&] -> T&; | gets owned object. |
|Make[this&] -> this; | |
|Make<T...>[this&,imut T pars] -> this; | allocate memory for type. |
|Make<T...>[this&,moved T pars] -> this; | allocate memory for type. |
LowLevel(Standardlibrary/Memory)
LowLevel is Class that Provides Low Level memory operations and functions like in languages like C or C++.
unsafe:
VoidPtr p = LowLevel::Malloc(4);
int& nump = bitcast<int&>(p);
nump = 10;
LowLevel::Free(p);
Member functions
Signature | Description |
---|---|
unsafe Malloc[uintptr size] -> VoidPtr; | allocate a block of memory in the heap. |
unsafe Free[uintptr size] -> VoidPtr; | deallocates the memory from calloc, malloc, or realloc. |
unsafe Realloc[VoidPtr ptr,uintptr size] -> VoidPtr; | deallocates the memory from calloc, malloc, or realloc. |
unsafe Calloc[size_t num,uintptr size] -> VoidPtr; | Allocates memory for an array of num objects of size and initializes all bytes in the allocated storage to zero. |
unsafe Memcpy[VoidPtr dest, const VoidPtr src, uintptr count] -> VoidPtr; | Copies count bytes from the object pointed to by src to the object pointed to by dest. Both objects are reinterpreted as arrays of bytes. |
unsafe Memset[VoidPtr dest,byte value, uintptr count] -> VoidPtr; | Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char). |
Notes
currently in the compiler it is unable to see these funcion like Malloc,Free Realloc to those specific IR instructions.meaning the compilers unable to optimize it as it just see the function as external calls.
Some Descrptions here are from en.cppreference.com
Ptr(Standardlibrary/Memory)
Ptr is Class that give the same pointer semantics like in C like languages avoiding automatic dereferencing and makes reassigning trivial.
int num = 10;
Ptr<int> val = ptr(num);
val.Write(20);
Fmt::Print(num); // 20
int num2 = 4;
val = ptr(num2);
Fmt::Print(val.Get()); // 4
External functions
Signature | Description |
---|---|
|ptr[imut T& address] -> imut Ptr<T>; | Makes a Ptr useing an address |
|ptr[T& address] -> Ptr<T>; | Makes a Ptr useing an address |
Member functions
Signature | Description |
---|---|
|Get[imut this&] -> imut T&; | return the address of the pointer. |
|Get[this&] -> T&; | returns the address of the pointer. |
|Write[this&,move T val] -> void; | Writes the value at the pointer. |
|Write[this&,imut T& val] -> void; | Writes the value at the pointer. |
Notes
Ptr will always the size of a pointer.
Ptr(Standardlibrary/VoidPtr)
A type that represents a void pointer like in c or c++.
$VoidPtr = Ptr<Empty>;
$Ptr<void> = VoidPtr;//generic specialization
See Ptr<T> for Member funcions and examples.
Ptr(Standardlibrary/VoidPtr)
A type that represents a void pointer like in c or c++.
$VoidPtr = Ptr<Empty>;
$Ptr<void> = VoidPtr;//generic specialization
See Ptr<T> for Member funcions and examples.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
File(Standardlibrary/IO/File)
The File Type allows for opening files,reading and writing files.
var file = ?File::Open("my.txt");
File Open functions
Signature | Description |
---|---|
|Open[PathSpan filename] -> OpenedFile ! OpenFileError | Opens file returns an error or an OpenedFile. |
|Open[imut Path& filename] -> OpenedFile ! OpenFileError | Opens file returns an error or an OpenedFile. |
|Open[imut String& filename] -> OpenedFile ! OpenFileError | Opens file returns an error or an OpenedFile. |
|Open[imut StringSpan& filename] -> OpenedFile ! OpenFileError | Opens file returns an error or an OpenedFile. |
File Read String functions
Signature | Description |
---|---|
|ReadString[imut StringSpan& filename] -> String ! OpenFileError | Tryes to file a as a string or returns an error if there is one. |
|ReadString[imut Path& filename] -> String ! OpenFileError | Tryes to read file a as a string or returns an error if there is one. |
|ReadString[PathSpan filename filename] -> String ! OpenFileError | Tryes read to file a as a string or returns an error if there is one. |
|ReadString[imut String filename] -> String ! OpenFileError | Tryes read to file a as a string or returns an error if there is one. |
File Read Bytes functions
Signature | Description |
---|---|
|ReadBytes[imut StringSpan filename] -> Vector<byte> ! OpenFileError | Tryes to read file a as a Vector of bytes or returns an error if there is one. |
|ReadBytes[imut String& filename] -> Vector<byte> ! OpenFileError | Tryes to read file a as a Vector of bytes or returns an error if there is one. |
|ReadBytes[imut PathSpan filename] -> Vector<byte> ! OpenFileError | Tryes to read file a as a Vector of bytes or returns an error if there is one. |
|ReadBytes[imut Path& filename]& -> Vector<byte> ! OpenFileError | Tryes to file read a as a Vector of bytes or returns an error if there is one. |
File Write String functions
Signature | Description |
---|---|
|Write[imut StringSpan filename,imut StringSpan data] -> Empty ! FileOpenWriteError | Writes data the a file or returns an error if there is one. |
|Write[imut String& filename,imut StringSpan data] -> Empty ! FileOpenWriteError | Writes data the a file or returns an error if there is one. |
|Write[imut PathSpan filename,imut StringSpan data] -> Empty ! FileOpenWriteError | Writes data the a file or returns an error if there is one. |
|Write[imut Path &filename,imut StringSpan data] -> Empty ! FileOpenWriteError | Writes data the a file or returns an error if there is one. |
File Write Bytes functions
Signature | Description |
---|---|
|Write[imut StringSpan filename,imut Span | Writes data the a file or returns an error if there is one. |
|Write[imut String& filename,imut Span | Writes data the a file or returns an error if there is one. |
|Write[imut PathSpan filename,imut Span | Writes data the a file or returns an error if there is one. |
|Write[imut Path &filename,imut Span | Writes data the a file or returns an error if there is one. |
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Atomic(Standardlibrary/Threading)
AtomicShared_ptr(Standardlibrary/Threading)
Thread(Standardlibrary/Threading)
Standardlibrary Types
The Standard library is intended to be the list of usefull types and funcions that most GameDevs May need.
All of the Standardlibrary is Under The ULang Namespace.
use ULang;
All of the Standardlibrary Part of StandardLibarary Module By UCodeLang.
import UCodeLang::StandardLibarary[0:0:0];
Containers
Name | Type | Description |
---|---|---|
Array<T,(uintptr:Size)> | Generic Class | A Fixed-size sequence container. |
Vector<T> | Generic Class | Used to store a List of Items. |
String_t<T> | Generic Class. | Used as a base to store a sequence of contiguous sequence of any char type. |
Alias Types
Name | Type | Description |
---|---|---|
StringSpan | Alias | Same As StringSpan_t<char>. Used refer to a contiguous sequence characters (text). |
String8Span | Alias | Same As StringSpan_t<uft8>. Used refer to a contiguous sequence of utf8 characters (text). |
String16Span | Alias | Same As StringSpan_t<uft16>. Used refer to a contiguous sequence of utf16 characters (text). |
String32Span | Alias | Same As StringSpan_t<uft32>. Used refer to a contiguous sequence of utf32 characters (text). |
ReferenceTypes
Name | Type | Description |
---|---|---|
StringSpan_t<T> | Generic Class | used as a base to reference a contiguous sequence of any char type. |
Span<T> | Generic Class | used store to reference a contiguous sequence of type T. |
Math Types
Name | Type | Description |
---|---|---|
Math | Class | Contains Mathematical Functions. |
Vec2 | Alias | Same As Vec2_t<float>. A vector with X and Y. |
Vec3 | Alias | Same As Vec3_t<float>. A vector with X and Y. |
Vec2i | Alias | Same As Vec2i_t<int>. A vector with X , Y and Z for float types. |
Vec3i | Alias | Same As Vec2i_t<int>. A Vector with X , Y and Z for int types. |
Vec2_t<T> | Generic Class | A Vector Base with X , Y for int types. |
Vec3_t<T> | Generic Class | A Vector Base with X , Y , Z for float types. |
Vec2i_t<T> | Generic Class | A Vector Base with X , Y. for int types. |
Vec3i_t<T> | Generic Class | A Vector Base with X , Y and Z for int types. |
Error Handleing
Name | Type | Description |
---|---|---|
Optional<T> | Generic Enum | Contains a value or Null |
Result<T,E> | Generic Enum | Contains a Success or Error. |
Memory
Name | Type | Description |
---|---|---|
Unique_ptr<T> | Generic Class | A Type that Owns and manages another object on the heap. |
Shared_ptr<T> | Generic Class | A Type that Shares ownership another object on the heap. |
LowLevel | Class | A Type That has LowLevel funcions like memcpy,memcpy,malloc. |
Ptr<T> | Generic Class | A Type that allows give C pointer semantics. |
VoidPtr | Alias | A pointer that has no type with it. |
Ptr<void> | Class Specialization | A pointer that has no type with it. |
Input/Output System
Name | Type | Description |
---|
Input/Output File
Name | Type | Description |
---|
Input/Output Networking
Name | Type | Description |
---|
Input/Output Serialization
Name | Type | Description |
---|
Miscellaneous
Name | Type | Description |
---|---|---|
Empty | class | A Zero-sized type. |
Buffer_t<T> | Generic trait | Gives the types that have continuous elements helper funcions such as Sort,Find and Filter. |
StringBuffer_t<T> | Generic trait | Gives the types that are strings funcions such as StartWith,EndWith and GetLines. |
Range_t<T> | Generic Class | Represents a Range with to and from values |
RangeFrom_t<T> | Generic Class | Represents a Range from a value |
RangeTo_t<T> | Generic Class | Represents a Range a to value |
RangeFull | Class | Represents a Full Range |
RangeInclusive_t<T> | Generic Class | Represents an Inclusive Range with a to and from a value |
RangeToInclusive_t<T> | Generic Class | Represents an Inclusive Range to a value |
Random_t<T> | Trait | Represents an Random Function and State. |
Random | alias | An ailas to RandomXorshift32 |
RandomXorshift32 | Class | A Random Number Generator. |
Notes
Under the hood the Standardlibrary uses NStandardlibrary API module to do operating system calls.
Empty(Standardlibrary/Miscellaneous)
Empty is a type that an empty type.it's mainly used as a placeholder or when the type is not important.
$Empty;
Any(Standardlibrary/Miscellaneous)
Buffer_t<T>(Standardlibrary/Miscellaneous)
The Buffer_t trait is a helper trait that gives types that have continuous elements helper funcions such as Sort,Find and Filter and others.
Member functions
Signature | Description |
---|---|
Empty[imut this&] -> bool; | Returns true if the size is 0. |
First[imut this&] -> imut T&?; | Returns First element if it exist. |
First[imut this&] -> imut T&?; | Returns First element if it exist. |
Last[this&] -> T&?; | Returns Last element if it exist. |
Last[this&] -> T&?; | Returns Last element if it exist. |
for[this&] -> Iterator; | Allows looping over all elements. |
for[imut this&] -> IIterator; | Allows looping over all elements. |
Find<[functor [imut T&] -> bool]Func>[this&,Func func] -> T&? | Loops over the items and returns the item if it matchs the funcs |
Find<[functor [imut T&] -> bool]Func>[imut this&,Func func] -> imut T&? | Loops over the items and returns the item if it matchs the funcs |
FindIndex<[functor [imut T&] -> bool]Func>[imut this&,Func func] -> imut T&? | Loops over the items and returns the index if it matchs the funcs |
FindIndex<[functor [imut T&] -> bool]Func>[this&,Func func] -> T&? | Loops over the items and returns the index if it matchs the funcs |
Reverse[this&] -> void; | Reverses all the elements. |
Shuffle<[Random_t]Rand>[this&,Rand& Rng] -> void; | Shuffles all the elements using the any Random Type |
AsSpan[this&] -> T[:]; | Gets the span of elements. |
AsSpan[imut this&] -> imut T[:]; | Gets the span of elements. |
[][this&,Range_t | Gets a Span to start and end of the range |
[][imut this&,Range_t | Gets a Span to start and end of the range |
[][this&,RangeFull_t Range] -> T[:]; | Gets the span of elements. |
[][imut this&,RangeFull_t Range] -> imut T[:]; | Gets the Span of elements. |
[][this&,RangeTo_t | Gets a Span thats starts at the range. |
[][imut this&,RangeTo_t | Gets a Span thats starts at the range |
[][this&,RangeFrom_t | Gets a Span thats ends at the range |
[][imut this&,RangeFrom_t | Gets a Span thats ends at the range |
StringBuffer_t(Standardlibrary/Miscellaneous)
Range_t<T>(Standardlibrary/Miscellaneous)
The Type holds a start and end of any type.
The Range_t type Can be used like so.
var Range = Range_t<int>(0,10);
Range_t<int> Range2 = Range(0,10);
Range_t<int> Range3 = 0..10; //this is short hand for calling the Range funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Range. |
|new[this&,T start,T end] -> void; | Makes a New Range with start and end. |
Global funcions
Signature | Description |
---|---|
Range | Makes a Range with the start and end. |
Notes
RangeFrom_t<T>(Standardlibrary/Miscellaneous)
The Type holds a range end of any type.
The Range_t type Can be used like so.
var Range = RangeFrom_t<int>(10);
RangeFrom_t<int> Range2 = RangeFrom(10);
RangeFrom_t<int> Range3 = 10..; //this is short hand for calling the RangeFrom funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Range. |
|new[this&,T start] -> void; | Makes a New Range with a start. |
Global funcions
Signature | Description |
---|---|
RangeFrom | Makes a Range with a start. |
Notes
RangeTo_t<T>(Standardlibrary/Miscellaneous)
The Type holds a end of any type.
The Range_t type Can be used like so.
var Range = RangeTo_t<int>(10);
RangeTo_t<int> Range2 = RangeTo(10);
RangeTo_t<int> Range3 = ..10; //this is short hand for calling the RangeTo funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New RangeTo_t. |
|new[this&,T end] -> void; | Makes a New RangeTo_t with start an end. |
Global funcions
Signature | Description |
---|---|
RangeTo | Makes a RangeTo_t with an end. |
Notes
RangeFull_t(Standardlibrary/Miscellaneous)
The Type represents the full range.
The Range_t type Can be used like so.
var Range = RangeFull_t();
var Range2 = ..; //this is short hand for calling the RangeFull_t funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Range. |
Global funcions
Signature | Description |
---|---|
RangeFull[] -> RangeFull_t; | Makes a Full Range. |
Notes
RangeInclusive_t<T>(Standardlibrary/Miscellaneous)
The Type holds a end of any type that and its inclusive.
The RangeInclusive_t type Can be used like so.
var Range = RangeInclusive_t<int>(0,10);
RangeInclusive_t<int> Range2 = RangeInclusive(0,10);
RangeInclusive_t<int> Range3 = 1..=10; //this is short hand for calling the RangeInclusive funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Range. |
|new[this&,T start] -> void; | Makes a New Range with a start. |
Global funcions
Signature | Description |
---|---|
RangeInclusive | Makes a Range with a start. |
Notes
RangeToInclusive_t<T>(Standardlibrary/Miscellaneous)
The Type holds a start and end of any type and its inclusive.
The Range_t type Can be used like so.
var Range = RangeToInclusive_t<int>(0,10);
RangeToInclusive_t<int> Range2 = RangeToInclusive(0,10);
RangeToInclusive_t<int> Range3 = ..=10; //this is short hand for calling the RangeToInclusive funcion
All being equivalent.
Member functions
Signature | Description |
---|---|
|new[this&] -> void; | Makes a New Range. |
|new[this&,T start,T end] -> void; | Makes a New Range with start and end. |
Global funcions
Signature | Description |
---|---|
RangeToInclusive | Makes a Range with the start and end. |
Notes
Random<T>(Standardlibrary/Miscellaneous)
Random
RandomXorshift32<T>(Standardlibrary/Miscellaneous)
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
bool
bool is used to represent a true or false value.
bool boolT = true;
bool boolF = false;
The bool type is the type used in if statements,while,for and do.
if true:
Fmt::Print("Im True");
while true:
Fmt::Print("I Loop forever");
char
The char keyword is used to represent an ASCII character and be used like so.
char MyLetter = 'A';
The type char can be cast to and from an uint8 to get the raw number value.
uint8 MyLetter = 'A' -> uint8;//65
byte MyLetter2 = 'A' -> byte;//65
utf8
The char keyword is used to represent an utf8 character and be used like so.
utf8 MyLetter = 'A';
The type can be cast to and from an uint8 to get the raw number value.
uint8 MyLetter = 'A' -> uint8;//65
byte MyLetter2 = 'A' -> byte;//65
utf16
The char keyword is used to represent an utf16 character and be used like so.
utf16 MyLetter = 'A';
The type can be cast to and from an uint16 to get the raw number value.
utf32
The char keyword is used to represent an utf32 character and be used like so.
utf32 MyLetter = 'A';
The type can be cast to and from an uint32 to get the raw number value.
float
floats types are used for floating-point values. Floating-point numbers are used for decimal values.
float A = 0.5;
float32 B = 0.5;
float32
The float32 keyword maps to float.
float32 can be casted to int32 and float64 and vice versa.
float64
float64 is the same as float but gives you 15 decimal digits precision but uses more space in memory.
float
floats types are used for floating-point values. Floating-point numbers are used for decimal values.
float A = 0.5;
float32 B = 0.5;
float32
The float32 keyword maps to float.
float32 can be casted to int32 and float64 and vice versa.
float64
float64 is the same as float but gives you 15 decimal digits precision but uses more space in memory.
This(KeyWord)
The 'this' is a keyword that refers to the this parameter.
It is a address that points to the object of the class of which the member function is called.
$Item:
int Hp;
|DoDamage[this&]:
this.Hp = 10;
Hp = 10;//does the same as above
int V = this.Hp;
int V2 = this.Hp;//does the same as above
The this keyword can also be used to be an alias current class type.
$BigTree:
int Hp;
|AddBoth[umut this&,umut this& Other] -> BigTree:
ret [this.Hp + Other.Hp];
becomes
$BigTree:
int Hp;
|AddBoth[umut BigTree,umut BigTree& Other] -> Item:
ret [this.Hp + Other.Hp];
reflection types(keywords)
Reflection types are the showed below all are keywords that can not be used at runtime.
- typeinfo : has Data about types
- classinfo : has Data about Classes
- enuminfo : has Data about Enums
- aliasinfo : has Data about alias
- traitinfo : has Data about traits
Note all functions and members are implemented internally by the compiler.
typeinfo
Can be accessed by useing type or typeof keywords.
it can be used also be used as a type by useing the bind keyword.
It has has the following functions.
$typeinfo:
//Get the Name of the type.
|Name[this&] -> char[\];
//Get the Full Name of the type.
|FullName[this&] -> char[\];
//Get the TypeID
|TypeID[this&] -> uintptr;
//if it's an Address. Ex:T&
|IsAddress[this&] -> bool;
//if it's an AddressArray. Ex:T[&]
|IsAddressArray[this&] -> bool;
//if it's an immutable. Ex: umut T
|IsImmutable[this&] -> bool;
//if it's an Dynamic. Ex: dynamic<T>
|IsDynamic[this&] -> bool;
//if it's an Moved. Ex: moved T
|IsMoved[this&] -> bool;
// try get the Class info.
|GetClassInfo[this&,out classinfo Info] -> bool;
// try get the Enum info.
|GetEnumInfo[this&,out enuminfo Info] -> bool;
classinfo
It has has the following functions.
$classinfo:
$fieldinfo:
//Get the Name of Field.
|Name[this&] -> umut char[&];
//Get the type of Field.
|GetType[this&] -> typeinfo;
//Get the byte offset.
|Offset[this&] -> uintptr;
//Get the Fields of the Class.
|Fields[this&] -> fieldinfo[\];
enuminfo
It has has the following functions.
$enuminfo:
$fieldinfo:
//Get the Name of EnumField.
|Name[this&] -> char[/];
//Get the Value of the EnumField.
//The Type is the Enum basetype.
|Value[this&] -> var;
//Gets the type of the Variant if it is one.
|TryGetVariant[this&,out typeinfo info] -> bool;
$variantinfo:
//Get the Base Type of the enum.
|BaseType[this&] -> typeinfo;
//Get the Fields of the enum.
|Fields[this&] -> fieldinfo[\];
//Gets the type of the Union of the Variant if it is one.
|TryGetVariantUnion[this&,out variantinfo info] -> bool;
var(Keyword)
In UCode, the auto keyword is used to specify that the variable’s data type will automatically be deducted from its initializer.
The compiler decides the data type for a variable by looking at its initialization.
var num = 10;//The data type is int32
var Str = "Hello World";//The data type is umut char[&]
This can also be done partially.
int A = 10;
var& B = A;//type will be come int&
lastly be used as function return.
|Func[] -> var:
ret 10;
//Func will be int32
note the compiler will the first return statement it finds as the function return.
|Func[] -> var:
if true:
ret true;
else:
ret 0;
//Func return type will be bool can and throw an error because int32 cant be implicitly convertible as bool.
note the compiler prefers returning by Value and not by address.
the two Funcs may look the same but have very different results.may cause subtle bugs if not observant.
|Func[] -> var:
static V;
ret V;
|Func[] -> var&:
static V;
ret V;
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
Enum(KeyWord)
Enums are a data type that assigns symbolic names to a set of constant expression values. For example:
$PrimaryColors enum:
Red,
Green,
Blue,
The base type of an enum is an byte by default, unless specified otherwise:
$PrimaryColors[int] enum:
Red,
Green,
Blue,
The value of each enum field is determined by the default value of the base type and the ‘++’ operator is use if the not specifyed.:
$PrimaryColors[int] enum:
Red ,//the default value of int is 0.
Green,//Red + 1 = 1
Blue,//Green + 1 = 2
You can also specify the value of an enum field with any other constant expression:
$PrimaryColors_t = int;
$PrimaryColors[PrimaryColors_t] enum:
Red = 5,//5
Green = 5 / 10,//2
Blue = 10 * (Green -> PrimaryColors_t),//20
Enum Variant
Enum Variants are Keys to maped Data.
$FireData;
$IceData;
$PowerUp enum:
None,
Fire[FireData],
Ice[IceData],
Damage[int Dmg],
Speed[int MaxSpeed,int acceleration],
Then Can be used like this.
|main[]:
PowerUp nonePower = PowerUp::None;
PowerUp speedPower = PowerUp::Speed(5,5);
//^set values
if PowerUp::Speed(speedPower,out Speed,out acceleration):
int NewMaxSpeed =Speed;
You must the pass the enum with out values to get the value to get the stored value in the Enum.
note it's not possible to get the stored enum without a conditional statement such as a if,else if,while,do,match.
Enum specification
Enum Variants are compiled down to classes and Unions showed below.
$FireData;
$IceData;
$PowerUp enum:
None,
Fire[FireData],
Ice[IceData],
Damage[int Dmg],
Speed[int MaxSpeed,int acceleration],
//As IR form
$FireData;
$IceData;
$PowerUp_Speed_type:
int MaxSpeed;
int acceleration;
$PowerUp_union union:
//none has no type associated so its uneeded.
FireData Item_1;//Fire
IceData Item_2;//Ice
int Item_3;// Damage
PowerUp_Speed_type Item_4;// Speed
$PowerUpClass:
uint8 EnumKey;
PowerUp_union union;
Enum Variants Destructors are a list if chans.
checking its Key With the field Key and calling its Destructor.the same idea applies to copy Constructors, move Constructors, copy assignments, and move assignments.
dynamic
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
Functor(KeyWord)
The Functor Keyword restricts generic type to be a funcion pointer,lambda object or any type that have the '()' funcion on it with a set parameters and a return type.
This Keyword also allows automatic type duction for lambdas.
|Func<[functor [int a,int b] -> int]FuncType>[FuncType val,int a,int b]:
ret val(a,b);
|main[]:
ret Func([a,b] => a * b,10,5);
// ^ both a and b are int because the functor states them as so.
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
new(keyword)
new calls a request for memory allocation and returns the Address
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
drop(keyword)
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
unsafe
bitcast<T>(keyword)
Converts a ptr into an other pointer or an uintptr.
|main[]:
int& NullPtr = bitcast<int&>(0);
uintptr PtrAsNumber = unsafe bitcast<uintptr>(NullPtr);
[!IMPORTANT] This Is section Is incomplete
This can cause undefined Behavior.
shr(keyword)
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
unq
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
thread
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
thread
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
eval(KeyWord)
The eval KeyWord works the same as constexpr KeyWord in c++.It tells the compiler evaluate the value of the function or variable at compile time.with no cost at runtime as there no IR Made for it.unlike static variables.
eval int SomeValue = 5;
eval Item = SomeValue * 10;
|main[this&]:
int Value = 50;
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
compiler(Keyword)
Is a type that refers to systematic analysis part of the compiler. systematic analysis is are were symbols and types are checked.
it is used the make new symbols,type,funcions. and can used to read compiler data and Settings.
bool onwindows = compiler::IsBackendWindows();
Methods
Funcion | Parameters | Return | Description |
---|---|---|---|
IsBackendC11 | None | eval bool | Is true if are targeting the C backend. |
IsBackendWasm | None | eval bool | Is true if we are targeting Wasm for the web. |
IsBackendUCodeVM | None | eval bool | Is true if we are targeting the UCodeVM. |
IsBackendWindows | None | eval bool | Is true if we are targeting windows. |
IsBackendLinux | None | eval bool | Is true if we are targeting Linux. |
IsBackendMacOS | None | eval bool | Is true if we are targeting MaxOS. |
IsCpuX86 | None | eval bool | Is true if we are targeting X86 Chips. |
IsCpuArm | None | eval bool | Is true if we are targeting Arm Chips. |
IsDebug | None | eval bool | Is true if the Debug flag was set. |
HasFlag | [char[\] Name] | eval bool | Is true a flag exists. |
GetFlagValue | [char[\] FlagName,out char[\] OutValue] | eval bool | returns the flag if it exists and sets OutValue the to the Associated value as a String. |
GetFlagValue | [char[\] FlagName,out int OutValue] | eval bool | returns the flag if it exists and sets OutValue the to the Associated value as a int. |
GetFlagValue | [char[\] FlagName,out bool OutValue] | eval bool | returns the flag if it exists and sets OutValue the to the Associated value as a bool. |
GetFlagValue | [char[\] FlagName,out float OutValue] | eval bool | returns the flag if it exists and sets OutValue the to the Associated value as a float. |
[!IMPORTANT]
GetFlagValue and HasFlag is not implemented in the compiler right now.
invalid(keyword)
the invalid keyword is the compile time variant of the Panic keyword
the invalid keyword will cause an Error at compile time when the compiler evaluates the statement.
for example:
|main[] -> void:
invalid("Error cant find the main implementation.");
the compiler will output the Error:
on line (Invaild keyword line number) invalid: "Error cant find the main implementation."
also works with vaild keyword as it makes an error.
invalid can take in the parameters
-
Span<char> or StringView //constant expression a span of chars.
-
String //constant expression string
-
0 parameters will out put the Error instead "Reached Invaild Statemet"
type/typeof/bind(keyword)
the type keyword allows for
- obtaining type info
- comparing types
- binding types
obtaining type info
to obtain type info can be done by
|main[] -> void:
BoolType B = type(bool);
var TypeInfo = typeof(B);
Note typeof is for expressions and will not will never execute the code at runtime.
Use cases can be found on type info.
comparing types
Comparing types can be done below
|main[] -> void:
var AreTheSameType = type(bool == int);
when comparing types it will return a constant expression Boolean.
here's the list of valid operators.
-
== : will will directly compare the two types and will return true if exactly the same and false otherwise.
-
!= will will directly compare the two types and will return false if exactly the same and true otherwise.
-
~= will will approximately compared the types works the same as == but will be also true if the following is true.
-if right side is the base type left of Ex: type(int ~= uint_t) is true. including traits.
binding types
using the bind keyword allows to convert type info to a type declaration.
|main[] -> void:
var BoolType = type(bool);
bind(BoolType) Item = true;
valid(keyword)
the valid keyword is an expression that returns a constant expression bool.
the keyword will check if an expression or statements will throw an compile time error.
for example:
|main[] -> void:
bool DoesFuncExist = valid(:Func(););
$if DoesFuncExist:
Console::Log("found func");
the varable "DoesFuncExist" is false because the compiler will detect that Func cant be found in the scope.
[!NOTE] The valid keyword only checks the statement or expression.the statement or expression will never execute the code at runtime.
Keywords
Keywords are reserved identifiers that have special meanings to the compiler. They can't be used as identifiers in your program
this article lists keywords.
Built-in Types
All keywords that can be used as a type.
Keyword | short Description |
---|---|
int | an alias to int32 |
byte | an alias to uint8 |
bool | the true or false type |
uintptr | a unsigned int thats the size of a pointer. |
sintptr | a signed int thats the size of a pointer. |
float | An 32 bit floating point number. |
float32 | An 32 bit floating point number. |
float64 | An 64 bit floating point number. |
char | an ASCII character type. |
utf8 | an utf8 character type. |
utf16 | an utf16 character type. |
utf32 | an utf32 character type. |
uint8 | an one byte unsigned int. |
uint16 | an two byte unsigned int. |
uint32 | an four byte unsigned int. |
uint64 | an eight bytes unsigned int. |
int8 | an one byte signed int. |
int16 | an two byte signed int. |
int32 | an four byte signed int. |
int64 | an eight bytes signed int. |
typeinfo | represents compile type information. |
type keywords
All keywords that can be used to make a type.
Keyword | short Description |
---|---|
enum | a group of constants |
trait | shareing behavior between types |
tag | add information about functions and classes |
dynamic | dynamically dispatched traits |
functor | Funcion Pointer/Lambda Object |
memory keyword
All keywords that can that deals with memory.
Keyword | short Description |
---|---|
new | allocate memory |
drop | free memory. |
unsafe | lets you do unsafe operations. |
bitcast | reinterpret the bytes of a type. |
shr | make a shared pointer. |
unq | make a unique pointer. |
varable types keywords
All keywords that can that deals changes how a varable works.
Keyword | short Description |
---|---|
static | global variables |
thread | global variables but one per thread. |
eval | compile time constant expression. |
Compile Time Keywords
All keywords that can that lets you do stuff at compile time.
Keyword | short Description |
---|---|
compiler | read compiler settings |
invaild | throw a compile time error |
type | get TypeInfo from an Type |
typeof | get TypeInfo from an expression |
bind | use TypeInfo as a type. |
valid | check a statement has errors. |
miscellaneous keywords
All keywords that dont fit in the other categories.
Keyword | short Description |
---|---|
for | loop over a list of items |
import | import a library |
out | a second output value. |
panic | throw a runtime error. |
defer | throw a runtime error. |
use | use a namespace |
for(KeyWord)
The for KeyWord can be used to make a loop or to loop for a list for items.
traditional for loop
a traditional for loop looks like this and works the same way as in C.
for [var Item = 0;Item < 10;Item++]:
Fmt::Print(Item);
this will Log 1,2,3,4,5,6,7,8,9 and 10.
modern for loops
a modern for loop can be used to loop over a list for Items and can be overloaded.As showed below.
$LoopAbleObject:
$LoopObject:
LoopAbleObject& _List;
uintptr I = 0;
//new loop
|new[this&,LoopAbleObject& List]:
_List &= List;
//Check Value
|?[this&] => I < _List.Size();
//Get Value and MoveNext
|->[this&]:
var& Item = _List._Buffer[I];
I++;
ret Item;
//loop ended
|drop[this&] -> void;
//
int[\3] _Buffer;
|Size[this&] => 3;
//overload
|for[this&] => LoopObject(this);
modern for int loops
modern for int loops can be showed below.
for [var I : 0..10]:
DoSomeThing();
This will Call DoSomeThing 10 times.
here's its equivalent code.
for [var Item = 0;Item < 10;Item++]:
DoSomeThing();
it also was its reverse variant.
for [var I : (0..10).Reverse()]:
DoSomeThing();
here's its equivalent code.
for [var Item = 10;Item != (0-1);Item--]:
DoSomeThing();
import(Keyword)
This keyword may get removed.
out(keyword)
[!IMPORTANT] This Is section Is incomplete but is implemented in the compiler.
use(keyword)
panic(keyword)
The panic keyword like in rust is used to represent a bug that has happen in the program so that the program may exit safely and to avoid putting the program in a unstable state.
|main[]:
panic("I Must panic.");
The panic keyword takes in only one argument a StringSpan or String.
Depending on the runtime the program may exit right after reaching a panic or only unwind the stack to call destructers and defers.
defer(keyword)
The defer keyword is used close or to free resources or deal with stacks. defer will execute the code after the scope has ended and even when the program panics.
it can be used like so.
defer func();
Or even have a list of statements
defer:
func();
func1();
func3();
Heres an example of when defer will execute the code.
use ULang;
int A = 0;
|func[]:
A = 10;
|main[]:
Fmt::Print("The Value of 'A' befor defer: {A}");
block:
defer func();
Fmt::Print("The Value of 'A' in the defer scope: {A}");
Fmt::Print("The Value of 'A' Out of defer scope: {A}");
Note varables captured on the defer keyword line.
so this will allways print 20 and not 30.
|main[]:
block:
int a = 20;
defer Fmt::Print(a);//the varable 'a' is captured here.
a = 30;