diff --git a/lib/rain.string b/lib/rain.string index d0cd1348..2969d6c1 160000 --- a/lib/rain.string +++ b/lib/rain.string @@ -1 +1 @@ -Subproject commit d0cd13488f18d5e473be090b70f72bd91d77fb97 +Subproject commit 2969d6c16e4e1f799e9d01406528939fc53353c2 diff --git a/src/generated/RainterpreterNPE2.pointers.sol b/src/generated/RainterpreterNPE2.pointers.sol index 0126ad37..6621bead 100644 --- a/src/generated/RainterpreterNPE2.pointers.sol +++ b/src/generated/RainterpreterNPE2.pointers.sol @@ -15,5 +15,4 @@ 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"; diff --git a/src/lib/parse/LibParseError.sol b/src/lib/parse/LibParseError.sol index 9a1e7e51..ef9d125d 100644 --- a/src/lib/parse/LibParseError.sol +++ b/src/lib/parse/LibParseError.sol @@ -1,4 +1,5 @@ -// SPDX-License-Identifier: CAL +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 thedavidmeister pragma solidity ^0.8.18; import {ParseState} from "./LibParseState.sol"; @@ -10,4 +11,15 @@ library LibParseError { offset := sub(cursor, add(data, 0x20)) } } + + function handleErrorSelector(ParseState memory state, bytes4 errorSelector, uint256 cursor) internal pure { + if (errorSelector != 0) { + uint256 errorOffset = parseErrorOffset(state, cursor); + assembly ("memory-safe") { + mstore(0, errorSelector) + mstore(4, errorOffset) + revert(0, 0x24) + } + } + } } diff --git a/src/lib/parse/literal/LibParseLiteralDecimal.sol b/src/lib/parse/literal/LibParseLiteralDecimal.sol index c0dc3445..4eab50cb 100644 --- a/src/lib/parse/literal/LibParseLiteralDecimal.sol +++ b/src/lib/parse/literal/LibParseLiteralDecimal.sol @@ -1,37 +1,22 @@ -// SPDX-License-Identifier: CAL +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 thedavidmeister pragma solidity ^0.8.18; import {ParseState} from "../LibParseState.sol"; -import { - DecimalLiteralOverflow, - ZeroLengthDecimal, - MalformedExponentDigits, - MalformedDecimalPoint, - DecimalLiteralPrecisionLoss -} from "../../../error/ErrParse.sol"; -import { - CMASK_E_NOTATION, - CMASK_NUMERIC_0_9, - CMASK_DECIMAL_POINT, - CMASK_NEGATIVE_SIGN, - 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"; +import {LibParseDecimalFloat} from "rain.math.float/lib/parse/LibParseDecimalFloat.sol"; library LibParseLiteralDecimal { using LibParseError for ParseState; - using LibParseLiteralDecimal for ParseState; - function parseDecimalFloatPacked(ParseState memory state) internal view returns (LibDecimalFloat.Data memory) { - LibDecimalFloat.Data memory result; - result = self.parseDecimalFloat(); - self.assertEnd(); - return result; + function parseDecimalFloatPacked(ParseState memory state, uint256 start, uint256 end) + internal + pure + returns (uint256, uint256) + { + (bytes4 errorSelector, uint256 cursor, uint256 packedFloat) = + LibParseDecimalFloat.parseDecimalFloatPacked(start, end); + state.handleErrorSelector(errorSelector, cursor); + return (cursor, packedFloat); } - - }