@@ -255,6 +255,10 @@ public bool SwapOperands()
255255 }
256256 return true ;
257257 }
258+
259+ public IInterimOperand Clone ( BasicBlock block )
260+ => new IRBinaryOp ( block , ( BinaryOpcode ) SetSourceLocation ( Operation ) , Left . Clone ( block ) , Right . Clone ( block ) ) ;
261+
258262 public override IEnumerable < Opcode > EmitOpcodes ( )
259263 {
260264 foreach ( Opcode opcode in Left . EmitOpcodes ( ) )
@@ -264,6 +268,7 @@ public override IEnumerable<Opcode> EmitOpcodes()
264268 Operation . Label = string . Empty ;
265269 yield return SetSourceLocation ( Operation ) ;
266270 }
271+
267272 public override string ToString ( )
268273 => Operation . ToString ( ) ;
269274 public bool Equals ( IInterimOperand other )
@@ -340,6 +345,9 @@ public IRUnaryOp(BasicBlock block, Opcode operation, IInterimOperand operand) :
340345 Operation = operation ;
341346 Operand = operand ;
342347 }
348+
349+ public IInterimOperand Clone ( BasicBlock block )
350+ => new IRUnaryOp ( block , Operation , Operand . Clone ( block ) ) ;
343351 public override IEnumerable < Opcode > EmitOpcodes ( )
344352 {
345353 foreach ( Opcode opcode in Operand . EmitOpcodes ( ) )
@@ -477,6 +485,8 @@ public IRNonVarPush(BasicBlock block, Opcode opcode) : base(opcode, block)
477485 {
478486 Operation = opcode ;
479487 }
488+ public IInterimOperand Clone ( BasicBlock block )
489+ => new IRNonVarPush ( block , Operation ) ;
480490 public override IEnumerable < Opcode > EmitOpcodes ( )
481491 {
482492 Operation . Label = string . Empty ;
@@ -501,6 +511,8 @@ public IRSuffixGet(BasicBlock block, IInterimOperand obj, OpcodeGetMember opcode
501511 Object = obj ;
502512 Suffix = opcodeGetMember . Identifier ;
503513 }
514+ public IInterimOperand Clone ( BasicBlock block )
515+ => new IRSuffixGet ( block , Object . Clone ( block ) , new OpcodeGetMember ( Suffix ) { SourceLine = SourceLine , SourceColumn = SourceColumn } ) ;
504516 public override IEnumerable < Opcode > EmitOpcodes ( )
505517 {
506518 foreach ( Opcode opcode in Object . EmitOpcodes ( ) )
@@ -533,7 +545,6 @@ public InterimConstantValue Evaluate()
533545 if ( ! IsInvariant )
534546 throw new InvalidOperationException ( ) ;
535547 throw new NotImplementedException ( ) ;
536- // MUSTFIX:
537548#pragma warning disable CS0162 // Unreachable code detected
538549 Encapsulation . Structure obj = ( Encapsulation . Structure ) ( Object as IEvaluatableToConstant ) . Evaluate ( ) ? . Value ;
539550#pragma warning restore CS0162 // Unreachable code detected
@@ -633,6 +644,8 @@ public IRIndexGet(BasicBlock block, IInterimOperand obj, IInterimOperand index,
633644 Object = obj ;
634645 Index = index ;
635646 }
647+ public IInterimOperand Clone ( BasicBlock block )
648+ => new IRIndexGet ( block , Object . Clone ( block ) , Index . Clone ( block ) , new OpcodeGetIndex ( ) { SourceLine = SourceLine , SourceColumn = SourceColumn } ) ;
636649 public override IEnumerable < Opcode > EmitOpcodes ( )
637650 {
638651 foreach ( Opcode opcode in Object . EmitOpcodes ( ) )
@@ -664,7 +677,6 @@ public InterimConstantValue Evaluate()
664677 {
665678 if ( ! IsInvariant )
666679 throw new InvalidOperationException ( ) ;
667- // MUSTFIX:
668680 throw new NotImplementedException ( ) ;
669681 //((Encapsulation.IIndexable)Object).GetIndex();
670682 }
@@ -795,6 +807,17 @@ public override IEnumerable<Opcode> EmitOpcodes()
795807 yield return SetSourceLocation ( new OpcodeBranchJump ( ) { DestinationLabel = False . Label } ) ;
796808 }
797809 }
810+ public IRBranch Clone ( BasicBlock block )
811+ {
812+ BranchOpcode opcode ;
813+ if ( PreferFalse )
814+ opcode = new OpcodeBranchIfFalse ( ) ;
815+ else
816+ opcode = new OpcodeBranchIfTrue ( ) ;
817+ opcode . SourceLine = SourceLine ;
818+ opcode . SourceColumn = SourceColumn ;
819+ return new IRBranch ( block , Condition . Clone ( block ) , True , False , opcode ) ;
820+ }
798821 public override string ToString ( )
799822 => string . Format ( "{{br.? {0}/{1}}}" , True . Label , False . Label ) ;
800823 public override bool Equals ( object obj )
@@ -838,13 +861,22 @@ private bool IsCallInvariant()
838861 }
839862 private Type GetDefaultReturnType ( )
840863 {
841- IRCodePart . IRFunction function = Block . CodePart . GetFunction ( this ) ;
864+ IRCodePart . IRFunction function = Block ? . CodePart ? . GetFunction ( this ) ;
865+ if ( function != null )
866+ return function . Returns . Type ;
842867 if ( Optimization . Optimizer . FunctionManager . Exists ( Function . Replace ( "()" , "" ) ) )
843868 return Optimization . Optimizer . FunctionManager . FunctionReturnType ( Function . Replace ( "()" , "" ) ) ;
844869 if ( ! Direct && IndirectMethod is IRSuffixGetMethod suffixGetMethod )
845870 return suffixGetMethod . Type ;
846871 return typeof ( Encapsulation . Structure ) ;
847872 }
873+ public IInterimOperand Clone ( BasicBlock block )
874+ => new IRCall ( block , new OpcodeCall ( Function )
875+ {
876+ Direct = Direct ,
877+ SourceLine = SourceLine ,
878+ SourceColumn = SourceColumn
879+ } , EmitArgMarker , Arguments ) ;
848880 public override IEnumerable < Opcode > EmitOpcodes ( )
849881 {
850882 if ( EmitArgMarker )
0 commit comments