Skip to content

Commit

Permalink
feat(#3): add puzzles to atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed May 13, 2024
1 parent 116ed61 commit 93ff6db
Show file tree
Hide file tree
Showing 33 changed files with 278 additions and 15 deletions.
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/as_phi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* As_phi.
* @return {Object} - As_phi object
* @todo #3:30min Implement as_phi atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const as_phi = function() {
const obj = object('as_phi')
Expand Down
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$and.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Bytes.and.
* @return {Object} - Bytes.and object
* @todo #3:30min Implement bytes$and atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$and = function() {
const obj = object('bytes$and')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom bytes$and is not implemented yet`
)
}
return obj
}

module.exports = bytes$and
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.concat.
* @return {Object} - Bytes.concat object
* @todo #3:30min Implement bytes$concat atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$concat = function() {
const obj = object('bytes$concat')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$eq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.eq.
* @return {Object} - Bytes.eq object
* @todo #3:30min Implement bytes$eq atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$eq = function() {
const obj = object('bytes$eq')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$not.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.not.
* @return {Object} - Bytes.not object
* @todo #3:30min Implement bytes$not atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$not = function() {
const obj = object('bytes$not')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$or.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.or.
* @return {Object} - Bytes.or object
* @todo #3:30min Implement bytes$or atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$or = function() {
const obj = object('bytes$or')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$right.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.right.
* @return {Object} - Bytes.right object
* @todo #3:30min Implement bytes$right atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$right = function() {
const obj = object('bytes$right')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$size.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.size.
* @return {Object} - Bytes.size object
* @todo #3:30min Implement bytes$size atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$size = function() {
const obj = object('bytes$size')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.slice.
* @return {Object} - Bytes.slice object
* @todo #3:30min Implement bytes$slice atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$slice = function() {
const obj = object('bytes$slice')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/bytes$xor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Bytes.xor.
* @return {Object} - Bytes.xor object
* @todo #3:30min Implement bytes$xor atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const bytes$xor = function() {
const obj = object('bytes$xor')
Expand Down
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/cage$encaged$encage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Cage.encaged.encage.
* @return {Object} - Cage.encaged.encage object
* @todo #3:30min Implement cage$encaged$encage atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const cage$encaged$encage = function() {
const obj = object('cage$encaged$encage')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom cage$encaged$encage is not implemented yet`
)
}
return obj
}

module.exports = cage$encaged$encage
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/cage$encaged$φ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Cage.encaged.φ.
* @return {Object} - Cage.encaged.φ object
* @todo #3:30min Implement cage$encaged$φ atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const cage$encaged$φ = function() {
const obj = object('cage$encaged$φ')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom cage$encaged$φ is not implemented yet`
)
}
return obj
}

module.exports = cage$encaged$φ
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/cage$φ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Cage.φ.
* @return {Object} - Cage.φ object
* @todo #3:30min Implement cage$φ atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const cage$φ = function() {
const obj = object('cage$φ')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom cage$φ is not implemented yet`
)
}
return obj
}

module.exports = cage$φ
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/dataized.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Dataized.
* @return {Object} - Dataized object
* @todo #3:30min Implement dataized atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const dataized = function() {
const obj = object('dataized')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom dataized is not implemented yet`
)
}
return obj
}

module.exports = dataized
4 changes: 4 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/int$div.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const at_void = require('../../../runtime/attribute/at-void')
/**
* Int.div.
* @return {any} - Int.div object
* @todo #3:30min Resolve division by 0 in int$div atom. The implementation of the atom is not
* complete because of the case with division by 0. We need to implement it and make sure it works.
* For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const int$div = function() {
const obj = object('int$div')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/io/stdin$next_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../../runtime/error/ErFailure');
/**
* Stdin.next_line.
* @return {Object} - Stdin.next_line object
* @todo #3:30min Implement stdin$next_line atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const stdin$next_line = function() {
const obj = object('stdin$next_line')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/io/stdin$φ.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../../runtime/error/ErFailure');
/**
* Stdin.φ.
* @return {Object} - Stdin.φ object
* @todo #3:30min Implement stdin$φ atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const stdin$φ = function() {
const obj = object('stdin$φ')
Expand Down
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/malloc$of$allocated$read.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Malloc.of.allocated.read.
* @return {Object} - Malloc.of.allocated.read object
* @todo #3:30min Implement malloc$of$allocated$read atom. We need to implement the atom and make
* sure it works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const malloc$of$allocated$read = function() {
const obj = object('malloc$of$allocated$read')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom malloc$of$allocated$read is not implemented yet`
)
}
return obj
}

