@@ -653,8 +653,21 @@ function defaultReader(x) {
653
653
}
654
654
}
655
655
656
- function compile ( lang , txt , options = { } ) {
656
+ function compile ( arg1 , arg2 , arg3 ) {
657
+ let options = { } ;
658
+ let txt = "" ;
659
+
660
+ if ( typeof arg2 === "string" ) {
661
+ // backward compatible
662
+ txt = arg2 ;
663
+ options = { ...arg3 , lang : arg1 } ;
664
+ } else {
665
+ txt = arg1 ;
666
+ options = arg2 ;
667
+ }
668
+
657
669
const {
670
+ lang = "js" ,
658
671
romanizeIdentifiers = "none" ,
659
672
resetVarCnt,
660
673
logCallback = x =>
@@ -695,7 +708,7 @@ function compile(lang, txt, options = {}) {
695
708
return 0 ;
696
709
}
697
710
698
- var macros = extractMacros ( lang , txt , { lib, reader } ) ;
711
+ var macros = extractMacros ( txt , { lib, reader, lang } ) ;
699
712
txt = expandMacros ( txt , macros ) ;
700
713
701
714
logCallback ( "\n\n=== [PASS 0] EXPAND-MACROS ===" ) ;
@@ -743,7 +756,8 @@ function compile(lang, txt, options = {}) {
743
756
targ =
744
757
mwrapper (
745
758
imports [ i ] ,
746
- compile ( lang , isrc , {
759
+ compile ( isrc , {
760
+ lang,
747
761
romanizeIdentifiers,
748
762
resetVarCnt : false ,
749
763
logCallback,
@@ -816,7 +830,7 @@ function evalCompiled(compiledCode, options = {}) {
816
830
function execute ( source , options = { } ) {
817
831
const { lang = "js" } = options ;
818
832
isLangSupportedForEval ( lang ) ;
819
- const compiled = compile ( lang , source , options ) ;
833
+ const compiled = compile ( source , options ) ;
820
834
evalCompiled ( compiled , options ) ;
821
835
}
822
836
0 commit comments