Пример #1
0
        public override LocalDefinition Clone()
        {
            var clone = new CapturedLocalDefinition();

            clone.Copy(this, Dummy.InternFactory);
            clone.capturingField = this.capturingField;
            return(clone);
        }
Пример #2
0
        public override void TraverseChildren(IAddressableExpression addressableExpression)
        {
            var definition = addressableExpression.Definition;
            var instance   = addressableExpression.Instance;

            if (instance == null)
            {
                var addressDeref = definition as IAddressDereference;
                if (addressDeref != null)
                {
                    var addressOf = addressDeref.Address as IAddressOf;
                    if (addressOf != null)
                    {
                        instance   = addressOf.Expression.Instance;
                        definition = addressOf.Expression.Definition;
                    }
                }
            }
            if (instance == null)
            {
                return;
            }
            var field = definition as IFieldReference;

            if (field == null)
            {
                return;
            }
            if (this.closures.Find(instance.Type.InternedKey) == null)
            {
                return;
            }
            if (this.closureFieldToLocalOrParameterMap[field.InternedKey] != null)
            {
                return;
            }
            var local = new CapturedLocalDefinition()
            {
                capturingField = field, MethodDefinition = this.method, Name = field.Name, Type = field.Type
            };

            this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, new BoundExpression()
            {
                Definition = local, Type = field.Type
            });
        }
Пример #3
0
        public override void TraverseChildren(IAssignment assignment)
        {
            base.TraverseChildren(assignment);
            var definition = assignment.Target.Definition;
            var instance   = assignment.Target.Instance;

            if (instance == null)
            {
                var addressDeref = assignment.Target.Definition as IAddressDereference;
                if (addressDeref != null)
                {
                    var addressOf = addressDeref.Address as IAddressOf;
                    if (addressOf != null)
                    {
                        instance   = addressOf.Expression.Instance;
                        definition = addressOf.Expression.Definition;
                    }
                }
            }
            if (instance == null)
            {
                return;
            }
            var field = definition as IFieldReference;

            if (field == null)
            {
                return;
            }
            if (this.closures.Find(instance.Type.InternedKey) == null)
            {
                return;
            }
            if (this.closureFieldToLocalOrParameterMap[field.InternedKey] != null)
            {
                return;
            }
            var thisRef = assignment.Source as ThisReference;

            if (thisRef != null)
            {
                this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, thisRef);
                return;
            }
            var binding = assignment.Source as BoundExpression;

            if (binding != null)
            {
                var par = binding.Definition as IParameterDefinition;
                if (par != null && par.Name == field.Name)
                {
                    this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, binding);
                    return;
                }
            }
            var local = new CapturedLocalDefinition()
            {
                capturingField = field, MethodDefinition = this.method, Name = field.Name, Type = field.Type
            };

            this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, new BoundExpression()
            {
                Definition = local, Type = field.Type
            });
        }
Пример #4
0
 public override LocalDefinition Clone() {
   var clone = new CapturedLocalDefinition();
   clone.Copy(this, Dummy.InternFactory);
   clone.capturingField = this.capturingField;
   return clone;
 }
Пример #5
0
 public override void TraverseChildren(IAddressableExpression addressableExpression) {
   var definition = addressableExpression.Definition;
   var instance = addressableExpression.Instance;
   if (instance == null) {
     var addressDeref = definition as IAddressDereference;
     if (addressDeref != null) {
       var addressOf = addressDeref.Address as IAddressOf;
       if (addressOf != null) {
         instance = addressOf.Expression.Instance;
         definition = addressOf.Expression.Definition;
       }
     }
   }
   if (instance == null) return;
   var field = definition as IFieldReference;
   if (field == null) return;
   if (this.closures.Find(instance.Type.InternedKey) == null) return;
   if (this.closureFieldToLocalOrParameterMap[field.InternedKey] != null) return;
   var local = new CapturedLocalDefinition() { capturingField = field, MethodDefinition = this.method, Name = field.Name, Type = field.Type };
   this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, new BoundExpression() { Definition = local, Type = field.Type });
 }
Пример #6
0
 public override void TraverseChildren(IAssignment assignment) {
   base.TraverseChildren(assignment);
   var definition = assignment.Target.Definition;
   var instance = assignment.Target.Instance;
   if (instance == null) {
     var addressDeref = assignment.Target.Definition as IAddressDereference;
     if (addressDeref != null) {
       var addressOf = addressDeref.Address as IAddressOf;
       if (addressOf != null) {
         instance = addressOf.Expression.Instance;
         definition = addressOf.Expression.Definition;
       }
     }
   }
   if (instance == null) return;
   var field = definition as IFieldReference;
   if (field == null) return;
   if (this.closures.Find(instance.Type.InternedKey) == null) return;
   if (this.closureFieldToLocalOrParameterMap[field.InternedKey] != null) return;
   var thisRef = assignment.Source as ThisReference;
   if (thisRef != null) {
     this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, thisRef);
     return;
   }
   var binding = assignment.Source as BoundExpression;
   if (binding != null) {
     var par = binding.Definition as IParameterDefinition;
     if (par != null && par.Name == field.Name) {
       this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, binding);
       return;
     }
   }
   var local = new CapturedLocalDefinition() { capturingField = field, MethodDefinition = this.method, Name = field.Name, Type = field.Type };
   this.closureFieldToLocalOrParameterMap.Add(field.InternedKey, new BoundExpression() { Definition = local, Type = field.Type });
 }