Skip to content

Commit

Permalink
use rain.string for int parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Nov 1, 2024
1 parent 9222db5 commit 5dfc95a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 59 deletions.
3 changes: 2 additions & 1 deletion src/generated/RainterpreterNPE2.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ bytes32 constant BYTECODE_HASH = bytes32(0xb2bb360cac3a5504625d94621550913d5024d
/// By setting these as a constant they can be inlined into the interpreter
/// and loaded at eval time for very low gas (~100) due to the compiler
/// optimising it to a single `codecopy` to build the in memory bytes array.
bytes constant OPCODE_FUNCTION_POINTERS = hex"06b407040746091209f90a0b0a1d0a360a780aca0adb0aec0b8e0bcb0c7a0cfe0d4d0e43";
bytes constant OPCODE_FUNCTION_POINTERS =
hex"06b407040746091209f90a0b0a1d0a360a780aca0adb0aec0b8e0bcb0c7a0cfe0d4d0e43";
2 changes: 1 addition & 1 deletion src/generated/RainterpreterParserNPE2.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0x6ceb7c73c69eaf63e3a95805892de0f17ff921c8cc8ae7694745fd7f832ecad5);
bytes32 constant BYTECODE_HASH = bytes32(0xd8315c246d10aebf39bd05e34e371579c45ebd604dc8ef3ffc5e8a236aeefd5c);

/// @dev The parse meta that is used to lookup word definitions.
/// The structure of the parse meta is:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xf8597dadf69ee1df0975d01a6e9e43563ff5966c950ed23c981086f46b4d7a8c);
bytes32 constant BYTECODE_HASH = bytes32(0x155b1207e5b24d9bcdd5de83fc1a9b543a3017dc1b9fb97674998f90cef422af);

/// @dev The hash of the meta that describes the contract.
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xadf71693c6ecf3fd560904bc46973d1b6e651440d15366673f9b3984749e7c16);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/parse/literal/LibParseLiteralDecimal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
CMASK_ZERO
} from "rain.string/lib/parse/LibParseCMask.sol";
import {LibParseChar} from "rain.string/lib/parse/LibParseChar.sol";
import {LibParseDecimal} from "rain.string/lib/parse/LibParseDecimal.sol";
import {LibParseError} from "../LibParseError.sol";
import {LibParse} from "../LibParse.sol";
import {LibDecimalFloatImplementation, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";
Expand All @@ -34,7 +35,10 @@ library LibParseLiteralDecimal {
uint256 isNeg = LibParseChar.isMask(cursor, end, CMASK_NEGATIVE_SIGN);
cursor += isNeg;

uint256 value = state.unsafeStrToInt(cursor, end);
(bool success, uint256 value) = LibParseDecimal.unsafeDecimalStringToInt(cursor, end);
if (!success) {
revert DecimalLiteralOverflow(state.parseErrorOffset(start));
}

if (isNeg != 0) {
if (value > uint256(type(int256).max) + 1) {
Expand Down

This file was deleted.

0 comments on commit 5dfc95a

Please sign in to comment.