mt-lang 0.2.21 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -1
- data/docs/index.html +2 -1
- data/docs/language-design.md +2 -0
- data/docs/language-manual.md +16 -1
- data/lib/milk_tea/base.rb +1 -1
- data/lib/milk_tea/core/ast.rb +2 -2
- data/lib/milk_tea/core/c_backend/expressions.rb +11 -0
- data/lib/milk_tea/core/c_backend/type_collectors.rb +49 -0
- data/lib/milk_tea/core/c_backend/type_declaration.rb +7 -0
- data/lib/milk_tea/core/c_backend/type_system.rb +12 -0
- data/lib/milk_tea/core/c_backend.rb +8 -0
- data/lib/milk_tea/core/compatibility_helpers.rb +4 -0
- data/lib/milk_tea/core/compile_time.rb +16 -0
- data/lib/milk_tea/core/ir.rb +1 -0
- data/lib/milk_tea/core/keywords.rb +1 -1
- data/lib/milk_tea/core/lowering/block.rb +48 -16
- data/lib/milk_tea/core/lowering/calls.rb +75 -1
- data/lib/milk_tea/core/lowering/declarations.rb +7 -0
- data/lib/milk_tea/core/lowering/expressions.rb +39 -8
- data/lib/milk_tea/core/lowering/functions.rb +1 -1
- data/lib/milk_tea/core/lowering/resolve.rb +70 -5
- data/lib/milk_tea/core/lowering/utils.rb +26 -0
- data/lib/milk_tea/core/module_binder.rb +4 -0
- data/lib/milk_tea/core/parser/expressions.rb +11 -3
- data/lib/milk_tea/core/parser/statements.rb +2 -2
- data/lib/milk_tea/core/parser/types.rb +8 -1
- data/lib/milk_tea/core/semantic_analyzer/calls.rb +97 -4
- data/lib/milk_tea/core/semantic_analyzer/expressions.rb +52 -2
- data/lib/milk_tea/core/semantic_analyzer/function_binding.rb +7 -0
- data/lib/milk_tea/core/semantic_analyzer/generics.rb +40 -0
- data/lib/milk_tea/core/semantic_analyzer/name_resolution.rb +11 -0
- data/lib/milk_tea/core/semantic_analyzer/statements.rb +21 -4
- data/lib/milk_tea/core/semantic_analyzer/top_level.rb +23 -0
- data/lib/milk_tea/core/semantic_analyzer/type_compatibility.rb +37 -0
- data/lib/milk_tea/core/types/layout.rb +7 -0
- data/lib/milk_tea/core/types/predicates.rb +44 -3
- data/lib/milk_tea/core/types/registry.rb +4 -0
- data/lib/milk_tea/core/types/types.rb +42 -0
- data/lib/milk_tea/core/types/visitor.rb +2 -0
- data/lib/milk_tea/lsp/server/completion.rb +1 -1
- data/lib/milk_tea/lsp/server/hover.rb +8 -1
- data/std/asset_pack.mt +13 -13
- data/std/binary.mt +1 -1
- data/std/hash.mt +11 -11
- data/std/net/session.mt +5 -5
- data/std/random.mt +23 -31
- data/std/raylib.mt +14 -14
- metadata +2 -2
data/std/random.mt
CHANGED
|
@@ -9,9 +9,9 @@ public struct Rng:
|
|
|
9
9
|
|
|
10
10
|
public function from_seed(seed: ulong) -> Rng:
|
|
11
11
|
var rng = Rng(state = 0ul, increment = (seed << 1ul) | 1ul)
|
|
12
|
-
rng.
|
|
12
|
+
rng.next_uint()
|
|
13
13
|
rng.state = rng.state + seed
|
|
14
|
-
rng.
|
|
14
|
+
rng.next_uint()
|
|
15
15
|
return rng
|
|
16
16
|
|
|
17
17
|
|
|
@@ -27,7 +27,7 @@ public function from_seed_str(seed_str: str) -> Rng:
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
extending Rng:
|
|
30
|
-
public editable function
|
|
30
|
+
public editable function next_uint() -> uint:
|
|
31
31
|
let oldstate = this.state
|
|
32
32
|
this.state = oldstate * pcg_multiplier + this.increment
|
|
33
33
|
let xorshifted = uint<-(((oldstate >> 18ul) ^ oldstate) >> 27ul)
|
|
@@ -35,67 +35,59 @@ extending Rng:
|
|
|
35
35
|
return (xorshifted >> rot) | (xorshifted << (32u - rot))
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
public editable function
|
|
39
|
-
let hi = ulong<-this.
|
|
40
|
-
let lo = ulong<-this.
|
|
38
|
+
public editable function next_ulong() -> ulong:
|
|
39
|
+
let hi = ulong<-this.next_uint()
|
|
40
|
+
let lo = ulong<-this.next_uint()
|
|
41
41
|
return (hi << 32ul) | lo
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
public editable function
|
|
45
|
-
let val = this.
|
|
44
|
+
public editable function next_double() -> double:
|
|
45
|
+
let val = this.next_uint()
|
|
46
46
|
return double<-val / 4294967296.0
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
public editable function
|
|
50
|
-
let val = this.
|
|
49
|
+
public editable function next_float() -> float:
|
|
50
|
+
let val = this.next_uint()
|
|
51
51
|
return float<-val / 4294967296.0
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
public editable function next_ubyte() -> ubyte:
|
|
55
|
-
let val = this.
|
|
55
|
+
let val = this.next_uint()
|
|
56
56
|
return ubyte<-(val & 0xFFu)
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
public editable function next_bool() -> bool:
|
|
60
|
-
let val = this.
|
|
60
|
+
let val = this.next_uint()
|
|
61
61
|
return (val & 1u) != 0u
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
public editable function next_uint() -> uint:
|
|
65
|
-
return this.next_u32()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
public editable function next_ulong() -> ulong:
|
|
69
|
-
return this.next_u64()
|
|
70
|
-
|
|
71
|
-
|
|
72
64
|
public editable function next_uint_range(min: uint, max: uint) -> uint:
|
|
73
65
|
if min >= max:
|
|
74
66
|
return min
|
|
75
67
|
let range = max - min
|
|
76
|
-
return min + (this.
|
|
68
|
+
return min + (this.next_uint() % range)
|
|
77
69
|
|
|
78
70
|
|
|
79
71
|
public editable function next_int_range(min: int, max: int) -> int:
|
|
80
72
|
if min >= max:
|
|
81
73
|
return min
|
|
82
74
|
let range = uint<-(max - min)
|
|
83
|
-
let offset = this.
|
|
75
|
+
let offset = this.next_uint() % range
|
|
84
76
|
return min + int<-offset
|
|
85
77
|
|
|
86
78
|
|
|
87
|
-
public editable function
|
|
88
|
-
let t = this.
|
|
79
|
+
public editable function next_double_range(min: double, max: double) -> double:
|
|
80
|
+
let t = this.next_double()
|
|
89
81
|
return min + (max - min) * t
|
|
90
82
|
|
|
91
83
|
|
|
92
|
-
public editable function
|
|
93
|
-
let t = this.
|
|
84
|
+
public editable function next_float_range(min: float, max: float) -> float:
|
|
85
|
+
let t = this.next_float()
|
|
94
86
|
return min + (max - min) * t
|
|
95
87
|
|
|
96
88
|
|
|
97
89
|
public editable function chance(probability: double) -> bool:
|
|
98
|
-
return this.
|
|
90
|
+
return this.next_double() < probability
|
|
99
91
|
|
|
100
92
|
|
|
101
93
|
public editable function pick_ref[T](items: span[T]) -> ptr[T]?:
|
|
@@ -130,17 +122,17 @@ extending Rng:
|
|
|
130
122
|
public editable function skip(count: ptr_uint) -> void:
|
|
131
123
|
var i: ptr_uint = 0
|
|
132
124
|
while i < count:
|
|
133
|
-
this.
|
|
125
|
+
this.next_uint()
|
|
134
126
|
i += 1
|
|
135
127
|
|
|
136
128
|
|
|
137
129
|
public editable function fork() -> Rng:
|
|
138
|
-
let seed = this.
|
|
130
|
+
let seed = this.next_ulong()
|
|
139
131
|
return from_seed(seed)
|
|
140
132
|
|
|
141
133
|
|
|
142
134
|
public editable function seeds() -> array[ulong, 4]:
|
|
143
135
|
return array[ulong, 4](
|
|
144
|
-
this.
|
|
145
|
-
this.
|
|
136
|
+
this.next_ulong(), this.next_ulong(),
|
|
137
|
+
this.next_ulong(), this.next_ulong()
|
|
146
138
|
)
|
data/std/raylib.mt
CHANGED
|
@@ -452,9 +452,9 @@ public foreign function image_draw_rectangle(inout dst: Image, pos_x: int, pos_y
|
|
|
452
452
|
public foreign function image_draw_rectangle_v(inout dst: Image, position: Vector2, size: Vector2, color: Color) -> void = c.ImageDrawRectangleV
|
|
453
453
|
public foreign function image_draw_rectangle_rec(inout dst: Image, rec: Rectangle, color: Color) -> void = c.ImageDrawRectangleRec
|
|
454
454
|
public foreign function image_draw_rectangle_lines(inout dst: Image, rec: Rectangle, thick: int, color: Color) -> void = c.ImageDrawRectangleLines
|
|
455
|
-
public foreign function image_draw_triangle(inout dst: Image,
|
|
456
|
-
public foreign function image_draw_triangle_ex(inout dst: Image,
|
|
457
|
-
public foreign function image_draw_triangle_lines(inout dst: Image,
|
|
455
|
+
public foreign function image_draw_triangle(inout dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) -> void = c.ImageDrawTriangle
|
|
456
|
+
public foreign function image_draw_triangle_ex(inout dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, c1: Color, c2: Color, c3: Color) -> void = c.ImageDrawTriangleEx
|
|
457
|
+
public foreign function image_draw_triangle_lines(inout dst: Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) -> void = c.ImageDrawTriangleLines
|
|
458
458
|
public foreign function image_draw_triangle_fan(inout dst: Image, points: const_ptr[Vector2], point_count: int, color: Color) -> void = c.ImageDrawTriangleFan
|
|
459
459
|
public foreign function image_draw_triangle_strip(inout dst: Image, points: const_ptr[Vector2], point_count: int, color: Color) -> void = c.ImageDrawTriangleStrip
|
|
460
460
|
public foreign function image_draw(inout dst: Image, src: Image, src_rec: Rectangle, dst_rec: Rectangle, tint: Color) -> void = c.ImageDraw
|
|
@@ -926,23 +926,23 @@ extending Image:
|
|
|
926
926
|
image_draw_rectangle_lines(this, rec, thick, color)
|
|
927
927
|
|
|
928
928
|
|
|
929
|
-
public editable function draw_triangle(
|
|
930
|
-
image_draw_triangle(this,
|
|
929
|
+
public editable function draw_triangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) -> void:
|
|
930
|
+
image_draw_triangle(this, v1, v2, v3, color)
|
|
931
931
|
|
|
932
932
|
|
|
933
933
|
public editable function draw_triangle_ex(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
934
|
+
v1: Vector2,
|
|
935
|
+
v2: Vector2,
|
|
936
|
+
v3: Vector2,
|
|
937
|
+
c1: Color,
|
|
938
|
+
c2: Color,
|
|
939
|
+
c3: Color
|
|
940
940
|
) -> void:
|
|
941
|
-
image_draw_triangle_ex(this,
|
|
941
|
+
image_draw_triangle_ex(this, v1, v2, v3, c1, c2, c3)
|
|
942
942
|
|
|
943
943
|
|
|
944
|
-
public editable function draw_triangle_lines(
|
|
945
|
-
image_draw_triangle_lines(this,
|
|
944
|
+
public editable function draw_triangle_lines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) -> void:
|
|
945
|
+
image_draw_triangle_lines(this, v1, v2, v3, color)
|
|
946
946
|
|
|
947
947
|
|
|
948
948
|
public editable function draw_triangle_fan(points: const_ptr[Vector2], point_count: int, color: Color) -> void:
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mt-lang
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Long (Teefan) Tran
|
|
@@ -586,7 +586,7 @@ metadata:
|
|
|
586
586
|
homepage_uri: https://teefan.github.io/mt-lang/
|
|
587
587
|
source_code_uri: https://github.com/teefan/mt-lang
|
|
588
588
|
post_install_message: |
|
|
589
|
-
Milk Tea 0.
|
|
589
|
+
Milk Tea 0.3.0 installed!
|
|
590
590
|
|
|
591
591
|
System requirements:
|
|
592
592
|
- A C compiler (gcc or clang) must be available on PATH
|