/// <summary> /// Initializes a new instance of the <see cref="Script"/> class. /// </summary> /// <param name="coreModules">The core modules to be pre-registered in the default global table.</param> public Script(CoreModules coreModules) { Options = new ScriptOptions(DefaultOptions); PerformanceStats = new PerformanceStatistics(); Registry = new Table(this); m_ByteCode = new ByteCode(this); m_MainProcessor = new Processor(this, m_GlobalTable, m_ByteCode); m_GlobalTable = new Table(this).RegisterCoreModules(coreModules); foreach (var t in TypeDescriptorRegistry.RegisteredTypes) { Type valType = t.Value.Type; if (valType.GetTypeInfo().Assembly.FullName != typeof(Script).GetTypeInfo().Assembly.FullName) { // m_GlobalTable.RegisterModuleType(t.Value.Type); if (t.Value is StandardUserDataDescriptor) { StandardUserDataDescriptor desc = (StandardUserDataDescriptor)t.Value; foreach (var member in desc.Members) { if (member.Value is MethodMemberDescriptor) { MethodMemberDescriptor methDesc = (MethodMemberDescriptor)member.Value; if (methDesc.IsConstructor) { m_GlobalTable.Set(methDesc.Name, methDesc.GetCallbackAsDynValue(this)); } } else if (member.Value is OverloadedMethodMemberDescriptor) { OverloadedMethodMemberDescriptor methDesc = (OverloadedMethodMemberDescriptor)member.Value; foreach (var overloadDesc in methDesc.m_Overloads) { if (overloadDesc is MethodMemberDescriptor) { MethodMemberDescriptor actualDesc = (MethodMemberDescriptor)overloadDesc; if (actualDesc.IsConstructor) { //m_GlobalTable.Set(desc.FriendlyName, actualDesc.GetCallbackAsDynValue(this)); m_GlobalTable.Set(desc.FriendlyName, DynValue.NewCallback(methDesc.GetCallbackFunction(this))); break; } } } } } } } } }