Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 5, 2024
2 parents 9804e1d + d9c5cd0 commit ee476c7
Show file tree
Hide file tree
Showing 35 changed files with 597 additions and 1,369 deletions.
4 changes: 3 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# are not available for the project. For example a lot of
# package name contains capital letter and such names are conventional.
exclude_paths:
- "eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOnew.java"
- "eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOfree.java"
- "eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java"
- "eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java"
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void containsObject(@TempDir final Path home) throws IOException {
@Test
void containsObjectWithDefaultHome(@TempDir final Path home) throws IOException {
final OyFilesystem objectionary = new OyFilesystem();
final String object = "org.eolang.ram";
final String object = "org.eolang.malloc";
OyFilesystemTest.save(object, home);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
Expand Down
3 changes: 2 additions & 1 deletion eo-runtime/src/main/eo/org/eolang/const.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

# Dataizes given `object`, makes new `bytes` from the data and behaves as given `bytes`.
[object] > const
memory.alloc object > cached
(memory object).alloc > cached

# Object for using the cached one.
[] > make
^.cached > @
27 changes: 12 additions & 15 deletions eo-runtime/src/main/eo/org/eolang/go.eo
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,30 @@
# ```
# Go to.
[] > go
memory.alloc 0 > counter
(malloc 1).id.as-bytes > id

# To.
[body] > to
seq > @
*
counter.write (counter.as-int.plus 1) > id!
try > iteration
body token
[e]
if > @
id.eq e.id
e.value
error e
TRUE
try > @
body token
[e]
if > @
&.^.id.eq e.id
e.value
error e
TRUE

# Token.
[] > token
# Backward jump.
error > backward
[]
&.^.iteration > value
&.^.id > id
&.^.@ > value
&.^.^.id > id

# Forward jump.
[res] > forward
error > @
[]
res > value
&.^.^.id > id
&.^.^.^.id > id
80 changes: 0 additions & 80 deletions eo-runtime/src/main/eo/org/eolang/heap.eo

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,33 @@
+rt jvm org.eolang:eo-runtime:0.0.0
+version 0.0.0

# Random-access memory (RAM).
[size] > ram
# Write bytes from position.
[position data] > write /true
# Allocates a block in memory of `size` bytes.
# You can use it like:
# ```
# (malloc 8).pointer > p
# seq
# *
# p.write 0 42 # write 8 bytes integer with offset 0
# p.read # read from memory, 42 will be returned
# p.free # free allocated block
# ```
# Clearing the block is optional and is up to programmer.
[size] > malloc
@.pointer > pointer

# Slice fixed size of bytes from position.
[position size] > slice /ram-slice
# Allocates a memory block in RAM and returns pointer to it.
[] > @ /memory-block-pointer

# Slice fixed size of bytes from position.
[position size] > ram-slice
# Fixed sliced bytes from position.
[] > @ /bytes
# Pointer to allocated block in memory.
# Here `id` is identifier of pointer, `size` is length of the block.
[id size] > memory-block-pointer
$ > pointer

# Write bytes to memory from position, according to the ram.slice object.
[data] > write /bytes
# Read `bytes` from the block in memory by the pointer.
[] > read /bytes

# Write `data` from `offset` to the block in memory by the pointer.
[offset data] > write /true

# Free the block in memory by the pointer.
[] > free /true
37 changes: 34 additions & 3 deletions eo-runtime/src/main/eo/org/eolang/memory.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,37 @@
+version 0.0.0

# Storage of data in memory.
[] > memory
# Allocate data in memory segment.
[data] > alloc /?
# You can use it like this:
# ```
# [] > obj
# 5 > @
# (memory obj).alloc > m
# seq > @
# *
# m.write 42 # write 8 bytes integer to memory
# m # dataization leads to reading from memory
# m.@ # taking @ attribute also leads to reading from memory
# m.free # clear memory
# ```
# Clearing the memory is optional and is up to programmer.
[data] > memory
@.alloc > alloc

# Allocate data in memory and return `allocated`.
[] > @ /allocated

# Data allocated in memory.
[pointer] > allocated
$ > alloc
pointer.read > @

# Write data into memory
[data] > write
seq > @
*
^.pointer.write 0 data
^.pointer.read

# Free memory.
[] > free
^.pointer.free > @
105 changes: 0 additions & 105 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOheap$EOpointer$EOblock.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,37 @@
*/
package EOorg.EOeolang;

import org.eolang.AtVoid;
import org.eolang.Atom;
import org.eolang.Attr;
import org.eolang.Data;
import org.eolang.Param;
import org.eolang.PhDefault;
import org.eolang.Phi;
import org.eolang.Versionized;
import org.eolang.XmirObject;

/**
* Slice fixed size of bytes from position.
* @since 0.25
* Malloc.pointer.free object.
*
* @since 0.36.0
* @checkstyle TypeNameCheck (5 lines)
*/
@Versionized
@XmirObject(oname = "ram.slice")
public final class EOram$EOslice extends PhDefault implements Atom {
@XmirObject(oname = "malloc.pointer.free")
public final class EOmalloc$EOmemory_block_pointer$EOfree extends PhDefault implements Atom {
/**
* Ctor.
* @param sigma Sigma
*/
public EOram$EOslice(final Phi sigma) {
public EOmalloc$EOmemory_block_pointer$EOfree(final Phi sigma) {
super(sigma);
this.add("position", new AtVoid("position"));
this.add("size", new AtVoid("size"));
}

@Override
public Phi lambda() {
final Phi rho = this.take(Attr.RHO);
final Phi slice = rho.take("ram-slice").copy();
slice.put("position", this.take("position"));
slice.put("size", this.take("size"));
return slice;
Heaps.INSTANCE.get().free(
new Param(this.take(Attr.RHO), "id").strong(Long.class).intValue()
);
return new Data.ToPhi(true);
}
}
Loading

3 comments on commit ee476c7

@0pdd
Copy link

@0pdd 0pdd commented on ee476c7 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2931-7e7e24f4 disappeared from eo-runtime/src/test/eo/org/eolang/heap-tests.eo), that's why I closed #3002. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on ee476c7 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2931-f14b83fe disappeared from eo-runtime/src/test/eo/org/eolang/ram-tests.eo), that's why I closed #3006. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on ee476c7 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3002-687bf80a discovered in eo-runtime/src/test/eo/org/eolang/goto-tests.eo) and submitted as #3055. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.