Skip to content
Snippets Groups Projects
Std.amy 1014 B
/** This module contains basic functionality for Amy,
  * including stub implementations for some built-in functions
  * (implemented in WASM or JavaScript)
  */
object Std 
  def printInt(i: Int(32)): Unit = {
    error("") // Stub implementation
  }
  def printString(s: String): Unit = {
    error("") // Stub implementation
  }
  def printBoolean(b: Boolean): Unit = {
    printString(booleanToString(b))
  }

  def readString(): String = {
    error("") // Stub implementation
  }

  def readInt(): Int(32) = {
    error("") // Stub implementation
  }

  def intToString(i: Int(32)): String = {
    if (i < 0) {
      "-" ++ intToString(-i)
    } else {
      val rem: Int(32) = i % 10;
      val div: Int(32) = i / 10;
      if (div == 0) { digitToString(rem) }
      else { intToString(div) ++ digitToString(rem) }
    }
  }
  def digitToString(i: Int(32)): String = {
    error("") // Stub implementation
  }
  def booleanToString(b: Boolean): String = {
    if (b) { "true" } else { "false" }
  }
end Std