Skip to content

Commit

Permalink
fixed instance caching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sealmove committed Nov 14, 2021
1 parent 2d53160 commit 9878485
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class NimClassCompiler(
lang.attrParse(pi, instName, endian)
}

lang.instanceCheckCacheAndReturn(instName, dataType)
lang.instanceReturn(instName, dataType)
lang.instanceFooter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,9 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
handleAssignmentSimple(instName, cast)
}
override def instanceCheckCacheAndReturn(instName: InstanceIdentifier, dataType: DataType): Unit = {
//out.puts(s"if not ${privateMemberName(instanceFlagIdentifier(instName))}:")
val flag = instanceFlagIdentifier(instName)
out.puts(s"if not this.$flag:")
out.puts(s"if this.${instanceFlagIdentifier(instName)}:")
out.inc
out.puts(s"this.$flag = true")
instanceReturn(instName, dataType)
out.puts(s"return ${privateMemberName(instName)}")
out.dec
}
override def instanceHeader(className: List[String], instName: InstanceIdentifier, dataType: DataType, isNullable: Boolean): Unit = {
Expand All @@ -241,6 +238,7 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts
}
override def instanceReturn(instName: InstanceIdentifier, attrType: DataType): Unit = {
out.puts(s"this.${instanceFlagIdentifier(instName)} = true")
out.puts(s"return ${privateMemberName(instName)}")
}
// def normalIO: String = ???
Expand Down

0 comments on commit 9878485

Please sign in to comment.