package Ġcom . j tran sc . gen . as 3 Ċ Ċ import Ġcom . j tran sc . Config OutputFile Ċ import Ġcom . j tran sc . Config Target Directory Ċ import Ġcom . j tran sc . ast .* Ċ import Ġcom . j tran sc . ast . feature . method . G otos Feature Ċ import Ġcom . j tran sc . ast . feature . method . Switch Feature Ċ import Ġcom . j tran sc . error . invalid Op Ċ import Ġcom . j tran sc . gen . Gen Target Descriptor Ċ import Ġcom . j tran sc . gen . Target Build Target Ċ import Ġcom . j tran sc . gen . common .* Ċ import Ġcom . j tran sc . injector . Injector Ċ import Ġcom . j tran sc . injector . Singleton Ċ import Ġcom . j tran sc . io . Process Result 2 Ċ import Ġcom . j tran sc . lang . map Ċ import Ġcom . j tran sc . text . Ind enter Ċ import Ġcom . j tran sc . text . Ind enter . Companion Ċ import Ġcom . j tran sc . text . quote Ċ import Ġcom . j tran sc . vfs .* Ċ import Ġjava . io . File Ċ Ċ // ĠSupports ĠGOTO Ġkeyword Ċ // ĠSupports Ġstatic Ġfields Ġand Ġmethods Ġon Ġinterfaces Ċ class ĠAs 3 Target Ġ: ĠGen Target Descriptor () Ġ{ Ċ ĉ override Ġval Ġname Ġ= Ġ" as 3 " Ċ ĉ override Ġval Ġlong Name Ġ= Ġ" Action Script 3 " Ċ ĉ override Ġval Ġsource Extension Ġ= Ġ" as " Ċ ĉ override Ġval Ġoutput Extension Ġ= Ġ" sw f " Ċ ĉ override Ġval Ġextra Libraries Ġ= ĠlistOf < String >() Ċ ĉ override Ġval Ġextra Classes Ġ= ĠlistOf < String >() Ċ ĉ override Ġval Ġrunning Available Ġ= Ġtrue Ċ ĉ override Ġval Ġprogram Features : ĠSet < Class < Ast Program Feature >> Ġ= Ġset Of () ĊĊ ĉ override Ġval Ġbuild Targets : ĠList < Target Build Target > Ġ= ĠlistOf ( Ċĉ ĉ Target Build Target (" as 3 ", Ġ" as 3 ", Ġ" program . as ", Ġminimize Names Ġ= Ġfalse ) Ċ ĉ ) ĊĊ ĉ @ Suppress (" Convert Lambda To Reference ") Ċ ĉ override Ġfun Ġget Generator ( injector : ĠInject or ): ĠCommon Generator Ġ{ Ċĉ ĉ val Ġsettings Ġ= Ġinjector . get < Ast Build Settings >() Ċĉ ĉ val Ġconfig Target Directory Ġ= Ġinjector . get < Config Target Directory >() Ċĉ ĉ val Ġconfig OutputFile Ġ= Ġinjector . get < Config OutputFile >() Ċĉ ĉ val Ġtarget Folder Ġ= ĠLocal V fs Ensure Dirs ( File ("${ config Target Directory . target Directory }/ j tran sc - as 3 ")) Ċĉ ĉ injector . map Instance ( Common Gen Folders ( settings . assets . map Ġ{ ĠLocal V fs ( it ) Ġ})) Ċĉ ĉ injector . map Instance ( Config Target Folder ( target Folder )) Ċĉ ĉ injector . map Instance ( Config Src Folder ( target Folder )) Ċĉ ĉ injector . map Instance ( Config OutputFile 2 ( target Folder [ config OutputFile . outputFile Base Name ]. real file )) Ċĉ ĉ return Ġinjector . get < As 3 Generator >() Ċ ĉ } ĊĊ ĉ override Ġfun Ġget Target By Extension ( ext : ĠString ): ĠString ? Ġ= Ġwhen Ġ( ext ) Ġ{ Ċĉ ĉ " sw f " Ġ-> Ġ" as 3 " Ċĉ ĉ else Ġ-> Ġnull Ċ ĉ } Ċ } Ċ Ċ @ Singleton Ċ class ĠAs 3 Generator ( injector : ĠInject or ) Ġ: ĠCommon Generator ( injector ) Ġ{ Ċ ĉ override Ġval ĠS INGLE _ FILE : ĠBoolean Ġ= Ġfalse ĊĊ ĉ // class ĠD Generator ( injector : ĠInject or ) Ġ: ĠFile Per Class Common Generator ( injector ) Ġ{ Ċ ĉ override Ġval Ġmethod Features Ġ= Ġset Of ( Switch Feature :: class . java , ĠG otos Feature :: class . java ) Ċ ĉ override Ġval Ġmethod Feature sWith Tr aps Ġ= Ġset Of ( Switch Feature :: class . java ) Ċ ĉ override Ġval Ġstring Pool Type : ĠString Pool . Type Ġ= ĠString Pool . Type . GLOBAL Ċ ĉ override Ġval Ġinterfaces Support Static Members : ĠBoolean Ġ= Ġfalse Ċ ĉ override Ġval Ġuse Packages Ġ= Ġtrue Ċ ĉ override Ġval Ġclass File Extension Ġ= Ġ". as " Ċ ĉ override Ġval Ġlanguage Requires Default In Switch Ġ= Ġtrue Ċ ĉ override Ġval Ġdefault Gen St m Switch Has Break s Ġ= Ġtrue Ċ ĉ override Ġval Ġallow Repeat Methods In Interface Chain Ġ= Ġfalse Ċ ĉ override Ġval Ġfloat Has FS uffix : ĠBoolean Ġ= Ġfalse ĊĊ ĉ override Ġval Ġkeywords Ġ= Ġset Of ( Ċĉ ĉ " abstract ", Ġ" alias ", Ġ" align ", Ġ" asm ", Ġ" assert ", Ġ" auto ", Ċĉ ĉ " body ", Ġ" bool ", Ġ" break ", Ġ" byte ", Ċĉ ĉ " case ", Ġ" cast ", Ġ" catch ", Ġ" c double ", Ġ" cent ", Ġ" c float ", Ġ" char ", Ġ" class ", Ġ" const ", Ġ" continue ", Ġ" cre al ", Ċĉ ĉ " d char ", Ġ" debug ", Ġ" default ", Ġ" delegate ", Ġ" delete ", Ġ" deprecated ", Ġ" do ", Ġ" double ", Ċĉ ĉ " else ", Ġ" enum ", Ġ" export ", Ġ" extern ", Ċĉ ĉ " false ", Ġ" final ", Ġ" finally ", Ġ" float ", Ġ" for ", Ġ" foreach ", Ġ" foreach _ reverse ", Ġ" function ", Ċĉ ĉ " goto ", Ċĉ ĉ " as ", Ġ" is ", Ċĉ ĉ " internal ", Ċĉ ĉ " ido uble ", Ġ" if ", Ġ" if loat ", Ġ" immutable ", Ġ" import ", Ġ" in ", Ġ" inout ", Ġ" int ", Ġ" interface ", Ġ" in variant ", Ġ" ire al ", Ġ" is ", Ċĉ ĉ " lazy ", Ġ" long ", Ċĉ ĉ " macro ", Ġ" mixin ", Ġ" module ", Ċĉ ĉ " new ", Ġ" no throw ", Ġ" null ", Ċĉ ĉ " out ", Ġ" override ", Ċĉ ĉ " package ", Ġ" pragma ", Ġ" private ", Ġ" protected ", Ġ" public ", Ġ" pure ", Ċĉ ĉ " real ", Ġ" ref ", Ġ" return ", Ċĉ ĉ " scope ", Ġ" shared ", Ġ" short ", Ġ" static ", Ġ" struct ", Ġ" super ", Ġ" switch ", Ġ" synchronized ", Ċĉ ĉ " template ", Ġ" this ", Ġ" throw ", Ġ" true ", Ġ" try ", Ġ" typedef ", Ġ" typeid ", Ġ" typeof ", Ċĉ ĉ " ubyte ", Ġ" uc ent ", Ġ" uint ", Ġ" ulong ", Ġ" union ", Ġ" unittest ", Ġ" ushort ", Ċĉ ĉ " version ", Ġ" void ", Ġ" volatile ", Ċĉ ĉ " wchar ", Ġ" while ", Ġ" with ", Ċĉ ĉ " __ FILE __", Ġ"__ FILE _ FULL _ PATH __", Ġ"__ MODULE __", Ġ"__ LINE __", Ġ"__ FUNCTION __", Ġ"__ PRE TTY _ FUNCTION __", Ġ" static ", Ġ"__ traits ", Ġ"__ vector ", Ġ"__ parameters ", ĊĊĉ ĉ // ĠKnown ĠObject Ġsymbols Ċĉ ĉ " clone ", Ġ" toString ", Ċĉ ĉ " std ", Ġ" core " Ċ ĉ ) ĊĊ ĉ override Ġfun Ġgen Compiler Command ( program File : ĠFile , Ġdebug : ĠBoolean , Ġlibs : ĠList < String >): ĠList < String > Ġ{ Ċĉ ĉ return ĠAs 3 Compiler . gen Command ( program File . parent File , ĠFile ( program File . parent File , Ġ" Main . as "), Ġdebug , Ġlibs ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġset Template Params After Building Source () Ġ{ Ċĉ ĉ super . set Template Params After Building Source () Ċĉ ĉ params [" AIR SDK _ VERSION _ INT "] Ġ= ĠAs 3 Compiler . AIR SDK _ VERSION _ INT Ċĉ ĉ params [" BASE _ CLASSES _ FQ NAMES "] Ġ= Ġget Classes For Static Construction (). map Ġ{ Ġit . name . target Name For Static Ġ} Ċĉ ĉ params [" STATIC _ CON STRUCT ORS "] Ġ= Ġgen Static Construct ors Sorted Lines () ĊĊĉ ĉ val Ġentry Point Fq Name Ġ= Ġprogram . entrypoint Ċĉ ĉ val Ġentry Point Class Ġ= Ġprogram [ entry Point Fq Name ] Ċĉ ĉ val Ġmain Method Ġ= Ġentry Point Class [ Ast Method Ref ( entry Point Fq Name , Ġ" main ", ĠAst Type . METHOD ( Ast Type . VOID , ĠARRAY ( Ast Type . STRING )) )] Ċĉ ĉ params [" MAIN _ METHOD _ CALL "] Ġ= Ġbuild Method ( main Method , Ġstatic Ġ= Ġtrue ) Ġ+ Ġ"( N . str Array ([] )); " ĊĊ ĉ } ĊĊ ĉ override Ġval ĠF q Name . target Name : ĠString Ġget () Ġ= Ġthis . fq name . replace ('.', Ġ'_ '). replace ('$ ', Ġ'_ ') Ċ ĉ // override Ġval ĠF q Name . target Name : ĠString Ġget () Ġ= Ġthis . actual Fq Name . fq name . replace ('$ ', Ġ'_ ') ĊĊ ĉ override Ġfun Ġrun ( redirect : ĠBoolean ): ĠProcess Result 2 Ġ{ Ċĉ ĉ val Ġnames Ġ= ĠlistOf (" Main . xml ") Ċĉ ĉ val Ġout File Ġ= Ġnames . map Ġ{ Ġconfig Target Folder . target Folder [ it ] Ġ}. first OrNull Ġ{ Ġit . exists Ġ} Ġ?: Ġinvalid Op (" Not Ġgenerated Ġoutput Ġfile Ġ$ names ") ĊĊĉ ĉ return ĠAs 3 Compiler . use Ad l Ġ{ Ċĉĉ ĉ Process Result 2 ( Root Local V fs (). exec ( listOf ( As 3 Compiler . AD L ) Ġ+ Ġ( if Ġ( debug Version ) ĠlistOf () Ġelse ĠlistOf ("- node bug ")) Ġ+ ĠlistOf ( out File . realpath OS ), ĠExec Options ( pas sth ru Ġ= Ġredirect , Ġsy se xec Ġ= Ġfalse , Ġfix Line End ings Ġ= Ġtrue ))) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġwrite Classes ( output : ĠSync V fs File ) Ġ{ Ċĉ ĉ // println ( program . resources V fs ) Ċĉ ĉ super . write Classes ( output ) ĊĊĉ ĉ val ĠString Fq Name Ġ= Ġbuild Template Class (" java . lang . String ". fq name ) ĊĊĉ ĉ output [" Bootstrap . as "] Ġ= ĠInd enter Ġ{ Ċĉĉ ĉ line (" package ") Ġ{ Ċĉĉĉ ĉ line (" public Ġclass ĠBootstrap ") Ġ{ Ċĉĉĉĉ ĉ for Ġ( lit Ġin Ġget Global Strings ()) Ġ{ Ċĉĉĉĉĉ ĉ line (" static Ġpublic Ġvar Ġ${ lit . name }: Ġ$ String Fq Name Ġ= ĠN . str Lit Escape (${ lit . str . quote () }); ") Ċĉĉĉĉ ĉ } ĊĊĉĉĉĉ ĉ line (" static Ġpublic Ġfunction Ġinit (): void ") Ġ{ Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen Field ( field : ĠAst Field ): ĠInd enter Ġ= ĠInd enter Ġ{ Ċĉ ĉ val Ġstatic Ġ= Ġfield . is Static . map (" static Ġ", Ġ"") ĊĊĉ ĉ line (" public Ġ${ static } var Ġ${ field . target Name }: Ġ${ field . type . target Name } Ġ= Ġ${ field . type . get Null (). escaped Constant }; ") Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen Class Part ( clazz : ĠAst Class , Ġtype : ĠMember Types ): ĠClass Result Ġ{ Ċĉ ĉ val Ġresult Ġ= Ġsuper . gen Class Part ( clazz , Ġtype ) Ċĉ ĉ return Ġresult . copy ( ind enter Ġ= ĠInd enter Ġ{ Ċĉĉ ĉ line (" package ") Ġ{ Ċĉĉĉ ĉ line (" import ĠInt 6 4 ; ") Ċĉĉĉ ĉ line (" import Ġav m 2 . intr insics . memory .*; ") Ċĉĉĉ ĉ for Ġ( header Ġin Ġclazz . annotations List . getHeaders For Target ( target Name )) Ġ{ Ċĉĉĉĉ ĉ line ( header ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ val Ġactual Imports Ġ= Ġarray ListOf < Fq Name >() Ċĉĉĉ ĉ line deferred Ġ{ Ċĉĉĉĉ ĉ for Ġ( import Ġin Ġactual Imports ) Ġ{ Ċĉĉĉĉĉ ĉ line (" import Ġ$ import ; ") Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉ ĉ line ( result . ind enter ) Ċĉĉĉ ĉ actual Imports Ġ+= Ġimports . toSet () Ċĉĉ ĉ } Ċĉ ĉ }) Ċ ĉ } ĊĊ ĉ // override Ġfun Ġgen Classes ( output : ĠSync V fs File ): ĠInd enter Ġ= ĠInd enter . gen Ġ{ Ċ ĉ // ĉ val ĠString Fq Name Ġ= Ġbuild Template Class (" java . lang . String ". fq name ) Ċ ĉ // ĉ val Ġclasses Str Ġ= Ġsuper . gen Classes ( output ) Ċ ĉ // ĉ line ( classes Str ) Ċ ĉ // ĉ line (" class ĠBootstrap ") Ġ{ Ċ ĉ // ĉ ĉ for Ġ( lit Ġin Ġget Global Strings ()) Ġ{ Ċ ĉ // ĉĉ ĉ line (" static Ġpublic Ġ$ String Fq Name Ġ${ lit . name }; ") Ċ ĉ // ĉ ĉ } Ċ ĉ // ĉ ĉ line (" static Ġpublic Ġvoid Ġ__ init Strings () ") Ġ{ Ċ ĉ // ĉĉ ĉ for Ġ( lit Ġin Ġget Global Strings ()) Ġ{ Ċ ĉ // ĉĉĉ ĉ // ĠSTRING LIT _ Ċ ĉ // ĉĉĉ ĉ line ("${ lit . name } Ġ= ĠN . str Lit Escape (${ lit . str . quote () }); ") Ċ ĉ // ĉĉ ĉ } Ċ ĉ // ĉ ĉ } Ċ ĉ // ĉ ĉ val Ġentry Point Fq Name Ġ= Ġprogram . entrypoint Ċ ĉ // ĉ ĉ val Ġentry Point Class Ġ= Ġprogram [ entry Point Fq Name ] Ċ ĉ // ĉ ĉ line (" static Ġvoid ĠMain ( string [] Ġargs )") Ġ{ Ċ ĉ // ĉĉ ĉ line (" try Ġ{ ") Ċ ĉ // ĉĉ ĉ indent Ġ{ Ċ ĉ // ĉĉĉ ĉ line (" N . init (); ") Ċ ĉ // ĉĉĉ ĉ line ("__ init Strings (); ") Ċ ĉ // ĉĉĉ ĉ line ( gen Static Construct ors Sorted ()) Ċ ĉ // ĉĉĉ ĉ // line ( build Static Init ( entry Point Fq Name )) Ċ ĉ // ĉĉĉ ĉ val Ġmain Method Ġ= Ġentry Point Class [ Ast Method Ref ( entry Point Fq Name , Ġ" main ", ĠAst Type . METHOD ( Ast Type . VOID , ĠARRAY ( Ast Type . STRING )) )] Ċ ĉ // ĉĉĉ ĉ line ( build Method ( main Method , Ġstatic Ġ= Ġtrue ) Ġ+ Ġ"( N . str Array ( args )); ") Ċ ĉ // ĉĉ ĉ } Ċ ĉ // ĉĉ ĉ line (" } Ġcatch Ġ( Wrapped Throwable Ġe ) Ġ{ ") Ċ ĉ // ĉĉ ĉ indent Ġ{ Ċ ĉ // ĉĉĉ ĉ line (" Console . WriteLine ( e . t . ToString ()); ") Ċ ĉ // ĉĉĉ ĉ line (" Console . WriteLine ( e . ToString ()); ") Ċ ĉ // ĉĉ ĉ } Ċ ĉ // ĉĉ ĉ line (" } Ġcatch Ġ( Exception Ġe ) Ġ{ ") Ċ ĉ // ĉĉ ĉ indent Ġ{ Ċ ĉ // ĉĉĉ ĉ line (" Console . WriteLine ( e . ToString ()); ") Ċ ĉ // ĉĉ ĉ } Ċ ĉ // ĉĉ ĉ line (" }") Ċ ĉ // ĉ ĉ } Ċ ĉ // ĉ } Ċ ĉ //} ĊĊ ĉ override Ġfun Ġgen Class Decl ( clazz : ĠAst Class , Ġkind : ĠMember Types ): ĠString Ġ{ Ċĉ ĉ val ĠCLASS Ġ= Ġwhen Ġ( kind ) Ġ{ Ċĉĉ ĉ Member Types . STATIC Ġ-> Ġ" class " Ċĉĉ ĉ else Ġ-> Ġif Ġ( clazz . is Interface ) Ġ" interface " Ġelse Ġ" class " Ċĉ ĉ } Ċĉ ĉ val Ġname Ġ= Ġwhen Ġ( kind ) Ġ{ Ċĉĉ ĉ Member Types . STATIC Ġ-> Ġclazz . name . target Name For Static Ċĉĉ ĉ else Ġ-> Ġclazz . name . target Simple Name Ċĉ ĉ } Ċĉ ĉ var Ġdecl Ġ= Ġ" public Ġ$ CLASS Ġ$ name " Ċĉ ĉ decl Ġ+= Ġwhen Ġ( kind ) Ġ{ Ċĉĉ ĉ Member Types . STATIC Ġ-> Ġ"" Ċĉĉ ĉ else Ġ-> Ġgen Class Decl Ext ends Implements ( clazz , Ġkind ) Ċĉ ĉ } Ċĉ ĉ return Ġdecl Ċ ĉ } ĊĊ ĉ // override Ġfun ĠgetType Target Name ( type : ĠAst Type ): ĠString Ġ{ Ċ ĉ // ĉ val Ġres Ġ= Ġsuper . getType Target Name ( type ) Ċ ĉ // ĉ return Ġif Ġ( res Ġ== Ġ" java _ lang _ Object ") Ġ"*" Ġelse Ġres Ċ ĉ //} ĊĊ ĉ override Ġval ĠAst Local . decl : ĠString Ġget () Ġ= Ġ" var Ġ${ this . target Name }: Ġ${ this . type . local Decl Type } Ġ= Ġ${ this . type . native Default String }; " Ċ ĉ override Ġval ĠAst Argument . decl : ĠString Ġget () Ġ= Ġ"${ this . target Name }: Ġ${ this . type . local Decl Type }" ĊĊ ĉ override Ġfun Ġgen Met od Decl ( method : ĠAst Method ): ĠString Ġ{ Ċĉ ĉ val Ġargs Ġ= Ġmethod . method Type . args . map Ġ{ Ġit . decl Ġ} ĊĊĉ ĉ // if Ġ( method . is Instance Init ) Ġmods Ġ+= Ġ" final Ġ" ĊĊĉ ĉ val Ġmods Ġ= Ġgen Method Decl Modifiers ( method ) Ċĉ ĉ val Ġclazz Ġ= Ġmethod . containing Class Ċĉ ĉ val Ġm Ġ= Ġmethod ĊĊĉ ĉ val Ġr mods Ġ= Ġif Ġ(! clazz . is Interface Ġ|| Ġm . is Static ) Ġmods Ġelse Ġ"" Ċĉ ĉ // val Ġr mods Ġ= Ġmods Ċĉ ĉ return Ġ"$ r mods Ġfunction Ġ${ method . target Name } (${ args . join ToString (", Ġ" )} ): Ġ${ method . actual Ret Type . target Name }" Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen Method Decl Modifiers ( method : ĠAst Method ): ĠString Ġ{ Ċĉ ĉ if Ġ( method . containing Class . is Interface ) Ġ{ Ċĉĉ ĉ return Ġ" public Ġ" Ġ+ Ġmethod . is Static . map (" static Ġ", Ġ"") Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ var Ġmods Ġ= Ġ"" Ċĉĉ ĉ if Ġ(! method . is Static Ġ&& Ġmethod . target Is Over riding ) Ġmods Ġ+= Ġ" override Ġ" Ċĉĉ ĉ if Ġ( method . is Static ) Ġmods Ġ+= Ġ" static Ġ" Ċĉĉ ĉ mods Ġ+= Ġ" public Ġ" Ċĉĉ ĉ return Ġmods Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun ĠN _ i 2 b ( str : ĠString ) Ġ= Ġ" avm 2 . intr insics . memory . s xi 8 ($ str )" Ċ ĉ override Ġfun ĠN _ i 2 c ( str : ĠString ) Ġ= Ġ"( ($ str )& 0 xFFFF )" Ċ ĉ override Ġfun ĠN _ i 2 s ( str : ĠString ) Ġ= Ġ" avm 2 . intr insics . memory . s xi 1 6 ($ str )" ĊĊ ĉ override Ġfun ĠN _ AG ET _ T ( array Type : ĠAst Type . ARRAY , Ġelement Type : ĠAst Type , Ġarray : ĠString , Ġindex : ĠString ): ĠString Ġ{ Ċĉ ĉ // Ġav m 2 . intr insics . memory . s xi 8 Ċĉ ĉ // Ġav m 2 . intr insics . memory . s xi 1 6 Ċĉ ĉ return Ġwhen Ġ( elementType ) Ġ{ Ċĉĉ ĉ // Ast Type . BYTE Ġ-> Ġ" (( ($ array . data [$ index ]) << 2 4 )>> 2 4 )" Ċĉĉ ĉ // Ast Type . CHAR Ġ-> Ġ" (( ($ array . data [$ index ])) & 0 xFFFF )" Ċĉĉ ĉ // Ast Type . SHORT Ġ-> Ġ" (( ($ array . data [$ index ]) << 1 6 )>> 1 6 )" Ċĉĉ ĉ Ast Type . BYTE Ġ-> ĠN _ i 2 b ("$ array . data [$ index ]") Ċĉĉ ĉ Ast Type . CHAR Ġ-> ĠN _ i 2 c ("$ array . data [$ index ]") Ċĉĉ ĉ Ast Type . SHORT Ġ-> ĠN _ i 2 s ("$ array . data [$ index ]") Ċĉĉ ĉ else Ġ-> Ġ" ($ array . data [$ index ]) " Ċĉ ĉ } Ċĉ ĉ // return Ġ"$ array . get ($ index )" Ċ ĉ } Ċ ĉ override Ġfun ĠN _ A SET _ T ( array Type : ĠAst Type . ARRAY , Ġelement Type : ĠAst Type , Ġarray : ĠString , Ġindex : ĠString , Ġvalue : ĠString ): ĠString Ġ{ Ċĉ ĉ return Ġ"$ array . data [$ index ] Ġ= Ġ$ value ;" Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen Expr IntArray Lit ( e : ĠAst Expr . INT ARRAY _ LITERAL ): ĠString Ġ{ Ċĉ ĉ return Ġ" JA _ I ${ static Access Operator } T ( new < int >[ Ġ" Ġ+ Ġe . values . join ToString (",") Ġ+ Ġ" Ġ]) " Ċ ĉ } ĊĊ ĉ override Ġfun ĠN _ f 2 d ( str : ĠString ) Ġ= Ġ" Number ($ str )" Ċ ĉ override Ġfun ĠN _ d 2 f ( str : ĠString ) Ġ= Ġ" Number ($ str )" ĊĊ ĉ override Ġfun ĠN _ is ( a : ĠString , Ġb : ĠString ): ĠString Ġ= Ġ"( ($ a ) Ġis Ġ$ b )" ĊĊ ĉ override Ġfun ĠN _ ine g ( str : ĠString ) Ġ= Ġ" N . ine g ($ str )" ĊĊ ĉ override Ġval ĠNull Type Ġby Ġlazy Ġ{ ĠAst Type . OBJECT . target Name Ġ} Ċ ĉ override Ġval ĠVoid Type Ġ= Ġ" void " Ċ ĉ override Ġval ĠBool Type Ġ= Ġ" Boolean " Ċ ĉ override Ġval ĠInt Type Ġ= Ġ" int " Ċ ĉ override Ġval ĠShort Type Ġ= Ġ" int " Ċ ĉ override Ġval ĠChar Type Ġ= Ġ" int " Ċ ĉ override Ġval ĠByte Type Ġ= Ġ" int " Ċ ĉ override Ġval ĠFloat Type Ġ= Ġ" Number " Ċ ĉ override Ġval ĠDouble Type Ġ= Ġ" Number " Ċ ĉ override Ġval ĠLong Type Ġ= Ġ" Int 6 4 " ĊĊĊ ĉ override Ġval ĠF q Name . target Simple Name : ĠString Ġget () Ġ= Ġthis . target Name ĊĊ ĉ override Ġfun ĠN _ c ( str : ĠString , Ġfrom : ĠAst Type , Ġto : ĠAst Type ) Ġ= Ġ"( ($ str ) Ġas Ġ${ to . target Name })" ĊĊ ĉ override Ġfun Ġgen Expr Array Length ( e : ĠAst Expr . ARRAY _ LENGTH ): ĠString Ġ= Ġ" (${ e . array . gen NotNull ()} Ġas Ġ$ Base ArrayType ). length " Ċ ĉ override Ġfun Ġgen St m Throw ( stm : ĠAst St m . THROW , Ġlast : ĠBoolean ) Ġ= ĠInd enter (" throw Ġnew ĠWr apped Throwable (${ stm . exception . gen Expr () }); ") ĊĊ ĉ override Ġfun Ġgen Label ( label : ĠAst Label ) Ġ= Ġ"${ label . name } :" ĊĊ ĉ override Ġfun Ġgen SI Method ( clazz : ĠAst Class ): ĠInd enter Ġ= ĠInd enter Ġ{ Ċĉ ĉ if Ġ( clazz . is Java Lang Object ) Ġ{ Ċĉĉ ĉ // line (" override Ġpublic Ġfunction ĠtoString (): ĠString ") Ġ{ Ċĉĉ ĉ line (" public Ġfunction ĠtoString (): ĠString ") Ġ{ Ċĉĉĉ ĉ val ĠtoString MethodName Ġ= Ġbuild Method ( clazz . getMethod Without Overrides (" toString ") !! , Ġstatic Ġ= Ġfalse ) Ċĉĉĉ ĉ line (" return ĠN . istr ($ toString MethodName ()); ") Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ if Ġ(! clazz . is Interface ) Ġ{ Ċĉĉ ĉ if Ġ( clazz . is Java Lang Object ) Ġ{ Ċĉĉĉ ĉ line (" public Ġvar Ġ__ JT __ CLASS _ ID : Ġint ; ") Ċĉĉĉ ĉ line (" public Ġfunction Ġ${ clazz . name . target Name }( CLASS _ ID : Ġint Ġ= Ġ${ clazz . class Id }) Ġ{ Ġthis .__ JT __ CLASS _ ID Ġ= ĠCLASS _ ID ; Ġ} ") Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ line (" public Ġfunction Ġ${ clazz . name . target Name }( CLASS _ ID : Ġint Ġ= Ġ${ clazz . class Id }) Ġ{ Ġsuper ( CLASS _ ID ); Ġ} ") Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ if Ġ( clazz . static Constructor Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ line (" static Ġpublic Ġfunction ĠSI (): Ġvoid ") Ġ{ Ċĉĉĉ ĉ val Ġclazz Name Ġ= Ġif Ġ( clazz . is Interface ) Ġclazz . name . target Name For Static Ġelse Ġclazz . name . target Name Ċĉĉĉ ĉ for Ġ( field Ġin Ġclazz . fields . filter Ġ{ Ġit . is Static Ġ}) Ġ{ Ċĉĉĉĉ ĉ line ("$ clazz Name .${ field . target Name } Ġ= Ġ${ field . escaped Constant Value }; ") Ċĉĉĉ ĉ } Ċĉĉĉ ĉ line ( gen SI Method Body ( clazz )) Ċĉĉ ĉ } Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ line (" static Ġpublic Ġfunction ĠSI (): Ġvoid Ġ{ Ġ} ") Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ // override Ġfun ĠN _ i ( str : ĠString ) Ġ= Ġ" (( int ) ($ str )) " Ċ ĉ override Ġfun ĠN _ i ( str : ĠString ) Ġ= Ġ" ($ str )" ĊĊ ĉ // override Ġfun ĠN _ f 2 i ( str : ĠString ) Ġ= Ġ" (( int ) ($ str )) " Ċ ĉ override Ġfun ĠN _ d 2 i ( str : ĠString ) Ġ= Ġ" int ($ str )" ĊĊ ĉ override Ġfun ĠN _ c _ eq ( l : ĠString , Ġr : ĠString ) Ġ= Ġ" ($ l Ġ== Ġ$ r )" Ċ ĉ override Ġfun ĠN _ c _ ne ( l : ĠString , Ġr : ĠString ) Ġ= Ġ" ($ l Ġ!= Ġ$ r )" ĊĊ ĉ override Ġfun ĠN _ i 2 f ( str : ĠString ) Ġ= Ġ" Number ($ str )" Ċ ĉ override Ġfun ĠN _ i 2 d ( str : ĠString ) Ġ= Ġ" Number ($ str )" ĊĊ ĉ override Ġfun ĠN _ j 2 f ( str : ĠString ) Ġ= Ġ" Number ($ str )" Ċ ĉ override Ġfun ĠN _ j 2 d ( str : ĠString ) Ġ= Ġ" Number ($ str )" ĊĊ ĉ // override Ġfun ĠN _ c _ div ( l : ĠString , Ġr : ĠString ) Ġ= Ġ" unchecked ($ l Ġ/ Ġ$ r )" ĊĊ ĉ override Ġfun ĠN _ id iv ( l : ĠString , Ġr : ĠString ): ĠString Ġ= Ġ" N . id iv ($ l , Ġ$ r )" Ċ ĉ override Ġfun ĠN _ ire m ( l : ĠString , Ġr : ĠString ): ĠString Ġ= Ġ" N . ire m ($ l , Ġ$ r )" ĊĊ ĉ override Ġfun Ġgen Missing Body ( method : ĠAst Method ): ĠInd enter Ġ= ĠInd enter Ġ{ Ċĉ ĉ val Ġmessage Ġ= Ġ" Missing Ġbody Ġ${ method . containing Class . name }.${ method . name }${ method . desc }" Ċĉ ĉ line (" throw Ġnew ĠError (${ message . quote () }); ") Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen St m Try Catch ( stm : ĠAst St m . TRY _ CATCH ) Ġ= Ġindent Ġ{ Ċĉ ĉ line (" try ") Ġ{ Ċĉĉ ĉ line ( stm . tr yst m . gen St m ()) Ċĉ ĉ } Ċĉ ĉ line (" catch Ġ( J __ i __ exception __: ĠWr apped Throwable )") Ġ{ Ċĉĉ ĉ line (" J __ exception __ Ġ= ĠJ __ i __ exception __. t ; ") Ċĉĉ ĉ line ( stm . catch . gen St m ()) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ // override Ġfun ĠN _ c _ ush r ( l : ĠString , Ġr : ĠString ) Ġ= Ġ" N . i ush r ($ l , Ġ$ r )" ĊĊ ĉ override Ġfun Ġcreate Array Mult is ure ( e : ĠAst Expr . NEW _ ARRAY , Ġdesc : ĠString ): ĠString Ġ{ Ċĉ ĉ return Ġ"$ Object ArrayType ${ static Access Operator } create Multi S ure (\" $ desc \", Ġ[ ${ e . counts . map Ġ{ Ġit . gen Expr () Ġ}. join ToString (", Ġ" )} ]) " Ċ ĉ } ĊĊ ĉ override Ġval ĠDouble Negative Infinity String Ġ= Ġ" Number . NEGATIVE _ INFINITY " Ċ ĉ override Ġval ĠDouble Positive Infinity String Ġ= Ġ" Number . POSITIVE _ INFINITY " Ċ ĉ override Ġval ĠDouble Nan String Ġ= Ġ" N . NaN " ĊĊ ĉ override Ġval ĠString . escape String : ĠString Ġget () Ġ= Ġ" Bootstrap . STRING LIT _${ alloc String ( current Class , Ġthis )}" ĊĊ ĉ override Ġfun ĠAst Expr . gen NotNull (): ĠString Ġ{ Ċĉ ĉ if Ġ( debug Version ) Ġ{ Ċĉĉ ĉ return Ġ"(" Ġ+ Ġgen Expr 2 ( this ) Ġ+ Ġ")" Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ return Ġgen Expr 2 ( this ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen St m Monitor Enter ( stm : ĠAst St m . MONITOR _ ENTER ) Ġ= Ġindent Ġ{ Ċĉ ĉ line (" N . monitor Enter (" Ġ+ Ġstm . expr . gen Expr () Ġ+ Ġ"); ") Ċ ĉ } ĊĊ ĉ override Ġfun Ġgen St m Monitor Exit ( stm : ĠAst St m . MONITOR _ EXIT ) Ġ= Ġindent Ġ{ Ċĉ ĉ line (" N . monitor Exit (" Ġ+ Ġstm . expr . gen Expr () Ġ+ Ġ"); ") Ċ ĉ } ĊĊ ĉ override Ġfun Ġbuild Static Init ( clazz Name : ĠF q Name ): ĠString ? Ġ= Ġnull ĊĊ ĉ override Ġfun Ġgen Expr Ca ught Exception ( e : ĠAst Expr . CA UG HT _ EXCEPTION ): ĠString Ġ= Ġ"( J __ exception __ Ġas Ġ${ e . type . target Name })" ĊĊ ĉ override Ġfun Ġgen Expr Cast Checked ( e : ĠString , Ġfrom : ĠAst Type . Reference , Ġto : ĠAst Type . Reference ): ĠString Ġ{ Ċĉ ĉ if Ġ( from Ġ== Ġto ) Ġreturn Ġe ; Ċĉ ĉ if Ġ( from Ġis ĠAst Type . NULL ) Ġreturn Ġe Ċĉ ĉ return Ġ" N . CHECK _ CAST ($ e , Ġ${ to . target Name Ref })" Ċ ĉ } Ċ }