well redesigned class vals and vars, classScope introduced for class functions
This commit is contained in:
parent
63b2808109
commit
2c2dae4d85
@ -1655,7 +1655,6 @@ class Compiler(
|
|||||||
// return
|
// return
|
||||||
currentInitScope += statement {
|
currentInitScope += statement {
|
||||||
val initValue = initialExpression?.execute(this)?.byValueCopy() ?: ObjNull
|
val initValue = initialExpression?.execute(this)?.byValueCopy() ?: ObjNull
|
||||||
// todo: get rid of classfield!
|
|
||||||
(thisObj as ObjClass).createClassField(name, initValue, isMutable, visibility, pos)
|
(thisObj as ObjClass).createClassField(name, initValue, isMutable, visibility, pos)
|
||||||
addItem(name, isMutable, initValue, visibility, ObjRecord.Type.Field)
|
addItem(name, isMutable, initValue, visibility, ObjRecord.Type.Field)
|
||||||
ObjVoid
|
ObjVoid
|
||||||
|
@ -44,6 +44,7 @@ class CompilerContext(val tokens: List<Token>) {
|
|||||||
if (type != it.type) throw ScriptError(it.pos, message)
|
if (type != it.type) throw ScriptError(it.pos, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
fun syntaxError(at: Pos, message: String = "Syntax error"): Nothing {
|
fun syntaxError(at: Pos, message: String = "Syntax error"): Nothing {
|
||||||
throw ScriptError(at, message)
|
throw ScriptError(at, message)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
scope.raiseIllegalArgument("serialized vars has bigger size than instance vars")
|
scope.raiseIllegalArgument("serialized vars has bigger size than instance vars")
|
||||||
println("deser state vars $vars")
|
println("deser state vars $vars")
|
||||||
for ((i, v) in vars.withIndex()) {
|
for ((i, v) in vars.withIndex()) {
|
||||||
localVars[i].value = vars[i]
|
localVars[i].value = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user