Skip to content

Commit

Permalink
Merge pull request #257 from kaitai-io/nim-to-string
Browse files Browse the repository at this point in the history
Implement classToString for Nim
  • Loading branch information
GreyCat authored Oct 11, 2023
2 parents bc6fb85 + c1b7358 commit 6e841b7
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts
}

override def classToString(toStringExpr: Ast.expr): Unit = {
out.puts
out.puts(s"proc `$$`(x: ${namespaced(typeProvider.nowClass.name)}): string =")
out.inc
out.puts(s"return ${translator.translate(toStringExpr)}")
out.dec
out.puts
}

override def opaqueClassDeclaration(classSpec: ClassSpec): Unit =
out.puts("import \"" + classSpec.name.head + "\"")
override def innerEnums = false
Expand Down

0 comments on commit 6e841b7

Please sign in to comment.