Skip to content

Commit 9638225

Browse files
committed
feat: callable convert for global functions
1 parent 76a7158 commit 9638225

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/Peachpie.CodeAnalysis/CodeGen/Graph/BoundExpression.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,37 @@ partial class BoundCallableConvert
23692369
{
23702370
internal override TypeSymbol Emit(CodeGenerator cg)
23712371
{
2372-
throw new NotImplementedException();
2372+
var target = cg.CoreTypes.IPhpCallable;
2373+
2374+
if (Receiver != null)
2375+
{
2376+
// Receiver -> Name(...)
2377+
throw new NotImplementedException();
2378+
}
2379+
else if (StaticReceiver != null)
2380+
{
2381+
// StaticReceiver :: Name(...)
2382+
throw new NotImplementedException();
2383+
}
2384+
else
2385+
{
2386+
// Name(...)
2387+
if (this.Name.IsDirect)
2388+
{
2389+
// TODO: PERF: use existing IPhpRoutine singleton
2390+
cg.Builder.EmitStringConstant(this.Name.NameValue.ToString());
2391+
}
2392+
else
2393+
{
2394+
cg.EmitConvertToString(cg.Emit(this.Name.NameExpression), this.Name.NameExpression.TypeRefMask);
2395+
}
2396+
2397+
// -> IPhpCallable
2398+
cg.EmitConvert(cg.CoreTypes.String, FlowAnalysis.TypeRefMask.AnyType, target);
2399+
}
2400+
2401+
//
2402+
return target;
23732403
}
23742404
}
23752405

0 commit comments

Comments
 (0)