Skip to content

Commit

Permalink
avoids struct .ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed May 3, 2023
1 parent 328db28 commit f629a42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Peachpie.CodeAnalysis/CodeGen/VariableReference.cs
Expand Up @@ -860,13 +860,13 @@ public virtual TypeSymbol EmitLoadAddress(CodeGenerator cg, ref LhsStack lhs)
}

/// <summary>
/// Template: new IndirectLocal( LOCALS, NAME )
/// Template: IndirectLocal.Create( LOCALS, NAME )
/// </summary>
internal TypeSymbol LoadIndirectLocal(CodeGenerator cg)
{
LoadVariablesArray(cg);
BoundName.EmitVariableName(cg);
return cg.EmitCall(ILOpCode.Newobj, cg.CoreMethods.Ctors.IndirectLocal_PhpArray_String);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Dynamic.CreateIndirectLocal_PhpArray_String);
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/Peachpie.CodeAnalysis/Symbols/CoreMembers.cs
Expand Up @@ -1004,8 +1004,6 @@ public ConstructorsHolder(CoreTypes ct)
ScriptDiedException = ct.ScriptDiedException.Ctor();
ScriptDiedException_Long = ct.ScriptDiedException.Ctor(ct.Long);
ScriptDiedException_PhpValue = ct.ScriptDiedException.Ctor(ct.PhpValue);

IndirectLocal_PhpArray_String = ct.IndirectLocal.Ctor(ct.PhpArray, ct.String);
}

public readonly CoreConstructor
Expand All @@ -1016,8 +1014,8 @@ public readonly CoreConstructor
ScriptAttribute_string_long, PhpTraitAttribute, PharAttribute_string, PhpTypeAttribute_string_string, PhpTypeAttribute_string_string_byte, PhpFieldsOnlyCtorAttribute, PhpHiddenAttribute,
DefaultValueAttribute_string,
NullableAttribute_byte, NullableContextAttribute_byte,
ScriptDiedException, ScriptDiedException_Long, ScriptDiedException_PhpValue,
IndirectLocal_PhpArray_String;
ScriptDiedException, ScriptDiedException_Long, ScriptDiedException_PhpValue
;
}

public struct ContextHolder
Expand Down Expand Up @@ -1090,12 +1088,15 @@ public DynamicHolder(CoreTypes ct)
GetPhpTypeInfo_T = ct.PhpTypeInfoExtension.Method("GetPhpTypeInfo");
GetPhpTypeInfo_Object = ct.PhpTypeInfoExtension.Method("GetPhpTypeInfo", ct.Object);
GetPhpTypeInfo_RuntimeTypeHandle = ct.PhpTypeInfoExtension.Method("GetPhpTypeInfo", ct.RuntimeTypeHandle);

CreateIndirectLocal_PhpArray_String = ct.IndirectLocal.Method("Create", ct.PhpArray, ct.String);
}

public readonly CoreMethod
BinderFactory_Function, BinderFactory_InstanceFunction, BinderFactory_StaticFunction,
GetFieldBinder, SetFieldBinder, GetClassConstBinder,
GetPhpTypeInfo_T, GetPhpTypeInfo_Object, GetPhpTypeInfo_RuntimeTypeHandle;
GetPhpTypeInfo_T, GetPhpTypeInfo_Object, GetPhpTypeInfo_RuntimeTypeHandle,
CreateIndirectLocal_PhpArray_String;
}

public struct ReflectionHolder
Expand Down
2 changes: 2 additions & 0 deletions src/Peachpie.Runtime/IndirectLocal.cs
Expand Up @@ -63,6 +63,8 @@ public IndirectLocal(PhpArray/*!*/locals, string/*!*/name)
{
}

public static IndirectLocal Create(PhpArray/*!*/locals, string/*!*/name) => new IndirectLocal(locals, name);

public override string ToString() => DisplayString;
}
}

0 comments on commit f629a42

Please sign in to comment.