-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new concept of "compiler operations" + @new
"Compiler Operations" are prefixed by @, they are not functions and just compile-time syntax sugar for common operations. In the instance of @new, it is a shorthand for taking the expression, creating enough space in the heap to put in the result, and storing the result there, and returning that pointer.
- Loading branch information
1 parent
e2e52a4
commit 794fc08
Showing
13 changed files
with
4,004 additions
and
3,710 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// fail: Cannot use `@new` on a pointer type | ||
|
||
struct Foo { | ||
a: i32 | ||
} | ||
|
||
def main() { | ||
let f: Foo | ||
let g = @new &f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// out: "5 10 12 15 20" | ||
|
||
struct BST { | ||
x: u32 | ||
l: &BST | ||
r: &BST | ||
} | ||
|
||
def BST::print(&this) { | ||
if not this? { | ||
return | ||
} | ||
.l.print() | ||
print(`{.x} `) | ||
.r.print() | ||
} | ||
|
||
def main() { | ||
let tree = @new BST( | ||
10, | ||
l: @new BST(5, null, null), | ||
r: @new BST( | ||
15, | ||
l: @new BST(12, null, null), | ||
r: @new BST(20, null, null) | ||
) | ||
) | ||
tree.print() | ||
} |