intertype
Advanced tools
Comparing version 0.109.1 to 0.110.0
@@ -334,2 +334,8 @@ (function() { | ||
return this.isa_optional.function(x.create); | ||
}, | ||
"@isa.boolean x.override": function(x) { | ||
return this.isa.boolean(x.override); | ||
}, | ||
"@isa.boolean x.replace": function(x) { | ||
return this.isa.boolean(x.replace); | ||
} | ||
@@ -336,0 +342,0 @@ } |
@@ -64,2 +64,9 @@ (function() { | ||
})); | ||
GUY.props.hide(this, 'remove', new Proxy(this._remove.bind(this), { | ||
get: (_, name) => { | ||
return (...P) => { | ||
return this._remove(name, ...P); | ||
}; | ||
} | ||
})); | ||
//....................................................................................................... | ||
@@ -230,6 +237,19 @@ GUY.props.hide(this, 'registry', GUY.props.Strict_owner.create()); | ||
//--------------------------------------------------------------------------------------------------------- | ||
_remove(typename) { | ||
var dsc; | ||
if ((dsc = GUY.props.get(this.registry, typename, null)) == null) { | ||
throw new E.Intertype_ETEMPTBD('^intertype.remove@5^', `unable to remove unknown type ${rpr(typename)}`); | ||
} | ||
delete this.registry[typename]; | ||
if (dsc.override) { | ||
this._remove_override(dsc); | ||
} | ||
return null; | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
_declare(...P) { | ||
/* TAINT handling of arguments here shimmed while we have not yet nailed down the exact calling | ||
convention for this method. */ | ||
var dsc, dscv, old_dsc, ref1; | ||
var dsc, dscv, old_dsc; | ||
dsc = this.type_factory.create_type(...P); | ||
@@ -253,8 +273,13 @@ //....................................................................................................... | ||
} | ||
if ((ref1 = old_dsc != null ? old_dsc.override : void 0) != null ? ref1 : false) { | ||
this._remove_override(old_dsc.typename); | ||
if (old_dsc != null ? old_dsc.override : void 0) { | ||
if (dsc.override) { | ||
this._replace_override(dsc); | ||
} else { | ||
this._remove_override(dsc); | ||
} | ||
} else { | ||
if (dsc.override) { | ||
this._add_override(dsc); | ||
} | ||
} | ||
if (dsc.override) { | ||
this.overrides.unshift([dsc.typename, dsc]); | ||
} | ||
//....................................................................................................... | ||
@@ -265,9 +290,16 @@ return null; | ||
//--------------------------------------------------------------------------------------------------------- | ||
_remove_override(typename) { | ||
_add_override(dsc) { | ||
this.overrides.unshift([dsc.typename, dsc]); | ||
return null; | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
_remove_override(dsc) { | ||
var i, idx, ref1; | ||
for (idx = i = ref1 = this.overrides.length - 1; i >= 0; idx = i += -1) { | ||
if (this.overrides[idx][0] !== typename) { | ||
if (this.overrides[idx][0] !== dsc.typename) { | ||
continue; | ||
} | ||
this.overrides.splice(idx, 1); | ||
break; | ||
} | ||
@@ -278,2 +310,15 @@ return null; | ||
//--------------------------------------------------------------------------------------------------------- | ||
_replace_override(dsc) { | ||
var i, idx, ref1; | ||
for (idx = i = ref1 = this.overrides.length - 1; i >= 0; idx = i += -1) { | ||
if (this.overrides[idx][0] !== dsc.typename) { | ||
continue; | ||
} | ||
this.overrides[idx][1] = dsc; | ||
break; | ||
} | ||
return null; | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
_validate_hedgerow(hedgerow) { | ||
@@ -280,0 +325,0 @@ var ref1, ref2, xr; |
{ | ||
"name": "intertype", | ||
"version": "0.109.1", | ||
"version": "0.110.0", | ||
"description": "A JavaScript typechecker", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -737,1 +737,3 @@ | ||
using `type_of()` | ||
* **[+]** implement deleting declarations and make replacements *keep* the position of the `override` entry; | ||
that way we don't need yet another cfg setting and can still handle precedence of overrides |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
356497
1912
739
33