Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
627582b6
Commit
627582b6
authored
Mar 18, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚧
Implementing operator<
parent
74820217
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
42 deletions
+64
-42
CMakeLists.txt
CMakeLists.txt
+1
-1
comparison.hpp
src/kyut/comparison.hpp
+63
-41
No files found.
CMakeLists.txt
View file @
627582b6
...
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.0)
project
(
wasm-watermarker VERSION 0.1.0 LANGUAGES C CXX
)
set
(
CMAKE_CXX_FLAGS
"-std=c++17 -Wall -Wextra -Werror -pedantic
-fconcepts
"
)
set
(
CMAKE_CXX_FLAGS
"-std=c++17 -Wall -Wextra -Werror -pedantic"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g3 -O0"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O2 -DNDEBUG"
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-g -Og"
)
...
...
src/kyut/comparison.hpp
View file @
627582b6
...
...
@@ -36,6 +36,23 @@ namespace wasm {
}
}
bool
operator
<
(
const
ExpressionList
&
lhs
,
const
ExpressionList
&
rhs
)
noexcept
{
auto
lIt
=
lhs
.
begin
();
auto
lEnd
=
lhs
.
end
();
auto
rIt
=
rhs
.
begin
();
auto
rEnd
=
rhs
.
end
();
for
(;
lIt
!=
lEnd
&&
rIt
!=
rEnd
;
++
lIt
,
++
rIt
)
{
if
(
**
lIt
<
**
rIt
)
{
return
true
;
}
else
if
(
**
rIt
<
**
lIt
)
{
return
false
;
}
}
return
!
(
lIt
!=
lEnd
)
&&
rIt
!=
rEnd
;
}
bool
operator
<
(
const
Expression
&
lhs
,
const
Expression
&
rhs
)
noexcept
{
if
(
lhs
.
_id
!=
rhs
.
_id
)
{
return
lhs
.
_id
<
rhs
.
_id
;
...
...
@@ -46,31 +63,7 @@ namespace wasm {
const
auto
&
l
=
static_cast
<
const
Block
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
Block
&>
(
rhs
);
if
(
l
.
type
!=
r
.
type
)
{
return
l
.
type
<
r
.
type
;
}
// FIXME: use std.
auto
lIt
=
std
::
begin
(
l
.
list
);
auto
lEnd
=
std
::
end
(
l
.
list
);
auto
rIt
=
std
::
begin
(
r
.
list
);
auto
rEnd
=
std
::
end
(
r
.
list
);
for
(;
lIt
!=
lEnd
&&
rIt
!=
rEnd
;
++
lIt
,
++
rIt
)
{
if
(
**
lIt
<
**
rIt
)
{
return
true
;
}
else
if
(
**
rIt
<
**
lIt
)
{
return
false
;
}
}
return
!
(
lIt
!=
lEnd
)
&&
rIt
!=
rEnd
;
// return std::lexicographical_compare(std::begin(l.list),
// std::end(l.list),
// std::begin(r.list),
// std::end(r.list),
// [](const auto &a, const auto &b) { return *a < *b; });
return
std
::
tie
(
l
.
type
,
l
.
list
)
<
std
::
tie
(
r
.
type
,
r
.
list
);
}
case
Expression
:
:
Id
::
IfId
:
{
...
...
@@ -108,11 +101,17 @@ namespace wasm {
case
Expression
:
:
Id
::
SwitchId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
CallId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
CallId
:
{
const
auto
&
l
=
static_cast
<
const
Call
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
Call
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
operands
,
l
.
target
)
<
std
::
tie
(
r
.
type
,
r
.
operands
,
r
.
target
);
}
case
Expression
:
:
Id
::
CallIndirectId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
CallIndirectId
:
{
const
auto
&
l
=
static_cast
<
const
CallIndirect
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
CallIndirect
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
operands
,
*
l
.
target
)
<
std
::
tie
(
r
.
type
,
r
.
operands
,
*
r
.
target
);
}
case
Expression
:
:
Id
::
GetLocalId
:
{
const
auto
&
l
=
static_cast
<
const
GetLocal
&>
(
lhs
);
...
...
@@ -138,11 +137,19 @@ namespace wasm {
return
std
::
tie
(
l
.
type
,
l
.
name
,
*
l
.
value
)
<
std
::
tie
(
r
.
type
,
r
.
name
,
*
r
.
value
);
}
case
Expression
:
:
Id
::
LoadId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
LoadId
:
{
const
auto
&
l
=
static_cast
<
const
Load
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
Load
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
bytes
,
l
.
signed_
,
l
.
offset
,
l
.
align
,
l
.
isAtomic
,
*
l
.
ptr
)
<
std
::
tie
(
r
.
type
,
r
.
bytes
,
r
.
signed_
,
r
.
offset
,
r
.
align
,
r
.
isAtomic
,
*
r
.
ptr
);
}
case
Expression
:
:
Id
::
StoreId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
StoreId
:
{
const
auto
&
l
=
static_cast
<
const
Store
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
Store
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
bytes
,
l
.
offset
,
l
.
align
,
l
.
isAtomic
,
*
l
.
ptr
,
*
l
.
value
)
<
std
::
tie
(
r
.
type
,
r
.
bytes
,
r
.
offset
,
r
.
align
,
r
.
isAtomic
,
*
r
.
ptr
,
*
r
.
value
);
}
case
Expression
:
:
Id
::
ConstId
:
{
const
auto
&
l
=
static_cast
<
const
Const
&>
(
lhs
);
...
...
@@ -197,17 +204,32 @@ namespace wasm {
case
Expression
:
:
Id
::
HostId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
AtomicRMWId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
AtomicRMWId
:
{
const
auto
&
l
=
static_cast
<
const
AtomicRMW
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
AtomicRMW
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
op
,
l
.
bytes
,
l
.
offset
,
*
l
.
ptr
,
*
l
.
value
)
<
std
::
tie
(
r
.
type
,
r
.
op
,
r
.
bytes
,
r
.
offset
,
*
r
.
ptr
,
*
r
.
value
);
}
case
Expression
:
:
Id
::
AtomicCmpxchgId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
AtomicCmpxchgId
:
{
const
auto
&
l
=
static_cast
<
const
AtomicCmpxchg
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
AtomicCmpxchg
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
bytes
,
l
.
offset
,
*
l
.
ptr
,
*
l
.
expected
,
*
l
.
replacement
)
<
std
::
tie
(
r
.
type
,
r
.
bytes
,
r
.
offset
,
*
r
.
ptr
,
*
r
.
expected
,
*
r
.
replacement
);
}
case
Expression
:
:
Id
::
AtomicWaitId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
AtomicWaitId
:
{
const
auto
&
l
=
static_cast
<
const
AtomicWait
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
AtomicWait
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
offset
,
*
l
.
ptr
,
*
l
.
expected
,
*
l
.
timeout
)
<
std
::
tie
(
r
.
type
,
r
.
offset
,
*
r
.
ptr
,
*
r
.
expected
,
*
r
.
timeout
);
}
case
Expression
:
:
Id
::
AtomicWakeId
:
WASM_UNREACHABLE
();
// TODO:
case
Expression
:
:
Id
::
AtomicWakeId
:
{
const
auto
&
l
=
static_cast
<
const
AtomicWake
&>
(
lhs
);
const
auto
&
r
=
static_cast
<
const
AtomicWake
&>
(
rhs
);
return
std
::
tie
(
l
.
type
,
l
.
offset
,
*
l
.
ptr
,
*
l
.
wakeCount
)
<
std
::
tie
(
r
.
type
,
r
.
offset
,
*
r
.
ptr
,
*
r
.
wakeCount
);
}
case
Expression
:
:
Id
::
SIMDExtractId
:
WASM_UNREACHABLE
();
// TODO:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment