Пример #1
0
 public override IExpression Rewrite(IThisReference thisReference) {
   var boundExpression = new BoundExpression();
   boundExpression.Instance = thisReference;
   boundExpression.Definition = iteratorClosure.ThisFieldReference;
   boundExpression.Type = iteratorClosure.ThisFieldReference.Type;
   return boundExpression;
 }
 public override void Visit(IThisReference thisReference)
 {
     if (Process(thisReference))
     {
         visitor.Visit(thisReference);
     }
     base.Visit(thisReference);
 }
Пример #3
0
        public override IExpression Rewrite(IThisReference thisReference)
        {
            var boundExpression = new BoundExpression();

            boundExpression.Instance   = thisReference;
            boundExpression.Definition = iteratorClosure.ThisFieldReference;
            boundExpression.Type       = iteratorClosure.ThisFieldReference.Type;
            return(boundExpression);
        }
        public override void Visit(IThisReference thisRef)
        {
            TryAdd(thisRef, "this");
            AddInstanceExpr(Type, thisRef);

            if (!Parent.ContainsKey(thisRef))
            {
                Parent.Add(thisRef, null);
            }
        }
Пример #5
0
        public override void TraverseChildren(IThisReference thisReference)
        {
            base.TraverseChildren(thisReference);
            var typeForThis = this.containingType.ResolvedType;

            if (typeForThis.IsValueType)
            {
                ((ThisReference)thisReference).Type = Immutable.ManagedPointerType.GetManagedPointerType(NamedTypeDefinition.SelfInstance(typeForThis, this.host.InternFactory), this.host.InternFactory);
            }
            else
            {
                ((ThisReference)thisReference).Type = NamedTypeDefinition.SelfInstance(typeForThis, this.host.InternFactory);
            }
        }
Пример #6
0
 private HLLocation ProcessThisReferenceExpression(IThisReference pExpression)
 {
     return HLParameterLocation.Create(Parameters[0]);
 }
Пример #7
0
 public override void Visit(IThisReference thisReference) {
   TranslatedExpressions.Push(new Bpl.IdentifierExpr(thisReference.Token(),
     this.sink.ThisVariable));
 }
Пример #8
0
 public void Visit(IThisReference thisReference)
 {
     Contract.Requires(thisReference != null);
       throw new NotImplementedException();
 }
Пример #9
0
 public void Visit(IThisReference thisReference)
 {
     this.traverser.Traverse(thisReference);
 }
