Bug 1882714 [wpt PR 44850] - Update wpt metadata, a=testonly
[gecko.git] / third_party / wasm2c / src / tracing.cc
blob21f512f587dd1cf50ed92e3f4234b6f86b688d91
1 /*
2 * Copyright 2017 WebAssembly Community Group participants
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define WABT_TRACING 1
18 #include "wabt/tracing.h"
20 namespace {
22 size_t indent = 0;
23 const char* indent_text = " ";
25 void Fill() {
26 for (size_t i = 0; i < indent; ++i)
27 fputs(indent_text, stderr);
30 void Indent() {
31 Fill();
32 ++indent;
35 void Dedent() {
36 if (indent) {
37 --indent;
39 Fill();
42 } // end of anonymous namespace
44 namespace wabt {
46 // static
48 TraceScope::TraceScope(const char* method) : method_(method) {
49 PrintEnter(method);
50 PrintNewline();
53 TraceScope::~TraceScope() {
54 Dedent();
55 fputs("<- ", stderr);
56 fputs(method_, stderr);
57 fputc('\n', stderr);
60 void TraceScope::PrintEnter(const char* method) {
61 Indent();
62 fputs("-> ", stderr);
63 fputs(method, stderr);
64 fputs("(", stderr);
67 void TraceScope::PrintNewline() {
68 fputs(")\n", stderr);
71 } // end of namespace wabt