-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleFunc.cs
More file actions
65 lines (58 loc) · 1.59 KB
/
Copy pathSimpleFunc.cs
File metadata and controls
65 lines (58 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections.Generic;
using Liu233w.StackMachine.Instructions;
namespace Liu233w.StackMachine.Test
{
public class SimpleFunc : StackFrameFunction
{
private int _param;
private List<int> _simpleList;
private int _variable;
public SimpleFunc(int param, List<int> simpleList)
:base(0)
{
_param = param;
_simpleList = simpleList;
}
public SimpleFunc(SimpleFunc that)
: base(that)
{
_variable = that._variable;
_param = that._param;
// 不对 list 进行深拷贝
_simpleList = that._simpleList;
}
public override object Clone()
{
return new SimpleFunc(this);
}
protected override FuncInstructionBase StepMove(int pc, object lastReturned)
{
switch (pc)
{
case 0:
{
_simpleList.Add(_param);
_variable = _param;
return Continue();
}
case 1:
{
++_variable;
if (_variable < 10)
{
_simpleList.Add(_variable);
return GoTo(1);
}
else
{
return Return((_param, _variable));
}
}
default:
{
return null;
}
}
}
}
}