Migration of Empires

Dan Korostelev (@nadako)

Team before me

Team before me

  • Settled with Haxe/OpenFL
  • Made as3hx work
  • Developed a "continous conversion" pipeline

Issues

  • OpenFL HTML5 performance ✔️
  • Flash/OpenFL behaviour inconsistencies ✔️
  • Complex building pipeline 🤷
  • Still AS3 source code 🤷‍♂️

Problems with as3hx

  • OK for compiling, bad for developing
  • Syntax-only AST
  • Comments/whitespace are AST nodes
  • Typing is very complicated
    • done on writing
    • no typed program representation
    • hard to transform the code

New converter: full-fidelity parsing

New converter: typed tree

New converter: SWC support

  • Load signatures from the ABC bytecode
  • ...into the same typed tree structure (dummy tokens)
  • Thanks, format library!

New converter: Type annotations

  • Override field, local and argument types
  • Strict Array/Dictionary/Function types
  • Supported in both AS3 and SWC

New converter: filters

  • Adapt AS3 code for Haxe
  • Insert missing type conversion
  • Remove redundant code (e.g useless casts)

New converter: output

  • Prints the filtered typed tree
  • ...with the comments and whitespace

AS3

Haxe (formatted)

Encapsulated Reflection

  • */Object -> ASAny/ASObject
  • Overriden property access and type conversions

  • Thanks, abstracts! \o/

It works! :)

  • HTML5 via JS and OpenFL 
  • Flash via SWF and SWC libs
  • AS3 is only used for conversion

 

...converter is fully in Haxe/JVM

Using the Flash target

  • Still relevant (payers on potatos) 
  • Using original SWCs (for now)
  • Had to fix compiler a bit
    • bytecode issues
    • flash properties
    • more interop (e.g. Vector)

Next step: full Haxe!

  • Final touches on code conversion style
  • Prepare dev environment
  • Educate the teams
  • Help other projects

Haxe 4

  • Compiler cache finally reliable!
  • IDE services work...
  • ...but are slow :(

Thank you!

Questions?

Migration of Empires

By Dan Korostelev

Migration of Empires

  • 1,455