module.exports = malloc$of$allocated$read
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/malloc$of$allocated$write.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Malloc.of.allocated.write.
* @return {Object} - Malloc.of.allocated.write object
* @todo #3:30min Implement malloc$of$allocated$write atom. We need to implement the atom and make
* sure it works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const malloc$of$allocated$write = function() {
const obj = object('malloc$of$allocated$write')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom malloc$of$allocated$write is not implemented yet`
)
}
return obj
}

module.exports = malloc$of$allocated$write
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/malloc$of$φ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Malloc.of.φ.
* @return {Object} - Malloc.of.φ object
* @todo #3:30min Implement malloc$of$φ atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const malloc$of$φ = function() {
const obj = object('malloc$of$φ')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom malloc$of$φ is not implemented yet`
)
}
return obj
}

module.exports = malloc$of$φ
22 changes: 22 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/rust.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const object = require('../../../runtime/object')
const {LAMBDA} = require('../../../runtime/attribute/specials');
const ErFailure = require('../../../runtime/error/ErFailure');

/**
* Rust.
* @return {Object} - Rust object
* @todo #3:30min Implement rust atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const rust = function() {
const obj = object('rust')
obj.assets[LAMBDA] = function(_) {
throw new ErFailure(
`Atom rust is not implemented yet`
)
}
return obj
}

module.exports = rust
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/seq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* Seq.
* @return {Object} - Seq object
* @todo #3:30min Implement seq atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const seq = function() {
const obj = object('seq')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/string$length.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* String.length.
* @return {Object} - String.length object
* @todo #3:30min Implement string$length atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const string$length = function() {
const obj = object('string$length')
Expand Down
3 changes: 3 additions & 0 deletions eo2js-runtime/src/objects/org/eolang/string$slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ErFailure = require('../../../runtime/error/ErFailure');
/**
* String.slice.
* @return {Object} - String.slice object
* @todo #3:30min Implement string$slice atom. We need to implement the atom and make sure it
* works. For the details of implementation check the Java analogue on
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const string$slice = function() {
const obj = object('string$slice')
Expand Down
14 changes: 9 additions & 5 deletions eo2js-runtime/src/objects/org/eolang/try.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const at_void = require('../../../runtime/attribute/at-void')
const {LAMBDA, RHO, DELTA} = require('../../../runtime/attribute/specials');
const {LAMBDA, DELTA} = require('../../../runtime/attribute/specials');
const ErError = require('../../../runtime/error/ErError');

/**
* Try.
* @return {Object} - Try object
* @todo #3:30min Fix implementation of "try" atom. Current implementation of "try" atom is wrong
* because "try" dataizes its body right inside lambda asset. Instead lambda asset should return
* new special object that dataizes body and catches exception when some attribute is taken from
* it. For the details of implementation check the Java analogue on:
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang
*/
const _try = function() {
const obj = object('try')
Expand All @@ -16,19 +21,18 @@ const _try = function() {
obj.assets[LAMBDA] = function(self) {
let ret
try {
ret = self.take('main').copy().with({[RHO]: self})
ret = self.take('main')
ret.assets[DELTA] = dataized(ret)
} catch (error) {
if (error instanceof ErError) {
ret = self.take('catch').copy().with({
[RHO]: self,
ret = self.take('catch').with({
0: error.enclosure
})
} else {
throw error
}
} finally {
dataized(self.take('finally').copy().with({[RHO]: self}))
dataized(self.take('finally'))
}
return ret
}
Expand Down
Loading

0 comments on commit 93ff6db

Please sign in to comment.