コード例 #1
0
ファイル: AssemblyCompiler.cs プロジェクト: JimmyJune/il2js
		public ModuleCompiler(int index, TypeData typeData)
			: base(
#if !OBFUSCATE
"Module=" + new Regex(@"[^a-zA-Z0-9_]", RegexOptions.Compiled).Replace(typeData.Type.Name, "_") + "=" +
#endif
Guid.NewGuid().ToString()
			) {
			this.Index = index;
			this.TypeData = typeData;
		}
コード例 #2
0
ファイル: AssemblyCompiler.cs プロジェクト: JimmyJune/il2js
		private TypeData doRegister(Type type) {
			if (type.IsGenericType) type = type.GetGenericTypeDefinition();

			TypeData data;
			if (this.typeData.TryGetValue(type, out data)) {
				++data.HitCount;
			} else {
				TypeData baseTypeData;
				if (type.BaseType != null && type.BaseType != typeof(object) && !NativesManager.Instance.IsNative(type.BaseType)) {
					baseTypeData = doRegister(type.BaseType);
				} else {
					baseTypeData = null;
				}

				//typy numerowane od 1. ciekawe kiedy sie to wysypie
				data = new TypeData(type, this.typeData.Count + 1);
				data.BaseTypeData = baseTypeData;
				this.typeData[type] = data;

				if (baseTypeData != null) {
					this.addDependency(data, baseTypeData);
					baseTypeData.SubTypes.Add(data);
				}

				// statyczne konstruktory tworza te enumy. z zalozenia one sa stringami tylko!
				if (!type.IsSubclassOf(typeof(MK.JavaScript.Framework.EnumString))) {
					ConstructorInfo cctor = type.GetConstructor(BindingFlags.Static | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
					if (cctor != null) {
						var native = cctor.GetCustomAttribute<JSNative>();
						if (native == null || !native.Ignore) {
							data.StaticConstructor = new MethodBaseData(cctor, this.staticConstructorsCount++);
							this.addDependency(data, data.StaticConstructor);
							this.methodsToCompile.Enqueue(data.StaticConstructor);
						}
					}
				}
			}
			return data;
		}