Expose more logic from BuildCache.
This commit is contained in:
@@ -106,23 +106,30 @@ class BuildCache {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getParam(name:String, ?pos:Position)
|
static public function getParams(name:String, ?pos:Position)
|
||||||
return
|
return
|
||||||
switch Context.getLocalType() {
|
switch Context.getLocalType() {
|
||||||
case TInst(_.toString() == name => true, [v]):
|
case TInst(_.toString() == name => true, v):
|
||||||
v;
|
Success(v);
|
||||||
case TInst(_.toString() == name => true, _):
|
|
||||||
pos.error('type parameter expected');
|
|
||||||
case TInst(_.get() => { pos: pos }, _):
|
case TInst(_.get() => { pos: pos }, _):
|
||||||
pos.error('Expected $name');
|
pos.makeFailure('Expected $name');
|
||||||
default:
|
case v:
|
||||||
throw 'assert';
|
pos.makeFailure('$v should be a class');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function getParam(name:String, ?pos:Position)
|
||||||
|
return
|
||||||
|
getParams(name, pos)
|
||||||
|
.flatMap(function (args:Array<Type>) return switch args {
|
||||||
|
case [v]: Success(v);
|
||||||
|
case []: pos.makeFailure('type parameter expected');
|
||||||
|
default: pos.makeFailure('too many parameters');
|
||||||
|
});
|
||||||
|
|
||||||
static public function getType(name, ?type, ?pos:Position, build:BuildContext->TypeDefinition) {
|
static public function getType(name, ?type, ?pos:Position, build:BuildContext->TypeDefinition) {
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
type = getParam(name, pos);
|
type = getParam(name, pos).sure();
|
||||||
|
|
||||||
var forName =
|
var forName =
|
||||||
switch cache[name] {
|
switch cache[name] {
|
||||||
|
Reference in New Issue
Block a user