well redesigned class vals and vars, classScope introduced for class functions

This commit is contained in:
Sergey Chernov 2025-08-06 11:47:45 +03:00
parent 63b2808109
commit 2c2dae4d85
3 changed files with 2 additions and 2 deletions

View File

@ -1655,7 +1655,6 @@ class Compiler(
// return
currentInitScope += statement {
val initValue = initialExpression?.execute(this)?.byValueCopy() ?: ObjNull
// todo: get rid of classfield!
(thisObj as ObjClass).createClassField(name, initValue, isMutable, visibility, pos)
addItem(name, isMutable, initValue, visibility, ObjRecord.Type.Field)
ObjVoid

View File

@ -44,6 +44,7 @@ class CompilerContext(val tokens: List<Token>) {
if (type != it.type) throw ScriptError(it.pos, message)
}
@Suppress("unused")
fun syntaxError(at: Pos, message: String = "Syntax error"): Nothing {
throw ScriptError(at, message)
}

View File

@ -81,7 +81,7 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
scope.raiseIllegalArgument("serialized vars has bigger size than instance vars")
println("deser state vars $vars")
for ((i, v) in vars.withIndex()) {
localVars[i].value = vars[i]
localVars[i].value = v
}
}
}