Пример #10
0
 /// <summary>
 /// Traverses the this reference expression.
 /// </summary>
 public void Traverse(IThisReference thisReference)
 {
     Contract.Requires(thisReference != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(thisReference);
       if (this.StopTraversal) return;
       this.TraverseChildren(thisReference);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(thisReference);
 }
Пример #11
0
        public override void TraverseChildren(IThisReference thisReference)
{ MethodEnter(thisReference);
            base.TraverseChildren(thisReference);
     MethodExit();   }
Пример #12
0
 public void Visit(IThisReference thisReference)
 {
     this.result = this.copier.Copy(thisReference);
 }
 /// <summary>
 /// Rewrites the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public virtual IExpression Rewrite(IThisReference thisReference)
 {
     return thisReference;
 }
Пример #14
0
 public override void Visit(IThisReference thisReference)
 {
     allElements.Add(new InvokInfo(Traverser, "IThisReference", thisReference));
 }
Пример #15
0
 /// <summary>
 /// Generates IL for the specified this reference.
 /// </summary>
 /// <param name="thisReference">The this reference.</param>
 public override void TraverseChildren(IThisReference thisReference)
 {
     this.generator.Emit(OperationCode.Ldarg_0);
       this.StackSize++;
 }
Пример #16
0
 public override void Visit(IThisReference thisRef)
 {
     AddTypeReference(Names.Type, thisRef);
 }
 public override void Visit(IThisReference thisReference)
 {
     if(Process(thisReference)){visitor.Visit(thisReference);}
     base.Visit(thisReference);
 }
Пример #18
0
 private HLLocation ProcessThisReferenceExpression(IThisReference pExpression)
 {
     return(HLParameterLocation.Create(Parameters[0]));
 }
Пример #19
0
 public virtual void onASTElement(IThisReference thisReference) { }
Пример #20
0
 public override void TraverseChildren(IThisReference thisReference) {
   base.TraverseChildren(thisReference);
   var typeForThis = this.containingType.ResolvedType;
   if (typeForThis.IsValueType)
     ((ThisReference)thisReference).Type = Immutable.ManagedPointerType.GetManagedPointerType(NamedTypeDefinition.SelfInstance(typeForThis, this.host.InternFactory), this.host.InternFactory);
   else
     ((ThisReference)thisReference).Type = NamedTypeDefinition.SelfInstance(typeForThis, this.host.InternFactory);
 }
Пример #21
0
 public void Visit(IThisReference thisReference)
 {
     this.result = this.rewriter.Rewrite(thisReference);
 }
Пример #22
0
    /// <summary>
    /// Returns a shallow copy of the given this reference expression.
    /// </summary>
    /// <param name="thisReference"></param>
    public ThisReference Copy(IThisReference thisReference) {
      Contract.Requires(thisReference != null);
      Contract.Ensures(Contract.Result<ThisReference>() != null);

      return new ThisReference(thisReference);
    }
Пример #23
0
 public virtual void onASTElement(IThisReference thisReference)
 {
 }
Пример #24
0
    /// <summary>
    /// Returns a deep copy of the given this reference expression.
    /// </summary>
    /// <param name="thisReference"></param>
    public ThisReference Copy(IThisReference thisReference) {
      Contract.Requires(thisReference != null);
      Contract.Ensures(Contract.Result<ThisReference>() != null);

      var mutableCopy = this.shallowCopier.Copy(thisReference);
      this.CopyChildren((Expression)mutableCopy);
      return mutableCopy;
    }
Пример #25
0
 /// <summary>
 /// Performs some computation with the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public virtual void Visit(IThisReference thisReference)
 {
 }
        /// <summary>
        /// If a definition should be captured, capture it. Otherwise noop.
        ///
        /// The act of capturing means mapping the definition (or its type's interned id if the definition is a reference to THIS) to
        /// a new BoundField object that represents a field in the closure class.
        /// </summary>
        /// <param name="definition"></param>
        private void CaptureDefinition(object definition)
        {
            IThisReference /*?*/ thisRef = definition as IThisReference;

            if (thisRef != null)
            {
                definition = thisRef.Type.ResolvedType.InternedKey;
            }
            if (this.fieldForCapturedLocalOrParameter.ContainsKey(definition))
            {
                return;
            }

            IName /*?*/            name  = null;
            ITypeReference /*?*/   type  = null;
            ILocalDefinition /*?*/ local = definition as ILocalDefinition;
            var containingClass          = this.generatedclosureClass;

            if (local != null)
            {
                if (!this.localOrParameter2ClosureClass.TryGetValue(local, out containingClass))
                {
                    return;
                }
                if (false && containingClass == this.generatedclosureClass)
                {
                    // A use of a local is captured only if it is found in a *nested* closure,
                    // not the closure where the local is defined.
                    return;
                }
                name = local.Name;
                type = local.Type;
            }
            else
            {
                IParameterDefinition /*?*/ par = definition as IParameterDefinition;
                if (par != null)
                {
                    if (!this.localOrParameter2ClosureClass.TryGetValue(par, out containingClass))
                    {
                        return;
                    }
                    name = par.Name;
                    type = par.Type;
                }
                else
                {
                    if (definition is uint)
                    {
                        type = thisRef.Type;
                        name = this.nameTable.GetNameFor("__this value");
                    }
                    else
                    {
                        return;
                    }
                }
            }
            if (name == null)
            {
                return;
            }

            FieldDefinition field = new FieldDefinition()
            {
                ContainingTypeDefinition = containingClass,
                InternFactory            = this.host.InternFactory,
                Name       = name,
                Type       = this.copyTypeToClosure.Visit(type),
                Visibility = TypeMemberVisibility.Public
            };

            containingClass.Fields.Add(field);
            BoundField be = new BoundField(field, field.Type);

            this.fieldForCapturedLocalOrParameter.Add(definition, be);
        }
Пример #27
0
 /// <summary>
 /// Traverses the children of the this reference expression.
 /// </summary>
 public virtual void TraverseChildren(IThisReference thisReference)
 {
     Contract.Requires(thisReference != null);
       this.TraverseChildren((IExpression)thisReference);
 }
Пример #28
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="thisReference"></param>
 public ThisReference(IThisReference thisReference)
     : base(thisReference)
 {
 }
Пример #29
0
 /// <summary>
 /// Performs some computation with the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public virtual void Visit(IThisReference thisReference)
 {
     this.Visit((IExpression)thisReference);
 }
Пример #30
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="host"></param>
 /// <param name="fromMethod"></param>
 /// <param name="toMethod"></param>
 /// <param name="expressions"></param>
 public BetaReducer(IMetadataHost host, IMethodDefinition fromMethod, IMethodDefinition toMethod, List<IExpression> expressions)
   : base(host) {
   this.fromParameters = new List<IParameterDefinition>(fromMethod.Parameters);
   this.expressions = expressions;
   for (ushort i = 0; i < fromMethod.ParameterCount; i++) {
     this.values.Add(this.fromParameters[i], expressions[i]);
   }
   this.targetMethod = toMethod;
   this.targetType = toMethod.ContainingType;
   this.sourceMethod = fromMethod;
   this.sourceType = fromMethod.ContainingType;
   this.ThisReference = new ThisReference() {
     Type = this.targetType,
   };
 }
Пример #31
0
 public void Visit(IThisReference thisReference)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Rewrites the given this reference expression.
 /// </summary>
 public override IExpression Rewrite(IThisReference thisReference) {
   if (this.isInsideAnonymousMethod) {
     IFieldReference thisField;
     if (this.fieldReferencesForUseInsideAnonymousMethods.TryGetValue(this.method, out thisField)) {
       return new BoundExpression() {
         Instance = this.GetClosureObjectInstanceContaining(thisField),
         Definition = thisField,
         Type = thisField.Type
       };
     }
   }
   return base.Rewrite(thisReference);
 }
 /// <summary>
 /// Performs some computation with the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public virtual void Visit(IThisReference thisReference)
 {
 }
Пример #34
0
 /// <summary>
 /// Rewrites the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 /// <returns></returns>
 public override IExpression Rewrite(IThisReference thisReference) {
   var t = thisReference.Type;
   var gt = t as IGenericTypeInstanceReference;
   if (gt != null) t = gt.GenericType;
   var k = t.InternedKey;
   if (k == this.sourceType.InternedKey) {
     ITypeReference st = this.targetType;
     return new ThisReference() {
       Type = NamedTypeDefinition.SelfInstance((INamedTypeDefinition)st.ResolvedType, this.host.InternFactory),
     };
   }
   return base.Rewrite(thisReference);
 }
Пример #35
0
 public override void Visit(IThisReference addition)
 {
     _formattedValue = "this";
 }
Пример #36
0
 /// <summary>
 /// Visits the specified this reference.
 /// </summary>
 /// <param name="thisReference">The this reference.</param>
 public override void Visit(IThisReference thisReference)
 {
     ThisReference mutableThisReference = new ThisReference(thisReference);
     this.resultExpression = this.myCodeCopier.DeepCopy(mutableThisReference);
 }
 public override void TraverseChildren(IThisReference thisReference) {
   if (this.currentAnonymousDelegate != null)
     this.anonymousDelegatesThatCaptureThis[this.currentAnonymousDelegate] = true;
 }
Пример #38
0
 /// <summary>
 /// Returns a deep copy of the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public ThisReference Copy(IThisReference thisReference)
 {
     var mutableCopy = this.shallowCopier.Copy(thisReference);
       this.CopyChildren((Expression)mutableCopy);
       return mutableCopy;
 }
 public override void TraverseChildren(IThisReference thisReference) {
   this.PrintToken(CSharpToken.This);
 }
Пример #40
0
 /// <summary>
 /// Returns a shallow copy of the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public ThisReference Copy(IThisReference thisReference)
 {
     return new ThisReference(thisReference);
 }
Пример #41
0
 public override void TraverseChildren(IThisReference thisReference)
 {
     MethodEnter(thisReference);
     base.TraverseChildren(thisReference);
     MethodExit();
 }
Пример #42
0
 /// <summary>
 /// Rewrites the given this reference expression.
 /// </summary>
 /// <param name="thisReference"></param>
 public virtual IExpression Rewrite(IThisReference thisReference)
 {
     var mutableThisReference = thisReference as ThisReference;
       if (mutableThisReference == null) return thisReference;
       this.RewriteChildren(mutableThisReference);
       return mutableThisReference;
 }