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

Applying REVERSE opcode for byte arrays too #57

Closed
wants to merge 2 commits into from

Conversation

igormcoelho
Copy link
Contributor

This is a possible solution to the issue raised at neo-vm page: #17

This is a possible solution to the issue raised at neo-vm page: neo-project#17
@erikzhang
Copy link
Member

erikzhang commented Oct 3, 2018

For Array, REVERSE does not push the result back onto the stack:

if (arrItem is VMArray array)
{
array.Reverse();
}

But in this PR, for byte array, it will push the result back onto the stack.

This makes the behavior of the REVERSE instruction inconsistent. I would prefer to add a new opcode.

Maybe we can delete the SIZE opcode because ARRAYSIZE can replace it.

case OpCode.ARRAYSIZE:
{
StackItem item = context.EvaluationStack.Pop();
if (item is ICollection collection)
context.EvaluationStack.Push(collection.Count);
else
context.EvaluationStack.Push(item.GetByteArray().Length);
}
break;

@igormcoelho
Copy link
Contributor Author

igormcoelho commented Oct 3, 2018

That's true, it's something I was starting to be worried about too... perhaps it becomes harder to simulate the results of the vm, and perhaps not worth the risk. Better not create opcodes with this irregular format.

This was referenced Oct 3, 2018
@igormcoelho
Copy link
Contributor Author

I'm abandoning this PR to favor this proposal here, I think it's better: #59

@igormcoelho igormcoelho closed this Oct 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants