internal Creators Clone() { Creators crtrs = new Creators(); crtrs.AddCreators(this); return(crtrs); }
internal void AddCreators(Creators crtrs) { foreach (AnnotatingVisitor visitor in crtrs.hash.Keys) { this[visitor].AddCreators(crtrs[visitor]); } }
private void setNext(NBTValue val) { this.next = val; this.types = null; this.flds = null; this.crtrs = null; }
internal ReferenceBTValue(BTType btType) { this.next = null; this.types = new ArrayList(); this.btType = btType; this.flds = new Hashtable(); this.crtrs = new Creators(); }
private static Creators pseudoMerge(ReferenceBTValue val1, ReferenceBTValue val2, BTValuePairs pairs) { val1 = val1.findLeaf(); val2 = val2.findLeaf(); bool flag = pairs[val1, val2]; if (!flag && val1 != val2 && val1.btType == BTType.Static && val2.btType == BTType.Static) { Creators crtrs = new Creators(); int count = 0; for (int i = 0; i < val1.types.Count; i++) { if (val2.types.Contains(val1.types[i])) { count++; } } if (val1.types.Count > count) { crtrs.AddCreators(val2.crtrs); } if (val2.types.Count > count) { crtrs.AddCreators(val1.crtrs); } foreach (object key in val2.flds.Keys) { ReferenceBTValue fld1 = val1.flds[key] as ReferenceBTValue; ReferenceBTValue fld2 = val2.flds[key] as ReferenceBTValue; if (fld1 != null) { crtrs.AddCreators(ReferenceBTValue.pseudoMerge(fld1, fld2, pairs)); } } return(crtrs); } else if (flag || val1.btType == val2.btType) { return(new Creators()); } else if (val1.btType == BTType.Static) { return(val1.crtrs); } else if (val2.btType == BTType.Static) { return(val2.crtrs); } else { throw new InternalException(); } }
internal static Creators MergeMethods(AnnotatedMethod method1, AnnotatedMethod method2) { Creators crtrs = new Creators(); for (int i = 0; i < method1.ParamVals.Count; i++) { crtrs.AddCreators(BTValue.Merge(method1.ParamVals[i].Val as ReferenceBTValue, method2.ParamVals[i].Val as ReferenceBTValue)); } crtrs.AddCreators(BTValue.Merge(method1.ReturnValue, method2.ReturnValue)); return(crtrs); }
internal AnnotatedMethod AnnotateMethod(AnnotatedMethod method) { int count = 0; foreach (AnnotatedMethod key in this.getMethods()) { if (method.SourceMethod == key.SourceMethod) { count++; if (AnnotatedMethod.EqualMethods(method, key)) { return(key); } } } if (count > AnnotatedAssemblyHolder.NUMBER_FOR_MERGE) { AnnotatedMethod keyMethod = null; int keyMethodCreators = 0; foreach (AnnotatedMethod key in this.getMethods()) { if (method.SourceMethod == key.SourceMethod) { int keyCreators = AnnotatedMethod.PseudoMergeMethods(method, key).Count; if (keyMethod == null || keyMethodCreators > keyCreators) { keyMethod = key; keyMethodCreators = keyCreators; } } } if (keyMethod != null && (keyMethodCreators == 0 || count > AnnotatedAssemblyHolder.NUMBER_FOR_LIFT)) { Creators crtrs = AnnotatedMethod.MergeMethods(method, keyMethod); if (!crtrs.IsEmpty) { throw new AnnotatingVisitor.LiftException(crtrs); } return(keyMethod); } } MethodBodyBlock mbbUp = Annotation.AnnotateMethod(this, method); this.addMethodBody(method, mbbUp); return(method); }
internal Creators ToReferenceBTValueCreators() { Creators crtrs = new Creators(); foreach (AnnotatingVisitor visitor in this.crtrs) { foreach (PrimitiveCreator crtr in this.crtrs[visitor]) { crtrs[visitor].AddCreator(new ToReferenceCreator(crtr as PrimitiveCreator)); } } return(crtrs); }
internal Creators LiftAllFields() { Creators crtrs = new Creators(); foreach (Type type in this.types) { if (type.IsArray) { crtrs.AddCreators(this.ArrayElements.Lift()); } else { foreach (FieldInfo fldInfo in ReflectionUtils.GetAllFields(type)) { crtrs.AddCreators(this[fldInfo].Lift()); } } } return(crtrs); }
internal static Creators PseudoMergeMethods(AnnotatedMethod method1, AnnotatedMethod method2) { Creators crtrs = new Creators(); for (int i = 0; i < method1.ParamVals.Count; i++) crtrs.AddCreators(BTValue.PseudoMerge(method1.ParamVals[i].Val as ReferenceBTValue, method2.ParamVals[i].Val as ReferenceBTValue)); crtrs.AddCreators(BTValue.PseudoMerge(method1.ReturnValue, method2.ReturnValue)); return crtrs; }
internal static Creators Merge(ReferenceBTValue val1, ReferenceBTValue val2) { val1 = val1.findLeaf(); val2 = val2.findLeaf(); if (val1 != val2 && val1.btType == BTType.Static && val2.btType == BTType.Static) { Creators crtrs = new Creators(); int count = 0; for (int i = 0; i < val1.types.Count; i++) { if (val2.types.Contains(val1.types[i])) { count++; } } if (val1.types.Count > count) { crtrs.AddCreators(val2.crtrs); } if (val2.types.Count > count) { crtrs.AddCreators(val1.crtrs); } val2.setNext(val1); foreach (object key in val2.flds.Keys) { ReferenceBTValue fld1 = val1.flds[key] as ReferenceBTValue; ReferenceBTValue fld2 = val2.flds[key] as ReferenceBTValue; if (fld1 == null) { val1.flds[key] = fld2; } else { crtrs.AddCreators(ReferenceBTValue.Merge(fld1, fld2)); } } return(crtrs); } else if (val1.btType == val2.btType) { return(new Creators()); } else if (val1.btType == BTType.Static) { val1.setNext(val2); return(val1.crtrs); } else if (val2.btType == BTType.Static) { val2.setNext(val1); return(val2.crtrs); } else { throw new InternalException(); } }
internal PrimitiveBTValue(BTType btType) { this.btType = btType; this.crtrs = new Creators(); }
internal void AddCreators(Creators crtrs) { foreach (AnnotatingVisitor visitor in crtrs.hash.Keys) this[visitor].AddCreators(crtrs[visitor]); }
internal Creators LiftAllFields() { Creators crtrs = new Creators(); foreach (Type type in this.types) if (type.IsArray) crtrs.AddCreators(this.ArrayElements.Lift()); else foreach (FieldInfo fldInfo in ReflectionUtils.GetAllFields(type)) crtrs.AddCreators(this[fldInfo].Lift()); return crtrs; }
internal ReferenceBTValue(Type type, BTType btType) { this.next = null; this.types = new ArrayList(); this.addType(type); this.btType = btType; this.flds = new Hashtable(); this.crtrs = new Creators(); }
internal NBTValue(BTType btType) { this.next = null; this.types = new ArrayList(); this.btType = btType; this.flds = new Hashtable(); this.crtrs = new Creators(); }
internal Creators Clone() { Creators crtrs = new Creators(); crtrs.AddCreators(this); return crtrs; }
private static Creators pseudoMergeStates(State state1, State state2) { Creators crtrs = new Creators(); for (int i = 0; i < state1.Stack.Count; i++) crtrs.AddCreators(BTValue.PseudoMerge(state1.Stack[i] as BTValue, state2.Stack[i] as BTValue)); foreach (Variable v in state1.Pool.GetVariables()) crtrs.AddCreators(BTValue.PseudoMerge(state1.Pool[v].Val as BTValue, state2.Pool[v].Val as BTValue)); return crtrs; }
private AnnotatedMethod checkAnnotatedMethodForCall(AnnotatedMethod method) { if (! method.SourceMethod.IsDefined(typeof(InlineAttribute), false) || (method.SourceMethod.IsConstructor && (method.ParamVals[0].Val as ReferenceBTValue).BTType == BTType.Dynamic)) { Creators crtrs = new Creators(); for (int i = 0; i < method.ParamVals.Count; i++) { ReferenceBTValue val = method.ParamVals[i].Val as ReferenceBTValue; if (val.BTType == BTType.Static) crtrs.AddCreators(val.LiftAllFields()); } ReferenceBTValue ret = method.ReturnValue; if (ret != null) crtrs.AddCreators(ret.Lift()); if (! crtrs.IsEmpty) throw new LiftException(crtrs); } return this.holder.AnnotateMethod(method); }
internal Creators ToReferenceBTValueCreators() { Creators crtrs = new Creators(); foreach (AnnotatingVisitor visitor in this.crtrs) foreach (PrimitiveCreator crtr in this.crtrs[visitor]) crtrs[visitor].AddCreator(new ToReferenceCreator(crtr as PrimitiveCreator)); return crtrs; }
private BTType checkAnnotatedMethodForInvoke(AnnotatedMethod aMethod) { MethodBase sMethod = aMethod.SourceMethod; if (sMethod.DeclaringType.ToString() == "System.Object" && sMethod.Name == ".ctor" && sMethod.GetParameters().Length == 0) { BTValue obj = aMethod.ParamVals[0].Val as BTValue; return obj.BTType; } else if (this.holder.WhiteList.Contains(sMethod)) { ObjectHashtable hash = new ObjectHashtable(); for (int i = 0; i < aMethod.ParamVals.Count; i++) getAllFieldBTValue(aMethod.ParamVals[i].Val as ReferenceBTValue, 5, hash); if (aMethod.ReturnValue != null) getAllFieldBTValue(aMethod.ReturnValue, 5, hash); foreach (ReferenceBTValue val in hash.Keys) if (val.BTType == BTType.Dynamic) goto P; return BTType.Static; } P: Creators crtrs = new Creators(); for (int i = 0; i < aMethod.ParamVals.Count; i++) crtrs.AddCreators((aMethod.ParamVals[i].Val as ReferenceBTValue).Lift()); ReferenceBTValue ret = aMethod.ReturnValue; if (ret != null) crtrs.AddCreators(ret.Lift()); if (! crtrs.IsEmpty) throw new LiftException(crtrs); return BTType.Dynamic; }
internal static Creators Merge(ReferenceBTValue val1, ReferenceBTValue val2) { val1 = val1.findLeaf(); val2 = val2.findLeaf(); if (val1 != val2 && val1.btType == BTType.Static && val2.btType == BTType.Static) { Creators crtrs = new Creators(); int count = 0; for (int i = 0; i < val1.types.Count; i++) if (val2.types.Contains(val1.types[i])) count++; if (val1.types.Count > count) crtrs.AddCreators(val2.crtrs); if (val2.types.Count > count) crtrs.AddCreators(val1.crtrs); val2.setNext(val1); foreach (object key in val2.flds.Keys) { ReferenceBTValue fld1 = val1.flds[key] as ReferenceBTValue; ReferenceBTValue fld2 = val2.flds[key] as ReferenceBTValue; if (fld1 == null) val1.flds[key] = fld2; else crtrs.AddCreators(ReferenceBTValue.Merge(fld1, fld2)); } return crtrs; } else if (val1.btType == val2.btType) return new Creators(); else if (val1.btType == BTType.Static) { val1.setNext(val2); return val1.crtrs; } else if (val2.btType == BTType.Static) { val2.setNext(val1); return val2.crtrs; } else throw new InternalException(); }
public LiftException(BTValue val) { this.Creators = val.Lift(); }
private static Creators pseudoMerge(ReferenceBTValue val1, ReferenceBTValue val2, BTValuePairs pairs) { val1 = val1.findLeaf(); val2 = val2.findLeaf(); bool flag = pairs[val1, val2]; if (! flag && val1 != val2 && val1.btType == BTType.Static && val2.btType == BTType.Static) { Creators crtrs = new Creators(); int count = 0; for (int i = 0; i < val1.types.Count; i++) if (val2.types.Contains(val1.types[i])) count++; if (val1.types.Count > count) crtrs.AddCreators(val2.crtrs); if (val2.types.Count > count) crtrs.AddCreators(val1.crtrs); foreach (object key in val2.flds.Keys) { ReferenceBTValue fld1 = val1.flds[key] as ReferenceBTValue; ReferenceBTValue fld2 = val2.flds[key] as ReferenceBTValue; if (fld1 != null) crtrs.AddCreators(ReferenceBTValue.pseudoMerge(fld1, fld2, pairs)); } return crtrs; } else if (flag || val1.btType == val2.btType) return new Creators(); else if (val1.btType == BTType.Static) return val1.crtrs; else if (val2.btType == BTType.Static) return val2.crtrs; else throw new InternalException(); }
public LiftException(Creators crtrs) { this.Creators = crtrs; }