Skip to content

Commit

Permalink
Merge pull request #242 from vein-lang/feature/migrate-std-into-runtime
Browse files Browse the repository at this point in the history
add std project
  • Loading branch information
0xF6 authored Jun 20, 2024
2 parents 8aa447f + 07a4fce commit 2698953
Show file tree
Hide file tree
Showing 73 changed files with 1,471 additions and 0 deletions.
Empty file added lib/vein.std/build.ps1
Empty file.
11 changes: 11 additions & 0 deletions lib/vein.std/std/.gitignore
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
47 changes: 47 additions & 0 deletions lib/vein.std/std/README.md
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
```
44 changes: 44 additions & 0 deletions lib/vein.std/std/asd/app.vein
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;
}
}
7 changes: 7 additions & 0 deletions lib/vein.std/std/asd/asd.vproj
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]
17 changes: 17 additions & 0 deletions lib/vein.std/std/asd/asd_ffi.ll
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
}
9 changes: 9 additions & 0 deletions lib/vein.std/std/asd/na.vein
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 added lib/vein.std/std/asd/output.o
Binary file not shown.
3 changes: 3 additions & 0 deletions lib/vein.std/std/asd/std_ffi.ll
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"
Binary file added lib/vein.std/std/src/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/vein.std/std/src/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## A standard core library for Ishtar VM and Vein Lang

14 changes: 14 additions & 0 deletions lib/vein.std/std/src/std.vproj
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
22 changes: 22 additions & 0 deletions lib/vein.std/std/src/vein/lang/App.vein
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);
}
27 changes: 27 additions & 0 deletions lib/vein.std/std/src/vein/lang/Array.vein
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;
}
13 changes: 13 additions & 0 deletions lib/vein.std/std/src/vein/lang/BitConvert.vein
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[]
{
// ...
}
*/
}
17 changes: 17 additions & 0 deletions lib/vein.std/std/src/vein/lang/Boolean.vein
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;
20 changes: 20 additions & 0 deletions lib/vein.std/std/src/vein/lang/Byte.vein
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;
11 changes: 11 additions & 0 deletions lib/vein.std/std/src/vein/lang/Char.vein
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;
9 changes: 9 additions & 0 deletions lib/vein.std/std/src/vein/lang/Decimal.vein
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;
}
12 changes: 12 additions & 0 deletions lib/vein.std/std/src/vein/lang/Double.vein
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;
45 changes: 45 additions & 0 deletions lib/vein.std/std/src/vein/lang/Exception.vein
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;
}
11 changes: 11 additions & 0 deletions lib/vein.std/std/src/vein/lang/Float.vein
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;
15 changes: 15 additions & 0 deletions lib/vein.std/std/src/vein/lang/GC.vein
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;
}
Loading

0 comments on commit 2698953

Please sign in to comment.