adjust structure
This commit is contained in:
parent
9c02033c41
commit
a02620cf53
169
draft.json
Normal file
169
draft.json
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"error": [],
|
||||||
|
"symbols": [
|
||||||
|
{
|
||||||
|
"name": "Main",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 31
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "module"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 17,
|
||||||
|
"line": 11
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 17,
|
||||||
|
"line": 12
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "c",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 11,
|
||||||
|
"line": 13
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 13
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Qus",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 14,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 11,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Qs",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 18,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "`main_o",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 27,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 20,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dependence_1",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 22
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "dependence_1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dependence_2",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 29
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "dependence_2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"languageId": "verilog",
|
||||||
|
"macro": {
|
||||||
|
"defines": [
|
||||||
|
{
|
||||||
|
"name": "main_o",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 19,
|
||||||
|
"line": 9
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"value": "out"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"error": [],
|
||||||
|
"includes": [
|
||||||
|
{
|
||||||
|
"path": "child_1.v",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 9,
|
||||||
|
"line": 8
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"invalid": []
|
||||||
|
}
|
||||||
|
}
|
201
draft2.json
Normal file
201
draft2.json
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
{
|
||||||
|
"content": {
|
||||||
|
"error": [],
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"instparams": null,
|
||||||
|
"instports": {
|
||||||
|
"end": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 21
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 4,
|
||||||
|
"line": 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "dependence_1",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 22
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 13,
|
||||||
|
"line": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "dependence_1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"instparams": null,
|
||||||
|
"instports": {
|
||||||
|
"end": {
|
||||||
|
"character": 9,
|
||||||
|
"line": 28
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 4,
|
||||||
|
"line": 25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "dependence_2",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 29
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 13,
|
||||||
|
"line": 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "dependence_2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Main",
|
||||||
|
"params": [],
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 17,
|
||||||
|
"line": 11
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input",
|
||||||
|
"width": "[3:0]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 17,
|
||||||
|
"line": 12
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input",
|
||||||
|
"width": "[2:0]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "c",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 11,
|
||||||
|
"line": 13
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 13
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "input",
|
||||||
|
"width": "Unknown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Qus",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 14,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 11,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output",
|
||||||
|
"width": "Unknown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Qs",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 18,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 16,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output",
|
||||||
|
"width": "Unknown"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "`main_o",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 27,
|
||||||
|
"line": 14
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 20,
|
||||||
|
"line": 14
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "output",
|
||||||
|
"width": "Unknown"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 31
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 0,
|
||||||
|
"line": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"languageId": "verilog",
|
||||||
|
"macro": {
|
||||||
|
"defines": [
|
||||||
|
{
|
||||||
|
"name": "main_o",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 19,
|
||||||
|
"line": 9
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"value": "out"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"error": [],
|
||||||
|
"includes": [
|
||||||
|
{
|
||||||
|
"path": "child_1.v",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 9,
|
||||||
|
"line": 8
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 1,
|
||||||
|
"line": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"invalid": []
|
||||||
|
}
|
||||||
|
}
|
@ -100,6 +100,7 @@ interface RawPrjInfo extends RawPrjInfoMeta {
|
|||||||
library?: Library
|
library?: Library
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function toSlash(path: Path): Path {
|
function toSlash(path: Path): Path {
|
||||||
return path.replace(/\\/g,"\/");
|
return path.replace(/\\/g,"\/");
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { AbsPath, RelPath } from '../global';
|
|||||||
import { HdlLangID } from '../global/enum';
|
import { HdlLangID } from '../global/enum';
|
||||||
import { verilogExts, vhdlExts, systemVerilogExts, hdlExts } from '../global/lang';
|
import { verilogExts, vhdlExts, systemVerilogExts, hdlExts } from '../global/lang';
|
||||||
import * as hdlPath from './path';
|
import * as hdlPath from './path';
|
||||||
import { HdlFileType } from '../hdlParser/base/common';
|
import { HdlFileType } from '../hdlParser/common';
|
||||||
import { opeParam } from '../global';
|
import { opeParam } from '../global';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +62,7 @@ function isSystemVerilogFile(path: AbsPath): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const ext = hdlPath.extname(path, false);
|
const ext = hdlPath.extname(path, false);
|
||||||
return systemVerilogExts.includes(path);
|
return systemVerilogExts.includes(ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHDLFile(path: AbsPath): boolean {
|
function isHDLFile(path: AbsPath): boolean {
|
||||||
@ -101,18 +101,12 @@ function pickFileRecursive(path: AbsPath | AbsPath[] | Set<AbsPath>, ignores?: A
|
|||||||
if (subHdlFiles.length > 0) {
|
if (subHdlFiles.length > 0) {
|
||||||
hdlFiles.push(...subHdlFiles);
|
hdlFiles.push(...subHdlFiles);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (!condition || condition(filePath)) {
|
||||||
(condition && condition(filePath))
|
|
||||||
|| (condition === undefined)
|
|
||||||
) {
|
|
||||||
hdlFiles.push(filePath);
|
hdlFiles.push(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hdlFiles;
|
return hdlFiles;
|
||||||
} else if (
|
} else if (!condition || condition(path)) {
|
||||||
(condition && condition(path))
|
|
||||||
|| (condition === undefined)
|
|
||||||
) {
|
|
||||||
return [path];
|
return [path];
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
@ -344,6 +338,27 @@ function isHasValue(obj: any, attr: string, value: any): boolean{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* walk(path: AbsPath | RelPath, condition?: (filePath: AbsPath) => boolean): Generator<AbsPath> {
|
||||||
|
if (isFile(path)) {
|
||||||
|
if (!condition || condition(path)) {
|
||||||
|
yield path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const file of fs.readdirSync(path)) {
|
||||||
|
const filePath = hdlPath.join(path, file);
|
||||||
|
if (isDir(filePath)) {
|
||||||
|
for (const targetPath of walk(filePath, condition)) {
|
||||||
|
yield targetPath;
|
||||||
|
}
|
||||||
|
} else if (isFile(filePath)) {
|
||||||
|
if (!condition || condition(filePath)) {
|
||||||
|
yield filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
isFile,
|
isFile,
|
||||||
isDir,
|
isDir,
|
||||||
@ -364,5 +379,6 @@ export {
|
|||||||
isHasValue,
|
isHasValue,
|
||||||
copyFile,
|
copyFile,
|
||||||
removeFile,
|
removeFile,
|
||||||
moveFile
|
moveFile,
|
||||||
|
walk
|
||||||
};
|
};
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { AbsPath, RelPath } from '../../global';
|
import { AbsPath, RelPath } from '../global';
|
||||||
|
|
||||||
interface Position {
|
interface Position {
|
||||||
// row/line of the cursor, index from 0
|
// row/line of the cursor, index from 0
|
||||||
@ -32,6 +32,11 @@ enum HdlFileType {
|
|||||||
RemoteLib = 'remote_lib'
|
RemoteLib = 'remote_lib'
|
||||||
};
|
};
|
||||||
enum InstModPathStatus {Current, Include, Others, Unknown};
|
enum InstModPathStatus {Current, Include, Others, Unknown};
|
||||||
|
enum SymbolType {
|
||||||
|
Module = 'module',
|
||||||
|
Input = 'input',
|
||||||
|
Output = 'output'
|
||||||
|
};
|
||||||
|
|
||||||
interface Error {
|
interface Error {
|
||||||
severity: number
|
severity: number
|
||||||
@ -95,6 +100,13 @@ interface RawHdlModule {
|
|||||||
range: Range
|
range: Range
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
interface RawSymbol {
|
||||||
|
name: string
|
||||||
|
type: SymbolType
|
||||||
|
range: Range
|
||||||
|
};
|
||||||
|
|
||||||
interface InstModPathSearchResult {
|
interface InstModPathSearchResult {
|
||||||
path: AbsPath
|
path: AbsPath
|
||||||
status: InstModPathStatus
|
status: InstModPathStatus
|
||||||
@ -123,5 +135,6 @@ export {
|
|||||||
RawHdlInstance,
|
RawHdlInstance,
|
||||||
RawHdlModule,
|
RawHdlModule,
|
||||||
InstModPathSearchResult,
|
InstModPathSearchResult,
|
||||||
HdlDependence
|
HdlDependence,
|
||||||
|
RawSymbol
|
||||||
};
|
};
|
@ -1,8 +1,8 @@
|
|||||||
import { AbsPath } from '../../global';
|
import { AbsPath } from '../global';
|
||||||
import { HdlLangID } from '../../global/enum';
|
import { HdlLangID } from '../global/enum';
|
||||||
|
|
||||||
import * as common from './common';
|
import * as common from './common';
|
||||||
import { hdlFile, hdlPath } from '../../hdlFs';
|
import { hdlFile, hdlPath } from '../hdlFs';
|
||||||
|
|
||||||
class HdlParam {
|
class HdlParam {
|
||||||
private readonly topModules : Set<HdlModule> = new Set<HdlModule>();
|
private readonly topModules : Set<HdlModule> = new Set<HdlModule>();
|
0
src/hdlParser/parser/index.d.ts
vendored
0
src/hdlParser/parser/index.d.ts
vendored
5
src/hdlParser/util.ts
Normal file
5
src/hdlParser/util.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { vlogAll, vlogFast } from '../../wasm/hdlParser';
|
||||||
|
|
||||||
|
function hello(path: string) {
|
||||||
|
vlogAll(path);
|
||||||
|
}
|
@ -5,7 +5,7 @@ import * as fspath from 'path';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { AbsPath, opeParam, PrjInfo } from '../../global';
|
import { AbsPath, opeParam, PrjInfo } from '../../global';
|
||||||
import { hdlParam } from '../../hdlParser/base/core';
|
import { hdlParam } from '../../hdlParser/core';
|
||||||
import { hdlFile, hdlDir, hdlPath } from '../../hdlFs';
|
import { hdlFile, hdlDir, hdlPath } from '../../hdlFs';
|
||||||
import { PropertySchema } from '../../global/propertySchema';
|
import { PropertySchema } from '../../global/propertySchema';
|
||||||
|
|
||||||
|
2
test.js
2
test.js
@ -2,7 +2,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const sysvlog_build = require('./src/hdlParser/parser/parser');
|
const sysvlog_build = require('./wasm/hdlParser/parser');
|
||||||
|
|
||||||
const COMMON_PATH = path.resolve('./lib/common/Driver');
|
const COMMON_PATH = path.resolve('./lib/common/Driver');
|
||||||
|
|
||||||
|
10
vsixmake.js
10
vsixmake.js
@ -1,17 +1,17 @@
|
|||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const HDLFile = require('./src/HDLfilesys/operation/files');
|
const hdlFile = require('./src/hdlFs/file');
|
||||||
const hdlPath = require('./src/HDLfilesys/operation/path');
|
const hdlPath = require('./src/hdlFs/path');
|
||||||
|
|
||||||
const PACKAGE_PATH = './package.json';
|
const PACKAGE_PATH = './package.json';
|
||||||
const SAVE_FOLDER = 'dist';
|
const SAVE_FOLDER = 'dist';
|
||||||
const WEBPACK_OUT_FOLDER = 'out';
|
const WEBPACK_OUT_FOLDER = 'out';
|
||||||
|
|
||||||
function changeMain(path) {
|
function changeMain(path) {
|
||||||
const packageJS = HDLFile.pullJsonInfo(PACKAGE_PATH);
|
const packageJS = hdlFile.pullJsonInfo(PACKAGE_PATH);
|
||||||
packageJS.main = path;
|
packageJS.main = path;
|
||||||
HDLFile.pushJsonInfo(PACKAGE_PATH, packageJS);
|
hdlFile.pushJsonInfo(PACKAGE_PATH, packageJS);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findVsix() {
|
function findVsix() {
|
||||||
@ -36,7 +36,7 @@ execSync('code --uninstall-extension sterben.digital-ide');
|
|||||||
|
|
||||||
const vsix = findVsix();
|
const vsix = findVsix();
|
||||||
const targetPath = path.join(SAVE_FOLDER, vsix);
|
const targetPath = path.join(SAVE_FOLDER, vsix);
|
||||||
HDLFile.moveFile(vsix, targetPath, true);
|
hdlFile.moveFile(vsix, targetPath, true);
|
||||||
hdlPath.deleteFolder(WEBPACK_OUT_FOLDER);
|
hdlPath.deleteFolder(WEBPACK_OUT_FOLDER);
|
||||||
|
|
||||||
const vsixPath = hdlPath.join(SAVE_FOLDER, vsix);
|
const vsixPath = hdlPath.join(SAVE_FOLDER, vsix);
|
||||||
|
27
wasm/hdlParser/index.d.ts
vendored
Normal file
27
wasm/hdlParser/index.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { RawHdlModule, Macro, RawSymbol } from '../../src/hdlParser/common';
|
||||||
|
import { HdlLangID } from '../../src/global/enum';
|
||||||
|
|
||||||
|
type AbsPath = string;
|
||||||
|
type RelPath = string;
|
||||||
|
type Path = AbsPath | RelPath;
|
||||||
|
|
||||||
|
interface Fast {
|
||||||
|
content: {
|
||||||
|
error : string[]
|
||||||
|
modules: RawHdlModule[]
|
||||||
|
}
|
||||||
|
languageId: HdlLangID
|
||||||
|
macro: Macro
|
||||||
|
}
|
||||||
|
|
||||||
|
interface All {
|
||||||
|
content: {
|
||||||
|
error: string[]
|
||||||
|
symbols: RawSymbol[]
|
||||||
|
}
|
||||||
|
languageId: HdlLangID
|
||||||
|
macro: Macro
|
||||||
|
}
|
||||||
|
|
||||||
|
export function vlogFast(path: AbsPath): Promise<Fast>;
|
||||||
|
export function vlogAll(path: AbsPath): Promise<All>;
|
38
wasm/hdlParser/index.js
Normal file
38
wasm/hdlParser/index.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
const hdlParser = require('./parser');
|
||||||
|
|
||||||
|
const _hdlParser = {
|
||||||
|
module: null,
|
||||||
|
tempPath: '/home/hdl_parser',
|
||||||
|
|
||||||
|
async acquire() {
|
||||||
|
const module = this.module;
|
||||||
|
if (module) {
|
||||||
|
return module;
|
||||||
|
} else {
|
||||||
|
const _m = await hdlParser();
|
||||||
|
this.module = _m;
|
||||||
|
return _m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function vlogFast(path) {
|
||||||
|
const wasmModule = await _hdlParser.acquire();
|
||||||
|
const source = fs.readFileSync(path, 'utf-8');
|
||||||
|
wasmModule.FS.writeFile(_hdlParser.tempPath, source, { encoding: 'utf8' });
|
||||||
|
const res = wasmModule.ccall('vlog_fast', 'string', ['string'], [_hdlParser.tempPath]);
|
||||||
|
return JSON.parse(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function vlogAll(path) {
|
||||||
|
const wasmModule = await _hdlParser.acquire();
|
||||||
|
const source = fs.readFileSync(path, 'utf-8');
|
||||||
|
wasmModule.FS.writeFile(_hdlParser.tempPath, source, { encoding: 'utf8' });
|
||||||
|
const res = wasmModule.ccall('vlog_all', 'string', ['string'], [_hdlParser.tempPath]);
|
||||||
|
return JSON.parse(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
vlogFast,
|
||||||
|
vlogAll
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user