refactor: isolate in the code the point of template instantiation

This commit is contained in:
Glen Whitney 2022-07-31 09:44:36 -07:00
parent 0fbcbf661e
commit 5cea71cb25
1 changed files with 15 additions and 1 deletions

View File

@ -404,7 +404,21 @@ export default class PocomathInstance {
Object.defineProperty(this, name, {configurable: true, value: 'limbo'})
const tf_imps = {}
for (const [rawSignature, behavior] of usableEntries) {
/* For now, replace theTemplateParam with 'any' */
/* Check if it's an ordinary non-template signature */
let explicit = true
for (const type of typesOfSignature(rawSignature)) {
if (this._templateParam(type)) { // template types need better check
explicit = false
break
}
}
if (explicit) {
this._addTFimplementation(
tf_imps, rawSignature, behavior.uses, behavior.does)
continue
}
/* It's a template, have to instantiate */
/* But just for initial testing, punt and use T as synonym for 'any' */
const signature = rawSignature.replaceAll(theTemplateParam, 'any')
this._addTFimplementation(
tf_imps, signature, behavior.uses, behavior.does)