Пример #1
0
 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();
 }