diff --git a/src/Neo.GUI/GUI/ElectionDialog.cs b/src/Neo.GUI/GUI/ElectionDialog.cs index ddc730589e..ef644074d9 100644 --- a/src/Neo.GUI/GUI/ElectionDialog.cs +++ b/src/Neo.GUI/GUI/ElectionDialog.cs @@ -10,7 +10,7 @@ // modifications are permitted. using Neo.Cryptography.ECC; -using Neo.IO; +using Neo.Extensions; using Neo.SmartContract.Native; using Neo.VM; using System; diff --git a/src/Neo.GUI/GUI/VotingDialog.cs b/src/Neo.GUI/GUI/VotingDialog.cs index d289cc48ca..ff5749e181 100644 --- a/src/Neo.GUI/GUI/VotingDialog.cs +++ b/src/Neo.GUI/GUI/VotingDialog.cs @@ -10,7 +10,7 @@ // modifications are permitted. using Neo.Cryptography.ECC; -using Neo.IO; +using Neo.Extensions; using Neo.SmartContract; using Neo.SmartContract.Native; using Neo.VM; diff --git a/src/Neo/Extensions/Collections/ICollectionExtensions.cs b/src/Neo/Extensions/Collections/ICollectionExtensions.cs index 724def6d80..742446a4e8 100644 --- a/src/Neo/Extensions/Collections/ICollectionExtensions.cs +++ b/src/Neo/Extensions/Collections/ICollectionExtensions.cs @@ -9,6 +9,7 @@ // Redistribution and use in source and binary forms with or without // modifications are permitted. +using Neo.Extensions; using Neo.IO; using System.Collections.Generic; using System.IO; diff --git a/src/Neo/Extensions/VM/ScriptBuilderExtensions.cs b/src/Neo/Extensions/VM/ScriptBuilderExtensions.cs new file mode 100644 index 0000000000..ee64bb5736 --- /dev/null +++ b/src/Neo/Extensions/VM/ScriptBuilderExtensions.cs @@ -0,0 +1,306 @@ +// Copyright (C) 2015-2024 The Neo Project. +// +// ScriptBuilderExtensions.cs file belongs to the neo project and is free +// software distributed under the MIT software license, see the +// accompanying file LICENSE in the main directory of the +// repository or http://www.opensource.org/licenses/mit-license.php +// for more details. +// +// Redistribution and use in source and binary forms with or without +// modifications are permitted. + +using Neo.Cryptography.ECC; +using Neo.IO; +using Neo.SmartContract; +using Neo.VM; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; + +namespace Neo.Extensions +{ + public static class ScriptBuilderExtensions + { + /// + /// Emits the opcodes for creating an array. + /// + /// The type of the elements of the array. + /// The to be used. + /// The elements of the array. + /// The same instance as . + public static ScriptBuilder CreateArray(this ScriptBuilder builder, IReadOnlyList list = null) + { + if (list is null || list.Count == 0) + return builder.Emit(OpCode.NEWARRAY0); + for (var i = list.Count - 1; i >= 0; i--) + builder.EmitPush(list[i]); + builder.EmitPush(list.Count); + return builder.Emit(OpCode.PACK); + } + + /// + /// Emits the opcodes for creating a map. + /// + /// The type of the key of the map. + /// The type of the value of the map. + /// The to be used. + /// The key/value pairs of the map. + /// The same instance as . + public static ScriptBuilder CreateMap(this ScriptBuilder builder, IEnumerable> map) + where TKey : notnull + where TValue : notnull + { + var count = map.Count(); + + if (count == 0) + return builder.Emit(OpCode.NEWMAP); + + foreach (var (key, value) in map.Reverse()) + { + builder.EmitPush(value); + builder.EmitPush(key); + } + builder.EmitPush(count); + return builder.Emit(OpCode.PACKMAP); + } + + /// + /// Emits the opcodes for creating a map. + /// + /// The type of the key of the map. + /// The type of the value of the map. + /// The to be used. + /// The key/value pairs of the map. + /// The same instance as . + public static ScriptBuilder CreateMap(this ScriptBuilder builder, IReadOnlyDictionary map) + where TKey : notnull + where TValue : notnull + { + if (map.Count == 0) + return builder.Emit(OpCode.NEWMAP); + + foreach (var (key, value) in map.Reverse()) + { + builder.EmitPush(value); + builder.EmitPush(key); + } + builder.EmitPush(map.Count); + return builder.Emit(OpCode.PACKMAP); + } + + /// + /// Emits the opcodes for creating a struct. + /// + /// The type of the property. + /// The to be used. + /// The list of properties. + /// The same instance as . + public static ScriptBuilder CreateStruct(this ScriptBuilder builder, IReadOnlyList array) + where T : notnull + { + if (array.Count == 0) + return builder.Emit(OpCode.NEWSTRUCT0); + for (var i = array.Count - 1; i >= 0; i--) + builder.EmitPush(array[i]); + builder.EmitPush(array.Count); + return builder.Emit(OpCode.PACKSTRUCT); + } + + /// + /// Emits the specified opcodes. + /// + /// The to be used. + /// The opcodes to emit. + /// The same instance as . + public static ScriptBuilder Emit(this ScriptBuilder builder, params OpCode[] ops) + { + foreach (var op in ops) + builder.Emit(op); + return builder; + } + + /// + /// Emits the opcodes for calling a contract dynamically. + /// + /// The to be used. + /// The hash of the contract to be called. + /// The method to be called in the contract. + /// The arguments for calling the contract. + /// The same instance as . + public static ScriptBuilder EmitDynamicCall(this ScriptBuilder builder, UInt160 scriptHash, string method, params object[] args) + { + return EmitDynamicCall(builder, scriptHash, method, CallFlags.All, args); + } + + /// + /// Emits the opcodes for calling a contract dynamically. + /// + /// The to be used. + /// The hash of the contract to be called. + /// The method to be called in the contract. + /// The for calling the contract. + /// The arguments for calling the contract. + /// The same instance as . + public static ScriptBuilder EmitDynamicCall(this ScriptBuilder builder, UInt160 scriptHash, string method, CallFlags flags, params object[] args) + { + builder.CreateArray(args); + builder.EmitPush(flags); + builder.EmitPush(method); + builder.EmitPush(scriptHash); + builder.EmitSysCall(ApplicationEngine.System_Contract_Call); + return builder; + } + + /// + /// Emits the opcodes for pushing the specified data onto the stack. + /// + /// The to be used. + /// The data to be pushed. + /// The same instance as . + public static ScriptBuilder EmitPush(this ScriptBuilder builder, ISerializable data) + { + return builder.EmitPush(data.ToArray()); + } + + /// + /// Emits the opcodes for pushing the specified data onto the stack. + /// + /// The to be used. + /// The data to be pushed. + /// The same instance as . + public static ScriptBuilder EmitPush(this ScriptBuilder builder, ContractParameter parameter) + { + if (parameter.Value is null) + builder.Emit(OpCode.PUSHNULL); + else + switch (parameter.Type) + { + case ContractParameterType.Signature: + case ContractParameterType.ByteArray: + builder.EmitPush((byte[])parameter.Value); + break; + case ContractParameterType.Boolean: + builder.EmitPush((bool)parameter.Value); + break; + case ContractParameterType.Integer: + if (parameter.Value is BigInteger bi) + builder.EmitPush(bi); + else + builder.EmitPush((BigInteger)typeof(BigInteger).GetConstructor([parameter.Value.GetType()]).Invoke([parameter.Value])); + break; + case ContractParameterType.Hash160: + builder.EmitPush((UInt160)parameter.Value); + break; + case ContractParameterType.Hash256: + builder.EmitPush((UInt256)parameter.Value); + break; + case ContractParameterType.PublicKey: + builder.EmitPush((ECPoint)parameter.Value); + break; + case ContractParameterType.String: + builder.EmitPush((string)parameter.Value); + break; + case ContractParameterType.Array: + { + var parameters = (IList)parameter.Value; + for (var i = parameters.Count - 1; i >= 0; i--) + builder.EmitPush(parameters[i]); + builder.EmitPush(parameters.Count); + builder.Emit(OpCode.PACK); + } + break; + case ContractParameterType.Map: + { + var pairs = (IList>)parameter.Value; + builder.CreateMap(pairs); + } + break; + default: + throw new ArgumentException(null, nameof(parameter)); + } + return builder; + } + + /// + /// Emits the opcodes for pushing the specified data onto the stack. + /// + /// The to be used. + /// The data to be pushed. + /// The same instance as . + public static ScriptBuilder EmitPush(this ScriptBuilder builder, object obj) + { + switch (obj) + { + case bool data: + builder.EmitPush(data); + break; + case byte[] data: + builder.EmitPush(data); + break; + case string data: + builder.EmitPush(data); + break; + case BigInteger data: + builder.EmitPush(data); + break; + case ISerializable data: + builder.EmitPush(data); + break; + case sbyte data: + builder.EmitPush(data); + break; + case byte data: + builder.EmitPush(data); + break; + case short data: + builder.EmitPush(data); + break; + case char data: + builder.EmitPush(data); + break; + case ushort data: + builder.EmitPush(data); + break; + case int data: + builder.EmitPush(data); + break; + case uint data: + builder.EmitPush(data); + break; + case long data: + builder.EmitPush(data); + break; + case ulong data: + builder.EmitPush(data); + break; + case Enum data: + builder.EmitPush(BigInteger.Parse(data.ToString("d"))); + break; + case ContractParameter data: + builder.EmitPush(data); + break; + case null: + builder.Emit(OpCode.PUSHNULL); + break; + default: + throw new ArgumentException(null, nameof(obj)); + } + return builder; + } + + /// + /// Emits the opcodes for invoking an interoperable service. + /// + /// The to be used. + /// The hash of the interoperable service. + /// The arguments for calling the interoperable service. + /// The same instance as . + public static ScriptBuilder EmitSysCall(this ScriptBuilder builder, uint method, params object[] args) + { + for (var i = args.Length - 1; i >= 0; i--) + EmitPush(builder, args[i]); + return builder.EmitSysCall(method); + } + } +} diff --git a/src/Neo/SmartContract/ContractParametersContext.cs b/src/Neo/SmartContract/ContractParametersContext.cs index c4129f0ad1..ea5ea35ab8 100644 --- a/src/Neo/SmartContract/ContractParametersContext.cs +++ b/src/Neo/SmartContract/ContractParametersContext.cs @@ -10,6 +10,7 @@ // modifications are permitted. using Neo.Cryptography.ECC; +using Neo.Extensions; using Neo.IO; using Neo.Json; using Neo.Network.P2P.Payloads; diff --git a/src/Neo/SmartContract/Helper.cs b/src/Neo/SmartContract/Helper.cs index d0bc3c939b..96ec2af03c 100644 --- a/src/Neo/SmartContract/Helper.cs +++ b/src/Neo/SmartContract/Helper.cs @@ -11,6 +11,7 @@ using Neo.Cryptography; using Neo.Cryptography.ECC; +using Neo.Extensions; using Neo.Network.P2P.Payloads; using Neo.Persistence; using Neo.SmartContract.Manifest; diff --git a/src/Neo/VM/Helper.cs b/src/Neo/VM/Helper.cs index 0a9a106e1f..3ac202a818 100644 --- a/src/Neo/VM/Helper.cs +++ b/src/Neo/VM/Helper.cs @@ -11,7 +11,6 @@ using Neo.Cryptography.ECC; using Neo.Extensions; -using Neo.IO; using Neo.Json; using Neo.SmartContract; using Neo.VM.Types; @@ -30,287 +29,6 @@ namespace Neo.VM /// public static class Helper { - /// - /// Emits the opcodes for creating an array. - /// - /// The type of the elements of the array. - /// The to be used. - /// The elements of the array. - /// The same instance as . - public static ScriptBuilder CreateArray(this ScriptBuilder builder, IReadOnlyList list = null) - { - if (list is null || list.Count == 0) - return builder.Emit(OpCode.NEWARRAY0); - for (int i = list.Count - 1; i >= 0; i--) - builder.EmitPush(list[i]); - builder.EmitPush(list.Count); - return builder.Emit(OpCode.PACK); - } - - /// - /// Emits the opcodes for creating a map. - /// - /// The type of the key of the map. - /// The type of the value of the map. - /// The to be used. - /// The key/value pairs of the map. - /// The same instance as . - public static ScriptBuilder CreateMap(this ScriptBuilder builder, IEnumerable> map) - where TKey : notnull - where TValue : notnull - { - var count = map.Count(); - - if (count == 0) - return builder.Emit(OpCode.NEWMAP); - - foreach (var (key, value) in map.Reverse()) - { - builder.EmitPush(value); - builder.EmitPush(key); - } - builder.EmitPush(count); - return builder.Emit(OpCode.PACKMAP); - } - - /// - /// Emits the opcodes for creating a map. - /// - /// The type of the key of the map. - /// The type of the value of the map. - /// The to be used. - /// The key/value pairs of the map. - /// The same instance as . - public static ScriptBuilder CreateMap(this ScriptBuilder builder, IReadOnlyDictionary map) - where TKey : notnull - where TValue : notnull - { - if (map.Count == 0) - return builder.Emit(OpCode.NEWMAP); - - foreach (var (key, value) in map.Reverse()) - { - builder.EmitPush(value); - builder.EmitPush(key); - } - builder.EmitPush(map.Count); - return builder.Emit(OpCode.PACKMAP); - } - - /// - /// Emits the opcodes for creating a struct. - /// - /// The type of the property. - /// The to be used. - /// The list of properties. - /// The same instance as . - public static ScriptBuilder CreateStruct(this ScriptBuilder builder, IReadOnlyList array) - where T : notnull - { - if (array.Count == 0) - return builder.Emit(OpCode.NEWSTRUCT0); - for (var i = array.Count - 1; i >= 0; i--) - builder.EmitPush(array[i]); - builder.EmitPush(array.Count); - return builder.Emit(OpCode.PACKSTRUCT); - } - - /// - /// Emits the specified opcodes. - /// - /// The to be used. - /// The opcodes to emit. - /// The same instance as . - public static ScriptBuilder Emit(this ScriptBuilder builder, params OpCode[] ops) - { - foreach (OpCode op in ops) - builder.Emit(op); - return builder; - } - - /// - /// Emits the opcodes for calling a contract dynamically. - /// - /// The to be used. - /// The hash of the contract to be called. - /// The method to be called in the contract. - /// The arguments for calling the contract. - /// The same instance as . - public static ScriptBuilder EmitDynamicCall(this ScriptBuilder builder, UInt160 scriptHash, string method, params object[] args) - { - return EmitDynamicCall(builder, scriptHash, method, CallFlags.All, args); - } - - /// - /// Emits the opcodes for calling a contract dynamically. - /// - /// The to be used. - /// The hash of the contract to be called. - /// The method to be called in the contract. - /// The for calling the contract. - /// The arguments for calling the contract. - /// The same instance as . - public static ScriptBuilder EmitDynamicCall(this ScriptBuilder builder, UInt160 scriptHash, string method, CallFlags flags, params object[] args) - { - builder.CreateArray(args); - builder.EmitPush(flags); - builder.EmitPush(method); - builder.EmitPush(scriptHash); - builder.EmitSysCall(ApplicationEngine.System_Contract_Call); - return builder; - } - - /// - /// Emits the opcodes for pushing the specified data onto the stack. - /// - /// The to be used. - /// The data to be pushed. - /// The same instance as . - public static ScriptBuilder EmitPush(this ScriptBuilder builder, ISerializable data) - { - return builder.EmitPush(data.ToArray()); - } - - /// - /// Emits the opcodes for pushing the specified data onto the stack. - /// - /// The to be used. - /// The data to be pushed. - /// The same instance as . - public static ScriptBuilder EmitPush(this ScriptBuilder builder, ContractParameter parameter) - { - if (parameter.Value is null) - builder.Emit(OpCode.PUSHNULL); - else - switch (parameter.Type) - { - case ContractParameterType.Signature: - case ContractParameterType.ByteArray: - builder.EmitPush((byte[])parameter.Value); - break; - case ContractParameterType.Boolean: - builder.EmitPush((bool)parameter.Value); - break; - case ContractParameterType.Integer: - if (parameter.Value is BigInteger bi) - builder.EmitPush(bi); - else - builder.EmitPush((BigInteger)typeof(BigInteger).GetConstructor(new[] { parameter.Value.GetType() }).Invoke(new[] { parameter.Value })); - break; - case ContractParameterType.Hash160: - builder.EmitPush((UInt160)parameter.Value); - break; - case ContractParameterType.Hash256: - builder.EmitPush((UInt256)parameter.Value); - break; - case ContractParameterType.PublicKey: - builder.EmitPush((ECPoint)parameter.Value); - break; - case ContractParameterType.String: - builder.EmitPush((string)parameter.Value); - break; - case ContractParameterType.Array: - { - IList parameters = (IList)parameter.Value; - for (int i = parameters.Count - 1; i >= 0; i--) - builder.EmitPush(parameters[i]); - builder.EmitPush(parameters.Count); - builder.Emit(OpCode.PACK); - } - break; - case ContractParameterType.Map: - { - var pairs = (IList>)parameter.Value; - builder.CreateMap(pairs); - } - break; - default: - throw new ArgumentException(null, nameof(parameter)); - } - return builder; - } - - /// - /// Emits the opcodes for pushing the specified data onto the stack. - /// - /// The to be used. - /// The data to be pushed. - /// The same instance as . - public static ScriptBuilder EmitPush(this ScriptBuilder builder, object obj) - { - switch (obj) - { - case bool data: - builder.EmitPush(data); - break; - case byte[] data: - builder.EmitPush(data); - break; - case string data: - builder.EmitPush(data); - break; - case BigInteger data: - builder.EmitPush(data); - break; - case ISerializable data: - builder.EmitPush(data); - break; - case sbyte data: - builder.EmitPush(data); - break; - case byte data: - builder.EmitPush(data); - break; - case short data: - builder.EmitPush(data); - break; - case char data: - builder.EmitPush(data); - break; - case ushort data: - builder.EmitPush(data); - break; - case int data: - builder.EmitPush(data); - break; - case uint data: - builder.EmitPush(data); - break; - case long data: - builder.EmitPush(data); - break; - case ulong data: - builder.EmitPush(data); - break; - case Enum data: - builder.EmitPush(BigInteger.Parse(data.ToString("d"))); - break; - case ContractParameter data: - builder.EmitPush(data); - break; - case null: - builder.Emit(OpCode.PUSHNULL); - break; - default: - throw new ArgumentException(null, nameof(obj)); - } - return builder; - } - - /// - /// Emits the opcodes for invoking an interoperable service. - /// - /// The to be used. - /// The hash of the interoperable service. - /// The arguments for calling the interoperable service. - /// The same instance as . - public static ScriptBuilder EmitSysCall(this ScriptBuilder builder, uint method, params object[] args) - { - for (int i = args.Length - 1; i >= 0; i--) - EmitPush(builder, args[i]); - return builder.EmitSysCall(method); - } - /// /// Generates the script for calling a contract dynamically. /// diff --git a/src/Neo/Wallets/AssetDescriptor.cs b/src/Neo/Wallets/AssetDescriptor.cs index 7b9be7b16b..e8ba27b4e4 100644 --- a/src/Neo/Wallets/AssetDescriptor.cs +++ b/src/Neo/Wallets/AssetDescriptor.cs @@ -9,6 +9,7 @@ // Redistribution and use in source and binary forms with or without // modifications are permitted. +using Neo.Extensions; using Neo.Persistence; using Neo.SmartContract; using Neo.SmartContract.Native; diff --git a/src/Plugins/RpcClient/ContractClient.cs b/src/Plugins/RpcClient/ContractClient.cs index f4ec020abc..02b8edc5ef 100644 --- a/src/Plugins/RpcClient/ContractClient.cs +++ b/src/Plugins/RpcClient/ContractClient.cs @@ -9,6 +9,7 @@ // Redistribution and use in source and binary forms with or without // modifications are permitted. +using Neo.Extensions; using Neo.Network.P2P.Payloads; using Neo.Network.RPC.Models; using Neo.SmartContract; diff --git a/tests/Neo.Plugins.OracleService.Tests/E2E_Https.cs b/tests/Neo.Plugins.OracleService.Tests/E2E_Https.cs index c404f3f982..b9e2d407f8 100644 --- a/tests/Neo.Plugins.OracleService.Tests/E2E_Https.cs +++ b/tests/Neo.Plugins.OracleService.Tests/E2E_Https.cs @@ -14,6 +14,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Neo.Cryptography; using Neo.Cryptography.ECC; +using Neo.Extensions; using Neo.Network.P2P.Payloads; using Neo.SmartContract; using Neo.SmartContract.Native; diff --git a/tests/Neo.Plugins.OracleService.Tests/TestBlockchain.cs b/tests/Neo.Plugins.OracleService.Tests/TestBlockchain.cs index 160ac0407e..229a5f361d 100644 --- a/tests/Neo.Plugins.OracleService.Tests/TestBlockchain.cs +++ b/tests/Neo.Plugins.OracleService.Tests/TestBlockchain.cs @@ -10,6 +10,7 @@ // modifications are permitted. using Akka.Actor; +using Neo.Extensions; using Neo.Ledger; using Neo.Network.P2P.Payloads; using Neo.Persistence; diff --git a/tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs b/tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs index a3f33f26a7..d32e16d0c6 100644 --- a/tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs +++ b/tests/Neo.UnitTests/Extensions/Nep17NativeContractExtensions.cs @@ -10,6 +10,7 @@ // modifications are permitted. using FluentAssertions; +using Neo.Extensions; using Neo.IO; using Neo.Network.P2P.Payloads; using Neo.Persistence; diff --git a/tests/Neo.UnitTests/SmartContract/Native/UT_NativeContract.cs b/tests/Neo.UnitTests/SmartContract/Native/UT_NativeContract.cs index f9a3089f9d..64d6338f0c 100644 --- a/tests/Neo.UnitTests/SmartContract/Native/UT_NativeContract.cs +++ b/tests/Neo.UnitTests/SmartContract/Native/UT_NativeContract.cs @@ -11,6 +11,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.Extensions; using Neo.Network.P2P.Payloads; using Neo.Persistence; using Neo.SmartContract; diff --git a/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.Contract.cs b/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.Contract.cs index f9dc5e7b46..2d71b97e25 100644 --- a/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.Contract.cs +++ b/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.Contract.cs @@ -11,6 +11,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.Extensions; using Neo.SmartContract; using Neo.VM; using System.Linq; diff --git a/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.cs b/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.cs index def978596e..26df1a1639 100644 --- a/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.cs +++ b/tests/Neo.UnitTests/SmartContract/UT_ApplicationEngine.cs @@ -11,6 +11,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.Extensions; using Neo.SmartContract; using Neo.SmartContract.Manifest; using Neo.UnitTests.Extensions; diff --git a/tests/Neo.UnitTests/SmartContract/UT_Contract.cs b/tests/Neo.UnitTests/SmartContract/UT_Contract.cs index 07ae320a0f..ecd8532faa 100644 --- a/tests/Neo.UnitTests/SmartContract/UT_Contract.cs +++ b/tests/Neo.UnitTests/SmartContract/UT_Contract.cs @@ -11,6 +11,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.Extensions; using Neo.Network.P2P.Payloads; using Neo.SmartContract; using Neo.SmartContract.Native; diff --git a/tests/Neo.UnitTests/VM/UT_Helper.cs b/tests/Neo.UnitTests/VM/UT_Helper.cs index cabe0c7a02..cd7b8f01bb 100644 --- a/tests/Neo.UnitTests/VM/UT_Helper.cs +++ b/tests/Neo.UnitTests/VM/UT_Helper.cs @@ -452,7 +452,7 @@ private void TestEmitPush3Ulong() { ScriptBuilder sb = new ScriptBuilder(); ulong temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -462,7 +462,7 @@ private void TestEmitPush3Long() { ScriptBuilder sb = new ScriptBuilder(); long temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -472,7 +472,7 @@ private void TestEmitPush3Uint() { ScriptBuilder sb = new ScriptBuilder(); uint temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -482,7 +482,7 @@ private void TestEmitPush3Int() { ScriptBuilder sb = new ScriptBuilder(); int temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -492,7 +492,7 @@ private void TestEmitPush3Ushort() { ScriptBuilder sb = new ScriptBuilder(); ushort temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -502,7 +502,7 @@ private void TestEmitPush3Char() { ScriptBuilder sb = new ScriptBuilder(); char temp = char.MinValue; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -512,7 +512,7 @@ private void TestEmitPush3Short() { ScriptBuilder sb = new ScriptBuilder(); short temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -522,7 +522,7 @@ private void TestEmitPush3Byte() { ScriptBuilder sb = new ScriptBuilder(); byte temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray()); @@ -532,7 +532,7 @@ private void TestEmitPush3Sbyte() { ScriptBuilder sb = new ScriptBuilder(); sbyte temp = 0; - VM.Helper.EmitPush(sb, temp); + sb.EmitPush(temp); byte[] tempArray = new byte[1]; tempArray[0] = (byte)OpCode.PUSH0; CollectionAssert.AreEqual(tempArray, sb.ToArray());