wrote interpreter (independent of type inferencer)
This commit is contained in:
parent
2279c54229
commit
32bdc23ea7
6 changed files with 104 additions and 602 deletions
|
|
@ -5,7 +5,7 @@ import { trie } from "dope2";
|
|||
import { CallContext } from "../../context/CallContext";
|
||||
import { EnvContext } from "../../context/EnvContext";
|
||||
import { GlobalContext } from "../../context/GlobalContext";
|
||||
import { inferTypeInput, type Environment, type Type, type TypeInfoInput } from "../../eval/infer_type";
|
||||
import { inferTypeInput, type StaticEnvironment, type Type, type TypeInfoInput } from "../../eval/infer_type";
|
||||
import { getActions } from "../app/actions";
|
||||
import { Input } from "../other/Input";
|
||||
import { Type as TypeBlock } from "../other/Type";
|
||||
|
|
@ -46,9 +46,11 @@ const attemptLiterals = [
|
|||
|
||||
const computeSuggestions = (
|
||||
text: string,
|
||||
env: Environment,
|
||||
env: StaticEnvironment,
|
||||
score: InputBlockProps['score'],
|
||||
): PrioritizedSuggestionType[] => {
|
||||
const startTime = performance.now();
|
||||
|
||||
const ls = [
|
||||
...attemptLiterals
|
||||
.filter(([_, test]) => test(text))
|
||||
|
|
@ -69,9 +71,17 @@ const computeSuggestions = (
|
|||
},
|
||||
})),
|
||||
];
|
||||
const midTime = performance.now();
|
||||
|
||||
// return []; // <-- uncomment to disable suggestions (useful for debugging)
|
||||
return ls.map((state) => [score(state), inferTypeInput(state, env).type, state] as PrioritizedSuggestionType)
|
||||
const result = ls.map((state) => [score(state), inferTypeInput(state, env).type, state] as PrioritizedSuggestionType)
|
||||
.sort(([a],[b]) => b-a);
|
||||
|
||||
const endTime = performance.now();
|
||||
|
||||
console.log(`computing suggestions took ${midTime-startTime} + ${endTime - midTime}`);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function InputBlock({ state, setState, score, onCancel, typeInfo }: InputBlockProps) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue