Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #72 from MoeOrganization/prakashk/logical-eq-rel-ops
More operators for ints/strings (take 2)
- Loading branch information
Showing
15 changed files
with
485 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.moe.runtime | ||
|
||
import org.moe.interpreter._ | ||
import org.moe.runtime._ | ||
import org.moe.ast._ | ||
|
||
/** | ||
* MoeLazyEval: Class for wrapping an AST node whose evaluation is deferred. | ||
* | ||
*/ | ||
|
||
class MoeLazyEval ( | ||
interpreter: Interpreter, | ||
runtime: MoeRuntime, | ||
env: MoeEnvironment, | ||
node: AST | ||
) extends MoeObject { | ||
def eval = { | ||
println("lazy eval - " + Serializer.toJSONPretty(node)) | ||
interpreter.eval(runtime, env, node) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
src/main/scala/org/moe/runtime/nativeobjects/MoeBoolObject.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
package org.moe.runtime.nativeobjects | ||
|
||
import org.moe.runtime._ | ||
import org.moe.runtime.nativeobjects._ | ||
|
||
import scala.util.{Try, Success, Failure} | ||
|
||
class MoeBoolObject( | ||
v: Boolean, klass : Option[MoeClass] = None | ||
) extends MoeNativeObject[Boolean](v, klass) { | ||
|
||
// MoeObject overrides | ||
// runtime methods | ||
|
||
def toInt: Int = if (getNativeValue) 1 else 0 | ||
|
||
override def isFalse: Boolean = getNativeValue == false | ||
override def toString: String = if (getNativeValue) "true" else "false" | ||
} | ||
|
||
// unboxing | ||
|
||
override def unboxToInt: Try[Int] = Try(toInt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.