MethodOrPropertySymbol
using Microsoft.CSharp.RuntimeBinder.Syntax;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal class MethodOrPropertySymbol : ParentSymbol
{
public uint modOptCount;
public new bool isStatic;
public bool isOverride;
public bool useMethInstead;
public bool isOperator;
public bool isParamArray;
public bool isHideByName;
private bool[] _optionalParameterIndex;
private bool[] _defaultParameterIndex;
private CONSTVAL[] _defaultParameters;
private CType[] _defaultParameterConstValTypes;
private bool[] _marshalAsIndex;
private UnmanagedType[] _marshalAsBuffer;
public SymWithType swtSlot;
public ErrorType errExpImpl;
public CType RetType;
private TypeArray _Params;
public AggregateDeclaration declaration;
public List<Name> ParameterNames { get; set; }
public TypeArray Params {
get {
return _Params;
}
set {
_Params = value;
_optionalParameterIndex = new bool[_Params.size];
_defaultParameterIndex = new bool[_Params.size];
_defaultParameters = new CONSTVAL[_Params.size];
_defaultParameterConstValTypes = new CType[_Params.size];
_marshalAsIndex = new bool[_Params.size];
_marshalAsBuffer = new UnmanagedType[_Params.size];
}
}
public MethodOrPropertySymbol()
{
ParameterNames = new List<Name>();
}
public bool IsParameterOptional(int index)
{
if (_optionalParameterIndex == null)
return false;
return _optionalParameterIndex[index];
}
public void SetOptionalParameter(int index)
{
_optionalParameterIndex[index] = true;
}
public bool HasOptionalParameters()
{
if (_optionalParameterIndex == null)
return false;
bool[] optionalParameterIndex = _optionalParameterIndex;
for (int i = 0; i < optionalParameterIndex.Length; i++) {
if (optionalParameterIndex[i])
return true;
}
return false;
}
public bool HasDefaultParameterValue(int index)
{
return _defaultParameterIndex[index];
}
public void SetDefaultParameterValue(int index, CType type, CONSTVAL cv)
{
ConstValFactory constValFactory = new ConstValFactory();
_defaultParameterIndex[index] = true;
_defaultParameters[index] = constValFactory.Copy(type.constValKind(), cv);
_defaultParameterConstValTypes[index] = type;
}
public CONSTVAL GetDefaultParameterValue(int index)
{
return _defaultParameters[index];
}
public CType GetDefaultParameterValueConstValType(int index)
{
return _defaultParameterConstValTypes[index];
}
public bool IsMarshalAsParameter(int index)
{
return _marshalAsIndex[index];
}
public void SetMarshalAsParameter(int index, UnmanagedType umt)
{
_marshalAsIndex[index] = true;
_marshalAsBuffer[index] = umt;
}
public UnmanagedType GetMarshalAsParameterValue(int index)
{
return _marshalAsBuffer[index];
}
public bool MarshalAsObject(int index)
{
UnmanagedType unmanagedType = (UnmanagedType)0;
if (IsMarshalAsParameter(index))
unmanagedType = GetMarshalAsParameterValue(index);
if (unmanagedType != UnmanagedType.Interface)
return unmanagedType == UnmanagedType.IUnknown;
return true;
}
public AggregateSymbol getClass()
{
return parent.AsAggregateSymbol();
}
public bool IsExpImpl()
{
return name == null;
}
public AggregateDeclaration containingDeclaration()
{
return declaration;
}
}
}