File tree Expand file tree Collapse file tree 4 files changed +14
-22
lines changed
Expand file tree Collapse file tree 4 files changed +14
-22
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1-
2-
31std = 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
164Vec type
175 x: u32
186end
197
208
21- to_string fn(self:Vec)
9+ foo fn(self: Vec)
2210end
2311
2412v = Vec(1)
25- p(v.to_string )
13+ print(v )
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments