Skip to content

Commit 2b5d373

Browse files
committed
added __prototype__
1 parent 82f6204 commit 2b5d373

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

design/primer.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

design/typesystem.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Type System
2+
3+
## Types
4+
5+
Types under the hood are just objects. Every object has a prototype which is the
6+
object it 'inherits' or shares data for. It is exposed via the `__prototype__`
7+
field

example/test.gila

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
2-
31
std = import std
4-
5-
6-
7-
8-
std.io.print("hi")
9-
std.io.print("im gila!")
10-
11-
p = std.io.print
12-
13-
p("shorthand!")
14-
2+
print = std.io.print
153

164
Vec type
175
x: u32
186
end
197

208

21-
to_string fn(self:Vec)
9+
foo fn(self: Vec)
2210
end
2311

2412
v = Vec(1)
25-
p(v.to_string)
13+
print(v)

src/execution.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,8 @@ impl<'a> ExecutionEngine<'a> {
843843

844844
let mut fields: HashMap<String, Object> = HashMap::new();
845845

846+
fields.insert("__prototype__".to_string(), fn_object.clone());
847+
846848
let mut arg_values: Vec<Object> = vec![];
847849
for i in call.arg_1..call.arg_1 + call.arg_2 {
848850
arg_values.push(stack_access!(self, i).clone());
@@ -859,8 +861,8 @@ impl<'a> ExecutionEngine<'a> {
859861
counter += 1;
860862
}
861863
_ => {
862-
// add any methods etc
863-
fields.insert(key.to_string(), typ.clone());
864+
// dont add methods
865+
// fields.insert(key.to_string(), typ.clone());
864866
}
865867
}
866868
}

0 commit comments

Comments
 (0)