aboutsummaryrefslogtreecommitdiff
path: root/interpreter/ElymasLinux.pm
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2012-12-08 14:29:18 +0100
committerDrahflow <drahflow@gmx.de>2012-12-08 14:29:18 +0100
commit74f3f1354afe9b6fe866527a1de2a8d16d1210b8 (patch)
treeb98303d84e99ab1829410ae38317c27c911217b5 /interpreter/ElymasLinux.pm
Initial commit
Diffstat (limited to 'interpreter/ElymasLinux.pm')
-rw-r--r--interpreter/ElymasLinux.pm58
1 files changed, 58 insertions, 0 deletions
diff --git a/interpreter/ElymasLinux.pm b/interpreter/ElymasLinux.pm
new file mode 100644
index 0000000..1718060
--- /dev/null
+++ b/interpreter/ElymasLinux.pm
@@ -0,0 +1,58 @@
+package ElymasLinux;
+
+use strict;
+use warnings;
+
+use Elymas;
+
+use POSIX ();
+
+our $linux = {
+ 'open' => [sub {
+ my ($data, $scope) = @_;
+
+ my $mode = popInt($data);
+ my $flags = popInt($data);
+ my $pathname = popString($data);
+
+ my $fd = POSIX::open($pathname, $flags, $mode);
+ $fd = -1 unless defined $fd;
+
+ push @$data, [$fd, 'int'];
+ }, ['func', 'linux .open'], 'active'],
+ 'close' => [sub {
+ my ($data, $scope) = @_;
+
+ my $fd = popInt($data);
+
+ my $ret = POSIX::close($fd);
+ $ret = -1 unless defined $ret;
+
+ push @$data, [$ret, 'int'];
+ }, ['func', 'linux .close'], 'active'],
+# 'read' => [sub {
+# my ($data, $scope) = @_;
+#
+# my $count = popInt($data);
+# my $buf = popArray($data);
+# my $fd = popInt($data);
+#
+# my $ret = POSIX::close($fd);
+# $ret = -1 unless defined $ret;
+#
+# push @$data, [$ret, 'int'];
+# }, ['func', 'linux .read'], 'active'],
+};
+
+map { installIntConstant($_) } qw(O_RDONLY O_RDWR O_WRONLY);
+
+sub installIntConstant {
+ my ($name) = @_;
+
+ my $elymasName = $name;
+ $elymasName =~ s/_//g;
+
+ $linux->{$elymasName} = [${$POSIX::{$name}}, 'int', 'passive'];
+}
+
+1;