Exemplo n.º 1
0
		public int RegisterCode(MemberInfoData callee, string value) {
			StringData data;
			if (!this.methodCodes.TryGetValue(value, out data)) {
				data = new StringData(this.methodCodes.Count, value);
				this.methodCodes[value] = data;
			}
			this.addDependency(callee, data);
			return data.Index;
		}
Exemplo n.º 2
0
		public int RegisterNative(MemberInfoData callee, MemberInfo member) {
			NativeData data;
			if (!this.nativeMembers.TryGetValue(member, out data)) {
				var native = NativesManager.Instance.GetNative(member);
				//w tych przypadkach nie rejestrujemy bo nie ma takiej potrzeby
				if (
					native.Value == null &&
					native.OpCode == null &&
					native.CommandType == NativeCommandType.None &&
					!native.Ignore
				) {
					data = new NativeData(0, native.AdditionalCode == null ? null : Program.PackCode(native.AdditionalCode, true));
					data.Index = native.Code == null ?
						this.Register(data, NativesManager.Instance.Get_native_Value(native, member)) :
						this.RegisterCode(data, Program.PackCode(native.Code, true));
					this.nativeMembers[member] = data;
				} else {
					return 0;
				}
			}
			this.addDependency(callee, data);
			return data.Index;
		}
Exemplo n.º 3
0
		public TypeData Register(MemberInfoData callee, Type type) {
			if (NativesManager.Instance.IsNative(type)) {
				//nie potrzebne bo nigdzie sie do tego nie odwoluje
				//this.RegisterNative(type);
				//try {
				//  var native = NativesManager.Instance.GetNative(type);
				//  Console.WriteLine(native.Name ?? type.Name);
				//} catch { }
				return null;
			} else {
				TypeData data = doRegister(type);
				var moduleCompiler = this.GetModuleCompiler(type);
				if (moduleCompiler == null) {
					this.addDependency(callee, data);
				}
				return data;
			}
		}
Exemplo n.º 4
0
		public int Register(MemberInfoData callee, MethodBase member) {
			if (NativesManager.Instance.IsNative(member)) {
				return this.RegisterNative(callee, member);
			} else {
				if ((member.IsVirtual || member.IsAbstract) && member.DeclaringType.IsSubclassOf(typeof(MK.JavaScript.Window))) {
					ThrowHelper.Throw("{0} cannot be called as it is virtual or abstract method of subclass of Window.", member.GetSignature());
				}
				MethodBaseData data;
				if (this.Methods.TryGetValue(member, out data)) {
					++data.HitCount;
				} else {
					//zaczynam numeracje metod od 1 a nie od zera... ciekawe kiedy to spowoduje problemy
					//dlaczego tak numeruje? bo if(0) zwraca false w .js
					data = new MethodBaseData(member, this.Methods.Count + 1);
					this.Methods[member] = data;

					if ((member.IsVirtual || member.IsAbstract)) {// && ((MethodInfo)member).GetBaseDefinition() == member) {
						var typeData = this.Resolve(member.DeclaringType);
						VirtualMethodCallData vmcd;
						if (!typeData.VirtualMethods.TryGetValue(data, out vmcd)) {
							typeData.VirtualMethods[data] = new VirtualMethodCallData();
						}
					}
					if (!member.IsAbstract)
						this.methodsToCompile.Enqueue(data);
				}
				if (this.PageCompiler.WindowAttribute.MethodsOnTop
					&& member.DeclaringType.GetDeclaringTypesWithType().Any(t => t == this.PageCompiler.WindowType)) {
					this.addDependency(this.PageCompiler.TypeData, data);
				} if (this.PageCompiler.WindowAttribute.RunAtThis.Any(t => member.DeclaringType.GetDeclaringTypesWithType().Contains(t))) {
					this.addDependency(this.PageCompiler.TypeData, data);
				} else {
					var moduleCompiler = this.GetModuleCompiler(member.DeclaringType);
					if (moduleCompiler != null) {
						this.addDependency(moduleCompiler.TypeData, data);
					} else {
						this.addDependency(callee, data);
					}
				}
				return data.Index;
			}
		}
Exemplo n.º 5
0
		public MemberInfoData RegisterFrameType(Type type) {
#warning .. to bylo poto by css'y sie dobrze dodawaly
			var value = new MemberInfoData(null, 0);
			this.Dependencies.AddVertice(value);
			this.Dependencies.AddEdge(value, doRegister(type));
			return value;


			//TypeData data = doRegister(type);
			//this.Dependencies.AddVertice(data);
			//return data;
		}
Exemplo n.º 6
0
		public int Register(MemberInfoData callee, FieldInfo member) {
			if (NativesManager.Instance.IsNative(member)) {
				return this.RegisterNative(callee, member);
			} else if (member.IsStatic) {
				Static_FieldInfoData data;
				if (this.staticFields.TryGetValue(member, out data)) {
					++data.HitCount;
				} else {
					data = new Static_FieldInfoData(member, this.staticFields.Count);
					this.staticFields[member] = data;
				}
				this.addDependency(callee, data);
				return data.Index;
			} else {
				return 0;
			}
		}
Exemplo n.º 7
0
		private void addDependency(MemberInfoData calee, MemberInfoData data) {
			this.Dependencies.AddEdge(calee, data);
			//if (data.Member != null && data.Member.MemberType != MemberTypes.TypeInfo && data.Member.DeclaringType!=null) {
			//  try {
			//    //this.dependencies.AddEdge(this.types[data.Member.DeclaringType], data);
			//  } catch { }
			//}
		}