Skip to content

Commit

Permalink
comment for jumptable (#3187)
Browse files Browse the repository at this point in the history
* update

* Update JumpTable.Push.cs

* update

* update

* update

* Update JumpTable.Compound.cs

* add pop and push times

* Update JumpTable.Push.cs
  • Loading branch information
chenzhitong authored Apr 2, 2024
1 parent c550fc2 commit 183fd9f
Show file tree
Hide file tree
Showing 9 changed files with 1,424 additions and 1 deletion.
45 changes: 45 additions & 0 deletions src/Neo.VM/JumpTable/JumpTable.Bitwisee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,32 @@

namespace Neo.VM
{
/// <summary>
/// Partial class for performing bitwise and logical operations on integers within a jump table.
/// </summary>
public partial class JumpTable
{
/// <summary>
/// Flips all of the bits of an integer.
/// <see cref="OpCode.INVERT"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 1, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void Invert(ExecutionEngine engine, Instruction instruction)
{
var x = engine.Pop().GetInteger();
engine.Push(~x);
}

/// <summary>
/// Computes the bitwise AND of two integers.
/// <see cref="OpCode.AND"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 2, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void And(ExecutionEngine engine, Instruction instruction)
{
Expand All @@ -30,6 +47,13 @@ public virtual void And(ExecutionEngine engine, Instruction instruction)
engine.Push(x1 & x2);
}

/// <summary>
/// Computes the bitwise OR of two integers.
/// <see cref="OpCode.OR"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 2, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void Or(ExecutionEngine engine, Instruction instruction)
{
Expand All @@ -38,6 +62,13 @@ public virtual void Or(ExecutionEngine engine, Instruction instruction)
engine.Push(x1 | x2);
}

/// <summary>
/// Computes the bitwise XOR (exclusive OR) of two integers.
/// <see cref="OpCode.XOR"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 2, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void XOr(ExecutionEngine engine, Instruction instruction)
{
Expand All @@ -46,6 +77,13 @@ public virtual void XOr(ExecutionEngine engine, Instruction instruction)
engine.Push(x1 ^ x2);
}

/// <summary>
/// Determines whether two objects are equal according to the execution engine's comparison rules.
/// <see cref="OpCode.EQUAL"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 2, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void Equal(ExecutionEngine engine, Instruction instruction)
{
Expand All @@ -54,6 +92,13 @@ public virtual void Equal(ExecutionEngine engine, Instruction instruction)
engine.Push(x1.Equals(x2, engine.Limits));
}

/// <summary>
/// Determines whether two objects are not equal according to the execution engine's comparison rules.
/// <see cref="OpCode.NOTEQUAL"/>
/// </summary>
/// <param name="engine">The execution engine.</param>
/// <param name="instruction">The instruction being executed.</param>
/// <remarks>Pop 2, Push 1</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void NotEqual(ExecutionEngine engine, Instruction instruction)
{
Expand Down
Loading

0 comments on commit 183fd9f

Please sign in to comment.