@@ -4,14 +4,11 @@ package cscompiler.components;
44import cscompiler .ast .* ;
55import cscompiler .ast .CSExprDef .CSInjectEntry ;
66import cscompiler .ast .CSStatement ;
7- import cscompiler .ast .CSVar .CSVarType ;
87
98import haxe .macro .Expr ;
109import haxe .macro .Type ;
11- import haxe .macro .TypeTools ;
1210
1311import reflaxe .compiler .TargetCodeInjection ;
14- import reflaxe .helpers .OperatorHelper ;
1512
1613using reflaxe .helpers .ModuleTypeHelper ;
1714using reflaxe .helpers .NameMetaHelper ;
@@ -462,7 +459,7 @@ class CSCompiler_Expr extends CSCompiler_Base {
462459 final haxeType = {
463460 #if macro
464461 // This function does not exist outside of "macro" target.
465- TypeTools .fromModuleType (maybeModuleType );
462+ haxe.macro. TypeTools .fromModuleType (maybeModuleType );
466463 #else
467464 throw " Impossible" ;
468465 #end
@@ -497,32 +494,6 @@ class CSCompiler_Expr extends CSCompiler_Base {
497494 }
498495 }
499496
500- /**
501- Generate a block scope from an expression.
502-
503- If the typed expression is `TypedExprDef.TBlock`, then each
504- sub-expression is compiled on a new line.
505-
506- Otherwise, the expression is compiled normally.
507-
508- Each line of the output is preemptively tabbed.
509- **/
510- function toIndentedScope (e : TypedExpr ): String {
511- return " " ;
512- /*
513- var el = switch(e.expr) {
514- case TBlock(el): el;
515- case _: [e];
516- }
517-
518- return if(el.length == 0) {
519- "";
520- } else {
521- compiler.compileExpressionsIntoLines(el).tab();
522- }
523- */
524- }
525-
526497 /**
527498 Generate an expression given a `TConstant` (from `TypedExprDef.TConst`).
528499 **/
@@ -628,87 +599,6 @@ class CSCompiler_Expr extends CSCompiler_Base {
628599 ];
629600 }
630601
631- /**
632- Generate an expression given a `Unop` and typed expression (from `TypedExprDef.TUnop`).
633- **/
634- function unopToCS (op : Unop , e : TypedExpr , isPostfix : Bool ): String {
635- final csExpr = compileToCSStatement (e );
636- final operatorStr = OperatorHelper .unopToString (op );
637- return isPostfix ? (csExpr + operatorStr ) : (operatorStr + csExpr );
638- }
639-
640- /**
641- Generate an expression given a `FieldAccess` and typed expression (from `TypedExprDef.TField`).
642- **/
643- function fieldAccessToCS (e : TypedExpr , fa : FieldAccess ): String {
644- final nameMeta : NameAndMeta = switch (fa ) {
645- case FInstance (_ , _ , classFieldRef ): classFieldRef .get ();
646- case FStatic (_ , classFieldRef ): classFieldRef .get ();
647- case FAnon (classFieldRef ): classFieldRef .get ();
648- case FClosure (_ , classFieldRef ): classFieldRef .get ();
649- case FEnum (_ , enumField ): enumField ;
650- case FDynamic (s ): {
651- name : s ,
652- meta : null
653- };
654- }
655-
656- return if (nameMeta .hasMeta (" :native" )) {
657- nameMeta .getNameOrNative ();
658- } else {
659- final name = compiler .compileVarName (nameMeta .getNameOrNativeName ());
660-
661- // Check if a special field access and intercept.
662- switch (fa ) {
663- case FStatic (clsRef , cfRef ): {
664- final cf = cfRef .get ();
665- final className = compiler .compileClassName (clsRef .get ());
666- // TODO: generate static access
667- // return ...
668- }
669- case FEnum (_ , enumField ): {
670- // TODO: generate enum access
671- // return ...
672- }
673- case _ :
674- }
675-
676- final csExpr = compileToCSStatement (e );
677-
678- // Check if a special field access that requires the compiled expression.
679- switch (fa ) {
680- case FAnon (classFieldRef ): {
681- // TODO: generate anon struct access
682- // return ...
683- }
684- case _ :
685- }
686-
687- csExpr + " ." + name ;
688- }
689- }
690-
691- function compileIf (condExpr : TypedExpr , ifContentExpr : TypedExpr , elseExpr : Null <TypedExpr >) {
692- var result = " if(" + compileToCSStatement (condExpr .unwrapParenthesis ()) + " ) {\n " ;
693- result + = toIndentedScope (ifContentExpr );
694- if (elseExpr != null ) {
695- switch (elseExpr .expr ) {
696- case TIf (condExpr2 , ifContentExpr2 , elseExpr2 ): {
697- result + = " \n } else " + compileIf (condExpr2 , ifContentExpr2 , elseExpr2 );
698- }
699- case _ :
700- {
701- result + = " \n } else {\n " ;
702- result + = toIndentedScope (elseExpr );
703- result + = " \n }" ;
704- }
705- }
706- } else {
707- result + = " \n }" ;
708- }
709- return result ;
710- }
711-
712602 function compileFuncArgs (args : Array <{
713603 v : TVar ,
714604 value : Null <TypedExpr >
0 commit comments