fix pipe issue in REPL, add ability to dump top in repl
This commit is contained in:
@@ -47,6 +47,9 @@ export let shim: NodeShim = {
|
|||||||
writeFileSync(name: string, data: string, enc?: string) {
|
writeFileSync(name: string, data: string, enc?: string) {
|
||||||
shim.files[name] = new TextEncoder().encode(data)
|
shim.files[name] = new TextEncoder().encode(data)
|
||||||
},
|
},
|
||||||
|
writeSync(fd: number, data: string) {
|
||||||
|
shim.stdout += data;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
process: {
|
process: {
|
||||||
argv: ["", ""],
|
argv: ["", ""],
|
||||||
|
|||||||
@@ -484,6 +484,7 @@ const processOutput = (
|
|||||||
let endLineNumber = +eline;
|
let endLineNumber = +eline;
|
||||||
let endColumn = +ecol
|
let endColumn = +ecol
|
||||||
// FIXME - pass the real path in
|
// FIXME - pass the real path in
|
||||||
|
if (file.startsWith("./")) file = file.slice(2);
|
||||||
if (fn && fn !== file) {
|
if (fn && fn !== file) {
|
||||||
startLineNumber = startColumn = 0;
|
startLineNumber = startColumn = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ data ReplCommand
|
|||||||
| GetDoc String
|
| GetDoc String
|
||||||
| BrowseCmd QName
|
| BrowseCmd QName
|
||||||
| HelpCmd
|
| HelpCmd
|
||||||
|
| DumpTop
|
||||||
|
|
||||||
kw : String → Parser String
|
kw : String → Parser String
|
||||||
kw s = satisfy (\t => t.val.text == s) "Expected \{show s}"
|
kw s = satisfy (\t => t.val.text == s) "Expected \{show s}"
|
||||||
@@ -61,6 +62,7 @@ commands
|
|||||||
:: MkCmd ":d" "document function" ArgIdent GetDoc
|
:: MkCmd ":d" "document function" ArgIdent GetDoc
|
||||||
:: MkCmd ":doc" "document function" ArgIdent GetDoc
|
:: MkCmd ":doc" "document function" ArgIdent GetDoc
|
||||||
:: MkCmd ":b" "browse namespace" ArgQName BrowseCmd
|
:: MkCmd ":b" "browse namespace" ArgQName BrowseCmd
|
||||||
|
:: MkCmd ":top" "dump top context as json" ArgNone DumpTop
|
||||||
-- type at point
|
-- type at point
|
||||||
-- solve hole
|
-- solve hole
|
||||||
-- search by prefix (for autocomplete - ideally include types at point, but we'd need recovery)
|
-- search by prefix (for autocomplete - ideally include types at point, but we'd need recovery)
|
||||||
|
|||||||
@@ -304,6 +304,9 @@ runCommand (GetDoc name) = getDoc name
|
|||||||
runCommand (Verbose Nothing) = modifyTop [ verbose $= _+_ 1 ]
|
runCommand (Verbose Nothing) = modifyTop [ verbose $= _+_ 1 ]
|
||||||
runCommand (Verbose (Just v)) = modifyTop [ verbose := v ]
|
runCommand (Verbose (Just v)) = modifyTop [ verbose := v ]
|
||||||
runCommand (OutputJS fn) = writeSource fn
|
runCommand (OutputJS fn) = writeSource fn
|
||||||
|
runCommand DumpTop = do
|
||||||
|
json <- jsonTopContext
|
||||||
|
putStrLn "TOP:\{renderJson json}"
|
||||||
|
|
||||||
-- Broken out to a separate function so I can hook it.
|
-- Broken out to a separate function so I can hook it.
|
||||||
runString : String → M Unit
|
runString : String → M Unit
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ instance HasIO IO where
|
|||||||
liftIO a = a
|
liftIO a = a
|
||||||
|
|
||||||
pfunc primPutStrLn uses (MkIORes MkUnit) : String → IO Unit := `(s) => (w) => {
|
pfunc primPutStrLn uses (MkIORes MkUnit) : String → IO Unit := `(s) => (w) => {
|
||||||
console.log(s)
|
require('fs').writeSync(1, s + '\n')
|
||||||
return Prelude_MkIORes(Prelude_MkUnit,w)
|
return Prelude_MkIORes(Prelude_MkUnit,w)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user