Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic test of STDIN, and hacky first version of IO#getc
- Loading branch information
Showing
5 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
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 @@ | ||
puts STDIN.getc |
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 @@ | ||
116 |
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 |
---|---|---|
@@ -1,11 +1,31 @@ | ||
|
||
class IO < Object | ||
def initialize | ||
# %s(puts "IO.new") | ||
end | ||
|
||
def getc | ||
c = 0 | ||
tmp = 0 | ||
|
||
# FIXME: This code is specific to a 32 bit little endian | ||
# arch, and is also horribly inefficient because we don't | ||
# have an easy way of getting the address of a stack allocated | ||
# variable. | ||
%s(do | ||
(assign tmp (malloc 4)) | ||
(assign (index tmp 0) 0) | ||
(read 0 tmp 1) | ||
(assign c (__get_fixnum (index tmp 0))) | ||
(free tmp) | ||
) | ||
c | ||
end | ||
|
||
def file? | ||
end | ||
|
||
def path | ||
end | ||
|
||
end |