aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@webassemblyjs/helper-code-frame
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/@webassemblyjs/helper-code-frame
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/@webassemblyjs/helper-code-frame')
-rw-r--r--node_modules/@webassemblyjs/helper-code-frame/LICENSE21
-rw-r--r--node_modules/@webassemblyjs/helper-code-frame/esm/index.js37
-rw-r--r--node_modules/@webassemblyjs/helper-code-frame/lib/index.js47
-rw-r--r--node_modules/@webassemblyjs/helper-code-frame/package.json23
-rw-r--r--node_modules/@webassemblyjs/helper-code-frame/webassemblyjs-helper-code-frame-1.7.10.tgzbin0 -> 1756 bytes
5 files changed, 128 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/helper-code-frame/LICENSE b/node_modules/@webassemblyjs/helper-code-frame/LICENSE
new file mode 100644
index 00000000..87e7e1ff
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-code-frame/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Sven Sauleau <sven@sauleau.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/@webassemblyjs/helper-code-frame/esm/index.js b/node_modules/@webassemblyjs/helper-code-frame/esm/index.js
new file mode 100644
index 00000000..791c65e6
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-code-frame/esm/index.js
@@ -0,0 +1,37 @@
+function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+import { print } from "@webassemblyjs/wast-printer";
+var SHOW_LINES_AROUND_POINTER = 5;
+
+function repeat(char, nb) {
+ return Array(nb).fill(char).join("");
+} // TODO(sven): allow arbitrary ast nodes
+
+
+export function codeFrameFromAst(ast, loc) {
+ return codeFrameFromSource(print(ast), loc);
+}
+export function codeFrameFromSource(source, loc) {
+ var start = loc.start,
+ end = loc.end;
+ var length = 1;
+
+ if (_typeof(end) === "object") {
+ length = end.column - start.column + 1;
+ }
+
+ return source.split("\n").reduce(function (acc, line, lineNbr) {
+ if (Math.abs(start.line - lineNbr) < SHOW_LINES_AROUND_POINTER) {
+ acc += line + "\n";
+ } // Add a new line with the pointer padded left
+
+
+ if (lineNbr === start.line - 1) {
+ acc += repeat(" ", start.column - 1);
+ acc += repeat("^", length);
+ acc += "\n";
+ }
+
+ return acc;
+ }, "");
+} \ No newline at end of file
diff --git a/node_modules/@webassemblyjs/helper-code-frame/lib/index.js b/node_modules/@webassemblyjs/helper-code-frame/lib/index.js
new file mode 100644
index 00000000..977de892
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-code-frame/lib/index.js
@@ -0,0 +1,47 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.codeFrameFromAst = codeFrameFromAst;
+exports.codeFrameFromSource = codeFrameFromSource;
+
+var _wastPrinter = require("@webassemblyjs/wast-printer");
+
+function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+var SHOW_LINES_AROUND_POINTER = 5;
+
+function repeat(char, nb) {
+ return Array(nb).fill(char).join("");
+} // TODO(sven): allow arbitrary ast nodes
+
+
+function codeFrameFromAst(ast, loc) {
+ return codeFrameFromSource((0, _wastPrinter.print)(ast), loc);
+}
+
+function codeFrameFromSource(source, loc) {
+ var start = loc.start,
+ end = loc.end;
+ var length = 1;
+
+ if (_typeof(end) === "object") {
+ length = end.column - start.column + 1;
+ }
+
+ return source.split("\n").reduce(function (acc, line, lineNbr) {
+ if (Math.abs(start.line - lineNbr) < SHOW_LINES_AROUND_POINTER) {
+ acc += line + "\n";
+ } // Add a new line with the pointer padded left
+
+
+ if (lineNbr === start.line - 1) {
+ acc += repeat(" ", start.column - 1);
+ acc += repeat("^", length);
+ acc += "\n";
+ }
+
+ return acc;
+ }, "");
+} \ No newline at end of file
diff --git a/node_modules/@webassemblyjs/helper-code-frame/package.json b/node_modules/@webassemblyjs/helper-code-frame/package.json
new file mode 100644
index 00000000..8169a4c0
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-code-frame/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "@webassemblyjs/helper-code-frame",
+ "version": "1.7.11",
+ "description": "",
+ "main": "lib/index.js",
+ "module": "esm/index.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/xtuc/webassemblyjs.git"
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "author": "Sven Sauleau",
+ "license": "MIT",
+ "dependencies": {
+ "@webassemblyjs/wast-printer": "1.7.11"
+ },
+ "devDependencies": {
+ "@webassemblyjs/ast": "1.7.11"
+ },
+ "gitHead": "4291990bfc4648bc6676091a955d12dc3c7e5909"
+}
diff --git a/node_modules/@webassemblyjs/helper-code-frame/webassemblyjs-helper-code-frame-1.7.10.tgz b/node_modules/@webassemblyjs/helper-code-frame/webassemblyjs-helper-code-frame-1.7.10.tgz
new file mode 100644
index 00000000..5b83fc8a
--- /dev/null
+++ b/node_modules/@webassemblyjs/helper-code-frame/webassemblyjs-helper-code-frame-1.7.10.tgz
Binary files differ