Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 private HLLocation ProcessDefaultValueExpression(IDefaultValue pExpression)
 {
     return(HLDefaultLocation.Create(HLDomain.GetOrCreateType(pExpression.DefaultValueType)));
 }