Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Nov 2, 2024
1 parent 238691b commit e27510a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
3 changes: 1 addition & 2 deletions src/generated/RainterpreterNPE2.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
14 changes: 13 additions & 1 deletion src/lib/parse/LibParseError.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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)
}
}
}
}
39 changes: 12 additions & 27 deletions src/lib/parse/literal/LibParseLiteralDecimal.sol
Original file line number Diff line number Diff line change
@@ -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);
}


}

0 comments on commit e27510a

Please sign in to comment.