File tree Expand file tree Collapse file tree 6 files changed +8
-10
lines changed
src/Domain/HydraScript.Domain.BackEnd
tests/HydraScript.UnitTests/Domain/BackEnd Expand file tree Collapse file tree 6 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 11namespace HydraScript . Domain . BackEnd ;
22
3- public class Frame ( IAddress returnAddress , Frame ? parentFrame = null )
3+ public class Frame ( Frame ? parentFrame = null )
44{
55 private readonly Dictionary < string , object ? > _variables = new ( ) ;
66
7- public IAddress ReturnAddress { get ; } = returnAddress ;
8-
97 public object ? this [ string id ]
108 {
119 get => _variables . TryGetValue ( id , out var value )
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ namespace HydraScript.Domain.BackEnd.Impl.Instructions;
22
33public class Return ( IValue ? value = null ) : Instruction
44{
5- public override IAddress Execute ( IExecuteParams executeParams )
5+ public override IAddress ? Execute ( IExecuteParams executeParams )
66 {
77 var frame = executeParams . Frames . Pop ( ) ;
88 var call = executeParams . CallStack . Pop ( ) ;
@@ -11,7 +11,7 @@ public override IAddress Execute(IExecuteParams executeParams)
1111 executeParams . Frames . Peek ( ) [ call . Where ] = value . Get ( frame ) ;
1212 }
1313
14- return frame . ReturnAddress ;
14+ return call . From . Next ;
1515 }
1616
1717 protected override string ToStringInternal ( ) =>
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ protected override void OnSetOfAddress(IAddress address)
1212
1313 public override IAddress Execute ( IExecuteParams executeParams )
1414 {
15- var frame = new Frame ( Address . Next ! , executeParams . Frames . Peek ( ) ) ;
15+ var frame = new Frame ( executeParams . Frames . Peek ( ) ) ;
1616 executeParams . CallStack . Push ( new Call ( Address , function , Left ) ) ;
1717 executeParams . Frames . Push ( frame ) ;
1818 return function . Start ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class VirtualMachine(IOutputWriter writer) : IVirtualMachine
66
77 public void Run ( AddressedInstructions instructions )
88 {
9- ExecuteParams . Frames . Push ( new Frame ( instructions . Start ) ) ;
9+ ExecuteParams . Frames . Push ( new Frame ( ) ) ;
1010
1111 var address = instructions . Start ;
1212 while ( address is not null )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public void Execute_String_NoQuotes(VirtualMachine vm)
1212 {
1313 // Arrange
1414 AddressedInstructions program = [ new AsString ( new Constant ( "string" ) ) ] ;
15- vm . ExecuteParams . Frames . Push ( new Frame ( program . Start ) ) ;
15+ vm . ExecuteParams . Frames . Push ( new Frame ( ) ) ;
1616
1717 // Act
1818 program [ program . Start ] . Execute ( vm . ExecuteParams ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public class VirtualMachineTests
1717 public void CorrectPrintToOutTest ( [ Frozen ] IOutputWriter writer , IExecuteParams exParams )
1818 {
1919 exParams . CallStack . Returns ( new Stack < Call > ( ) ) ;
20- exParams . Frames . Returns ( new Stack < Frame > ( [ new Frame ( new HashAddress ( 0 ) ) ] ) ) ;
20+ exParams . Frames . Returns ( new Stack < Frame > ( [ new Frame ( ) ] ) ) ;
2121 exParams . Arguments . Returns ( new Queue < object ? > ( ) ) ;
2222
2323 var print = new Print ( new Constant ( 223 ) )
@@ -95,7 +95,7 @@ public void VirtualMachineHandlesRecursionTest(VirtualMachine vm)
9595 [ Theory , AutoHydraScriptData ]
9696 public void CreateArrayReservesCertainSpaceTest ( ExecuteParams vm )
9797 {
98- vm . Frames . Push ( new Frame ( new HashAddress ( 0 ) ) ) ;
98+ vm . Frames . Push ( new Frame ( ) ) ;
9999
100100 var createArray = new CreateArray ( "arr" , 6 )
101101 {
You can’t perform that action at this time.
0 commit comments