Bug 1310949: Code style tweaks; r=luke
authorBenjamin Bouvier <benj@benj.me>
Wed, 19 Oct 2016 18:00:59 +0200
changeset 319218 bd4555428a116a2819715116dd34a13fa8203308
parent 319217 aedd3947ef5a9692aa6fbaafca13b4a4259cece3
child 319219 743986b85b599eab0581b08172b8805ce3a44abc
push id33488
push usercbook@mozilla.com
push dateTue, 25 Oct 2016 08:49:50 +0000
treeherderautoland@2bcd92f4caa0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1310949
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1310949: Code style tweaks; r=luke MozReview-Commit-ID: EsMJrGDPdKM
js/src/asmjs/WasmBinaryToText.cpp
--- a/js/src/asmjs/WasmBinaryToText.cpp
+++ b/js/src/asmjs/WasmBinaryToText.cpp
@@ -356,17 +356,17 @@ RenderGetLocal(WasmRenderContext& c, Ast
     MAP_AST_EXPR(c, gl);
     if (!c.buffer.append("get_local "))
         return false;
     return RenderRef(c, gl.local());
 }
 
 static bool
 RenderSetLocal(WasmRenderContext& c, AstSetLocal& sl)
- {
+{
     if (!RenderExpr(c, sl.value()))
         return false;
 
     if (!RenderIndent(c))
         return false;
 
     MAP_AST_EXPR(c, sl);
     if (!c.buffer.append("set_local "))
@@ -746,28 +746,28 @@ RenderLoadStoreBase(WasmRenderContext& c
 {
     return RenderExpr(c, lsa.base());
 }
 
 static bool
 RenderLoadStoreAddress(WasmRenderContext& c, const AstLoadStoreAddress& lsa, uint32_t defaultAlignLog2)
 {
     if (lsa.offset() != 0) {
-      if (!c.buffer.append(" offset="))
-          return false;
-      if (!RenderInt32(c, lsa.offset()))
-          return false;
+        if (!c.buffer.append(" offset="))
+            return false;
+        if (!RenderInt32(c, lsa.offset()))
+            return false;
     }
 
     uint32_t alignLog2 = lsa.flags();
     if (defaultAlignLog2 != alignLog2) {
-      if (!c.buffer.append(" align="))
-          return false;
-      if (!RenderInt32(c, 1 << alignLog2))
-          return false;
+        if (!c.buffer.append(" align="))
+            return false;
+        if (!RenderInt32(c, 1 << alignLog2))
+            return false;
     }
 
     return true;
 }
 
 static bool
 RenderLoad(WasmRenderContext& c, AstLoad& load)
 {
@@ -949,18 +949,18 @@ RenderBranch(WasmRenderContext& c, AstBr
 
     return RenderRef(c, branch.target());
 }
 
 static bool
 RenderBrTable(WasmRenderContext& c, AstBranchTable& table)
 {
     if (table.maybeValue()) {
-      if (!RenderExpr(c, *(table.maybeValue())))
-          return false;
+        if (!RenderExpr(c, *(table.maybeValue())))
+            return false;
     }
 
     // Index
     if (!RenderExpr(c, table.index()))
         return false;
 
     if (!RenderIndent(c))
         return false;
@@ -1111,44 +1111,44 @@ RenderExpr(WasmRenderContext& c, AstExpr
 }
 
 static bool
 RenderSignature(WasmRenderContext& c, const AstSig& sig, const AstNameVector* maybeLocals = nullptr)
 {
     uint32_t paramsNum = sig.args().length();
 
     if (maybeLocals) {
-      for (uint32_t i = 0; i < paramsNum; i++) {
-          if (!c.buffer.append(" (param "))
-              return false;
-          const AstName& name = (*maybeLocals)[i];
-          if (!name.empty()) {
-              if (!RenderName(c, name))
-                  return false;
-              if (!c.buffer.append(" "))
-                  return false;
-          }
-          ValType arg = sig.args()[i];
-          if (!RenderValType(c, arg))
-              return false;
-          if (!c.buffer.append(")"))
-              return false;
-      }
+        for (uint32_t i = 0; i < paramsNum; i++) {
+            if (!c.buffer.append(" (param "))
+                return false;
+            const AstName& name = (*maybeLocals)[i];
+            if (!name.empty()) {
+                if (!RenderName(c, name))
+                    return false;
+                if (!c.buffer.append(" "))
+                    return false;
+            }
+            ValType arg = sig.args()[i];
+            if (!RenderValType(c, arg))
+                return false;
+            if (!c.buffer.append(")"))
+                return false;
+        }
     } else if (paramsNum > 0) {
-      if (!c.buffer.append(" (param"))
-          return false;
-      for (uint32_t i = 0; i < paramsNum; i++) {
-          if (!c.buffer.append(" "))
-              return false;
-          ValType arg = sig.args()[i];
-          if (!RenderValType(c, arg))
-              return false;
-      }
-      if (!c.buffer.append(")"))
-          return false;
+        if (!c.buffer.append(" (param"))
+            return false;
+        for (uint32_t i = 0; i < paramsNum; i++) {
+            if (!c.buffer.append(" "))
+                return false;
+            ValType arg = sig.args()[i];
+            if (!RenderValType(c, arg))
+                return false;
+        }
+        if (!c.buffer.append(")"))
+            return false;
     }
     if (sig.ret() != ExprType::Void) {
         if (!c.buffer.append(" (result "))
             return false;
         if (!RenderExprType(c, sig.ret()))
             return false;
         if (!c.buffer.append(")"))
             return false;
@@ -1197,33 +1197,32 @@ RenderTableSection(WasmRenderContext& c,
         return false;
 
     if (!c.buffer.append("(table anyfunc (elem "))
         return false;
 
     for (const AstRef& elem : segment.elems()) {
         if (!c.buffer.append(" "))
             return false;
+
         uint32_t index = elem.index();
         AstName name = index < module.funcImportNames().length()
-                           ? module.funcImportNames()[index]
-                           : module.funcs()[index - module.funcImportNames().length()]->name();
+                       ? module.funcImportNames()[index]
+                       : module.funcs()[index - module.funcImportNames().length()]->name();
+
         if (name.empty()) {
             if (!RenderInt32(c, index))
                 return false;
         } else {
-          if (!RenderName(c, name))
-              return false;
+            if (!RenderName(c, name))
+                return false;
         }
     }
 
-    if (!c.buffer.append("))\n"))
-        return false;
-
-    return true;
+    return c.buffer.append("))\n");
 }
 
 static bool
 RenderGlobal(WasmRenderContext& c, const AstGlobal& glob, bool inImport = false)
 {
     if (!c.buffer.append("(global "))
         return false;
 
@@ -1368,20 +1367,17 @@ RenderExport(WasmRenderContext& c, AstEx
         if (name.empty()) {
             if (!RenderInt32(c, index))
                 return false;
         } else {
             if (!RenderName(c, name))
                 return false;
         }
     }
-    if (!c.buffer.append(")\n"))
-        return false;
-
-    return true;
+    return c.buffer.append(")\n");
 }
 
 static bool
 RenderExportSection(WasmRenderContext& c, const AstModule::ExportVector& exports,
                     const AstModule::NameVector& funcImportNames,
                     const AstModule::FuncVector& funcs)
 {
     uint32_t numExports = exports.length();
@@ -1405,36 +1401,36 @@ RenderFunctionBody(WasmRenderContext& c,
     if (localsNum > 0) {
         if (!RenderIndent(c))
             return false;
         for (uint32_t i = 0; i < localsNum; i++) {
             if (!c.buffer.append("(local "))
                 return false;
             const AstName& name = func.locals()[argsNum + i];
             if (!name.empty()) {
-              if (!RenderName(c, name))
-                  return false;
-              if (!c.buffer.append(" "))
-                  return false;
+                if (!RenderName(c, name))
+                    return false;
+                if (!c.buffer.append(" "))
+                    return false;
             }
             ValType local = func.vars()[i];
             if (!RenderValType(c, local))
                 return false;
             if (!c.buffer.append(") "))
                 return false;
         }
         if (!c.buffer.append("\n"))
             return false;
     }
 
 
     uint32_t exprsNum = func.body().length();
     for (uint32_t i = 0; i < exprsNum; i++) {
-      if (!RenderExpr(c, *func.body()[i]))
-          return false;
+        if (!RenderExpr(c, *func.body()[i]))
+            return false;
     }
 
     size_t endExprIndex = c.maybeSourceMap ? c.maybeSourceMap->exprlocs().length() : 0;
     uint32_t endLineno = c.buffer.lineno();
 
     if (c.maybeSourceMap) {
         if (!c.maybeSourceMap->functionlocs().emplaceBack(startExprIndex, endExprIndex, startLineno, endLineno))
             return false;
@@ -1452,18 +1448,18 @@ RenderCodeSection(WasmRenderContext& c, 
         uint32_t sigIndex = func->sig().index();
         AstSig* sig = sigs[sigIndex];
 
         if (!RenderIndent(c))
             return false;
         if (!c.buffer.append("(func "))
             return false;
         if (!func->name().empty()) {
-          if (!RenderName(c, func->name()))
-              return false;
+            if (!RenderName(c, func->name()))
+                return false;
         }
 
         if (!RenderSignature(c, *sig, &(func->locals())))
             return false;
         if (!c.buffer.append("\n"))
             return false;
 
         c.currentFuncIndex = funcIndex;
@@ -1473,67 +1469,66 @@ RenderCodeSection(WasmRenderContext& c, 
             return false;
         c.indent--;
         if (!RenderIndent(c))
             return false;
         if (!c.buffer.append(")\n"))
             return false;
     }
 
-   return true;
+    return true;
 }
 
-
 static bool
 RenderDataSection(WasmRenderContext& c, const AstModule& module)
 {
     if (!module.hasMemory())
         return true;
 
     if (!RenderIndent(c))
         return false;
     if (!c.buffer.append("(memory "))
         return false;
     if (!RenderInt32(c, module.memory().initial))
-       return false;
+        return false;
     Maybe<uint32_t> memMax = module.memory().maximum;
     if (memMax) {
         if (!c.buffer.append(" "))
             return false;
         if (!RenderInt32(c, *memMax))
             return false;
     }
 
     c.indent++;
 
     uint32_t numSegments = module.dataSegments().length();
     if (!numSegments) {
-      if (!c.buffer.append(")\n"))
-          return false;
-      return true;
+        if (!c.buffer.append(")\n"))
+            return false;
+        return true;
     }
     if (!c.buffer.append("\n"))
         return false;
 
     for (uint32_t i = 0; i < numSegments; i++) {
         const AstDataSegment* segment = module.dataSegments()[i];
 
         if (!RenderIndent(c))
             return false;
         if (!c.buffer.append("(segment "))
-           return false;
+            return false;
         if (!RenderInt32(c, segment->offset()->as<AstConst>().val().i32()))
-           return false;
+            return false;
         if (!c.buffer.append(" \""))
-           return false;
+            return false;
 
         RenderEscapedString(c, segment->text());
 
         if (!c.buffer.append("\")\n"))
-           return false;
+            return false;
     }
 
     c.indent--;
     if (!c.buffer.append(")\n"))
         return false;
 
     return true;
 }