public override void RewriteChildren(AddressableExpression addressableExpression) { IExpression capturedThing; var field = addressableExpression.Definition as IFieldReference; if (field != null) { var k = field.InternedKey; var spec = field as ISpecializedFieldReference; if (spec != null) { k = spec.UnspecializedVersion.InternedKey; } if (this.capturedThings.TryGetValue(k, out capturedThing)) { var be = capturedThing as IBoundExpression; if (be == null) { System.Diagnostics.Debug.Assert(false); } addressableExpression.Definition = be.Definition; addressableExpression.Instance = be.Instance; return; } } base.RewriteChildren(addressableExpression); }
public override void RewriteChildren(AddressableExpression addressableExpression) { BoundField /*?*/ boundField; if (this.fieldForCapturedLocalOrParameter.TryGetValue(addressableExpression.Definition, out boundField)) { addressableExpression.Instance = new ThisReference(); addressableExpression.Definition = iteratorClosure.GetReferenceOfFieldUsedByPeers(boundField.Field); addressableExpression.Type = boundField.Type; return; } base.RewriteChildren(addressableExpression); }
/// <summary> /// Allocates an expression that takes the address of a target expression. /// </summary> /// <param name="address">An expression that represents an addressable location in memory.</param> /// <param name="sourceLocation"></param> public VccAddressOf(AddressableExpression address, ISourceLocation sourceLocation) : base(address, sourceLocation) { }
private IExpression GetProjectedExpression() { VccCompilationHelper helper = (VccCompilationHelper)this.Helper; string/*?*/ str = this.Value as string; if (str == null) return CodeDummy.Expression; GlobalVariableDeclaration/*?*/ globalVar; if (!helper.StringTable.TryGetValue(str, out globalVar)) { NameDeclaration dummyName = new NameDeclaration(this.NameTable.GetNameFor("?mappedLiteral"+this.GetHashCode()), this.SourceLocation); VccArrayTypeExpression arrayType = new VccArrayTypeExpression(TypeExpression.For(this.PlatformType.SystemUInt8.ResolvedType), new CompileTimeConstant(str.Length+1, SourceDummy.SourceLocation), SourceDummy.SourceLocation); globalVar = new GlobalVariableDeclaration(FieldDeclaration.Flags.ReadOnly, TypeMemberVisibility.Assembly, arrayType, dummyName, this, this.SourceLocation); if (this.ContainingBlock.ContainingTypeDeclaration != null) { this.ContainingBlock.ContainingTypeDeclaration.AddHelperMember(globalVar); globalVar.SetContainingTypeDeclaration(this.ContainingBlock.ContainingTypeDeclaration, true); helper.StringTable.Add(str, globalVar); } else { return CodeDummy.Expression; //TODO: error } } //^ assume globalVar != null; AddressableExpression fieldRef = new AddressableExpression(new BoundExpression(this, globalVar.FieldDefinition)); VccAddressOf addressOf = new VccAddressOf(fieldRef, this.SourceLocation); addressOf.SetContainingExpression(this); Conversion conversion = new Conversion(addressOf, this.Type, this.SourceLocation); return conversion.ProjectAsIExpression(); }