@@ -393,23 +393,6 @@ private boolean compileSetFieldExpr(AST.SetFieldExpr setFieldExpr) {
393393 return false ;
394394 }
395395
396- private void codeNew (Type type ) {
397- var temp = createTemp (type );
398- if (type instanceof Type .TypeArray typeArray ) {
399- code (new Instruction .NewArray (typeArray , temp ));
400- }
401- else if (type instanceof Type .TypeStruct typeStruct ) {
402- code (new Instruction .NewStruct (typeStruct , temp ));
403- }
404- else
405- throw new CompilerException ("Unexpected type: " + type );
406- }
407-
408- private void codeStoreAppend () {
409- var operand = pop ();
410- code (new Instruction .AStoreAppend ((Operand .RegisterOperand ) top (), operand ));
411- }
412-
413396 private boolean compileNewExpr (AST .NewExpr newExpr ) {
414397 codeNew (newExpr .type );
415398 if (newExpr .initExprList != null && !newExpr .initExprList .isEmpty ()) {
@@ -636,6 +619,23 @@ else if (indexed instanceof Operand.LoadFieldOperand loadFieldOperand) {
636619 code (new Instruction .Move (value , indexed ));
637620 }
638621
622+ private void codeNew (Type type ) {
623+ var temp = createTemp (type );
624+ if (type instanceof Type .TypeArray typeArray ) {
625+ code (new Instruction .NewArray (typeArray , temp ));
626+ }
627+ else if (type instanceof Type .TypeStruct typeStruct ) {
628+ code (new Instruction .NewStruct (typeStruct , temp ));
629+ }
630+ else
631+ throw new CompilerException ("Unexpected type: " + type );
632+ }
633+
634+ private void codeStoreAppend () {
635+ var operand = pop ();
636+ code (new Instruction .AStoreAppend ((Operand .RegisterOperand ) top (), operand ));
637+ }
638+
639639 private boolean vstackEmpty () {
640640 return virtualStack .isEmpty ();
641641 }
0 commit comments