-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from vein-lang/feature/migrate-std-into-runtime
add std project
- Loading branch information
Showing
73 changed files
with
1,471 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Build and Release Folders | ||
[Oo]bj/ | ||
[Bb]in/ | ||
|
||
# Other files and folders | ||
.cache/ | ||
|
||
# Executables and metadata | ||
*.wll | ||
*.bin | ||
*.lay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
|
||
> Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support. | ||
|
||
--- | ||
|
||
## OS Support | ||
|
||
OS | Version | Architectures | ||
------------------------------|-------------------------------|---------------- | ||
Windows 10 | 1607+ | x64, ARM64 | ||
OSX | 10.14+ | x64 | ||
Linux | | x64, ARM64 | ||
|
||
|
||
## Compiling from source | ||
|
||
### Building on Windows | ||
|
||
For building, you need the following tools: | ||
- dotnet 6.0 | ||
- Win10 SDK | ||
- vsbuild-tools-2019 with MSVC 2019, MSVC142 for ARM64 | ||
|
||
|
||
Checkout mana sources | ||
```bash | ||
git clone https://github.com/vein-lang/vein.git --recurse-submodules | ||
cd ./vein-lang | ||
git fetch --prune --unshallow --tags | ||
|
||
dotnet restore | ||
``` | ||
|
||
#### Compile IshtarVM | ||
Go to ishtar folder | ||
```base | ||
cd ./runtime/ishtar.vm | ||
``` | ||
Compile for Windows 10 x64 | ||
```bash | ||
dotnet publish -r win10-x64 -c Release | ||
``` | ||
Compile for Windows 10 ARM64 | ||
``` | ||
dotnet publish -r win-arm64 -c Release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#space "test" | ||
#use "vein/lang" | ||
|
||
struct App { | ||
public static master(): void { | ||
|
||
if (false) { | ||
Out.print("Assert: if (false) got true! BAD"); | ||
} | ||
|
||
let a1 = 1 == 1; // true | ||
|
||
if (!a1) { | ||
Out.print("Assert: 1 == 1 got false!"); | ||
} | ||
|
||
let a4 = 1 < 2; // true | ||
|
||
if (!a4) { | ||
Out.print("Assert: 1 < 2 got false!"); | ||
} | ||
|
||
let a5 = 1 <= 2; // true | ||
|
||
if (!a5) { | ||
Out.print("Assert: 1 <= 2 got false!"); | ||
} | ||
} | ||
|
||
|
||
static Fib(x: i32): i32 { | ||
if (x == 0) return 0; | ||
|
||
auto prev = 0; | ||
auto next = 1; | ||
for (auto i = 1; i < x; i++) | ||
{ | ||
auto sum = prev + next; | ||
prev = next; | ||
next = sum; | ||
} | ||
return next; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 1.0.0.0 | ||
author: | ||
- name: yuuki | ||
github: '' | ||
license: MIT license | ||
packages: | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; ModuleID = '_ffi' | ||
source_filename = "_ffi" | ||
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
declare i32 @kernel32_GetConsoleWindow() | ||
|
||
define { [16 x i8], i32 } @GetConsoleWindow(ptr %0, i32 %1) { | ||
entry: | ||
%2 = call i32 @kernel32_GetConsoleWindow() | ||
%retStackVal = alloca { [16 x i8], i32 }, align 8 | ||
%retDataPtr = getelementptr inbounds { [16 x i8], i32 }, ptr %retStackVal, i32 0, i32 0 | ||
store i32 %2, ptr %retDataPtr, align 4 | ||
%retTypePtr = getelementptr inbounds { [16 x i8], i32 }, ptr %retStackVal, i32 0, i32 1 | ||
store i32 9, ptr %retTypePtr, align 4 | ||
%retVal = load { [16 x i8], i32 }, ptr %retStackVal, align 4 | ||
ret { [16 x i8], i32 } %retVal | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#space "test" | ||
|
||
#use "vein/lang" | ||
|
||
public static class Na | ||
{ | ||
[native("kernel32", "GetConsoleWindow")] | ||
public static extern foobar(): i32; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
; ModuleID = '_ffi' | ||
source_filename = "_ffi" | ||
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## A standard core library for Ishtar VM and Vein Lang | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: std | ||
version: '0.30.0' | ||
license: MIT | ||
packable: true | ||
description: A standard core library for Ishtar VM and Vein Lang | ||
author: | ||
- name: Yuuki Wesp | ||
github: '0xF6' | ||
- name: Vein Lang | ||
github: 'vein-lang' | ||
urls: | ||
BugUrl: https://github.com/vein-lang/std | ||
HomepageUrl: https://github.com/vein-lang/std | ||
Repository: https://github.com/vein-lang/std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#space "vein/lang" | ||
|
||
public static class App | ||
{ | ||
[native("__internal__", "@_get_os_value")] | ||
private extern static @_get_os_value(): i32; | ||
[native("__internal__", "@_exit")] | ||
private extern static @_exit(msg: string, exitCode: i32): void; | ||
[native("__internal__", "@_switch_flag")] | ||
private extern static @_switch_flag(key: string, value: bool): void; | ||
|
||
public static GetFrameworkName(): string | ||
{ | ||
return "Application.getPlatform()"; | ||
} | ||
|
||
public static Shutdown(msg: string, exitCode: i32): void | ||
|> Application.@_exit(msg, exitCode); | ||
|
||
public static SwitchFlag(key: string, value: bool): void | ||
|> @_switch_flag(key, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#space "vein/lang" | ||
|
||
[special, forwarded] | ||
public class Array | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
|
||
[native("!!block")] | ||
private _block: i64; | ||
|
||
[native("!!size")] | ||
public readonly Length: i64; | ||
|
||
[native("!!rank")] | ||
public readonly Rank: i64; | ||
|
||
public override toString(): string | ||
{ | ||
return "Array"; | ||
} | ||
|
||
public static empty: Array = new object[0]; | ||
|
||
//protected extern _indexer_get(index: i64): object; | ||
//protected extern _indexer_set(index: i64, o: object): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#space "vein/lang" | ||
|
||
|
||
|
||
public class BitConvert : Object | ||
{ | ||
/* | ||
public static Tou8s(str: string): u8[] | ||
{ | ||
// ... | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded, alias("bool")] | ||
public struct Boolean : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
|
||
public const True: bool = true; | ||
public const False: bool = false; | ||
|
||
public const TrueString: string = "true"; | ||
public const FalseString: string = "false"; | ||
} | ||
|
||
alias bool <| Boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded, alias("u8")] | ||
public struct Byte : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
|
||
public foo(): void | ||
|> Call.call(); | ||
|
||
public foo(): void { | ||
while(true) { | ||
let a = 15; | ||
} | ||
} | ||
} | ||
|
||
alias u8 <| Byte; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded, alias("char")] | ||
public struct Char : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
} | ||
|
||
alias char <| Char; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded] | ||
public struct Decimal : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded, alias("f64")] | ||
public struct Double : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
} | ||
|
||
|
||
alias f64 <| Double; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded] | ||
public class Exception : Object | ||
{ | ||
public message: string; | ||
|
||
|
||
public override toString(): string | ||
|> this.message; | ||
} | ||
|
||
public class NullPointerException : Exception | ||
{ | ||
public new() | ||
|> this.message = "Null pointer detected"; | ||
} | ||
|
||
public class TypeLoadFault : Exception | ||
{ | ||
public new(msg: string) | ||
|> this.message = msg; | ||
} | ||
|
||
public class IncorrectCastFault : Exception | ||
{ | ||
public new(); | ||
public new(msg: string) | ||
|> this.message = msg; | ||
} | ||
|
||
public class FreeImmortalObjectFault : Exception | ||
{ | ||
public new(); | ||
public new(msg: string) | ||
|> this.message = msg; | ||
} | ||
|
||
public class PlatformIsNotSupportFault : Exception | ||
{ | ||
public new(); | ||
public new(msg: string) | ||
|> this.message = msg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#space "vein/lang" | ||
|
||
|
||
[special, forwarded, alias("f32")] | ||
public struct Float : ValueType | ||
{ | ||
[native("!!value")] | ||
private _value: ValueType; | ||
} | ||
|
||
alias f32 <| Float; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#space "vein/lang" | ||
|
||
|
||
public static class GC | ||
{ | ||
public static allocated: u64 | ||
|> self._get_allocated(); | ||
public static alive_objects: u64 | ||
|> self._get_alive_objects(); | ||
|
||
[native("__internal__", "i_call_GC_get_allocated")] | ||
private static extern _get_allocated(): u64; | ||
[native("__internal__", "i_call_GC_get_alive_objects")] | ||
private static extern _get_alive_objects(): u64; | ||
} |
Oops, something went wrong.