/// <summary> /// <para>Cuando hay un item en el toggle</para> /// </summary> /// <param name="defineItem"></param> /// <param name="eType"></param> private void OnGUIDefineItemToggle(GlobalDefine defineItem, COMPILER eType) // Cuando hay un item en el toggle { GUIStyle togStyle = EditorStyles.miniButtonMid; if (eType == COMPILER.END) { togStyle = EditorStyles.miniButtonRight; } string name = "Unity"; if (eType == COMPILER.CSHARP) { name = "C#"; } else if (eType == COMPILER.CSHARP_EDITOR) { name = "C# editor"; } bool isEnabled = defineItem.IsEnabled(eType); GUI.backgroundColor = isEnabled ? Color.cyan : Color.white; bool newValue = GUILayout.Toggle(isEnabled, name, togStyle, GUILayout.Width(BUTTON_WIDTH)); if (newValue == isEnabled) { return; } defineItem.SetEnable(eType, newValue); SetSelectedDefine(defineItem); }
/// <summary> /// <para>Carga los RSP</para> /// </summary> /// <param name="compilerType"></param> private void CargarRspFile(COMPILER compilerType) // Carga los RSP { string path = RspFilePath(compilerType); if (!File.Exists(path)) { return; } string rspOption = File.ReadAllText(path); MatchCollection defineMatchs = Regex.Matches(rspOption, PATRON); foreach (Match match in defineMatchs) { Group group = match.Groups[NOMBRE_GRUPO]; foreach (Capture cap in group.Captures) { GlobalDefine define = GetData(cap.Value); if (define != null) { define.SetEnable(compilerType, true); } } } }
//------------------------------------------------------------ // CController.Compile // /// <summary> /// <para>Call RunCompiler method, then call Cleanup method.</para> /// </summary> /// <param name="pProgress"></param> /// <returns></returns> //------------------------------------------------------------ virtual internal bool Compile(CCompileProgress pProgress) { COMPILER compiler = null; // dummy bool br = RunCompiler(pProgress, ref compiler, null); Cleanup(); return(br); }
/// <summary> /// <para>Habilita el tipo de copilacion.</para> /// </summary> /// <param name="tipoCopilador"></param> /// <param name="isEnable"></param> public void SetEnable(COMPILER tipoCopilador, bool isEnable) // Habilita el tipo de copilacion { uint compilerIndex = (uint)tipoCopilador; if (compilerIndex < isEnableSettings.Length) { isEnableSettings[compilerIndex] = isEnable; } }
/// <summary> /// <para>Obtener los archivos</para> /// </summary> /// <param name="compilerType"></param> /// <returns></returns> private static string RspFilePath(COMPILER compilerType) // Obtener los archivos { uint compilerIndex = (uint)compilerType; if (compilerIndex < RSP_FILE_PATHs.Length) { return(RSP_FILE_PATHs[compilerIndex]); } return(""); }
//------------------------------------------------------------ // OutFileIteratorBase.Reset // /// <summary> /// OUTFILESYMs are elements of the child list /// of compiler.MainSymbolManager.FileRootSym. /// Search the first valid OUTFILESYM in the list /// and set it currentOutFileSym. /// </summary> /// <param name="compiler"></param> //------------------------------------------------------------ virtual internal OUTFILESYM Reset(COMPILER compiler) { currentOutFileSym = compiler.GetFirstOutFile(); if (currentOutFileSym == null) { return(null); } AdvanceToValid(); return(Current); }
/// <summary> /// <para>Esta activo el tipo de copilacion</para> /// </summary> /// <param name="tipoCopilador"></param> /// <returns></returns> public bool IsEnabled(COMPILER tipoCopilador) // Esta activo el tipo de copilacion { uint compilerIndex = (uint)tipoCopilador; if (compilerIndex < isEnableSettings.Length) { return(isEnableSettings[compilerIndex]); } return(false); }
//------------------------------------------------------------ // CController.RunCompiler // /// <summary> /// <list type="number"> /// <item><description>Create a COMPILER instance.</description></item> /// <item><description>Register input/out files to the COMPILER instance.</description></item> /// <item><description>call COMPILER.Complie method.</description></item> /// </list> /// </summary> /// <param name="bindCallback"></param> /// <param name="compiler"></param> /// <param name="progress"></param> /// <returns>if succeeded, return true.returns> /// <remarks> /// ICSCompiler Helpers /// </remarks> //------------------------------------------------------------ internal bool RunCompiler( CCompileProgress progress, ref COMPILER compiler, ICompileCallback bindCallback) { // Reset the error count here in case there's a problem // with one of the input-sets or imports this.countOfReportedErrors = 0; this.countOfWarnsReportedAsErrors = 0; //bool needsCleanUp = false; bool br = true; // Instantiate a compiler on the stack // Initialize it compiler = new COMPILER(this, NameManager); // For each imported assemblies and added modules, create INFILESYMs // and add then to compiler.MainSymbolManager.MetadataFileRootSym br = compiler.Init(); if (br) { // For each input set, add the appropriate data to the compiler // For outputfile, create an OUTFILESYM and add it to GlobalSymbolManager.FileRootSym. // For source files and resource files, create INFILESYM and add then to the OUTFILESYM. foreach (CInputSet inpset in this.inputSetList) { br = compiler.AddInputSet(inpset); if (!br) { break; } } } // Tell it to compile if (br && countOfReportedErrors == 0) { compiler.CompileCallback.Init(bindCallback); br = compiler.Compile(progress); } return(br); }
//------------------------------------------------------------ // ReflectionUtil.GetConstructedFieldInfo // /// <summary></summary> /// <param name="compiler"></param> /// <param name="fieldSym"></param> /// <param name="aggTypeSym"></param> /// <returns></returns> //------------------------------------------------------------ internal static FieldInfo GetConstructedFieldInfo( COMPILER compiler, MEMBVARSYM fieldSym, AGGTYPESYM aggTypeSym) { DebugUtil.Assert(compiler != null && compiler.Emitter != null); EMITTER emitter = compiler.Emitter; DebugUtil.Assert(emitter != null && fieldSym != null && aggTypeSym != null); SymUtil.EmitParentSym(emitter, aggTypeSym); SymUtil.GetSystemTypeFromSym(aggTypeSym, null, null); emitter.EmitMembVarDef(fieldSym); Type parentType = aggTypeSym.Type; FieldInfo fieldDefInfo = fieldSym.FieldInfo; Exception ex = null; if (!parentType.IsGenericType) { return(fieldDefInfo); } FieldInfo cstrFieldInfo = null; try { cstrFieldInfo = parentType.GetField(fieldDefInfo.Name); } catch (NotSupportedException) { cstrFieldInfo = ReflectionUtil.GetFieldInfo( parentType, fieldDefInfo, out ex); } return(cstrFieldInfo); }
/// <summary> /// <para>Guarda los archivos RSP</para> /// </summary> /// <param name="compilerType"></param> private void GuardarRspFile(COMPILER compilerType) // Guarda los archivos RSP { string path = RspFilePath(compilerType); string rspOption = ""; if (File.Exists(path)) { rspOption = File.ReadAllText(path); MatchCollection defineMatchs = Regex.Matches(rspOption, PATRON); foreach (Match match in defineMatchs) { rspOption = rspOption.Replace(match.Value, ""); } } string appendDefine = ""; foreach (GlobalDefine define in dicDefines.Values) { if (define == null || define.IsEnabled(compilerType) == false) { continue; } appendDefine += define.Nombre + DEFINE_DELIMITER; } if (string.IsNullOrEmpty(appendDefine) == false) { rspOption += RSP_DEFINE_OPTION + appendDefine; } using (StreamWriter writer = new StreamWriter(path)) { writer.Write(rspOption); } }
//------------------------------------------------------------ // CController.BuildForEnc // /// <summary></summary> /// <param name="pProgress"></param> /// <returns></returns> //------------------------------------------------------------ virtual internal bool BuildForEnc(CCompileProgress pProgress) { // Reset the error count here in case there's a problem // with one of the input-sets or imports this.countOfReportedErrors = 0; COMPILER comp = new COMPILER(this, NameManager); bool br = true; if (comp.Init()) { for (int i = 0; i < inputSetList.Count; ++i) { br = comp.AddInputSet(inputSetList[i]); if (!br) { break; } } } Cleanup(); return(br); }
private Parallel() { _compiler = COMPILER.Singleton; Buffer = new BUFFERS(); }
//------------------------------------------------------------ // ReflectionUtil.GetConstructedMethodInfo // /// <summary></summary> /// <param name="compiler"></param> /// <param name="methodSym"></param> /// <param name="aggTypeSym"></param> /// <param name="methTypeArguments"></param> /// <returns></returns> //------------------------------------------------------------ internal static MethodInfo GetConstructedMethodInfo( COMPILER compiler, METHSYM methodSym, AGGTYPESYM aggTypeSym, TypeArray methTypeArguments) { DebugUtil.Assert(compiler != null && compiler.Emitter != null); EMITTER emitter = compiler.Emitter; DebugUtil.Assert(emitter != null && methodSym != null && aggTypeSym != null); SymUtil.EmitParentSym(emitter, aggTypeSym); SymUtil.GetSystemTypeFromSym(aggTypeSym, null, null); emitter.EmitMethodDef(methodSym); Type parentType = aggTypeSym.Type; MethodInfo methodDefInfo = methodSym.MethodInfo; bool isGenericType = parentType.IsGenericType; bool isGenericMethod = methodDefInfo.IsGenericMethod; //-------------------------------------------------------- // (1-1) Non-generic Type, non-generic method //-------------------------------------------------------- if (!isGenericType && !isGenericMethod) { return(methodDefInfo); } //-------------------------------------------------------- // Parameter types //-------------------------------------------------------- TypeArray paramTypeArray = methodSym.ParameterTypes; TypeArray paramTypeArray2 = null; Type[] paramTypes = null; if (paramTypeArray != null && paramTypeArray.Count > 0) { paramTypeArray2 = compiler.MainSymbolManager.SubstTypeArray( paramTypeArray, aggTypeSym.AllTypeArguments, methTypeArguments, SubstTypeFlagsEnum.NormNone); paramTypes = SymUtil.GetSystemTypesFromTypeArray( paramTypeArray2, methodSym.ClassSym, methodSym); } else { paramTypes = Type.EmptyTypes; } //-------------------------------------------------------- // (1-2) Non-generic Type, generic method //-------------------------------------------------------- if (!isGenericType) { DebugUtil.Assert(methTypeArguments != null); Exception ex = null; Type[] typeArgs = SymUtil.GetSystemTypesFromTypeArray( methTypeArguments, methodSym.ClassSym, methodSym); return(ReflectionUtil.GetGenericMethod( methodDefInfo, typeArgs, out ex)); } //-------------------------------------------------------- // (2) Generic Type //-------------------------------------------------------- else { string methodName = methodDefInfo.Name; MethodInfo cstrMethInfo = null; Exception ex = null; try { cstrMethInfo = parentType.GetMethod(methodName, paramTypes); } catch (NotSupportedException) { cstrMethInfo = GetMethodInfo(parentType, methodDefInfo, out ex); } if (!isGenericMethod) { return(cstrMethInfo); } DebugUtil.Assert(methTypeArguments != null); Type[] typeArgs = SymUtil.GetSystemTypesFromTypeArray( methTypeArguments, methodSym.ClassSym, methodSym); return(ReflectionUtil.GetGenericMethod( cstrMethInfo, typeArgs, out ex)); } }
//------------------------------------------------------------ // ReflectionUtil.GetConstructedConstructorInfo // /// <summary></summary> /// <param name="compiler"></param> /// <param name="methodSym"></param> /// <param name="aggTypeSym"></param> /// <returns></returns> //------------------------------------------------------------ internal static ConstructorInfo GetConstructedConstructorInfo( COMPILER compiler, METHSYM methodSym, AGGTYPESYM aggTypeSym) { DebugUtil.Assert(compiler != null && compiler.Emitter != null); EMITTER emitter = compiler.Emitter; DebugUtil.Assert(emitter != null && methodSym != null && aggTypeSym != null); SymUtil.EmitParentSym(emitter, aggTypeSym); SymUtil.GetSystemTypeFromSym(aggTypeSym, null, null); emitter.EmitMethodDef(methodSym); Type parentType = aggTypeSym.Type; ConstructorInfo cnstrDefInfo = methodSym.ConstructorInfo; DebugUtil.Assert(cnstrDefInfo != null); bool isGenericType = parentType.IsGenericType; //-------------------------------------------------------- // (1) Non-generic Type //-------------------------------------------------------- if (!isGenericType) { return(cnstrDefInfo); } //-------------------------------------------------------- // (2) Generic Type //-------------------------------------------------------- TypeArray paramTypeArray = methodSym.ParameterTypes; TypeArray paramTypeArray2 = null; Type[] paramTypes = null; if (paramTypeArray != null && paramTypeArray.Count > 0) { paramTypeArray2 = compiler.MainSymbolManager.SubstTypeArray( paramTypeArray, aggTypeSym.AllTypeArguments, null, SubstTypeFlagsEnum.NormNone); paramTypes = SymUtil.GetSystemTypesFromTypeArray( paramTypeArray2, methodSym.ClassSym, methodSym); } else { paramTypes = Type.EmptyTypes; } ConstructorInfo constructedInfo = null; Exception ex = null; try { constructedInfo = parentType.GetConstructor(paramTypes); } catch (NotSupportedException) { constructedInfo = GetConstructorInfo(parentType, cnstrDefInfo, out ex); } return(constructedInfo); }
internal NestedTypeResolver(COMPILER comp, AGGSYM sym) { this.compiler = comp; this.EnclosingAggSym = sym; }
//------------------------------------------------------------ // CombinedFileIterator.Reset //------------------------------------------------------------ internal INFILESYM Reset(COMPILER compiler) { outIteratorBase.Reset(compiler); inIteratorBase.Reset(outIteratorBase.Current); return(Current); }