void OutMode::CmdOptions() { const Workspace& wspc = ide.IdeWorkspace(); int pi = wspc.GetCount() > 0 ? 0 : -1; if (pi < 0) { PromptOK("No main package"); return; } VectorMap<String, String> bm = ide.GetMethodVars(~method); if (bm.GetCount() == 0) { PromptOK("Invalid build method"); return; } One<Host> host = ide.CreateHost(false); One<Builder> b = ide.CreateBuilder(~host); const String& p = wspc[pi]; String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true)); if (output.Right(1) == ".") output = output.Left(output.GetCount() - 1); const ModePane& pane = ~mode == 0 ? debug : release; int blitzpackage = pane.package.Get(0, 2); bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz && (IsNull(blitzpackage) ? true : blitzpackage); CmdBuildOptionsWindow window(p, ~method, ~config, output, ~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild); LoadFromGlobal(window, "CmdBuildOptionsWindow"); window.GenerateCmd(); window.Run(); StoreToGlobal(window, "CmdBuildOptionsWindow"); }
void Ide::NavigatorDlg() { NavDlg dlg; LoadFromGlobal(dlg, "NavDlg"); dlg.theide = this; dlg.Search(); if(dlg.ExecuteOK()) dlg.GoTo(); StoreToGlobal(dlg, "NavDlg"); }
String SelectPackage(const char *title, const char *startwith, bool selectvars, bool main) { SelectPackageDlg dlg(title, selectvars, main); const char *c = main ? "SelectPkgMain" : "SelectPkg"; LoadFromGlobal(dlg, c); dlg.SyncBrief(); String b = dlg.Run(startwith); StoreToGlobal(dlg, c); return b; }
void SvnSyncDirs(const Vector<String>& working) { if(!CheckSvn()) return; Ptr<Ctrl> f = Ctrl::GetFocusCtrl(); SvnSync svn; String msgs; LoadFromGlobal(msgs, "svn-msgs"); svn.SetMsgs(msgs); for(int i = 0; i < working.GetCount(); i++) svn.Dir(working[i]); svn.DoSync(); msgs = svn.GetMsgs(); StoreToGlobal(msgs, "svn-msgs"); if(f) f->SetFocus(); }
Operand* ConstantFolder::HandleLoad(Operand* sourceOp) { // Handle cases when we know the result is undefined. // load undef -> undef // load nullptr -> undef if(sourceOp->IsUndefinedConstant()) { return sourceOp; } else if(sourceOp->IsNullConstant()) { return GetUndefined(sourceOp); } // Handle first the simple cases when we load directly from a global variable. auto loadType = sourceOp->GetType()->As<PointerType>()->PointeeType(); if(auto variableRef = sourceOp->IsVariableReference()) { return LoadFromGlobal(sourceOp, loadType, 0 /* start offset */); } // Try to load from an 'addr', 'index' or 'elem' instruction that index into // a global variable (for example, 'a[i]', 'a.b', 'a.c[i].d', '*(p + 2)', etc.). return LoadFromAddress(sourceOp, loadType, 0 /* start offset */); }
void SelectPackageDlg::OnNew() { TemplateDlg dlg; LoadFromGlobal(dlg, "NewPackage"); int f = ~filter; dlg.Load(GetUppDirs(), f & MAIN); while(dlg.Run() == IDOK) { String nest = ~dlg.nest; String name = NativePath(String(~dlg.package)); String path = AppendFileName(nest, AppendFileName(name, GetFileName(name) + ".upp")); if(FileExists(path) && !PromptYesNo("Package [* \1" + path + "\1] already exists.&" "Do you wish to recreate the files?")) continue; RealizePath(path); if(!SaveFile(path, Null)) { Exclamation("Error writing the file [* \1" + path + "\1]."); continue; } dlg.Create(); selected = name; Break(IDYES); break; } StoreToGlobal(dlg, "NewPackage"); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Operand* ConstantFolder::LoadFromAddress(Operand* op, const Type* loadType, __int64 offset) { // If the operand has a defining instruction then we try to compute // the offset from which we should load. If it's a variable reference // we try to load from the offset that was already computed. if(op->HasDefiningInstruction() == false) { return LoadFromGlobal(op, loadType, offset); } auto instr = op->DefiningInstruction(); switch(instr->GetOpcode()) { case Instr_Index: { // If the index operand is not a constant give up. auto indexInstr = instr->As<IndexInstr>(); auto indexConst = indexInstr->IndexOp()->As<IntConstant>(); if(indexConst == nullptr) { return nullptr; } // The type of the base is 'pointer-to-array', so we need to strip the pointer. auto elementType = indexInstr->GetElementType(); __int64 index = indexConst->Value(); __int64 elemSize = TypeInfo::GetSize(elementType, target_); // The offset is incremented by the index multiplied with the element size. __int64 newOffset = offset + (index * elemSize); return LoadFromAddress(indexInstr->BaseOp(), loadType, newOffset); } case Instr_Element: { auto elemInstr = instr->As<ElementInstr>(); __int64 index = elemInstr->GetFieldIndex(); // The type of the base is 'pointer-to-record', // so we need to strip the pointer. auto recordType = elemInstr->GetRecordType(); // Obtain the offset of the selected field. // The new offset is the old one added with the field offset. __int64 fieldOffset = recordType->Fields()[index].FieldOffset; __int64 newOffset = offset + fieldOffset; return LoadFromAddress(elemInstr->BaseOp(), loadType, newOffset); } case Instr_Address: { // If the index operand is not a constant give up. auto addrInstr = instr->As<AddressInstr>(); auto indexConst = addrInstr->IndexOp()->As<IntConstant>(); if(indexConst == nullptr) { return nullptr; } // The type of the base is 'pointer-to-object', // so we need to strip the pointer. auto objectType = addrInstr->GetPointeeType(); __int64 index = indexConst->Value(); __int64 elemSize = TypeInfo::GetSize(objectType, target_); // The offset is incremented by the index multiplied with the object size. __int64 newOffset = offset + (index * elemSize); return LoadFromAddress(addrInstr->BaseOp(), loadType, newOffset); } case Instr_Ptop: { // This instruction is ignored (the previous recursion step // has already taken care about its effects). auto ptopInstr = instr->As<PtopInstr>(); auto targetInstr = ptopInstr->TargetOp()->DefiningInstruction(); return LoadFromAddress(ptopInstr->TargetOp(), loadType, offset); } case Instr_Load: { // This happens when the variable is a pointer. auto loadInstr = instr->As<LoadInstr>(); return LoadFromAddress(loadInstr->SourceOp(), loadType, offset); } default: { // All other cases don't lead to a constant operand. return nullptr; } } }