Last active
April 17, 2016 00:54
-
-
Save yorickpeterse/cb5b1f58d7f10a4d3b96f24e28b87d77 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
aeon $ cat -n /tmp/test.aeon | |
1 class Integer: | |
2 # Overwrites the default prototype with the actual integer prototype. | |
3 __set_literal_attr(self, __get_integer_prototype(_), '__prototype') | |
4 | |
5 def +(other): | |
6 __integer_add(_, self, other) | |
7 | |
8 def -(other): | |
9 __integer_sub(_, self, other) | |
10 | |
11 def /(other): | |
12 __integer_div(_, self, other) | |
13 | |
14 def to_string: | |
15 __integer_to_string(_, self) | |
16 | |
17 def to_float: | |
18 __integer_to_float(_, self) | |
19 | |
20 class Float: | |
21 __set_literal_attr(self, __get_float_prototype(_), '__prototype') | |
22 | |
23 def +(other): | |
24 __float_add(_, self, other) | |
25 | |
26 def to_string: | |
27 __float_to_string(_, self) | |
28 | |
29 class STDOUT: | |
30 def self.print(message): | |
31 __stdout_write(_, message.to_string) | |
32 | |
33 class String: | |
34 __set_literal_attr(self, __get_string_prototype(_), '__prototype') | |
35 | |
36 def to_string: | |
37 self | |
38 | |
39 let sum = ((10 + 20 - 2) / 2).to_float + 0.5 | |
40 | |
41 STDOUT.print(sum) | |
42 STDOUT.print("\n") | |
43 | |
44 # vim: set ft=aeon sts=2 sw=2 ts=2: | |
aeon $ ruby bootstrap/bin/compile /tmp/test.aeon | |
aeon $ cargo run -- /tmp/test.aeonc | |
Running `target/debug/aeonvm /tmp/test.aeonc` | |
14.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment