Skip to content

Commit c532624

Browse files
committed
added fun.bind() support
1 parent 9e72f5d commit c532624

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

hscript/Checker.hx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ class Checker {
819819
case TAnon(fl):
820820
for( f in fl )
821821
fields.push({ name : f.name, t : f.t });
822+
case TFun(args, ret):
823+
if( isCompletion )
824+
fields.push({ name : "bind", t : TFun(args,TVoid) });
822825
default:
823826
}
824827
return fields;
@@ -993,6 +996,25 @@ class Checker {
993996
case EParent(e):
994997
return typeExpr(e,withType);
995998
case ECall(e, params):
999+
switch( edef(e) ) {
1000+
case EField(val, "bind"):
1001+
var ft = typeExpr(val, Value);
1002+
switch( ft ) {
1003+
case TFun(args,ret):
1004+
var remainArgs = args.copy();
1005+
for( p in params ) {
1006+
var a = remainArgs.shift();
1007+
if( a == null ) {
1008+
error("Too many arguments", p);
1009+
return TFun([], ret);
1010+
}
1011+
typeExprWith(p, a.t);
1012+
}
1013+
return TFun(remainArgs, ret);
1014+
default:
1015+
}
1016+
default:
1017+
}
9961018
var ft = typeExpr(e, switch( [edef(e),withType] ) {
9971019
case [EIdent(_),WithType(TEnum(_))]: withType;
9981020
default: Value;

0 commit comments

Comments
 (0)