private HLLocation ProcessBoundExpression(IBoundExpression pExpression) { if (pExpression.Definition is ILocalDefinition) { ILocalDefinition definition = pExpression.Definition as ILocalDefinition; HLLocation location = HLLocalLocation.Create(HLDomain.GetLocal(definition)); if (pExpression.Type.ResolvedType.TypeCode == PrimitiveTypeCode.Reference) { location = location.AddressOf(); } return(location); } else if (pExpression.Definition is IParameterDefinition) { return(HLParameterLocation.Create(HLDomain.GetParameter(pExpression.Definition as IParameterDefinition))); } else if (pExpression.Definition is IFieldDefinition || pExpression.Definition is IFieldReference) { IFieldDefinition definition = pExpression.Definition is IFieldDefinition ? (IFieldDefinition)pExpression.Definition : ((IFieldReference)pExpression.Definition).ResolvedField; HLType typeFieldContainer = HLDomain.GetOrCreateType(definition.Container); HLField field = HLDomain.GetField(definition); if (field.IsStatic) { return(HLStaticFieldLocation.Create(field)); } HLLocation instance = ProcessExpression(pExpression.Instance); return(HLFieldLocation.Create(instance, field)); } throw new NotSupportedException(); }
private HLLocation ProcessTargetExpression(ITargetExpression pExpression) { if (pExpression.Definition is ILocalDefinition) { return(HLLocalLocation.Create(HLDomain.GetLocal(pExpression.Definition as ILocalDefinition))); } else if (pExpression.Definition is IParameterDefinition) { HLParameter parameter = HLDomain.GetParameter(pExpression.Definition as IParameterDefinition); parameter.RequiresAddressing = true; return(HLParameterLocation.Create(parameter)); } else if (pExpression.Definition is IFieldDefinition || pExpression.Definition is IFieldReference) { IFieldDefinition definition = pExpression.Definition is IFieldDefinition ? (IFieldDefinition)pExpression.Definition : ((IFieldReference)pExpression.Definition).ResolvedField; HLType typeFieldContainer = HLDomain.GetOrCreateType(definition.Container); HLField field = HLDomain.GetField(definition); if (field.IsStatic) { return(HLStaticFieldLocation.Create(field)); } HLLocation instance = ProcessExpression(pExpression.Instance); return(HLFieldLocation.Create(instance, field)); } else if (pExpression.Definition is IAddressDereference) { IAddressDereference definition = pExpression.Definition as IAddressDereference; HLLocation locationAddress = ProcessExpression(definition.Address); return(HLIndirectAddressLocation.Create(locationAddress, HLDomain.GetOrCreateType(pExpression.Type))); } throw new NotSupportedException(); }
private HLLocation ProcessAddressableExpression(IAddressableExpression pExpression) { if (pExpression.Definition is ILocalDefinition) { return(HLLocalLocation.Create(HLDomain.GetLocal(pExpression.Definition as ILocalDefinition))); } else if (pExpression.Definition is IParameterDefinition) { return(HLParameterLocation.Create(HLDomain.GetParameter(pExpression.Definition as IParameterDefinition))); } else if (pExpression.Definition is IFieldDefinition || pExpression.Definition is IFieldReference) { IFieldDefinition definition = pExpression.Definition is IFieldDefinition ? (IFieldDefinition)pExpression.Definition : ((IFieldReference)pExpression.Definition).ResolvedField; HLType typeFieldContainer = HLDomain.GetOrCreateType(definition.Container); HLField field = HLDomain.GetField(definition); if (field.IsStatic) { return(HLStaticFieldLocation.Create(field)); } HLLocation instance = ProcessExpression(pExpression.Instance); return(HLFieldLocation.Create(instance, field)); } else if (pExpression.Definition is IArrayIndexer) { IArrayIndexer definition = (IArrayIndexer)pExpression.Definition; if (definition.Indices.Count() != 1) { throw new NotSupportedException(); } HLLocation locationInstance = ProcessExpression(pExpression.Instance); HLLocation locationIndex = ProcessExpression(definition.Indices.First()); HLType typeElement = HLDomain.GetOrCreateType(pExpression.Type); return(HLArrayElementLocation.Create(locationInstance, locationIndex, typeElement)); } else if (pExpression.Definition is IDefaultValue) { HLType typeDefaultValue = HLDomain.GetOrCreateType(((IDefaultValue)pExpression.Definition).DefaultValueType); HLLocation locationDefaultValue = HLTemporaryLocation.Create(CreateTemporary(typeDefaultValue)); mCurrentBlock.EmitAssignment(locationDefaultValue, HLDefaultLocation.Create(typeDefaultValue)); return(locationDefaultValue); } throw new NotSupportedException(); }
private static HLField CreateField(HLType pContainer, IFieldDefinition pDefinition) { HLField field = new HLField(); //field.Definition = pDefinition; field.Name = pDefinition.Name.Value; field.Signature = HLDomain.GetFieldSignature(pDefinition); sFields[field.Signature] = field; field.Container = pContainer; pContainer.Fields.Add(field); field.IsStatic = pDefinition.IsStatic; field.IsCompileTimeConstant = pDefinition.IsCompileTimeConstant; if (field.IsCompileTimeConstant) { field.CompileTimeConstant = pDefinition.Constant.Value; } field.Type = GetOrCreateType(pDefinition.Type); return(field); }
private static HLField CreateField(HLType pContainer, IFieldDefinition pDefinition) { HLField field = new HLField(); //field.Definition = pDefinition; field.Name = pDefinition.Name.Value; field.Signature = HLDomain.GetFieldSignature(pDefinition); sFields[field.Signature] = field; field.Container = pContainer; pContainer.Fields.Add(field); field.IsStatic = pDefinition.IsStatic; field.IsCompileTimeConstant = pDefinition.IsCompileTimeConstant; if (field.IsCompileTimeConstant) field.CompileTimeConstant = pDefinition.Constant.Value; field.Type = GetOrCreateType(pDefinition.Type); return field; }