summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 44326948b..c1ef75ea9 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -74,11 +74,11 @@ namespace wasm {
struct Name : public cashew::IString {
Name() : cashew::IString() {}
- Name(const char *str) : cashew::IString(str, false) {}
+ Name(const char* str) : cashew::IString(str, false) {}
Name(cashew::IString str) : cashew::IString(str) {}
- Name(const std::string &str) : cashew::IString(str.c_str(), false) {}
+ Name(const std::string& str) : cashew::IString(str.c_str(), false) {}
- friend std::ostream& operator<<(std::ostream &o, Name name) {
+ friend std::ostream& operator<<(std::ostream& o, Name name) {
assert(name.str);
return o << '$' << name.str; // reference interpreter requires we prefix all names
}
@@ -305,7 +305,7 @@ private:
static void printFloat(std::ostream &o, float f) {
if (std::isnan(f)) {
- const char *sign = std::signbit(f) ? "-" : "";
+ const char* sign = std::signbit(f) ? "-" : "";
o << sign << "nan";
if (uint32_t payload = NaNPayload(f)) {
o << ":0x" << std::hex << payload << std::dec;
@@ -315,13 +315,13 @@ private:
printDouble(o, f);
}
- static void printDouble(std::ostream &o, double d) {
+ static void printDouble(std::ostream& o, double d) {
if (d == 0 && std::signbit(d)) {
o << "-0";
return;
}
if (std::isnan(d)) {
- const char *sign = std::signbit(d) ? "-" : "";
+ const char* sign = std::signbit(d) ? "-" : "";
o << sign << "nan";
if (uint64_t payload = NaNPayload(d)) {
o << ":0x" << std::hex << payload << std::dec;
@@ -332,7 +332,7 @@ private:
o << (std::signbit(d) ? "-infinity" : "infinity");
return;
}
- const char *text = cashew::JSPrinter::numToString(d);
+ const char* text = cashew::JSPrinter::numToString(d);
// spec interpreter hates floats starting with '.'
if (text[0] == '.') {
o << '0';
@@ -343,7 +343,7 @@ private:
o << text;
}
- friend std::ostream& operator<<(std::ostream &o, Literal literal) {
+ friend std::ostream& operator<<(std::ostream& o, Literal literal) {
o << '(';
prepareMinorColor(o) << printWasmType(literal.type) << ".const ";
switch (literal.type) {
@@ -909,7 +909,7 @@ public:
}
};
-inline const char *getExpressionName(Expression *curr) {
+inline const char* getExpressionName(Expression* curr) {
switch (curr->_id) {
case Expression::Id::InvalidId: abort();
case Expression::Id::BlockId: return "block";
@@ -978,7 +978,9 @@ public:
If() : ifFalse(nullptr) {}
If(MixedArena& allocator) : If() {}
- Expression *condition, *ifTrue, *ifFalse;
+ Expression* condition;
+ Expression* ifTrue;
+ Expression* ifFalse;
// set the type given you know its type, which is the case when parsing
// s-expression or binary, as explicit types are given. the only additional work
@@ -995,7 +997,7 @@ public:
Loop(MixedArena& allocator) {}
Name name;
- Expression *body;
+ Expression* body;
// set the type given you know its type, which is the case when parsing
// s-expression or binary, as explicit types are given. the only additional work
@@ -1014,8 +1016,8 @@ public:
}
Name name;
- Expression *value;
- Expression *condition;
+ Expression* value;
+ Expression* condition;
void finalize() {
if (condition) {
@@ -1038,8 +1040,8 @@ public:
ArenaVector<Name> targets;
Name default_;
- Expression *condition;
- Expression *value;
+ Expression* condition;
+ Expression* value;
};
class Call : public SpecificExpression<Expression::CallId> {
@@ -1090,7 +1092,7 @@ public:
ExpressionList operands;
Name fullType;
- Expression *target;
+ Expression* target;
};
class GetLocal : public SpecificExpression<Expression::GetLocalId> {
@@ -1107,7 +1109,7 @@ public:
SetLocal(MixedArena& allocator) {}
Index index;
- Expression *value;
+ Expression* value;
bool isTee() {
return type != none;
@@ -1133,7 +1135,7 @@ public:
SetGlobal(MixedArena& allocator) {}
Name name;
- Expression *value;
+ Expression* value;
};
class Load : public SpecificExpression<Expression::LoadId> {
@@ -1145,7 +1147,7 @@ public:
bool signed_;
Address offset;
Address align;
- Expression *ptr;
+ Expression* ptr;
// type must be set during creation, cannot be inferred
};
@@ -1158,7 +1160,8 @@ public:
uint8_t bytes;
Address offset;
Address align;
- Expression *ptr, *value;
+ Expression* ptr;
+ Expression* value;
WasmType valueType; // the store never returns a value
void finalize() {
@@ -1186,7 +1189,7 @@ public:
Unary(MixedArena& allocator) {}
UnaryOp op;
- Expression *value;
+ Expression* value;
bool isRelational() { return op == EqZInt32 || op == EqZInt64; }
@@ -1249,7 +1252,8 @@ public:
Binary(MixedArena& allocator) {}
BinaryOp op;
- Expression *left, *right;
+ Expression* left;
+ Expression* right;
// the type is always the type of the operands,
// except for relationals
@@ -1307,7 +1311,9 @@ public:
Select() {}
Select(MixedArena& allocator) {}
- Expression *ifTrue, *ifFalse, *condition;
+ Expression* ifTrue;
+ Expression* ifFalse;
+ Expression* condition;
void finalize() {
assert(ifTrue && ifFalse);
@@ -1320,7 +1326,7 @@ public:
Drop() {}
Drop(MixedArena& allocator) {}
- Expression *value;
+ Expression* value;
};
class Return : public SpecificExpression<Expression::ReturnId> {
@@ -1330,7 +1336,7 @@ public:
}
Return(MixedArena& allocator) : Return() {}
- Expression *value;
+ Expression* value;
};
class Host : public SpecificExpression<Expression::HostId> {
@@ -1373,7 +1379,7 @@ public:
std::vector<WasmType> params; // function locals are
std::vector<WasmType> vars; // params plus vars
Name type; // if null, it is implicit in params and result
- Expression *body;
+ Expression* body;
// local names. these are optional.
std::vector<Name> localNames;
@@ -1489,7 +1495,7 @@ public:
Expression* offset;
std::vector<char> data; // TODO: optimize
Segment() {}
- Segment(Expression* offset, const char *init, Address size) : offset(offset) {
+ Segment(Expression* offset, const char* init, Address size) : offset(offset) {
data.resize(size);
std::copy_n(init, size, data.begin());
}
@@ -1588,7 +1594,7 @@ public:
globalsMap[curr->name] = curr;
}
- void addStart(const Name &s) {
+ void addStart(const Name& s) {
start = s;
}