FlatLang / Flat

(Deprecated) Soon-to-be legacy Flat compiler all in one
6 stars 0 forks source link

Add `lazy` parameter support #436

Open BSteffaniak opened 2 years ago

BSteffaniak commented 2 years ago

Where this is transformed from this:

public trace(lazy Object value, Bool: newLine = true) {
  if (loggingLevel >= TRACE) {
    let content = formatContent(value.toString(), TRACE)
    logMessage(getPrefix(TRACE) + content, "log", newLine)
  }
}

to:

public trace(value() -> Object, Bool: newLine = true) {
  let __value = null
  if (loggingLevel >= TRACE) {
    let content = formatContent((__value || value()).toString(), TRACE)
    logMessage(getPrefix(TRACE) + content, "log", newLine)
  }
}

and transforms call like this:

thing() {
  log.trace("Checked \"#{location}\" against pattern #pattern: #matches")
}

to:

thing() {
  log.trace({ "Checked \"#{location}\" against pattern #pattern: #matches" })
}