11
22Casts :: module {
33 // Float casting
4- cast:: float(x : int) #inline {
4+ cast:: float(x : int) #inline; #noast {
55 return #cast x : float;
66 }
7- cast:: float(x : char) #inline {
7+ cast:: float(x : char) #inline; #noast {
88 return #cast x : float;
99 }
10- cast:: float(x : float) #inline {
10+ cast:: float(x : float) #inline; #noast {
1111 return #cast x : float;
1212 }
13- cast:: float(x : double) #inline {
13+ cast:: float(x : double) #inline; #noast {
1414 return #cast x : float;
1515 }
16- cast:: float(x : bool) #inline {
16+ cast:: float(x : bool) #inline; #noast {
1717 return #cast x : float;
1818 }
1919 // Double
20- cast:: double(x : int) #inline {
20+ cast:: double(x : int) #inline; #noast {
2121 return #cast x : double;
2222 }
23- cast:: double(x : char) #inline {
23+ cast:: double(x : char) #inline; #noast {
2424 return #cast x : double;
2525 }
26- cast:: double(x : float) #inline {
26+ cast:: double(x : float) #inline; #noast {
2727 return #cast x : double;
2828 }
29- cast:: double(x : double) #inline {
29+ cast:: double(x : double) #inline; #noast {
3030 return #cast x : double;
3131 }
32- cast:: double(x : bool) #inline {
32+ cast:: double(x : bool) #inline; #noast {
3333 return #cast x : double;
3434 }
3535
3636 // Int casting
37- cast:: int(x : float) #inline {
37+ cast:: int(x : float) #inline; #noast {
3838 return #cast x : int;
3939 }
40- cast:: int(x : double) #inline {
40+ cast:: int(x : double) #inline; #noast {
4141 return #cast x : int;
4242 }
43- cast:: int(x : int) #inline {
43+ cast:: int(x : int) #inline; #noast {
4444 return #cast x : int;
4545 }
46- cast:: int(x : uint) #inline {
46+ cast:: int(x : uint) #inline; #noast {
4747 return #cast x : int;
4848 }
49- cast:: int(x : bool) #inline {
49+ cast:: int(x : bool) #inline; #noast {
5050 return #cast x : int;
5151 }
5252
53- cast:: uint(x : float) #inline {
53+ cast:: uint(x : float) #inline; #noast {
5454 return #cast x : uint;
5555 }
56- cast:: uint(x : double) #inline {
56+ cast:: uint(x : double) #inline; #noast {
5757 return #cast x : uint;
5858 }
59- cast:: uint(x : int) #inline {
59+ cast:: uint(x : int) #inline; #noast {
6060 return #cast x : uint;
6161 }
62- cast:: uint(x : uint) #inline {
62+ cast:: uint(x : uint) #inline; #noast {
6363 return #cast x : uint;
6464 }
65- cast:: uint(x : bool) #inline {
65+ cast:: uint(x : bool) #inline; #noast {
6666 return #cast x : uint;
6767 }
6868
69- cast:: uint64(x : float) #inline {
69+ cast:: uint64(x : float) #inline; #noast {
7070 return #cast x : uint64;
7171 }
72- cast:: uint64(x : double) #inline {
72+ cast:: uint64(x : double) #inline; #noast {
7373 return #cast x : uint64;
7474 }
75- cast:: uint64(x : int) #inline {
75+ cast:: uint64(x : int) #inline; #noast {
7676 return #cast x : uint64;
7777 }
78- cast:: uint64(x : uint) #inline {
78+ cast:: uint64(x : uint) #inline; #noast {
7979 return #cast x : uint64;
8080 }
81- cast:: uint64(x : bool) #inline {
81+ cast:: uint64(x : bool) #inline; #noast {
8282 return #cast x : uint64;
8383 }
8484
85- cast:: uint16(x : float) #inline {
85+ cast:: uint16(x : float) #inline; #noast {
8686 return #cast x : uint16;
8787 }
88- cast:: uint16(x : double) #inline {
88+ cast:: uint16(x : double) #inline; #noast {
8989 return #cast x : uint16;
9090 }
91- cast:: uint16(x : int) #inline {
91+ cast:: uint16(x : int) #inline; #noast {
9292 return #cast x : uint16;
9393 }
94- cast:: uint16(x : uint) #inline {
94+ cast:: uint16(x : uint) #inline; #noast {
9595 return #cast x : uint16;
9696 }
97- cast:: uint16(x : bool) #inline {
97+ cast:: uint16(x : bool) #inline; #noast {
9898 return #cast x : uint16;
9999 }
100100}
101101
102102Operators::module{
103- unary ++ :: int(i : ref int) #inline {
103+ operator ++ :: int(i : ref int) #inline; #noast {
104104 i += 1;
105105 return i;
106106 }
107- unary -- :: int(i : ref int) #inline {
107+ operator -- :: int(i : ref int) #inline; #noast {
108108 i -= 1;
109109 return i;
110110 }
@@ -116,61 +116,61 @@ Memory :: module{
116116 #extern free::(p : *int);
117117}
118118
119- Strings :: module{
120- #import Builtin.Memory;
121- #import Builtin.Operators;
122-
123- string :: struct {
124- address : *char;
125- length : uint32;
126-
127- size::uint32(){
128- return length;
129- }
130-
131- cast::string(c : *char){
132- len = 0;
133- for(i : 0..4_294_967_296){
134- if(c[i] == '\0')
135- break;
136- len++;
137- }
138- address = malloc(len);
139- for(i : 0..len){
140- address[i] = c[i];
141- }
142- length = len;
143- }
144-
145- binary+ :: string(s : ref string, c : char) #inline {
146- s.length += 1;
147- newAddress : *char = malloc(s.length);
148- for(i : 0..s.length-1){
149- newAddress[i] = s.address[i];
150- }
151- free(s.address);
152- newAddress[s.length-1] = c;
153- s.address = newAddress;
154- return s;
155- }
156-
157- binary+ :: string(s : ref string, otherStr : string) #inline {
158- oldLength = s.length;
159- s.length += otherStr.length;
160- newAddress : *char = malloc(s.length);
161- for(i : 0..oldLength){
162- newAddress[i] = s.address[i];
163- }
164- free(s.address);
165- for(i : oldLength..otherStr.length){
166- newAddress[i] = otherStr.address[i-oldLength];
167- }
168- s.address = newAddress;
169- return s;
170- }
171-
172- binary[] :: char(s : ref string, i : int) #inline {
173- return s.address[i];
174- }
175- }
176- }
119+ // Strings :: module{
120+ // #import Builtin.Memory;
121+ // #import Builtin.Operators;
122+ //
123+ // string :: struct {
124+ // address : *char;
125+ // length : uint32;
126+ //
127+ // size::uint32(){
128+ // return length;
129+ // }
130+ //
131+ // cast::string(c : *char){
132+ // len = 0;
133+ // for(i : 0..4_294_967_296){
134+ // if(c[i] == '\0')
135+ // break;
136+ // len++;
137+ // }
138+ // address = malloc(len);
139+ // for(i : 0..len){
140+ // address[i] = c[i];
141+ // }
142+ // length = len;
143+ // }
144+ //
145+ // binary+ :: string(s : ref string, c : char) #inline {
146+ // s.length += 1;
147+ // newAddress : *char = malloc(s.length);
148+ // for(i : 0..s.length-1){
149+ // newAddress[i] = s.address[i];
150+ // }
151+ // free(s.address);
152+ // newAddress[s.length-1] = c;
153+ // s.address = newAddress;
154+ // return s;
155+ // }
156+ //
157+ // binary+ :: string(s : ref string, otherStr : string) #inline {
158+ // oldLength = s.length;
159+ // s.length += otherStr.length;
160+ // newAddress : *char = malloc(s.length);
161+ // for(i : 0..oldLength){
162+ // newAddress[i] = s.address[i];
163+ // }
164+ // free(s.address);
165+ // for(i : oldLength..otherStr.length){
166+ // newAddress[i] = otherStr.address[i-oldLength];
167+ // }
168+ // s.address = newAddress;
169+ // return s;
170+ // }
171+ //
172+ // binary[] :: char(s : ref string, i : int) #inline {
173+ // return s.address[i];
174+ // }
175+ // }
176+ // }
0 commit comments