Skip to content

Commit

Permalink
Merge with develop and restored the NullValue class for managing unas…
Browse files Browse the repository at this point in the history
…sign variables on program calls.
  • Loading branch information
foresti-smeup committed Jan 25, 2024
1 parent 60b1d46 commit c2a4243
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class InterpreterStatus(
fun indicator(key: IndicatorKey) = indicators[key] ?: BooleanValue.FALSE
fun getVar(abstractDataDefinition: AbstractDataDefinition): Value {
val tmpValue = symbolTable[abstractDataDefinition]
if (tmpValue is VoidValue) {
if (tmpValue is NullValue) {
throw IllegalArgumentException("Void value for ${abstractDataDefinition.name}")
}
return tmpValue
Expand Down Expand Up @@ -279,7 +279,7 @@ open class InternalInterpreter(
if (it is DataDefinition) {
try {
val tmpValue = globalSymbolTable[it]
if (tmpValue !is VoidValue) {
if (tmpValue !is NullValue) {
it.defaultValue = tmpValue.copy()
}
} catch (exc: IllegalArgumentException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class RpgProgram(val cu: CompilationUnit, val name: String = "<UNNAMED RPG PROGR
"Expected params: ${params().asSequence().map { it.name }.joinToString(", ")}"
}

// Set not passed params to VoidValue
// Set not passed params to NullValue
params().forEach {
if (it.name !in params.keys) {
params[it.name] = VoidValue
params[it.name] = NullValue
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,22 @@ object BlanksValue : Value {
}
}

object NullValue : Value {
override fun toString(): String {
return "NullValue"
}

override fun assignableTo(expectedType: Type): Boolean {
return true
}

override fun copy(): NullValue = this

override fun asString(): StringValue {
return StringValue(this.toString())
}
}

object HiValValue : Value {
private val MAX_INT = IntValue(Long.MAX_VALUE)

Expand Down Expand Up @@ -1038,18 +1054,17 @@ fun areEquals(value1: Value, value2: Value): Boolean {

@Serializable
object VoidValue : Value {
override fun toString(): String {
return "VoidValue"

override fun asString(): StringValue {
TODO("Not yet implemented")
}

override fun assignableTo(expectedType: Type): Boolean {
return true
TODO("Not yet implemented")
}

override fun copy(): VoidValue = this

override fun asString(): StringValue {
return StringValue(this.toString())
override fun copy(): Value {
TODO("Not yet implemented")
}
}

Expand Down

0 comments on commit c2a4243

Please sign in to comment.