kiss-vscode evalString

This commit is contained in:
2021-03-16 21:46:43 -06:00
parent e700dd8049
commit 7fc23574ca
3 changed files with 15 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
-lib hxnodejs -lib hxnodejs
-lib kiss -lib kiss
-lib uuid -lib uuid
-lib hscript
-cp src -cp src
-js bin/extension.js -js bin/extension.js
-D analyzer-optimize -D analyzer-optimize

View File

@@ -4,6 +4,10 @@ import kiss.Kiss;
import kiss.Prelude; import kiss.Prelude;
import vscode.*; import vscode.*;
import js.lib.Promise; import js.lib.Promise;
import js.node.ChildProcess;
import js.node.buffer.Buffer;
import hscript.Parser;
import hscript.Interp;
typedef Command = (String) -> Void; typedef Command = (String) -> Void;

View File

@@ -46,11 +46,21 @@
(defvar :Map<String,Command> commands (new Map)) (defvar :Map<String,Command> commands (new Map))
(defvar &mut :String lastCommand null) (defvar &mut :String lastCommand null)
(defvar parser (new Parser))
(defvar interp (new Interp))
/** /**
* Functionality * Functionality
*/ */
(defun convertToHScript [kiss]
(.toString (the Buffer .stdout (ChildProcess.spawnSync "haxelib" ["run" "kiss" "--all"] (object input kiss)))))
(defun evalString [kiss]
(interp.execute
(parser.parseString
(convertToHScript kiss))))
(defun runCommand [&opt command] (defun runCommand [&opt command]
(if command (if command
{(set lastCommand command) ((dictGet commands command) (selectedText))} {(set lastCommand command) ((dictGet commands command) (selectedText))}