aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/elymasLexer.ey2
-rw-r--r--compiler/standardClient.ey2
-rw-r--r--interpreter/ElymasSys.pm53
3 files changed, 4 insertions, 53 deletions
diff --git a/compiler/elymasLexer.ey b/compiler/elymasLexer.ey
index 2929285..411e7ad 100644
--- a/compiler/elymasLexer.ey
+++ b/compiler/elymasLexer.ey
@@ -43,7 +43,7 @@
{ /input defv
"" {
- 4096 input .readstr cat
+ 4096 input .read cat
_ "" streq not
} {
{ _ "([^\\n]*)\\n(.*)" regex } { -102 -- TOKINT TOKSTR TOKID elymas .tokenize {
diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey
index 2d62826..b92d5a4 100644
--- a/compiler/standardClient.ey
+++ b/compiler/standardClient.ey
@@ -428,7 +428,7 @@
} /writeall deff
{ =*f "" ==buffer
{
- buffer 4096 read cat =buffer # FIXME interpreter API should also have .read defined as returning string
+ buffer 4096 read cat =buffer
buffer "" streq not
} {
buffer "\n" str .split ==lines
diff --git a/interpreter/ElymasSys.pm b/interpreter/ElymasSys.pm
index 9cb07d4..ad79b02 100644
--- a/interpreter/ElymasSys.pm
+++ b/interpreter/ElymasSys.pm
@@ -71,56 +71,8 @@ sub createFile {
my $ret = POSIX::read($$scope->{' fd'}->[0], $buf, $count);
die "read failed: $!" unless defined $ret;
- $buf = [map { [ord, 'int'] } split //, $buf];
-
- push @$data, [$buf, ['array', '[]', [['range', 0, $#{$buf}]], ['int']]];
- }, ['func', 'sys .file .read'], 'active'],
- 'readall' => [sub {
- my ($data) = @_;
-
- die "file not open" if $$scope->{' fd'}->[0] == -1;
-
- my $count = popInt($data);
-
- my $buf = [];
- while($count) {
- my $readbuf;
- my $ret = POSIX::read($$scope->{' fd'}->[0], $readbuf, $count);
- die "read failed: $!" unless defined $ret;
-
- $buf = [@$buf, map { [ord, 'int'] } split //, $readbuf];
- $count -= $ret;
- }
-
- push @$data, [$buf, ['array', '[]', [['range', 0, $#{$buf}]], ['int']]];
- }, ['func', 'sys .file .read'], 'active'],
- 'readstr' => [sub {
- # FIXME: give the file an encoding and respect it here, buffering half-characters if needed
- my ($data) = @_;
-
- die "file not open" if $$scope->{' fd'}->[0] == -1;
-
- my $count = popInt($data);
-
- my $buf;
- my $ret = POSIX::read($$scope->{' fd'}->[0], $buf, $count);
- die "read failed: $!" unless defined $ret;
-
push @$data, [$buf, 'string'];
- }, ['func', 'sys .file .readstr'], 'active'],
- 'write' => [sub {
- my ($data) = @_;
-
- die "file not open" if $$scope->{' fd'}->[0] == -1;
-
- my $buf = popArray($data);
- $buf = join '', map { chr($_->[0]) } @$buf;
-
- my $ret = POSIX::write($$scope->{' fd'}->[0], $buf, length $buf);
- die "write failed: $!" unless defined $ret;
-
- push @$data, [$ret, 'int'];
- }, ['func', 'sys .file .write'], 'active'],
+ }, ['func', 'sys .file .read'], 'active'],
'writeall' => [sub {
my ($data) = @_;
@@ -135,8 +87,7 @@ sub createFile {
$buf = substr($buf, $ret);
}
}, ['func', 'sys .file .writeall'], 'active'],
- 'writestr' => [sub {
- # FIXME: give the file an encoding and respect it here
+ 'write' => [sub {
my ($data) = @_;
die "file not open" if $$scope->{' fd'}->[0] == -1;