Skip to content

Commit

Permalink
feat(#3251): arguments with self
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Sep 5, 2024
1 parent 3a65107 commit ec86f74
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/sys/posix.eo
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
# Timeval structure for "gettimeofday" syscall.
# Here `tv-sec` is seconds since Jan 1, 1970, and `tv-usec` - microseconds.
[tv-sec tv-usec] > timeval
$ > self
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/sys/win32.eo
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@

# Structure for "GetSystemTime" function call.
[year month day day-of-week hour minute second milliseconds] > system-time
$ > self
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public Phi make(final Phi... params) {
final Phi result = this.posix.take("return").copy();
final GettimeofdaySyscall.Timeval timeval = new GettimeofdaySyscall.Timeval();
result.put(0, new Data.ToPhi(CStdLib.INSTANCE.gettimeofday(timeval, null)));
params[0].put(0, new Data.ToPhi(timeval.sec));
params[0].put(1, new Data.ToPhi(timeval.usec));
result.put(1, params[0]);
final Phi struct = params[0].take("self");
struct.put(0, new Data.ToPhi(timeval.sec));
struct.put(1, new Data.ToPhi(timeval.usec));
result.put(1, struct);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ public Phi make(final Phi... params) {
final GetSystemTimeFuncCall.SystemTime time = new GetSystemTimeFuncCall.SystemTime();
Kernel32.INSTANCE.GetSystemTime(time);
result.put(0, new Data.ToPhi(true));
params[0].put(0, new Data.ToPhi(time.year));
params[0].put(1, new Data.ToPhi(time.month));
params[0].put(2, new Data.ToPhi(time.day));
params[0].put(3, new Data.ToPhi(time.dayOfWeek));
params[0].put(4, new Data.ToPhi(time.hour));
params[0].put(5, new Data.ToPhi(time.minute));
params[0].put(6, new Data.ToPhi(time.second));
params[0].put(7, new Data.ToPhi(time.milliseconds));
result.put(1, params[0]);
final Phi struct = params[0].take("self");
struct.put(0, new Data.ToPhi(time.year));
struct.put(1, new Data.ToPhi(time.month));
struct.put(2, new Data.ToPhi(time.day));
struct.put(3, new Data.ToPhi(time.dayOfWeek));
struct.put(4, new Data.ToPhi(time.hour));
struct.put(5, new Data.ToPhi(time.minute));
struct.put(6, new Data.ToPhi(time.second));
struct.put(7, new Data.ToPhi(time.milliseconds));
result.put(1, struct);
return result;
}

Expand Down

0 comments on commit ec86f74

Please sign in to comment.