OpenASIP 2.2
Loading...
Searching...
No Matches
OperationPropertyDialog.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file OperationPropertyDialog.cc
26 *
27 * Declaration of OperationProperty class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @author Mikael Lepistö 2007 (mikael.lepisto-no.spam-cs.tut.fi)
31 * @author Tero Ryynänen 2008 (tero.ryynanen-no.spam-tut.fi)
32 * @note rating: red
33 */
34
35#include <wx/valgen.h>
36#include <boost/format.hpp>
37#include <fstream>
38#include <iostream>
39#include <string>
40
42#include "OperationDAGDialog.hh"
43#include "OperationContainer.hh"
44#include "WxConversion.hh"
45#include "WidgetTools.hh"
46#include "InputOperandDialog.hh"
48#include "OSEdConstants.hh"
49#include "Application.hh"
50#include "GUITextGenerator.hh"
51#include "OSEdTextGenerator.hh"
52#include "ErrorDialog.hh"
53#include "ConfirmDialog.hh"
54#include "CommandThread.hh"
55#include "DialogPosition.hh"
56#include "OSEd.hh"
57#include "StringTools.hh"
58#include "OperationIndex.hh"
59#include "Operation.hh"
60#include "Operand.hh"
61#include "OperationModule.hh"
62#include "ObjectState.hh"
63#include "WarningDialog.hh"
64#include "OperationDAG.hh"
65#include "TCEString.hh"
66#include "FileSystem.hh"
67#include "OperationBehavior.hh"
68#include "OSEdOptions.hh"
69
70using std::string;
71using std::vector;
72using std::ifstream;
73using boost::format;
74
75BEGIN_EVENT_TABLE(OperationPropertyDialog, wxDialog)
78
81
84
87
90
93
97
101
104
107
111
113
114/**
115 * Constructor.
116 *
117 * @param parent The parent window.
118 * @param op Operation to be created or modified.
119 * @param module Module in which operation belongs to.
120 * @param path Path in which module belongs to.
121 */
123 wxWindow* parent,
124 Operation* op,
125 OperationModule& module,
126 const std::string& path) :
127 wxDialog(
128 parent, -1, _T(""),
129 DialogPosition::getPosition(DialogPosition::DIALOG_PROPERTIES),
130 wxDefaultSize, wxRESIZE_BORDER),
131 operation_(op), name_(_T("")), module_(module), path_(path),
132 operationWasCreatedHere_(false) {
133
134 createContents(this, true, true);
135
136 affectedByList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_AFFECTED_BY));
137 affectsList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_AFFECTS));
138 inputOperandList_ =
139 dynamic_cast<wxListCtrl*>(FindWindow(ID_INPUT_OPERANDS));
140 outputOperandList_ =
141 dynamic_cast<wxListCtrl*>(FindWindow(ID_OUTPUT_OPERANDS));
142 affectedByChoice_ =
143 dynamic_cast<wxComboBox*>(FindWindow(ID_OPERATION_AFFECTED_BY));
144 affectsChoice_ =
145 dynamic_cast<wxComboBox*>(FindWindow(ID_OPERATION_AFFECTS));
146 readMemoryCB_ = dynamic_cast<wxCheckBox*>(FindWindow(ID_READS_MEMORY));
147 writeMemoryCB_ = dynamic_cast<wxCheckBox*>(FindWindow(ID_WRITES_MEMORY));
148 canTrapCB_ = dynamic_cast<wxCheckBox*>(FindWindow(ID_CAN_TRAP));
149 sideEffectsCB_ =
150 dynamic_cast<wxCheckBox*>(FindWindow(ID_HAS_SIDE_EFFECTS));
151 clockedCB_ =
152 dynamic_cast<wxCheckBox*>(FindWindow(ID_CLOCKED));
153
154 editDescription_ = dynamic_cast<wxTextCtrl*>(FindWindow(ID_EDIT_DESCRIPTION));
155
156 FindWindow(ID_NAME)->SetValidator(
157 wxTextValidator(wxFILTER_ASCII, &name_));
158
159 FindWindow(ID_READS_MEMORY)->SetValidator(
160 wxGenericValidator(&readMemory_));
161
162 FindWindow(ID_WRITES_MEMORY)->SetValidator(
163 wxGenericValidator(&writeMemory_));
164
165 FindWindow(ID_CAN_TRAP)->SetValidator(wxGenericValidator(&canTrap_));
166
167 FindWindow(ID_HAS_SIDE_EFFECTS)->SetValidator(
168 wxGenericValidator(&hasSideEffects_));
169
170 FindWindow(ID_CLOCKED)->SetValidator(
171 wxGenericValidator(&clocked_));
172
173 // set OK button as default choice
174 FindWindow(ID_OK_BUTTON)->SetFocus();
175
176 if (operation_ != NULL) {
177 for (int i = 1; i <= operation_->numberOfInputs(); i++) {
178 Operand* op = new Operand(operation_->operand(i));
179 inputOperands_.push_back(op);
180 }
181
182 for (int i = operation_->numberOfInputs() + 1;
183 i <= operation_->numberOfInputs() + operation_->numberOfOutputs(); i++) {
184
185 Operand* op = new Operand(operation_->operand(i));
186 outputOperands_.push_back(op);
187 }
188
189 for (int i = 0; i < operation_->affectsCount(); i++) {
190 affects_.push_back(operation_->affects(i));
191 }
192
193 for (int i = 0; i < operation_->affectedByCount(); i++) {
194 affectedBy_.push_back(operation_->affectedBy(i));
195 }
196 } else {
197 operation_ = new Operation("", NullOperationBehavior::instance());
198 operationWasCreatedHere_ = true;
199 }
200
201 orig_ = operation_->saveState(); // save original operation's state
202
203 setTexts();
204}
205
206/**
207 * Destructor.
208 */
210
211 for (unsigned int i = 0; i < inputOperands_.size(); i++) {
212 delete inputOperands_[i];
213 }
214
215 for (unsigned int i = 0; i < outputOperands_.size(); i++) {
216 delete outputOperands_[i];
217 }
218
219 int x, y;
220 GetPosition(&x, &y);
221 wxPoint point(x, y);
223
225 delete operation_;
226 operation_ = NULL;
227 }
228}
229
230/**
231 * Returns operation object of dialog.
232 *
233 * @return Operation object of dialog.
234 */
235Operation*
239
240/**
241 * Set texts to all widgets.
242 */
243void
245
248
249 // title
251 SetTitle(WxConversion::toWxString(fmt.str()));
252
255
256 // buttons
259
260 WidgetTools::setLabel(&guiText, FindWindow(wxID_CANCEL),
262
265
268
271
274
277
280
283
286
289
292
295
296
298
299 // column titles
301 affectedByList_->InsertColumn(
302 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
304
305 affectsList_->InsertColumn(
306 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
308
310
311 inputOperandList_->InsertColumn(
312 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
313 110);
314
316
317 inputOperandList_->InsertColumn(
318 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
319 110);
320
322
323 inputOperandList_->InsertColumn(
324 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
325 110);
326
328
329 inputOperandList_->InsertColumn(
330 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
331 70);
332
334
335 outputOperandList_->InsertColumn(
336 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
337 110);
338
340
341 outputOperandList_->InsertColumn(
342 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
343 110);
344
346
347 outputOperandList_->InsertColumn(
348 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
349 110);
350
352
353 outputOperandList_->InsertColumn(
354 0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
355 70);
356
357 // check boxes
360
363
366
369
372
373 // box sizers
376
379
382
385
386
387}
388
389/**
390 * Sets the has behavior label.
391 */
392void
403
404/**
405 * Transfers data to window.
406 *
407 * @return True if transfer is successful.
408 */
409bool
411 if (operation_ != NULL) {
413 editDescription_->Clear();
425 } else {
426 readMemory_ = false;
427 writeMemory_ = false;
428 canTrap_ = false;
429 hasSideEffects_ = false;
430 clocked_ = false;
431 controlFlow_ = false;
432 isCall_ = false;
433 isBranch_ = false;
434 }
435
436 return wxWindow::TransferDataToWindow();
437}
438
439/**
440 * Updates the operand lists.
441 */
442void
444
445 inputOperandList_->DeleteAllItems();
446 outputOperandList_->DeleteAllItems();
447
448 for (unsigned int i = 0; i < inputOperands_.size(); i++) {
449 wxString id = WxConversion::toWxString(i + 1);
450 inputOperandList_->InsertItem(i, id);
451 std::string type = inputOperands_.at(i)->typeString();
452 inputOperandList_->SetItem(i, 1, WxConversion::toWxString(type));
453 std::string elemWidth = Conversion::toString(
454 inputOperands_.at(i)->elementWidth());
455 inputOperandList_->SetItem(i, 2, WxConversion::toWxString(elemWidth));
456 std::string elemCount = Conversion::toString(
457 inputOperands_.at(i)->elementCount());
458 inputOperandList_->SetItem(i, 3, WxConversion::toWxString(elemCount));
459 }
460 int k = 0;
461 for (unsigned int i = inputOperands_.size() + 1;
462 i <= inputOperands_.size() + outputOperands_.size(); i++) {
463
464 wxString id = WxConversion::toWxString(i);
465 outputOperandList_->InsertItem(k, id);
466 std::string type = outputOperands_.at(k)->typeString();
467 outputOperandList_->SetItem(k, 1, WxConversion::toWxString(type));
468 std::string elemWidth = Conversion::toString(
469 outputOperands_.at(k)->elementWidth());
470 outputOperandList_->SetItem(k, 2, WxConversion::toWxString(elemWidth));
471 std::string elemCount = Conversion::toString(
472 outputOperands_.at(k)->elementCount());
473 outputOperandList_->SetItem(k, 3, WxConversion::toWxString(elemCount));
474 k++;
475 }
476
477 wxListEvent dummy;
479}
480
481/**
482 * Updates the affects and affected by lists.
483 */
484void
486
487 affectedByList_->DeleteAllItems();
488 affectsList_->DeleteAllItems();
489
490 for (unsigned int i = 0; i < affectedBy_.size(); i++) {
491 wxString oper = WxConversion::toWxString(affectedBy_[i]);
492 affectedByList_->InsertItem(i, oper);
493 }
494
495 for (unsigned int i = 0; i < affects_.size(); i++) {
496 wxString oper = WxConversion::toWxString(affects_[i]);
497 affectsList_->InsertItem(i, oper);
498 }
499
501 affectsChoice_->Clear();
502 affectedByChoice_->Clear();
503 for (int i = 0; i < index.pathCount(); i++) {
504 string path = index.path(i);
505 int modules = index.moduleCount(path);
506 for (int j = 0; j < modules; j++) {
507 OperationModule& module = index.module(j, path);
508 int operations = 0;
509 try {
510 operations = index.operationCount(module);
511 } catch (const Exception& e) {
512 continue;
513 }
514 for (int k = 0; k < operations; k++) {
515 string name = index.operationName(k, module);
516 if (affectsList_->
517 FindItem(-1, WxConversion::toWxString(name)) == -1) {
518
520 }
521 if (affectedByList_->
522 FindItem(-1, WxConversion::toWxString(name)) == -1) {
523
525 }
526 }
527
528 }
529 }
530 affectsChoice_->SetSelection(0);
531 affectedByChoice_->SetSelection(0);
532
533 if (affectsChoice_->GetCount() == 0) {
535 } else {
537 }
538
539 if (affectedByChoice_->GetCount() == 0) {
541 } else {
543 }
544
545 wxListEvent dummy;
547}
548
549
550/**
551 * Handles the event when an item is selected from a list.
552 *
553 * Item selection affects statuses of several buttons.
554 */
555void
557
558 if (affectedByList_->GetSelectedItemCount() < 1) {
560 } else {
562 }
563
564 if (affectsList_->GetSelectedItemCount() < 1) {
566 } else {
568 }
569
570 if (inputOperandList_->GetSelectedItemCount() < 1) {
572 } else {
574 }
575
576 if (outputOperandList_->GetSelectedItemCount() < 1) {
578 } else {
580 }
581
582 if (inputOperandList_->GetSelectedItemCount() != 1) {
584 FindWindow(ID_INPUT_UP_BUTTON)->Disable();
586 } else {
588
590 int id = Conversion::toInt(idString);
591
592 if (id != 1) {
594 } else {
595 FindWindow(ID_INPUT_UP_BUTTON)->Disable();
596 }
597
598 if (id != static_cast<int>(inputOperands_.size())) {
600 } else {
602 }
603 }
604
605 if (outputOperandList_->GetSelectedItemCount() != 1) {
609 } else {
611
613 int id = Conversion::toInt(idString);
614
615 if (id != static_cast<int>(inputOperands_.size()) + 1) {
617 } else {
619 }
620
621 if (id != static_cast<int>(inputOperands_.size()) +
622 static_cast<int>(outputOperands_.size())) {
624 } else {
626 }
627 }
628}
629
630/**
631 * Handles adding new item to affected by list.
632 */
633void
635
636 wxString name = affectedByChoice_->GetValue();
638
640 format fmt = texts.text(
642 fmt % name;
643 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
644 dialog.ShowModal();
645 } else {
646 affectedBy_.push_back(WxConversion::toString(name));
648 }
649}
650
651/**
652 * Handles deleting an item from affected by list.
653 */
654void
656
657 vector<string> toBeDeleted = getSelectedItems(affectedByList_);
658
659 for (size_t i = 0; i < toBeDeleted.size(); i++) {
660 vector<string>::iterator it = affectedBy_.begin();
661 while (it != affectedBy_.end()) {
662 if (*it == toBeDeleted[i]) {
663 affectedBy_.erase(it);
664 break;
665 }
666 it++;
667 }
668 }
670}
671
672/**
673 * Handles event of adding new item to affects list.
674 */
675void
677
678 wxString name = affectsChoice_->GetValue();
680
682 format fmt = texts.text(
684 fmt % name;
685 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
686 dialog.ShowModal();
687 } else {
688 affects_.push_back(WxConversion::toString(name));
690 }
691}
692
693/**
694 * Handles event of deleting item from affects list.
695 */
696void
698
699 vector<string> toBeDeleted = getSelectedItems(affectsList_);
700
701 for (size_t i = 0; i < toBeDeleted.size(); i++) {
702 vector<string>::iterator it = affects_.begin();
703 while (it != affects_.end()) {
704 if (*it == toBeDeleted[i]) {
705 affects_.erase(it);
706 break;
707 }
708 it++;
709 }
710 }
712}
713
714/**
715 * Handles event for adding new operand to input operand list.
716 */
717void
719 Operand* input =
720 new Operand(true, inputOperands_.size() + 1, Operand::SINT_WORD);
721
722 InputOperandDialog dialog(
723 this, input, inputOperands_.size(), inputOperands_.size() + 1);
724
725 if (dialog.ShowModal() == wxID_OK) {
726 inputOperands_.push_back(input);
728 } else {
729 delete input;
730 }
732}
733
734/**
735 * Handles the event for modifying input operand.
736 */
737void
740 int id = Conversion::toInt(idString);
741 Operand* operand = NULL;
742 operand = inputOperands_[id - 1];
743 assert(operand != NULL);
744 InputOperandDialog dialog(this, operand, inputOperands_.size(), id);
745 dialog.ShowModal();
747}
748
749/**
750 * Handles the event of deleting input operand.
751 */
752void
754
755 vector<string> toBeDeleted = getSelectedItems(inputOperandList_);
756 size_t i = 0;
757 vector<Operand*>::iterator it = inputOperands_.begin();
758 int index = 1;
759
760 updateSwapLists(toBeDeleted);
761 while (it != inputOperands_.end() && i < toBeDeleted.size()) {
762 int id = Conversion::toInt(toBeDeleted[i]);
763 while (index < id) {
764 it++;
765 index++;
766 }
767 delete *it;
768 it = inputOperands_.erase(it);
769 index++;
770 i++;
771 }
773}
774
775/**
776 * Handles the event of adding new output operand.
777 */
778void
780 unsigned int id = inputOperands_.size() + outputOperands_.size() + 1;
781 Operand* output = new Operand(false, id, Operand::SINT_WORD);
782 OutputOperandDialog dialog(this, output, id);
783 if (dialog.ShowModal() == wxID_OK) {
784 outputOperands_.push_back(output);
786 } else {
787 delete output;
788 }
790}
791
792/**
793 * Handles the event for mofifying output operand.
794 */
795void
798 int realId = Conversion::toInt(idString);
799 int id = realId - static_cast<int>(inputOperands_.size());
800 Operand* operand = NULL;
801 operand = outputOperands_[id - 1];
802 assert(operand != NULL);
803 OutputOperandDialog dialog(this, operand, realId);
804 dialog.ShowModal();
806}
807
808/**
809 * Handles the event of deleting output operand.
810 */
811void
813
814 vector<string> toBeDeleted = getSelectedItems(outputOperandList_);
815 size_t i = 0;
816 vector<Operand*>::iterator it = outputOperands_.begin();
817 int index = inputOperands_.size() + 1;
818
819 while (it != outputOperands_.end() && i < toBeDeleted.size()) {
820 int id = Conversion::toInt(toBeDeleted[i]);
821 while (index < id) {
822 it++;
823 index++;
824 }
825 delete *it;
826 it = outputOperands_.erase(it);
827 index++;
828 i++;
829 }
831}
832
833/**
834 * Handles the event when input operand is moved up.
835 */
836void
842
843/**
844 * Handles the event when input operand is moved down.
845 */
846void
852
853/**
854 * Handles the event when output operand is moved up.
855 */
856void
859 int id = Conversion::toInt(idString) -
860 static_cast<int>(inputOperands_.size());
862}
863
864/**
865 * Handles the event when output operand is moved down.
866 */
867void
870 int id = Conversion::toInt(idString) -
871 static_cast<int>(inputOperands_.size());
873}
874
875/**
876 * Handles the event when Open button is pushed.
877 */
878void
880
882 OSEdOptions* options = wxGetApp().options();
883 string editor = options->editor();
884 if (editor == "") {
886 ErrorDialog error(this, WxConversion::toWxString(fmt.str()));
887 error.ShowModal();
888 } else {
889 if (FileSystem::fileExists(editor)) {
891 string code = module_.behaviorSourceModule();
892 string cmd = editor + " " + code;
893
894 launchEditor(cmd);
895 } else {
896 // new behavior is added for the module
897 string code = module_.propertiesModule();
898 size_t pos = code.find_last_of(".");
899 code.erase(pos);
900 code += ".cc";
901
902 // copy template file as new file
903 string dir =
907
908 string templateFile = dir + FileSystem::DIRECTORY_SEPARATOR +
910
911 FileSystem::copy(templateFile, code);
912
913 string cmd = editor + " " + code;
914 launchEditor(cmd);
915 }
916 } else {
917 format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_OPEN);
918 fmt % editor;
919 ErrorDialog error(this, WxConversion::toWxString(fmt.str()));
920 error.ShowModal();
921 }
922 }
923
925}
926
927/**
928 * Handles the event when Open DAG button is pushed.
929 */
930void
932
934 updateOperation(true);
935 }
936 // TODO: here set the number of operands of new operation.
937 OperationDAGDialog dialog(this, operation_);
938 dialog.ShowModal();
939}
940
941/**
942 * Moves operand up.
943 *
944 * @param list List from which operand is selected.
945 * @param id Id of the operand.
946 * @param ops Operands.
947 */
948void
950 std::vector<Operand*>& ops,
951 int id,
952 wxListCtrl* list) {
953
954 if (id != 1) {
955 Operand* temp = ops[id - 2];
956 ops[id - 2] = ops[id - 1];
957 ops[id - 1] = temp;
958 long item = -1;
959 item = list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
960 list->SetItemState(
961 item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
962 list->SetItemState(item, 0, wxLIST_STATE_SELECTED);
963 }
964}
965
966/**
967 * Moves operand down.
968 *
969 * @param list List from which operand is selected.
970 * @param ops Operands.
971 * @param id Id of the operand.
972 */
973void
975 std::vector<Operand*>& ops,
976 int id,
977 wxListCtrl* list) {
978
979 if (static_cast<unsigned int>(id) != ops.size()) {
980 Operand* temp = ops[id - 1];
981 ops[id - 1] = ops[id];
982 ops[id] = temp;
983 long item = -1;
984 item = list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
985 list->SetItemState(
986 item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
987 list->SetItemState(item, 0, wxLIST_STATE_SELECTED);
988 }
989}
990
991/**
992 * Returns all the selected items of the list control.
993 *
994 * @param listCtrl List control which is investigated.
995 * @return All selected items as a vector.
996 */
997vector<string>
999 vector<string> selected;
1000 long item = -1;
1001 for (;;) {
1002 item = listCtrl->GetNextItem(
1003 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1004 if (item == -1) {
1005 break;
1006 }
1007 wxListItem info;
1008 info.SetId(item);
1009 info.SetColumn(0);
1010 listCtrl->GetItem(info);
1011 selected.push_back(WxConversion::toString(info.GetText()));
1012 }
1013 return selected;
1014}
1015
1016/**
1017 * Handles the event when OK button is pushed.
1018 */
1019void
1021 updateOperation(false);
1022}
1023
1024void
1026 TransferDataFromWindow();
1027 string opName =
1029
1030 if (newOpDag && opName == "") {
1031 opName = "__UnnamedNewOperation";
1032 }
1033
1035
1036 if (opName == "" && operation_->name() == "") {
1037 format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_NO_NAME);
1038 fmt % "operation";
1039 WarningDialog dialog(this, WxConversion::toWxString(fmt.str()));
1040 dialog.ShowModal();
1041 } else {
1042
1043 // let's check there isn't already an operation by the same name.
1044 // Do the check only if we are renaming this op.
1045 if (operation_ != NULL && operation_->name() != opName) {
1046
1047 Operation* op =
1049
1050 // there was old operation with same name
1051 if (op != NULL) {
1052 format fmt =
1055 WarningDialog dialog(this, WxConversion::toWxString(fmt.str()));
1056 dialog.ShowModal();
1057 return;
1058 }
1059 }
1060
1061 ObjectState* mod = saveOperation(); // load modified operation's settings from gui
1062 ObjectState* orig = orig_;
1063
1064 if (newOpDag) {
1065 operation_->loadState(mod);
1066 } else {
1067 if (*orig != *mod) {
1068 format fmt = texts.text(
1070 ConfirmDialog dialog(this, WxConversion::toWxString(fmt.str()));
1071 int ans = dialog.ShowModal();
1072 if (ans == wxID_YES) {
1073 try {
1074 operation_->loadState(mod);
1075 } catch (ObjectStateLoadingException& e) {
1076 std::cerr << "Exception caught: " << e.errorMessage()
1077 << std::endl;
1078 assert(false);
1079 }
1080 }
1081
1082 delete mod;
1083
1084 if (ans == wxID_YES) {
1085 delete orig;
1086 EndModal(wxID_OK);
1087 } else if (ans == wxID_NO) {
1088 EndModal(wxID_CANCEL);
1089 }
1090 } else {
1091 delete orig;
1092 delete mod;
1093 EndModal(wxID_OK);
1094 }
1095 }
1096 }
1097}
1098
1099/**
1100 * Returns the operation properties as ObjectState tree.
1101 *
1102 * @return Operation properties as ObjectState tree.
1103 */
1106
1109
1110 std::string description("");
1111 wxString wxTemp;
1112
1113 for (int i = 0; i < editDescription_->GetNumberOfLines(); ++i)
1114 {
1115 wxTemp = editDescription_->GetLineText(i);
1116#if wxCHECK_VERSION(2, 6, 0)
1117 std::string stdTemp(wxTemp.mb_str());
1118#else
1119 std::string stdTemp(wxTemp.c_str());
1120#endif
1121 if (!StringTools::endsWith(stdTemp, "\n"))
1122 stdTemp = stdTemp + "\n";
1123 description += stdTemp;
1124 }
1125
1126 description = StringTools::trim(description);
1127
1128 root->setAttribute(Operation::OPRN_DESCRIPTION, description);
1129
1130 int inputs = inputOperands_.size();
1131 int outputs = outputOperands_.size();
1132
1133 root->setAttribute(Operation::OPRN_INPUTS, inputs);
1134 root->setAttribute(Operation::OPRN_OUTPUTS, outputs);
1135
1144
1145 if (affectedBy_.size() > 0) {
1147 for (unsigned int i = 0; i < affectedBy_.size(); i++) {
1148 ObjectState* affectedByChild =
1150 affectedByChild->setAttribute(Operation::OPRN_NAME, affectedBy_[i]);
1151 affectedBy->addChild(affectedByChild);
1152 }
1153 root->addChild(affectedBy);
1154 }
1155
1156 if (affects_.size() > 0) {
1158 for (unsigned int i = 0; i < affects_.size(); i++) {
1159 ObjectState* affectsChild =
1161 affectsChild->setAttribute(Operation::OPRN_NAME, affects_[i]);
1162 affects->addChild(affectsChild);
1163 }
1164 root->addChild(affects);
1165 }
1166
1167 for (unsigned int i = 0; i < inputOperands_.size(); i++) {
1168 ObjectState* operand = inputOperands_[i]->saveState();
1169 operand->setName(Operation::OPRN_IN);
1170 int index = i + 1;
1171 operand->setAttribute(Operand::OPRND_ID, index);
1172 std::string type = inputOperands_.at(i)->typeString();
1173 operand->setAttribute(Operand::OPRND_TYPE, type);
1174 root->addChild(operand);
1175 }
1176
1177 for (unsigned int i = 0; i < outputOperands_.size(); i++) {
1178 ObjectState* operand = outputOperands_[i]->saveState();
1179 operand->setName(Operation::OPRN_OUT);
1180 int index = inputOperands_.size() + i + 1;
1181 operand->setAttribute(Operand::OPRND_ID, index);
1182 std::string type = outputOperands_.at(i)->typeString();
1183 operand->setAttribute(Operand::OPRND_TYPE, type);
1184 root->addChild(operand);
1185 }
1186
1187 // copy dags from operation to objectState tree
1188 for (int i = 0; i < operation_->dagCount(); i++) {
1190 trigger->setValue(operation_->dagCode(i));
1191 root->addChild(trigger);
1192 }
1193
1194 return root;
1195}
1196
1197/**
1198 * Launches editor for editing operation behavior.
1199 *
1200 * @param cmd Command for launching the editor.
1201 */
1202void
1204 CommandThread* thread = new CommandThread(cmd);
1205 thread->Create();
1206 thread->Run();
1207}
1208
1209/**
1210 * Deletes deleted operands from swap lists.
1211 *
1212 * @param deletedOperands Deleted operands.
1213 */
1214void
1215OperationPropertyDialog::updateSwapLists(vector<string> deletedOperands) {
1216
1217 for (size_t i = 0; i < inputOperands_.size(); i++) {
1218 Operand* operand = inputOperands_[i];
1219 ObjectState* state = operand->saveState();
1220 for (int j = 0; j < state->childCount(); j++) {
1221 if (state->child(j)->name() == Operand::OPRND_CAN_SWAP) {
1222 ObjectState* canSwap = state->child(j);
1223
1224 int k = 0;
1225 while (k < canSwap->childCount()) {
1226 ObjectState* child = canSwap->child(k);
1227 int id = child->intAttribute(Operand::OPRND_ID);
1228 string idString = Conversion::toString(id);
1229
1230 bool deleted = false;
1231 for (size_t r = 0; r < deletedOperands.size(); r++) {
1232 if (deletedOperands[r] == idString) {
1233 delete child;
1234 child = NULL;
1235 k--;
1236 deleted = true;
1237 break;
1238 }
1239 }
1240
1241 if (!deleted) {
1242 int dec = 0;
1243 for (size_t r = 0; r < deletedOperands.size(); r++) {
1244 int delId = Conversion::toInt(deletedOperands[r]);
1245 if (delId < id) {
1246 dec++;
1247 }
1248 }
1249 id = id - dec;
1250 child->setAttribute(Operand::OPRND_ID, id);
1251 }
1252 k++;
1253 }
1254 }
1255 }
1256 operand->loadState(state);
1257 }
1258}
1259
1260/**
1261 * Creates the contents of the dialog.
1262 *
1263 * NOTE! This function was generated by wxDesigner, that's why it is so ugly.
1264 *
1265 * @param parent Parent window.
1266 * @param call_fit If true, fits the contents inside the dialog.
1267 * @param set_sizer If true, sets the main sizer as dialog contents.
1268 * @return The created sizer.
1269 */
1270wxSizer*
1272 wxWindow* parent,
1273 bool call_fit,
1274 bool set_sizer) {
1275
1276 wxBoxSizer *item0 = new wxBoxSizer(wxVERTICAL);
1277
1278 wxGridSizer *item1 = new wxGridSizer(2, 0, 0);
1279
1280 wxBoxSizer *opHeaderSizer = new wxBoxSizer(wxHORIZONTAL);
1281
1282 wxBoxSizer *nameSizer = new wxBoxSizer(wxHORIZONTAL);
1283
1284 wxStaticText *item2 = new wxStaticText(parent, ID_TEXT_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0);
1285 nameSizer->Add(item2, 0, wxALL, 5);
1286
1287 wxTextCtrl *item3 = new wxTextCtrl(parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(200,-1), 0);
1288 nameSizer->Add(item3, 0, wxALL, 5);
1289
1290 wxStaticBox *opProperties = new wxStaticBox(parent, -1, wxT("Operation properties"));
1291 wxStaticBoxSizer *opPropertiesContainer = new wxStaticBoxSizer(opProperties, wxVERTICAL);
1292
1293 opPropertiesContainer->Add(nameSizer, 0, wxGROW, 5);
1294 opPropertiesContainer->Add(item1, 0, wxGROW, 5);
1295
1296 wxStaticBox *opDescription = new wxStaticBox(parent, -1, wxT("Operation description"));
1297 wxTextCtrl* editDescription = new wxTextCtrl(parent, ID_EDIT_DESCRIPTION, wxT(""), wxDefaultPosition, wxSize(250,50), wxTE_MULTILINE);
1298 wxStaticBoxSizer *opDescriptionContainer = new wxStaticBoxSizer(opDescription, wxHORIZONTAL);
1299
1300 opDescriptionContainer->Add(editDescription, 0, wxALL|wxEXPAND, 5);
1301
1302 opHeaderSizer->Add(opPropertiesContainer, 0, wxALL, 5);
1303 opHeaderSizer->Add(opDescriptionContainer, 0, wxALL|wxGROW, 5);
1304
1305 wxCheckBox *item4 = new wxCheckBox(parent, ID_READS_MEMORY, wxT("Reads memory"), wxDefaultPosition, wxDefaultSize, 0);
1306 item1->Add(item4, 0, wxALL, 5);
1307
1308 wxCheckBox *item5 = new wxCheckBox(parent, ID_WRITES_MEMORY, wxT("Writes memory"), wxDefaultPosition, wxDefaultSize, 0);
1309 item1->Add(item5, 0, wxALL, 5);
1310
1311 wxCheckBox *item6 = new wxCheckBox(parent, ID_CAN_TRAP, wxT("Can trap"), wxDefaultPosition, wxDefaultSize, 0);
1312 item1->Add(item6, 0, wxALL, 5);
1313
1314 wxCheckBox *item7 = new wxCheckBox(parent, ID_HAS_SIDE_EFFECTS, wxT("Has side effects"), wxDefaultPosition, wxDefaultSize, 0);
1315 item1->Add(item7, 0, wxALL, 5);
1316
1317 wxCheckBox *clocked = new wxCheckBox(parent, ID_CLOCKED, wxT("Clocked"), wxDefaultPosition, wxDefaultSize, 0);
1318 item1->Add(clocked, 0, wxALL, 5);
1319
1320 item0->Add(opHeaderSizer, 0, wxALIGN_CENTER|wxALL, 5);
1321
1322 wxGridSizer *item8 = new wxGridSizer(2, 0, 0);
1323
1324 wxStaticBox *item10 = new wxStaticBox(parent, -1, wxT("Affected by"));
1325 wxStaticBoxSizer *item9 = new wxStaticBoxSizer(item10, wxVERTICAL);
1326 affectedBySizer_ = item9;
1327
1328 wxListCtrl *item11 = new wxListCtrl(parent, ID_AFFECTED_BY, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER);
1329 item9->Add(item11, 0, wxGROW|wxALL, 10);
1330
1331 wxBoxSizer *item12 = new wxBoxSizer(wxHORIZONTAL);
1332
1333 wxString strs13[] =
1334 {
1335 wxT("ComboItem")
1336 };
1337 wxComboBox *item13 = new wxComboBox(parent, ID_OPERATION_AFFECTED_BY, wxT(""), wxDefaultPosition, wxSize(100,-1), 1, strs13, wxCB_SORT);
1338 item12->Add(item13, 0, wxALIGN_CENTER|wxALL, 5);
1339
1340 wxButton *item14 = new wxButton(parent, ID_AFFECTED_ADD_BUTTON, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0);
1341 item12->Add(item14, 0, wxALIGN_CENTER|wxALL, 5);
1342
1343 wxButton *item15 = new wxButton(parent, ID_AFFECTED_DELETE_BUTTON, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0);
1344 item12->Add(item15, 0, wxALIGN_CENTER|wxALL, 5);
1345
1346 item9->Add(item12, 0, wxGROW|wxALL, 5);
1347
1348 item8->Add(item9, 0, wxGROW|wxALL, 5);
1349
1350 // Operation inputs
1351 wxStaticBox *item17 = new wxStaticBox(parent, -1, wxT("Input operands"));
1352 wxStaticBoxSizer *item16 = new wxStaticBoxSizer(item17, wxVERTICAL);
1353 inputSizer_ = item16;
1354
1355 wxBoxSizer *item18 = new wxBoxSizer(wxHORIZONTAL);
1356
1357 wxListCtrl *item19 = new wxListCtrl(parent, ID_INPUT_OPERANDS, wxDefaultPosition, wxSize(335,120), wxLC_REPORT|wxSUNKEN_BORDER);
1358 item18->Add(item19, 0, wxALIGN_CENTER|wxALL, 5);
1359
1360 // BoxSizer for up and down buttons
1361 wxBoxSizer *item20 = new wxBoxSizer(wxVERTICAL);
1362
1363 // Move up and down buttons
1364 wxBitmapButton *item21 = new wxBitmapButton(parent, ID_INPUT_UP_BUTTON, createBitmaps(0), wxDefaultPosition, wxDefaultSize);
1365 item20->Add(item21, 0, wxALL, 5);
1366
1367 wxBitmapButton *item22 = new wxBitmapButton(parent, ID_INPUT_DOWN_BUTTON, createBitmaps(1), wxDefaultPosition, wxDefaultSize);
1368 item20->Add(item22, 0, wxALIGN_CENTER|wxALL, 5);
1369
1370 item18->Add(item20, 0, wxALIGN_CENTER|wxALL, 5);
1371
1372 item16->Add(item18, 0, wxGROW|wxALL, 5);
1373
1374 wxBoxSizer *item23 = new wxBoxSizer(wxHORIZONTAL);
1375
1376 wxButton *item24 = new wxButton(parent, ID_INPUT_ADD_BUTTON, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0);
1377 item23->Add(item24, 0, wxALIGN_CENTER|wxALL, 5);
1378
1379 wxButton *item25 = new wxButton(parent, ID_INPUT_MODIFY_BUTTON, wxT("Modify..."), wxDefaultPosition, wxDefaultSize, 0);
1380 item23->Add(item25, 0, wxALIGN_CENTER|wxALL, 5);
1381
1382 wxButton *item26 = new wxButton(parent, ID_INPUT_DELETE_BUTTON, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0);
1383 item23->Add(item26, 0, wxALIGN_CENTER|wxALL, 5);
1384
1385 item16->Add(item23, 0, wxALIGN_CENTER|wxALL, 5);
1386
1387 item8->Add(item16, 0, wxGROW|wxALL, 5);
1388
1389 wxStaticBox *item28 = new wxStaticBox(parent, -1, wxT("Affects"));
1390 wxStaticBoxSizer *item27 = new wxStaticBoxSizer(item28, wxVERTICAL);
1391 affectsSizer_ = item27;
1392
1393 wxListCtrl *item29 = new wxListCtrl(parent, ID_AFFECTS, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER);
1394 item27->Add(item29, 0, wxGROW|wxALL, 10);
1395
1396 wxBoxSizer *item30 = new wxBoxSizer(wxHORIZONTAL);
1397
1398 wxString strs31[] =
1399 {
1400 wxT("ComboItem")
1401 };
1402 wxComboBox *item31 = new wxComboBox(parent, ID_OPERATION_AFFECTS, wxT(""), wxDefaultPosition, wxSize(100,-1), 1, strs31, wxCB_SORT);
1403 item30->Add(item31, 0, wxALIGN_CENTER|wxALL, 5);
1404
1405 wxButton *item32 = new wxButton(parent, ID_AFFECTS_ADD_BUTTON, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0);
1406 item30->Add(item32, 0, wxALIGN_CENTER|wxALL, 5);
1407
1408 wxButton *item33 = new wxButton(parent, ID_AFFECTS_DELETE_BUTTON, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0);
1409 item30->Add(item33, 0, wxALIGN_CENTER|wxALL, 5);
1410
1411 item27->Add(item30, 0, wxGROW|wxALL, 5);
1412
1413 item8->Add(item27, 0, wxGROW|wxALL, 5);
1414
1415 wxStaticBox *item35 = new wxStaticBox(parent, -1, wxT("Output operands"));
1416 wxStaticBoxSizer *item34 = new wxStaticBoxSizer(item35, wxVERTICAL);
1417 outputSizer_ = item34;
1418
1419 wxBoxSizer *item36 = new wxBoxSizer(wxHORIZONTAL);
1420
1421 wxListCtrl *item37 = new wxListCtrl(parent, ID_OUTPUT_OPERANDS, wxDefaultPosition, wxSize(335,120), wxLC_REPORT|wxSUNKEN_BORDER);
1422 item36->Add(item37, 0, wxALIGN_CENTER|wxALL, 5);
1423
1424 wxBoxSizer *item38 = new wxBoxSizer(wxVERTICAL);
1425
1426 wxBitmapButton *item39 = new wxBitmapButton(parent, ID_OUTPUT_UP_BUTTON, createBitmaps(0), wxDefaultPosition, wxDefaultSize);
1427 item38->Add(item39, 0, wxALIGN_CENTER|wxALL, 5);
1428
1429 wxBitmapButton *item40 = new wxBitmapButton(parent, ID_OUTPUT_DOWN_BUTTON, createBitmaps(1), wxDefaultPosition, wxDefaultSize);
1430 item38->Add(item40, 0, wxALIGN_CENTER|wxALL, 5);
1431
1432 item36->Add(item38, 0, wxALIGN_CENTER|wxALL, 5);
1433
1434 item34->Add(item36, 0, wxGROW|wxALL, 5);
1435
1436 wxBoxSizer *item41 = new wxBoxSizer(wxHORIZONTAL);
1437
1438 wxButton *item42 = new wxButton(parent, ID_OUTPUT_ADD_BUTTON, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0);
1439 item41->Add(item42, 0, wxALIGN_CENTER|wxALL, 5);
1440
1441 wxButton *item43 = new wxButton(parent, ID_OUTPUT_MODIFY_BUTTON, wxT("Modify..."), wxDefaultPosition, wxDefaultSize, 0);
1442 item41->Add(item43, 0, wxALIGN_CENTER|wxALL, 5);
1443
1444 wxButton *item44 = new wxButton(parent, ID_OUTPUT_DELETE_BUTTON, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0);
1445 item41->Add(item44, 0, wxALIGN_CENTER|wxALL, 5);
1446
1447 item34->Add(item41, 0, wxALIGN_CENTER|wxALL, 5);
1448
1449 item8->Add(item34, 0, wxALIGN_CENTER|wxALL, 5);
1450
1451 wxBoxSizer *pageSizer = new wxBoxSizer(wxHORIZONTAL);
1452 pageSizer->Add(item8, 0, wxALL, 5);
1453
1454 item0->Add(pageSizer, 0, wxALIGN_CENTER|wxALL, 5);
1455
1456 wxGridSizer *item45 = new wxGridSizer(2, 0, 0);
1457
1458 wxBoxSizer *item46 = new wxBoxSizer(wxHORIZONTAL);
1459
1460 wxStaticText *item47 = NULL;
1461 if (module_.hasBehaviorSource()) {
1462 item47 = new wxStaticText(parent, ID_TEXT_OPEN, _T("Operation behavior module defined."), wxDefaultPosition, wxDefaultSize, 0);
1463 } else {
1464 item47 = new wxStaticText(parent, ID_TEXT_OPEN, wxT("Operation behavior module not defined."), wxDefaultPosition, wxDefaultSize, 0);
1465 }
1466 item46->Add(item47, 0, wxALIGN_CENTER|wxALL, 5);
1467
1468 wxButton *item48 = new wxButton(parent, ID_OPEN_BUTTON, wxT("Open"), wxDefaultPosition, wxDefaultSize, 0);
1469 item46->Add(item48, 0, wxALIGN_CENTER|wxALL, 5);
1470
1471 wxButton *OpenDAG = new wxButton(parent, ID_DAG_BUTTON, wxT("Open DAG"), wxDefaultPosition, wxDefaultSize, 0);
1472 item46->Add(OpenDAG, 0, wxALIGN_CENTER|wxALL, 5);
1473
1474 item45->Add(item46, 0, wxALL, 5);
1475
1476 wxBoxSizer *item49 = new wxBoxSizer(wxHORIZONTAL);
1477
1478 wxButton *item50 = new wxButton(parent, ID_OK_BUTTON, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0);
1479 item49->Add(item50, 0, wxALIGN_CENTER|wxALL, 5);
1480
1481 wxButton *item51 = new wxButton(parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
1482 item49->Add(item51, 0, wxALIGN_CENTER|wxALL, 5);
1483
1484 item45->Add(item49, 0, wxALL, 5);
1485
1486 item0->Add(item45, 0, wxGROW|wxALL, 5);
1487
1488 if (set_sizer)
1489 {
1490 parent->SetSizer(item0);
1491 if (call_fit)
1492 item0->SetSizeHints(parent);
1493 }
1494
1495 return item0;
1496}
1497
1498/**
1499 * Creates the bitmaps.
1500 *
1501 * NOTE! This function was created by wxDesigner.
1502 *
1503 * @param index Index of the bitmap.
1504 * @return The bitmap.
1505 */
1506wxBitmap
1508 if (index == 0)
1509 {
1510 /* XPM */
1511 static const char *xpm_data[] = {
1512 /* columns rows colors chars-per-pixel */
1513 "16 30 2 1",
1514 " c None",
1515 "a c Black",
1516 /* pixels */
1517 " ",
1518 " ",
1519 " ",
1520 " aa ",
1521 " aaaa ",
1522 " aaaaaa ",
1523 " aa aa aa ",
1524 " aa aa aa ",
1525 " aa aa aa ",
1526 " aa aa aa ",
1527 " a aa a ",
1528 " aa ",
1529 " aa ",
1530 " aa ",
1531 " aa ",
1532 " aa ",
1533 " aa ",
1534 " aa ",
1535 " aa ",
1536 " aa ",
1537 " aa ",
1538 " aa ",
1539 " aa ",
1540 " aa ",
1541 " aa ",
1542 " aa ",
1543 " aa ",
1544 " aa ",
1545 " aa ",
1546 " "
1547 };
1548 wxBitmap bitmap(xpm_data);
1549 return bitmap;
1550 }
1551 if (index == 1)
1552 {
1553 /* XPM */
1554 static const char *xpm_data[] = {
1555 /* columns rows colors chars-per-pixel */
1556 "16 30 2 1",
1557 " c None",
1558 "a c Black",
1559 /* pixels */
1560 " ",
1561 " aa ",
1562 " aa ",
1563 " aa ",
1564 " aa ",
1565 " aa ",
1566 " aa ",
1567 " aa ",
1568 " aa ",
1569 " aa ",
1570 " aa ",
1571 " aa ",
1572 " aa ",
1573 " aa ",
1574 " aa ",
1575 " aa ",
1576 " aa ",
1577 " aa ",
1578 " aa ",
1579 " aa ",
1580 " a aa a ",
1581 " aa aa aa ",
1582 " aa aa aa ",
1583 " aa aa aa ",
1584 " aaaaaa ",
1585 " aaaa ",
1586 " aa ",
1587 " ",
1588 " ",
1589 " "
1590 };
1591 wxBitmap bitmap(xpm_data);
1592 return bitmap;
1593 }
1594 return wxNullBitmap;
1595}
#define assert(condition)
END_EVENT_TABLE() using namespace IDF
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection EVT_LIST_ITEM_DESELECTED(ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_ARCH_PORT_LIST
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation EVT_LIST_ITEM_SELECTED(ID_EXTERNAL_PORT_LIST, FUImplementationDialog::onExternalPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_EXTERNAL_PORT_LIST
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
find Finds info of the inner loops in the false
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
static std::string toString(const T &source)
static int toInt(const T &source)
static void setPosition(Dialogs dialog, wxPoint point)
@ DIALOG_PROPERTIES
Operation properties dialog.
static std::string dataDirPath(const std::string &prog)
std::string errorMessage() const
Definition Exception.cc:123
static const std::string DIRECTORY_SEPARATOR
static void copy(const std::string &source, const std::string &target)
static bool fileExists(const std::string fileName)
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
@ TXT_BUTTON_ADD
Label for an add button.
static GUITextGenerator * instance()
static NullOperationBehavior & instance()
static const int DEFAULT_COLUMN_WIDTH
Default column width.
static const wxString APPLICATION_NAME
The name of the application.
static const std::string BEHAVIOR_TEMPLATE_FILE_NAME
Name of the behavior template file name.
static OSEdTextGenerator & instance()
@ TXT_PROPERTY_DIALOG_TITLE
Property dialog title.
@ TXT_BUTTON_MODIFY
Modify button label.
@ TXT_COLUMN_ELEMENT_WIDTH
Operand element width header.
@ TXT_CHECKBOX_WRITES_MEMORY
Writes memory label.
@ TXT_CHECKBOX_CLOCKED
Clocked label.
@ TXT_BOX_OUTPUT_OPERANDS
Output operand sizer label.
@ TXT_CHECKBOX_CAN_TRAP
Can trap label.
@ TXT_COLUMN_ELEMENT_COUNT
Operand element count header.
@ TXT_LABEL_OPERATION_NAME
Operation name label.
@ TXT_COLUMN_OPERAND
Operand column header.
@ TXT_ERROR_OPERATION_EXISTS
Operation exists error.
@ TXT_COLUMN_OPERATION
Operation column header.
@ TXT_LABEL_HAS_BEHAVIOR
Has behavior label.
@ TXT_LABEL_NO_BEHAVIOR
No behavior label.
@ TXT_ERROR_OPEN
Error when opening fails.
@ TXT_ERROR_NO_NAME
Error when no name is given.
@ TXT_BOX_AFFECTS
Affects sizer label.
@ TXT_COLUMN_TYPE
Type column header.
@ TXT_ERROR_NO_EDITOR
Error when no editor is given.
@ TXT_ERROR_NON_EXISTING_OPERATION
Error when operation does not exist.
@ TXT_BOX_INPUT_OPERANDS
Input operand sizer label.
@ TXT_CHECKBOX_READS_MEMORY
Reads memory label.
@ TXT_BOX_AFFECTED_BY
Affected by sizer label.
@ TXT_QUESTION_SAVE_PROPERTIES
Save properties question.
@ TXT_CHECKBOX_HAS_SIDE_EFFECTS
Has side effects label.
@ TXT_BUTTON_OPEN
Open button label.
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
void setValue(const std::string &value)
ObjectState * child(int index) const
void addChild(ObjectState *child)
int intAttribute(const std::string &name) const
std::string name() const
int childCount() const
static const std::string OPRND_CAN_SWAP
Object state name for can swap.
Definition Operand.hh:92
static const std::string OPRND_TYPE
Object state name for operand type.
Definition Operand.hh:84
@ SINT_WORD
Definition Operand.hh:59
virtual ObjectState * saveState() const
Definition Operand.cc:490
static const std::string OPRND_ID
Object state name for operand id.
Definition Operand.hh:82
virtual void loadState(const ObjectState *state)
Definition Operand.cc:383
static bool operationExists(const std::string &name)
static Operation * operation(const std::string &path, const std::string &module, const std::string &oper)
static OperationIndex & operationIndex()
std::string operationName(int i, const OperationModule &om)
std::string path(int i) const
int operationCount(const OperationModule &om)
int pathCount() const
int moduleCount() const
virtual bool hasBehaviorSource() const
virtual std::string name() const
virtual std::string behaviorSourceModule() const
virtual std::string propertiesModule() const
void onOk(wxCommandEvent &event)
bool controlFlow_
Can operation can change program flow.
OperationModule & module_
Module in which operation belongs to.
void onDeleteAffectedBy(wxCommandEvent &event)
void updateSwapLists(std::vector< std::string > deletedOperands)
wxListCtrl * outputOperandList_
List of output operands.
bool isCall_
Operation performs function call.
bool hasSideEffects_
Does operation has side effects?
void onModifyInputOperand(wxCommandEvent &event)
void onDeleteInputOperand(wxCommandEvent &event)
void onOpen(wxCommandEvent &event)
bool writeMemory_
Does operation write memory?
wxString name_
Name of the operation.
void onMoveInputDown(wxCommandEvent &event)
Operation * operation_
Operation to be created or to be modified.
void onSelection(wxListEvent &event)
bool readMemory_
Does operation read memory?
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
void onDeleteAffects(wxCommandEvent &event)
wxBitmap createBitmaps(size_t index)
std::vector< Operand * > outputOperands_
Output operands.
void onDeleteOutputOperand(wxCommandEvent &event)
wxStaticBoxSizer * affectsSizer_
Affects sizer.
std::vector< std::string > getSelectedItems(wxListCtrl *listCtrl)
std::string path_
Path in which module belongs to.
void onMoveInputUp(wxCommandEvent &event)
void onAddInputOperand(wxCommandEvent &event)
void onModifyOutputOperand(wxCommandEvent &event)
bool canTrap_
Can operation trap?
void onAddAffectedBy(wxCommandEvent &event)
bool isBranch_
Operation is branch.
void onAddAffects(wxCommandEvent &event)
void moveDown(std::vector< Operand * > &ops, int id, wxListCtrl *list)
ObjectState * orig_
Original operation's ObjectState tree.
wxListCtrl * inputOperandList_
List of input operands.
wxStaticBoxSizer * affectedBySizer_
Affected by sizer.
void onAddOutputOperand(wxCommandEvent &event)
wxListCtrl * affectedByList_
List of affected by operations.
wxStaticBoxSizer * outputSizer_
Output operand sizer.
bool clocked_
Is operation clocked?
void onOpenDAG(wxCommandEvent &event)
void onMoveOutputUp(wxCommandEvent &event)
void onMoveOutputDown(wxCommandEvent &event)
std::vector< Operand * > inputOperands_
Input operands.
void launchEditor(const std::string &cmd)
std::vector< std::string > affects_
Operations that affects this operation.
wxComboBox * affectsChoice_
Choice box for new affects operations.
wxStaticBoxSizer * inputSizer_
Input operand sizer.
void moveUp(std::vector< Operand * > &ops, int id, wxListCtrl *list)
std::vector< std::string > affectedBy_
Operations that are affected by this operation.
wxListCtrl * affectsList_
List of affects operations.
wxComboBox * affectedByChoice_
Choice box for new affected by operations.
static const char * OPRN_CONTROL_FLOW
Object state name for control flow property.
Definition Operation.hh:81
virtual bool readsMemory() const
Definition Operation.cc:242
static const char * OPRN_ISBRANCH
Object state name for branch property.
Definition Operation.hh:99
virtual TCEString name() const
Definition Operation.cc:93
static const char * OPRN_DESCRIPTION
Object state name for description.
Definition Operation.hh:69
virtual TCEString dagCode(int index) const
Definition Operation.cc:159
virtual TCEString description() const
Definition Operation.cc:103
virtual bool isCall() const
Definition Operation.cc:318
static const char * OPRN_IN
Object state name for input operand.
Definition Operation.hh:91
virtual bool isControlFlowOperation() const
Definition Operation.cc:294
static const char * OPRN_CLOCKED
Object state name for clockedness.
Definition Operation.hh:79
virtual bool canTrap() const
Definition Operation.cc:262
static const char * OPRN_TRAP
Object state name for trap.
Definition Operation.hh:75
virtual bool hasSideEffects() const
Definition Operation.cc:272
virtual bool isBranch() const
Definition Operation.cc:306
static const char * OPRN_AFFECTED_BY
Object state name for affected by.
Definition Operation.hh:89
virtual bool isClocked() const
Definition Operation.cc:282
virtual bool writesMemory() const
Definition Operation.cc:252
static const char * OPRN_OPERATION
Object state name for operation.
Definition Operation.hh:65
static const char * OPRN_TRIGGER
Object state name for trigger semantics.
Definition Operation.hh:95
static const char * OPRN_ISCALL
Object state name for call property.
Definition Operation.hh:97
static const char * OPRN_SIDE_EFFECTS
Object state name for side effects.
Definition Operation.hh:77
static const char * OPRN_READS_MEMORY
Object state name for reads memory.
Definition Operation.hh:83
static const char * OPRN_OUT
Object state name for output operand.
Definition Operation.hh:93
virtual int dagCount() const
Definition Operation.cc:134
static const char * OPRN_OUTPUTS
Object state name for outputs.
Definition Operation.hh:73
static const char * OPRN_NAME
Object state name for name.
Definition Operation.hh:67
static const char * OPRN_INPUTS
Object state name for inputs.
Definition Operation.hh:71
static const char * OPRN_AFFECTS
Object state name for affects.
Definition Operation.hh:87
static const char * OPRN_WRITES_MEMORY
Object state name for writes memory.
Definition Operation.hh:85
virtual void loadState(const ObjectState *state)
Definition Operation.cc:480
static std::string stringToUpper(const std::string &source)
static bool endsWith(const std::string &source, const std::string &searchString)
static std::string trim(const std::string &source)
virtual boost::format text(int textId)
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
static std::string lcStringSelection(wxListCtrl *list, int column)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)