Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtb0x1 committed Dec 30, 2024
1 parent 800fb82 commit 5e07222
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 64 deletions.
15 changes: 7 additions & 8 deletions src/support/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include "support/istring.h"
#include "support/safe_integer.h"
#include "support/utilities.h"

namespace json {

Expand Down Expand Up @@ -264,19 +265,15 @@ struct Value {
} \
ptr++; \
}
#define RUNTIME_ASSERT(condition) \
if (!(condition)) { \
std::cerr << "Assertion failed: " #condition << " at " << __FILE__ << ":" \
<< __LINE__ << "\n"; \
std::terminate(); \
}
skip();
if (*curr == '"') {
// String
curr++;
char* close = curr;
skip_escaped_characters(close);
RUNTIME_ASSERT(*close == '"');
if (!(*close == '"')) {
wasm::Fatal() << "Assertion failed (close == '\"') ";
}
*close = 0; // end this string, and reuse it straight from the input
setString(curr);
curr = close + 1;
Expand Down Expand Up @@ -323,7 +320,9 @@ struct Value {
curr++;
char* close = curr;
skip_escaped_characters(close);
RUNTIME_ASSERT(*close == '"');
if (!(*close == '"')) {
wasm::Fatal() << "Assertion failed (close == '\"') ";
}
*close = 0; // end this string, and reuse it straight from the input
IString key(curr);
curr = close + 1;
Expand Down
30 changes: 2 additions & 28 deletions test/lit/metadce/functions_with_names_need_escape.wat
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-metadce %s --graph-file %s.json -S -o - | filecheck %s --check-prefix=TXT
;; RUN: wasm-as %s -o %t.wasm --source-map %t.map
;; RUN: wasm-metadce %t.wasm --input-source-map %t.map --graph-file %s.json -o %t.out.wasm --output-source-map %t.out.map
;; RUN: wasm-dis %t.out.wasm --source-map %t.out.map -o - | filecheck %s --check-prefix=BIN

;; Test that sourcemap information is preserved
;; RUN: wasm-metadce %s --graph-file %s.json -S -o -

(module
;;@ a:1:2
;; TXT: (type $0 (func))

;; TXT: (export "f" (func $f))

;; TXT: (func $f
;; TXT-NEXT: ;;@ a:7:8:someSymbol
;; TXT-NEXT: (nop)
;; TXT-NEXT: ;;@ a:9:10
;; TXT-NEXT: )
(func $f (export "f")
;;@ a:7:8:someSymbol
(nop)
;;@ a:9:10
)
)
;; BIN: (type $0 (func))

;; BIN: (export "f" (func $0))

;; BIN: (func $0
;; BIN-NEXT: ;;@ a:7:8:someSymbol
;; BIN-NEXT: (nop)
;; BIN-NEXT: ;;@ a:9:10
;; BIN-NEXT: )
)
30 changes: 2 additions & 28 deletions test/lit/metadce/keys_quoted_unquoted.wat
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-metadce %s --graph-file %s.json -S -o - | filecheck %s --check-prefix=TXT
;; RUN: wasm-as %s -o %t.wasm --source-map %t.map
;; RUN: wasm-metadce %t.wasm --input-source-map %t.map --graph-file %s.json -o %t.out.wasm --output-source-map %t.out.map
;; RUN: wasm-dis %t.out.wasm --source-map %t.out.map -o - | filecheck %s --check-prefix=BIN

;; Test that sourcemap information is preserved
;; RUN: wasm-metadce %s --graph-file %s.json -S -o -

(module
;;@ a:1:2
;; TXT: (type $0 (func))

;; TXT: (export "f" (func $f))

;; TXT: (func $f
;; TXT-NEXT: ;;@ a:7:8:someSymbol
;; TXT-NEXT: (nop)
;; TXT-NEXT: ;;@ a:9:10
;; TXT-NEXT: )
(func $f (export "f")
;;@ a:7:8:someSymbol
(nop)
;;@ a:9:10
)
)
;; BIN: (type $0 (func))

;; BIN: (export "f" (func $0))

;; BIN: (func $0
;; BIN-NEXT: ;;@ a:7:8:someSymbol
;; BIN-NEXT: (nop)
;; BIN-NEXT: ;;@ a:9:10
;; BIN-NEXT: )
)

0 comments on commit 5e07222

Please sign in to comment.