Skip to content

Commit 123fb7d

Browse files
authored
Merge branch 'nox' into main
2 parents b0641e2 + 0609ffa commit 123fb7d

File tree

4 files changed

+119
-20
lines changed

4 files changed

+119
-20
lines changed

ideas.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,99 @@ pub const main = fn () int {
108108
}
109109
```
110110

111-
## Build System Integration
111+
## impl and its unique features
112+
# simple example
113+
impl [func list...] -> [struct list...] {
114+
if (1 > 0) {
115+
define a function one way
116+
} else {
117+
define the same function another way
118+
}
119+
}
120+
# The goals of the impl is to implement functions for structs.
121+
# It should have the ability to conditionally make functions.
122+
# The functions are `injected` into the struct and can reference
123+
# `self` which is a pointer to the struct AstNode that should already be there.
124+
# There should be two types of functions for this instance. Runtime ready, and compile time optional.
125+
# with a tag of #runtime, the function will be compiled and optionally ran during runtime.
126+
# two instances of the same function can only run one at a time, and must be derived from an expression.
127+
# a #compile tag from a function within a conditional will be optionally compiled, and so only one available at runtime.
128+
# Why the two? One use case for @run_time is to allow dynamic function assignment. Lets say you must work with an api.
129+
# This api does not respond with the same data, same type of data and so on. This means you can write multiple capture() functions.
130+
# Yes this is function overloading, but conditionally, and can be programmed for the potential context the appliction will be in.
131+
# For @compile_time, it optionally compiles one of the implementations of the function. Say you need portability, you can use the same
132+
# source code and target specific architectures. This can be thought of #IF_WINDOWS bullshit from C, you can conditionaly compile
133+
# one function or another, but in a nice and effecient way.
134+
135+
## the ? and None type
136+
someType: ?; # is a None, or a real type.
137+
# Thats what it does. Gives a way to init without a type. Can also be used to identify things. if (someType? == None) {return "Nothing found";}
138+
# It is our solution to NULL, but it provides a more meaning. Because it can also be a value if (someType?) {return "value found";}
139+
# This is very straigh forward in its concept. someType? returns the value inside, or it returns the None type.
140+
141+
## the set type
142+
# A set is a fixed sized array of types
143+
# a, b, c : (int, float, char);
144+
# const func1 = fn () (int, float, int) {}
145+
# The same thing.
146+
# a, b, c : () = func1;
147+
# changes the the position for the returning set.
148+
# a, b, c : (float, int, int) = func1;
149+
# The () is here to be explicit that we are expecting a set from func1.
150+
151+
## Luma Post-Processing and Build System (LPBS).
152+
# LPBS is made in Luma and uses a subset (vars, funcs, if (expr)).
153+
154+
// -V2 : verbose level 2 for strictness?
155+
// -OB : object files
156+
cc_o = luma-1 -OB -V2;
157+
158+
// -x86_64 could be used to verify the executable and compatability for translate()
159+
cc = luma-1 -O3 -x86_64;
160+
161+
// the output for artefacts and exe
162+
output = "bin/";
163+
164+
src_files = {
165+
if (check_dir_exists("src/")) {
166+
-> ("main.lx", "src/*lx");
167+
}
168+
-> ("main.lx");
169+
}
170+
171+
compile:
172+
output("Getting internal and external libraries\n");
173+
get_libs -> () {
174+
path_ex = find_external("raylib", "opengl");
175+
path_in = find_internal("std::math", "std::stl::stack", "std::net::network");
176+
return path_ex, path_in;
177+
}
178+
179+
libs, clibs = get_libs();
180+
181+
get_obj -> (cc, src_files, libs, clibs) {
182+
output("Getting luma obj files\n");
183+
obj_files = cc_o src_files -l libs;
184+
output("Getting external library obj files\Combining all obj files\n");
185+
return obj_files + translate(clibs);
186+
}
187+
// compiler, obj files, to where
188+
output("Compiling program\n");
189+
compile(cc, get_obj(), output);
190+
output("Compiled, output: ", output);
191+
192+
clean:
193+
clean_all -> (where) {
194+
remove(output);
195+
output("Removed all artefacts\n");
196+
}
197+
198+
# compile: and clean: are labels, there are the external commands a user can run (lpbs compile, lpbs clean).
199+
# Lets break it down. Post-Processing is about understanding end context from the src code and a solution.
200+
# The LPB System should generate bindings for the end result.
201+
# It should manage ffi for C and providing that compatability.
202+
# It should provide a way to create, manage, and work with shared libraries or static libraries.
203+
# Then it should build the program, it should read in a simp
112204

113205
### Manual Binding Generation
114206
```bash

std/terminal.lx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub const enable_raw_mode -> fn () void {
1111
if (raw_mode_enabled == 1) {
1212
return; // Already enabled
1313
}
14-
14+
// nooo
1515
// Save terminal state and set up restoration on exit
1616
system("stty -g > /tmp/luma_termios_backup");
1717

@@ -179,4 +179,4 @@ pub const get_terminal_size -> fn () void {
179179
system("tput cols > /tmp/luma_cols");
180180
system("tput lines > /tmp/luma_lines");
181181
// Read back from files...
182-
}
182+
}

tests/test.lx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
@module "main"
22

3-
const Person -> struct {
4-
name: *char,
5-
age: int,
6-
7-
init -> fn (age: int, name: *char) void {
8-
self.name = name;
9-
self.age = age;
10-
},
11-
12-
greet -> fn () void {
13-
output("I am ", self.name, " and I am ", self.age, " years old.\n");
14-
}
3+
const randomStruct -> struct {
4+
x: int,
5+
y: int,
6+
z: int
157
};
168

179
pub const main -> fn () int {
18-
let p: Person;
1910

20-
p.init(20, "Connor");
21-
p.greet();
11+
impl [func1: int] -> [randomStruct] {
12+
const func1 -> fn() int {
13+
self.x = 10;
14+
self.y = 20;
15+
self.z = 30;
16+
17+
if (self.x < self.y && self.y < self.z) {
18+
return 1;
19+
}
20+
return 0;
21+
}
22+
}
23+
24+
randomStruct.func1();
2225

23-
return 0;
24-
}
26+
return 0;
27+
}

todo.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ These AST node types are fully implemented in code generation:
3434
- [x] `AST_STMT_PRINT`
3535
- [x] `AST_STMT_DEFER`
3636
- [x] `AST_STMT_LOOP` (this is for, while, and while-true)
37+
- [x] `AST_STMT_IMPL`
3738

3839
### Types
3940
- [x] `AST_TYPE_BASIC`
4041
- [x] `AST_TYPE_POINTER`
4142
- [x] `AST_TYPE_ARRAY`
4243
- [x] `AST_TYPE_FUNCTION`
44+
- [ ] `AST_TYPE_SET`
45+
- [ ] `AST_TYPE_SOME`
4346

4447
---
4548

@@ -60,6 +63,7 @@ These AST node types are fully implemented in code generation:
6063
- [ ] Track when `ptr2 = ptr1` creates aliases
6164
- [ ] Warn when analyzer can't track aliased pointers
6265
- [ ] Consider ownership transfer semantics
66+
- [ ] Allowing structs to point to itself -- name struct {some: *name};
6367

6468
#### Control Flow Analysis
6569
- [ ] **Conditional path tracking**

0 commit comments

Comments
 (0)