// true if error bool ProjectData::Execute() { wxString name; #ifndef __WXGTK__ wxFileName::SplitPath(GetSourceFile(0)->Path(), NULL, NULL, &name, NULL); #else name=GetSourceFile(0)->Path(); name=name.Left(name.Length()-4); #endif wxString file=::wxFindFirstFile(name+".z*"); if(file.IsEmpty()) { Compile(); file=::wxFindFirstFile(name+".z*"); if(file.IsEmpty()) { frame->logWindow->AppendText("No Inform data file found."); return true; } } wxString cmd="\""+frame->cmdExecute+"\" "+file; frame->logWindow->AppendText("Executing: "+cmd+"\n"); long status=wxExecute(cmd); if(status==0) { frame->logWindow->AppendText("Failed: Check Terp settings in Edit/Preferences\n"); return true; } return false; }
void CSourceDataGenerator::SaveCharmap(const CharMap &charmap, bool compress, enum OutputFormat format, const wxString &fileName) { wxFileName fileNameInfo(fileName, wxPATH_NATIVE); wxString hFilePath, cFilePath; if (fileNameInfo.GetExt() == "h") { hFilePath = fileName; fileNameInfo.SetExt("c"); if (fileNameInfo.Exists() && wxMessageBox(_("Also the file \"") + fileNameInfo.GetFullName() + _("\" will be generated. Do you want to overwrite it?"), _("Confirm"), wxYES_NO) == wxNO) { return; } cFilePath = fileNameInfo.GetFullPath(); } else if (fileNameInfo.GetExt() == "c") { cFilePath = fileName; fileNameInfo.SetExt("h"); if (fileNameInfo.Exists() && wxMessageBox(_("The file \"") + fileNameInfo.GetFullName() + _("\" will be generated. Do you want to overwrite it?"), _("Confirm"), wxYES_NO) == wxNO) { return; } hFilePath = fileNameInfo.GetFullPath(); } wxFFileOutputStream hFile(hFilePath); wxFFileOutputStream cFile(cFilePath); wxTextOutputStream hOut(hFile); wxTextOutputStream cOut(cFile); EMGL_font_t *font = LoadEMGLFont(charmap, compress, format); hOut << GetHeaderFile(fileNameInfo.GetName()); cOut << GetSourceFile(font, fileNameInfo.GetName()); DeleteEMGLFont(font); }
void ProjectData::UpdateObject(ObjectData *object) { GetSourceFile(object->file)->ParseObject(object); // To update the label frame->objectTree->UpdateNode(object->treeId, object); }
void ProjectData::RemoveObject(ObjectData *object) { GetSourceFile(object->file)->RemoveCode(object->b[INF_SOURCE], object->e[INF_SOURCE]); frame->objectTree->RemoveNode(object->treeId); objects.DeleteObject(object); delete object; }
// true if error bool ProjectData::Compile() { if(IsModified()) Save(); wxString cmd="\""+frame->cmdCompiler+"\" +\""+frame->cmdLibrary+"\" "+GetSourceFile(0)->Name(); wxString msg="Compiling: "+cmd+"\n\n"; frame->logWindow->AppendText(msg); wxArrayString output; long status=wxExecute(cmd, output); msg=""; unsigned int i; for(i=0; i<output.GetCount() && i<20; i++) { msg+=output[i]+"\n"; } frame->logWindow->AppendText(msg); if(output.GetCount()>i) { frame->logWindow->AppendText("[Compiler output truncated]\n"); } if(status!=0) { frame->logWindow->AppendText("\nCompilation failed\n"); if(status==-1) frame->logWindow->AppendText("Check Compiler and Library settings in Edit/Preferences\n"); return true; } frame->logWindow->AppendText("\nCompilation successful!\n"); return false; }
void ProjectData::UpdateSourceFile(int fileno) { //TODO: now we remove all objects, while we only should remove // the objects that belong to this file. We should also reinsert // objects at the same place when we reparse the file. // The current approach will break when more than one source // file is used. SourceFile *src=GetSourceFile(fileno); // Remove old objects objects.Clear(); src->Parse(); }
void PHPExpression::Suggest(PHPEntityBase::Ptr_t resolved, PHPLookupTable& lookup, PHPEntityBase::List_t& matches) { // sanity if(!resolved) return; PHPEntityBase::Ptr_t currentScope = GetSourceFile()->CurrentScope(); // GetCount() == 0 && !GetFilter().IsEmpty() i.e. a word completion is required. // We enhance the list with the following: // - PHP keywords // - Global functions // - Global constants // - Function arguments // - Local variables (of the current scope) // - And aliases e.g. 'use foo\bar as Bar;' if(GetCount() == 0 && !GetFilter().IsEmpty()) { // For functions and constants, PHP will fall back to global functions or constants if a // namespaced function or constant does not exist. PHPEntityBase::List_t globals = lookup.FindGlobalFunctionAndConsts(PHPLookupTable::kLookupFlags_Contains, GetFilter()); matches.insert(matches.end(), globals.begin(), globals.end()); if(currentScope && (currentScope->Is(kEntityTypeFunction) || currentScope->Is(kEntityTypeNamespace))) { // If the current scope is a function // add the local variables + function arguments to the current list of matches const PHPEntityBase::List_t& children = currentScope->GetChildren(); PHPEntityBase::List_t::const_iterator iter = children.begin(); for(; iter != children.end(); ++iter) { PHPEntityBase::Ptr_t child = *iter; if(child->Is(kEntityTypeVariable) && child->GetShortName().Contains(GetFilter()) && child->GetShortName() != GetFilter()) { matches.push_back(child); } } } { // Add aliases PHPEntityBase::List_t aliases = GetSourceFile()->GetAliases(); PHPEntityBase::List_t::iterator iter = aliases.begin(); for(; iter != aliases.end(); ++iter) { if((*iter)->GetShortName().Contains(GetFilter())) { matches.push_back(*iter); } } } { // Add $this incase we are inside a class (but only if '$this' contains the filter string) wxString lcFilter = GetFilter().Lower(); if(GetSourceFile()->Class() && wxString("$this").Contains(lcFilter)) { PHPEntityBase::Ptr_t thiz(new PHPEntityVariable()); thiz->SetFullName("$this"); thiz->SetShortName("$this"); thiz->SetFilename(currentScope->GetFilename()); matches.push_back(thiz); } } } // Add the scoped matches // for the code completion size_t flags = PHPLookupTable::kLookupFlags_Contains | GetLookupFlags(); if(resolved->Is(kEntityTypeClass)) { if(resolved->Cast<PHPEntityClass>()->IsInterface() || resolved->Cast<PHPEntityClass>()->IsAbstractClass()) { flags |= PHPLookupTable::kLookupFlags_IncludeAbstractMethods; } } PHPEntityBase::List_t scopeChildren = lookup.FindChildren(resolved->GetDbId(), flags, GetFilter()); matches.insert(matches.end(), scopeChildren.begin(), scopeChildren.end()); // Incase the resolved is a namespace, suggest all children namespaces if(resolved->Is(kEntityTypeNamespace)) { PHPEntityBase::List_t namespaces = lookup.FindNamespaces(resolved->GetFullName(), GetFilter()); matches.insert(matches.end(), namespaces.begin(), namespaces.end()); } // and make the list unique DoMakeUnique(matches); }
num_errors DoPass2( section_ptr sec, unsigned_8 *contents, orl_sec_size size, label_list sec_label_list, ref_list sec_ref_list ) // perform pass 2 on one section { struct pass2 data; label_entry l_entry; dis_dec_ins decoded; char name[ MAX_INS_NAME ]; char ops[ MAX_OBJ_NAME + 24 ]; // at most 1 label/relocation per instruction, plus room for registers, brackets and other crap dis_inst_flags flags; scantab_ptr st; int is_intel; sa_disasm_struct sds; char *FPU_fixup; int pos_tabs; bool is32bit; routineBase = 0; st = sec->scan; data.size = size; sds.data = contents; sds.last = size - 1; l_entry = NULL; if( sec_label_list != NULL ) { l_entry = sec_label_list->first; } if( sec_ref_list != NULL ) { data.r_entry = sec_ref_list->first; } else { data.r_entry = NULL; } data.disassembly_errors = 0; if( source_mix ) { GetSourceFile( sec ); } PrintHeader( sec ); if( size && sec_label_list ) PrintAssumeHeader( sec ); flags.u.all = DIF_NONE; if( GetMachineType() == ORL_MACHINE_TYPE_I386 ) { if( ( GetFormat() != ORL_OMF ) || ( ORLSecGetFlags( sec->shnd ) & ORL_SEC_FLAG_USE_32 ) ) { flags.u.x86 = DIF_X86_USE32_FLAGS; } is_intel = 1; } else { is_intel = IsIntelx86(); } is32bit = ( size >= 0x10000 ); for( data.loop = 0; data.loop < size; data.loop += decoded.size ) { // process data in code segment while( st && ( data.loop > st->end ) ) { st = st->next; } if( st && ( data.loop >= st->start ) ) { decoded.size = 0; processDataInCode( sec, contents, &data, st->end - data.loop, &l_entry ); st = st->next; continue; } // data may not be listed in scan table, but a fixup at this offset will // give it away while( data.r_entry && ( data.r_entry->offset < data.loop ) ) { data.r_entry = data.r_entry->next; } FPU_fixup = processFpuEmulatorFixup( &data.r_entry, data.loop ); if( data.r_entry && ( data.r_entry->offset == data.loop ) ) { if( is_intel || IsDataReloc( data.r_entry ) ) { // we just skip the data decoded.size = 0; processDataInCode( sec, contents, &data, RelocSize( data.r_entry ), &l_entry ); continue; } } if( source_mix ) { MixSource( data.loop ); } DisDecodeInit( &DHnd, &decoded ); decoded.flags.u.all |= flags.u.all; sds.offs = data.loop; DisDecode( &DHnd, &sds, &decoded ); if( sec_label_list ) { l_entry = handleLabels( sec->name, data.loop, data.loop + decoded.size, l_entry, size ); if( ( l_entry != NULL ) && ( l_entry->offset > data.loop ) && ( l_entry->offset < data.loop + decoded.size ) ) { /* If we have a label planted in the middle of this instruction (see inline memchr for example), put out a couple of data bytes, and then restart decode and label process from offset of actual label. */ decoded.size = 0; processDataInCode( sec, contents, &data, l_entry->offset - data.loop, &l_entry ); continue; } } DisFormat( &DHnd, &data, &decoded, DFormat, name, sizeof( name ), ops, sizeof( ops ) ); if( FPU_fixup != NULL ) { if( !(DFormat & DFF_ASM) ) { BufferAlignToTab( PREFIX_SIZE_TABS ); } BufferStore( "\t%sFPU fixup %s\n", CommentString, FPU_fixup ); } if( !(DFormat & DFF_ASM) ) { unsigned_64 *tmp_64; unsigned_32 *tmp_32; unsigned_16 *tmp_16; tmp_64 = (unsigned_64 *)(contents + data.loop); tmp_32 = (unsigned_32 *)(contents + data.loop); tmp_16 = (unsigned_16 *)(contents + data.loop); if( DHnd.need_bswap ) { switch( DisInsSizeInc( &DHnd ) ) { //case 8: SWAP_64( *tmp_64 ); // break; case 4: SWAP_32( *tmp_32 ); break; case 2: SWAP_16( *tmp_16 ); break; default: break; } } PrintLinePrefixAddress( data.loop, is32bit ); PrintLinePrefixData( contents, data.loop, size, DisInsSizeInc( &DHnd ), decoded.size ); BufferAlignToTab( PREFIX_SIZE_TABS ); } BufferStore( "\t%s", name ); if( *ops != '\0' ) { pos_tabs = ( DisInsNameMax( &DHnd ) + TAB_WIDTH ) / TAB_WIDTH + 1; if( !(DFormat & DFF_ASM) ) { pos_tabs += PREFIX_SIZE_TABS; } BufferAlignToTab( pos_tabs ); BufferConcat( ops ); } BufferConcatNL(); BufferPrint(); } if( sec_label_list ) { l_entry = handleLabels( sec->name, size, (orl_sec_offset)-1, l_entry, size ); } if( !(DFormat & DFF_ASM) ) { routineSize = data.loop - routineBase; BufferConcatNL(); BufferMsg( ROUTINE_SIZE ); BufferStore(" %d ", routineSize ); BufferMsg( BYTES ); BufferConcat(", "); BufferMsg( ROUTINE_BASE ); BufferStore(" %s + %04X\n\n", sec->name, routineBase ); BufferPrint(); } if( source_mix ) { EndSourceMix(); } PrintTail( sec ); return( data.disassembly_errors ); }
ObjectData *ProjectData::AddObject(const wxString& code) { ObjectData *obj=GetSourceFile(-1)->AppendObject(code); frame->objectTree->AddNode(obj); return obj; }