Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
add new opcode REMOVE
Browse files Browse the repository at this point in the history
close #25
  • Loading branch information
Erik Zhang committed Jan 17, 2018
1 parent cb1c4c9 commit 2ab361a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/neo-vm/ExecutionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ private void ExecuteOp(OpCode opcode, ExecutionContext context)
items.Add(newItem);
}
break;

case OpCode.REVERSE:
{
StackItem arrItem = EvaluationStack.Pop();
Expand All @@ -796,6 +795,24 @@ private void ExecuteOp(OpCode opcode, ExecutionContext context)
((Types.Array)arrItem).Reverse();
}
break;
case OpCode.REMOVE:
{
int index = (int)EvaluationStack.Pop().GetBigInteger();
StackItem arrItem = EvaluationStack.Pop();
if (!arrItem.IsArray)
{
State |= VMState.FAULT;
return;
}
IList<StackItem> items = arrItem.GetArray();
if (index < 0 || index >= items.Count)
{
State |= VMState.FAULT;
return;
}
items.RemoveAt(index);
}
break;

// Exceptions
case OpCode.THROW:
Expand Down
1 change: 1 addition & 0 deletions src/neo-vm/OpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public enum OpCode : byte
NEWSTRUCT = 0xC6, //用作值類型
APPEND = 0xC8,
REVERSE = 0xC9,
REMOVE = 0xCA,

// Exceptions
THROW = 0xF0,
Expand Down
2 changes: 1 addition & 1 deletion src/neo-vm/neo-vm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Copyright>2016-2017 The Neo Project</Copyright>
<AssemblyTitle>Neo.VM</AssemblyTitle>
<Description>Neo.VM</Description>
<Version>2.0.4</Version>
<Version>2.0.5</Version>
<Authors>The Neo Project</Authors>
<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
<AssemblyName>Neo.VM</AssemblyName>
Expand Down

0 comments on commit 2ab361a

Please sign in to comment.