Skip to content

Commit

Permalink
now compiler will use c++ implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yudonglin committed Jan 26, 2024
1 parent 4cd931b commit e909072
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 370 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ vns-vscode/LICENSE
.vs/
vns-cpp/libs/
vns-cpp/CMakeUserPresets.json
vns-python/pyvns/vns.exe
353 changes: 0 additions & 353 deletions vns-python/pyvns/_processor.py

This file was deleted.

23 changes: 6 additions & 17 deletions vns-python/pyvns/compiler.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
import json
import time
from glob import glob
from os import path as OS_PATH
from subprocess import check_output
from typing import Any

from ._processor import Processor
from ._version import REVISION, VERSION


class Compiler:
# 直接加载
@staticmethod
def load(path: str) -> dict[str, Any]:
_processor: Processor = Processor()
_processor.process(path)
return {
"dialogs": _processor.get_output(),
"compiler": {
"version": VERSION,
"reversion": REVISION,
"compiledAt": int(time.time()),
},
"id": _processor.get_id(),
"language": _processor.get_language(),
}
output = check_output(
[OS_PATH.join(OS_PATH.dirname(__file__), "vns.exe"), "-i", path, "-s"]
).decode()
return json.loads(output)

# 编译
@classmethod
def compile(cls, path: str, out_dir: str | None = None) -> None:
if not OS_PATH.isdir(path) and path.endswith(Processor.SCRIPTS_FILE_EXTENSION):
if not OS_PATH.isdir(path) and path.endswith(".vns"):
cls._save(
cls.load(path),
out_dir if out_dir is not None else OS_PATH.dirname(path),
Expand Down

0 comments on commit e909072

Please sign in to comment.