summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/SourceRange.h
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-11 01:16:17 +0430
committerLinus Groh <mail@linusgroh.de>2021-07-11 21:41:54 +0100
commit1a9518ebe313f10091da92e73de76b4ab2f2d875 (patch)
tree0bcf7429be2941e314df5209f5ed8f7983f328fb /Userland/Libraries/LibJS/SourceRange.h
parent7fc6cd6b20ea0f9252c733de5c3249605a3bd130 (diff)
downloadserenity-1a9518ebe313f10091da92e73de76b4ab2f2d875.zip
LibJS: Implement parsing and evaluation for AssignmentPatterns
e.g. `[...foo] = bar` can now be evaluated :^)
Diffstat (limited to 'Userland/Libraries/LibJS/SourceRange.h')
-rw-r--r--Userland/Libraries/LibJS/SourceRange.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/SourceRange.h b/Userland/Libraries/LibJS/SourceRange.h
index 936863ecc7..b92208dc32 100644
--- a/Userland/Libraries/LibJS/SourceRange.h
+++ b/Userland/Libraries/LibJS/SourceRange.h
@@ -13,9 +13,12 @@ namespace JS {
struct Position {
size_t line { 0 };
size_t column { 0 };
+ size_t offset { 0 };
};
struct SourceRange {
+ [[nodiscard]] bool contains(Position const& position) const { return position.offset <= end.offset && position.offset >= start.offset; }
+
StringView filename;
Position start;
Position end;