Перенос.

This commit is contained in:
2023-09-17 22:13:42 +03:00
parent dd2e0ca7e0
commit 629d8b8477
1239 changed files with 61161 additions and 1 deletions

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GlobalData.Module.UI.ModuleAnchestorFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="730" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f6ea3" class="javax.swing.JComboBox" binding="cbCompilers">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
</properties>
</component>
<vspacer id="2c3c6">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="da1b3" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="компилятор"/>
</properties>
</component>
<component id="70919" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="флаги"/>
</properties>
</component>
<component id="54213" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="команда компиляции"/>
<toolTipText value="дополнительная команда компиляции помимо флагов"/>
</properties>
</component>
<component id="f1643" class="javax.swing.JComboBox" binding="cbCommands">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="false"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="flink"/>
<item value="clink"/>
<item value="f"/>
<item value="c"/>
</model>
<toolTipText value="Выберите из списка дополнительную команду компиляции ( актуально для DVM компиляторов)"/>
</properties>
</component>
<toolbar id="3961e">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="3ccf3" class="javax.swing.JComboBox" binding="cbFlags" custom-create="true">
<constraints/>
<properties>
<editable value="true"/>
<font name="Times New Roman" size="16" style="0"/>
<model>
<item value=""/>
<item value="-O2 -g -fprofile-arcs -ftest-coverage"/>
</model>
</properties>
</component>
<component id="76c58" class="javax.swing.JButton" binding="bHelp">
<constraints/>
<properties>
<icon value="icons/Help.png"/>
<text value=""/>
<toolTipText value="Отобразить справочную информацию компилятора"/>
</properties>
</component>
<component id="91678" class="javax.swing.JButton" binding="BPickOptions">
<constraints/>
<properties>
<icon value="icons/Menu/Regions.png"/>
<text value=""/>
<toolTipText value="Назначить опции компилятора"/>
</properties>
</component>
</children>
</toolbar>
</children>
</grid>
</form>

View File

@@ -0,0 +1,74 @@
package GlobalData.Module.UI;
import Common.Current;
import Common.UI.ComboBox.StyledTextComboBox;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DialogFields;
import GlobalData.Compiler.Compiler;
import GlobalData.Makefile.Makefile;
import GlobalData.Module.Module;
import GlobalData.Module.ModuleAnchestor;
import ProjectData.LanguageName;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
public class ModuleAnchestorFields implements DialogFields {
public JPanel content;
public JComboBox<Compiler> cbCompilers;
public JComboBox<String> cbCommands;
public JComboBox<String> cbFlags;
private JButton bHelp;
private JButton BPickOptions;
private Compiler compiler;
//считаем что машина есть.
public ModuleAnchestorFields() {
//-
LinkedHashMap<Integer, Compiler> compilers = Current.getMachine().getCompilers();
compilers.values().forEach(compiler -> cbCompilers.addItem(compiler));
bHelp.addActionListener(e -> {
if (cbCompilers.getSelectedItem() != null) {
Pass_2021.passes.get(PassCode_2021.ShowCompilerHelp).Do(compiler, true);
} else UI.Info("Компилятор не выбран");
});
BPickOptions.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021<String> pass = Pass_2021.passes.get(PassCode_2021.PickCompilerOptions);
if (pass.Do(compiler)) {
UI.TrySelect(cbFlags, pass.target);
}
}
});
cbCompilers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
compiler = (Compiler) cbCompilers.getSelectedItem();
}
});
}
public void setListeners(ModuleAnchestor target) {
boolean linker = (target instanceof Makefile);
LanguageName languageName = linker ?
(Current.HasProject() ? Current.getProject().languageName : LanguageName.n) :
((Module) target).language;
cbCompilers.addActionListener(e -> {
if (cbCompilers.getSelectedItem() instanceof Compiler) {
Compiler compiler = ((Compiler) cbCompilers.getSelectedItem());
UI.TrySelect(cbCommands,
linker ? compiler.getSpecialLinkCommand(languageName) : compiler.getSpecialCompilationCommand(languageName));
}
});
}
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
cbFlags = new StyledTextComboBox();
}
}

View File

@@ -0,0 +1,107 @@
package GlobalData.Module.UI;
import Common.Current;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import GlobalData.Compiler.Compiler;
import GlobalData.Compiler.CompilerType;
import GlobalData.Makefile.Makefile;
import GlobalData.Module.Module;
import GlobalData.Module.ModuleAnchestor;
import ProjectData.LanguageName;
public class ModuleAnchestorForm<T extends ModuleAnchestor> extends DBObjectDialog<T, ModuleAnchestorFields> {
public static String[] banned_flags = new String[]{
"-c", "-o",
"-ffree-form", "-ffixed-line-length-132", "-ffixed-form",
"-FI", "-f90",
"-fixed", "-free"
};
String command;
String flags;
public ModuleAnchestorForm() {
super(ModuleAnchestorFields.class);
}
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void validateFields() {
Compiler compiler = (Compiler) fields.cbCompilers.getSelectedItem();
command = (String) fields.cbCommands.getSelectedItem();
if (command == null) {
Log.Writeln("команда компиляции не выбрана");
} else {
if ((compiler != null) && compiler.type.equals(CompilerType.dvm)) {
//проверим команду.
if (Result instanceof Makefile) {
//могут быть только flink/clink
if (!command.equals("flink") && !command.equals("clink")) {
Log.Writeln("При линковке DVM системой допустимы\n" +
"только команды flink или clink");
}
} else if (Result instanceof Module) {
//могут быть только f/c
LanguageName languageName = ((Module) Result).language;
switch (languageName) {
case fortran:
case c:
if (!command.equals(languageName.getDVMCompile()))
Log.Writeln("компиляция " + languageName.getDescription() +
" программ DVM системой осуществляется только командой " +
languageName.getDVMCompile()
);
break;
default:
Log.Writeln("язык " + languageName + " не поддерживается DVM системой");
break;
}
}
} else {
if (!command.isEmpty())
Log.Writeln("Для всех компиляторов, кроме DVM системы, команда компиляции/линковки должна быть пуста.");
}
}
flags = (String) fields.cbFlags.getSelectedItem();
if (flags == null) Log.Writeln("флаги компиляции не выбраны");
else {
//проверка на служебные флаги
String[] data = flags.split(" ");
for (String flag : data) {
if (!flag.isEmpty()) {
/*
if (!flag.startsWith("-")) {
Log.Writeln("неверный формат флага " + Utils.Brackets(flag));
} else {
*/
for (String banned_flag : banned_flags) {
if (flag.equalsIgnoreCase(banned_flag)) {
Log.Writeln("флаги:\n" +
String.join(",", banned_flags) +
"\арезервированы системой.");
return;
}
// }
}
}
}
}
//проврка команды
}
@Override
public void fillFields() {
UI.TrySelect(fields.cbFlags, Result.flags);
UI.TrySelect(fields.cbCommands, Result.command);
UI.TrySelect(fields.cbCompilers, Result.getCompiler());
//--------------------------------------------
fields.setListeners(Result);
}
@Override
public void ProcessResult() {
Result.machine_id = Current.getMachine().id;
Compiler compiler = (Compiler) fields.cbCompilers.getSelectedItem();
Result.compiler_id = (compiler != null) ? compiler.id : Utils.Nan;
Result.command = command;
Result.flags = flags;
}
}