Initial commit.

This commit is contained in:
blitz-research
2014-01-31 08:23:00 +13:00
commit 08a613ed0e
322 changed files with 45306 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

+324
View File
@@ -0,0 +1,324 @@
# Microsoft Developer Studio Project File - Name="debugger" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=debugger - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "debugger.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "debugger.mak" CFG="debugger - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "debugger - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "debugger - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "debugger - Win32 Blitz3DRelease" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "debugger - Win32 Blitz2DRelease" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "debugger - Win32 Blitz3DEdu" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "debugger - Win32 Blitz3DDemo" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "debugger - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x1409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\blitzbasic\bin\debugger.dll"
# SUBTRACT LINK32 /pdb:none /force
!ELSEIF "$(CFG)" == "debugger - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /YX /FD /GZ /c
# SUBTRACT CPP /Gy
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x1409 /d "_DEBUG"
# ADD RSC /l 0x1409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /incremental:no /debug /machine:I386 /out:"..\blitzbasic\bin\debugger.dll" /fixed:no
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DRelease"
# PROP BASE Use_MFC 1
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "debugger___Win32_Blitz3DRelease"
# PROP BASE Intermediate_Dir "debugger___Win32_Blitz3DRelease"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "debugger___Win32_Blitz3DRelease"
# PROP Intermediate_Dir "debugger___Win32_Blitz3DRelease"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /YX /FD /c
# ADD CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "_WINDOWS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "PRO" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\blitzbasic\bin\debugger.dll"
# SUBTRACT BASE LINK32 /pdb:none /force
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3drelease\bin\debugger.dll"
# SUBTRACT LINK32 /pdb:none /force
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz2DRelease"
# PROP BASE Use_MFC 1
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "debugger___Win32_Blitz2DRelease"
# PROP BASE Intermediate_Dir "debugger___Win32_Blitz2DRelease"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "debugger___Win32_Blitz2DRelease"
# PROP Intermediate_Dir "debugger___Win32_Blitz2DRelease"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3drelease\bin\debugger.dll"
# SUBTRACT BASE LINK32 /pdb:none /force
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz2drelease\bin\debugger.dll"
# SUBTRACT LINK32 /pdb:none /force
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DEdu"
# PROP BASE Use_MFC 1
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "debugger___Win32_Blitz3DEdu"
# PROP BASE Intermediate_Dir "debugger___Win32_Blitz3DEdu"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "debugger___Win32_Blitz3DEdu"
# PROP Intermediate_Dir "debugger___Win32_Blitz3DEdu"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /D "PRO" /YX /FD /c
# ADD CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "_WINDOWS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "PRO" /D "EDU" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3drelease\bin\debugger.dll"
# SUBTRACT BASE LINK32 /pdb:none /force
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3dedu\bin\debugger.dll"
# SUBTRACT LINK32 /pdb:none /force
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DDemo"
# PROP BASE Use_MFC 1
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "debugger___Win32_Blitz3DDemo"
# PROP BASE Intermediate_Dir "debugger___Win32_Blitz3DDemo"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 1
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "debugger___Win32_Blitz3DDemo"
# PROP Intermediate_Dir "debugger___Win32_Blitz3DDemo"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /D "PRO" /YX /FD /c
# ADD CPP /nologo /G6 /Gz /MT /W3 /GX /O1 /D "_WINDOWS" /D "_USRDLL" /D "DEBUGGER_EXPORTS" /D "_WINDLL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "PRO" /D "DEMO" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3drelease\bin\debugger.dll"
# SUBTRACT BASE LINK32 /pdb:none /force
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\release\blitz3ddemo\bin\debugger.dll"
# SUBTRACT LINK32 /pdb:none /force
!ENDIF
# Begin Target
# Name "debugger - Win32 Release"
# Name "debugger - Win32 Debug"
# Name "debugger - Win32 Blitz3DRelease"
# Name "debugger - Win32 Blitz2DRelease"
# Name "debugger - Win32 Blitz3DEdu"
# Name "debugger - Win32 Blitz3DDemo"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\debugger.rc
# End Source File
# Begin Source File
SOURCE=.\debuggerapp.cpp
# End Source File
# Begin Source File
SOURCE=.\debugtree.cpp
# End Source File
# Begin Source File
SOURCE=.\mainframe.cpp
# End Source File
# Begin Source File
SOURCE=.\prefs.cpp
# End Source File
# Begin Source File
SOURCE=.\sourcefile.cpp
# End Source File
# Begin Source File
SOURCE=.\stdafx.cpp
!IF "$(CFG)" == "debugger - Win32 Release"
# ADD CPP /Yc"stdafx.h"
!ELSEIF "$(CFG)" == "debugger - Win32 Debug"
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DRelease"
# ADD BASE CPP /Yc"stdafx.h"
# ADD CPP /Yc"stdafx.h"
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz2DRelease"
# ADD BASE CPP /Yc"stdafx.h"
# ADD CPP /Yc"stdafx.h"
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DEdu"
# ADD BASE CPP /Yc"stdafx.h"
# ADD CPP /Yc"stdafx.h"
!ELSEIF "$(CFG)" == "debugger - Win32 Blitz3DDemo"
# ADD BASE CPP /Yc"stdafx.h"
# ADD CPP /Yc"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\stdutil.cpp
# End Source File
# Begin Source File
SOURCE=.\tabber.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\debugger.h
# End Source File
# Begin Source File
SOURCE=.\debuggerapp.h
# End Source File
# Begin Source File
SOURCE=.\debugtree.h
# End Source File
# Begin Source File
SOURCE=.\mainframe.h
# End Source File
# Begin Source File
SOURCE=.\prefs.h
# End Source File
# Begin Source File
SOURCE=.\sourcefile.h
# End Source File
# Begin Source File
SOURCE=.\stdafx.h
# End Source File
# Begin Source File
SOURCE=.\tabber.h
# End Source File
# End Group
# End Target
# End Project
+19
View File
@@ -0,0 +1,19 @@
#ifndef DEBUGGER_H
#define DEBUGGER_H
class Debugger{
public:
virtual void debugRun()=0;
virtual void debugStop()=0;
virtual void debugStmt( int srcpos,const char *file )=0;
virtual void debugEnter( void *frame,void *env,const char *func )=0;
virtual void debugLeave()=0;
virtual void debugLog( const char *msg )=0;
virtual void debugMsg( const char *msg,bool serious )=0;
virtual void debugSys( void *msg )=0;
};
extern "C" _declspec(dllexport) Debugger * _cdecl debuggerGetDebugger( void *mod,void *env );
#endif
+63
View File
@@ -0,0 +1,63 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (New Zealand) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENZ)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_NZ
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (New Zealand) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+50
View File
@@ -0,0 +1,50 @@
#include "stdafx.h"
#include "debugger.h"
#include "debuggerapp.h"
#include "resource.h"
#include "prefs.h"
DebuggerApp debuggerApp;
DebuggerApp::~DebuggerApp(){
}
BOOL DebuggerApp::InitInstance(){
AfxInitRichEdit();
main_frame=new MainFrame();
m_pMainWnd=main_frame;
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA,0,&rect,0 );
int x=rect.left;
int w=rect.right-x;
int h=240;
int y=rect.bottom-h;
main_frame->Create( 0,"Blitz Debugger",
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
CRect( x,y,x+w,y+h ) );
main_frame->ShowWindow( SW_SHOW );
main_frame->UpdateWindow();
return TRUE;
}
int DebuggerApp::ExitInstance(){
main_frame->DestroyWindow();
return 0;
}
MainFrame *DebuggerApp::mainFrame(){
return debuggerApp.main_frame;
}
Debugger * _cdecl debuggerGetDebugger( void *mod,void *env ){
debuggerApp.mainFrame()->setRuntime( mod,env );
return debuggerApp.mainFrame();
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef DEBUGGERAPP_H
#define DEBUGGERAPP_H
#include "mainframe.h"
class DebuggerApp : public CWinApp{
MainFrame *main_frame;
public:
~DebuggerApp();
virtual BOOL InitInstance();
virtual int ExitInstance();
MainFrame *mainFrame();
};
extern DebuggerApp debuggerApp;
#endif
+225
View File
@@ -0,0 +1,225 @@
#include "stdafx.h"
#include "debugtree.h"
#include "prefs.h"
#include "../bbruntime/basic.h"
IMPLEMENT_DYNAMIC( DebugTree,CTreeCtrl )
BEGIN_MESSAGE_MAP( DebugTree,CTreeCtrl )
ON_WM_CREATE()
END_MESSAGE_MAP()
DebugTree::DebugTree():st_nest(0){
}
DebugTree::~DebugTree(){
}
int DebugTree::OnCreate( LPCREATESTRUCT lpCreateStruct ){
CTreeCtrl::OnCreate( lpCreateStruct );
SetBkColor( prefs.rgb_bkgrnd );
SetTextColor( prefs.rgb_default );
SetFont( &prefs.debugFont );
return 0;
}
static string typeTag( Type *t ){
if( t->intType() ) return "";
if( t->floatType() ) return "#";
if( t->stringType() ) return "$";
if( StructType *s=t->structType() ) return "."+s->ident;
if( VectorType *v=t->vectorType() ){
string s=typeTag( v->elementType )+"[";
for( int k=0;k<v->sizes.size();++k ){
if( k ) s+=",";
s+=itoa( v->sizes[k]-1 );
}
return s+"]";
}
return "";
}
HTREEITEM DebugTree::insertVar( void *var,Decl *d,const string &name,HTREEITEM it,HTREEITEM parent ){
string s=name;
ConstType *ct=d->type->constType();
StructType *st=d->type->structType();
VectorType *vt=d->type->vectorType();
if( ct ){
Type *t=ct->valueType;
s+=typeTag(t);
if( t->intType() ){
s+="="+itoa( ct->intValue );
}else if( t->floatType() ){
s+="="+ftoa( ct->floatValue );
}else if( t->stringType() ){
s+="=\""+ct->stringValue+'\"';
}
}else if( var ){
Type *t=d->type;
s+=typeTag( t );
if( t->intType() ){
s+="="+itoa( *(int*)var );
}else if( t->floatType() ){
s+="="+ftoa( *(float*)var );
}else if( t->stringType() ){
BBStr *str=*(BBStr**)var;
if( str ) s+="=\""+*str+'\"';
else s+="=\"\"";
}else if( st ){
var=*(void**)var;
if( var ) var=*(void**)var;
if( !var ) s+=" (Null)";
}
}
if( it ){
if( GetItemText( it )!=s.c_str() ){
SetItemText( it,s.c_str() );
}
}else{
it=InsertItem( s.c_str(),parent );
}
++st_nest;
if( st ){
if( var ){
if( st_nest<4 ){
HTREEITEM st_it=GetChildItem( it );
for( int k=0;k<st->fields->size();++k ){
Decl *st_d=st->fields->decls[k];
void *st_var=(char*)var+st_d->offset;
char name[256];
st_d->getName( name );
st_it=insertVar( st_var,st_d,name,st_it,it );
}
}
}else{
while( HTREEITEM t=GetChildItem( it ) ){
DeleteItem( t );
}
}
}
--st_nest;
return it ? GetNextSiblingItem( it ) : 0;
}
/******************************* CONSTS ***********************************/
ConstsTree::ConstsTree(){
}
void ConstsTree::reset( Environ *env ){
HTREEITEM it=GetChildItem( TVI_ROOT );
for( int k=0;k<env->decls->size();++k ){
Decl *d=env->decls->decls[k];
if( !(d->kind & (DECL_GLOBAL) ) ) continue;
if( d->type->constType() ){
char name[256];
d->getName( name );
it=insertVar( 0,d,name,it,TVI_ROOT );
}
}
}
/******************************* GLOBALS **********************************/
GlobalsTree::GlobalsTree():module(0),envron(0){
}
void GlobalsTree::reset( Module *mod,Environ *env ){
module=mod;
envron=env;
}
void GlobalsTree::refresh(){
if( !module || !envron ) return;
HTREEITEM it=GetChildItem( TVI_ROOT );
for( int k=0;k<envron->decls->size();++k ){
Decl *d=envron->decls->decls[k];
if( !(d->kind & (DECL_GLOBAL) ) ) continue;
if( !d->type->constType() ){
char name[256];
d->getName( name );
void *var=0;
module->findSymbol( ("_v"+string(name)).c_str(),(int*)&var );
it=insertVar( var,d,name,it,TVI_ROOT );
}
}
}
/******************************** LOCALS **********************************/
LocalsTree::LocalsTree():envron(0){
}
void LocalsTree::reset( Environ *env ){
envron=env;
}
void LocalsTree::refresh(){
if( !envron || !frames.size() ) return;
HTREEITEM item=GetChildItem( TVI_ROOT );
int n=0;
for( n=0;n<frames.size();++n ){
if( !item || item!=frames[n].item ) break;
item=GetNextSiblingItem( item );
}
while( item ){
HTREEITEM next=GetNextSiblingItem( item );
DeleteItem( item );
item=next;
}
for( ;n<frames.size();++n ){
item=frames[n].item=InsertItem( frames[n].func,TVI_ROOT,TVI_LAST );
if( n<frames.size()-1 ) refreshFrame( frames[n] );
}
refreshFrame( frames.back() );
}
void LocalsTree::refreshFrame( const Frame &f ){
HTREEITEM it=GetChildItem( f.item );
for( int n=0;n<f.env->decls->size();++n ){
Decl *d=f.env->decls->decls[n];
if( !(d->kind & (DECL_LOCAL|DECL_PARAM) ) ) continue;
char name[256];
d->getName( name );
if( !isalpha( name[0] ) ) continue;
it=insertVar( (char*)f.frame+d->offset,d,name,it,f.item );
}
}
void LocalsTree::pushFrame( void *f,void *e,const char *func ){
frames.push_back( Frame( f,(Environ*)e,func ) );
}
void LocalsTree::popFrame(){
frames.pop_back();
}
+70
View File
@@ -0,0 +1,70 @@
#ifndef DEBUGTREE_H
#define DEBUGTREE_H
#include "../linker/linker.h"
#include "../compiler/environ.h"
class DebugTree : public CTreeCtrl{
int st_nest;
protected:
HTREEITEM insertVar( void *var,Decl *d,const string &name,HTREEITEM it,HTREEITEM parent );
public:
DebugTree();
~DebugTree();
DECLARE_DYNAMIC( DebugTree )
DECLARE_MESSAGE_MAP()
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
};
class ConstsTree : public DebugTree{
public:
ConstsTree();
void reset( Environ *env );
};
class GlobalsTree : public DebugTree{
Module *module;
Environ *envron;
public:
GlobalsTree();
void reset( Module *mod,Environ *env );
void refresh();
};
class LocalsTree : public DebugTree{
Module *module;
Environ *envron;
struct Frame{
void *frame;
Environ *env;
const char *func;
HTREEITEM item;
Frame( void *f,Environ *e,const char *fn ):frame(f),env(e),func(fn),item(0){}
};
vector<Frame> frames;
void refreshFrame( const Frame &f );
public:
LocalsTree();
void reset( Environ *env );
void refresh();
void pushFrame( void *frame,void *env,const char *func );
void popFrame();
int size()const{ return frames.size(); }
};
#endif
+325
View File
@@ -0,0 +1,325 @@
#include "stdafx.h"
#include "mainframe.h"
#include "resource.h"
#include "debuggerapp.h"
#include "prefs.h"
#define WM_IDLEUPDATECMDUI 0x0363 // wParam == bDisableIfNoHandler
enum{
WM_STOP=WM_USER+1,WM_RUN,WM_END
};
enum{
STARTING,RUNNING,STOPPED,ENDING
};
IMPLEMENT_DYNAMIC( MainFrame,CFrameWnd )
BEGIN_MESSAGE_MAP( MainFrame,CFrameWnd )
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_CLOSE()
ON_WM_WINDOWPOSCHANGING()
ON_COMMAND( ID_STOP,cmdStop )
ON_COMMAND( ID_RUN,cmdRun )
ON_COMMAND( ID_STEPOVER,cmdStepOver )
ON_COMMAND( ID_STEPINTO,cmdStepInto )
ON_COMMAND( ID_STEPOUT,cmdStepOut )
ON_COMMAND( ID_END,cmdEnd )
ON_UPDATE_COMMAND_UI( ID_STOP,updateCmdUI )
ON_UPDATE_COMMAND_UI( ID_RUN,updateCmdUI )
ON_UPDATE_COMMAND_UI( ID_STEPOVER,updateCmdUI )
ON_UPDATE_COMMAND_UI( ID_STEPINTO,updateCmdUI )
ON_UPDATE_COMMAND_UI( ID_STEPOUT,updateCmdUI )
ON_UPDATE_COMMAND_UI( ID_END,updateCmdUI )
END_MESSAGE_MAP()
MainFrame::MainFrame():state(STARTING),step_level(-1),cur_pos(0),cur_file(0){
}
MainFrame::~MainFrame(){
map<const char*,SourceFile*>::iterator it;
for( it=files.begin();it!=files.end();++it ) delete it->second;
}
int MainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ){
CFrameWnd::OnCreate( lpCreateStruct );
prefs.open();
string tb=prefs.homeDir+"/cfg/dbg_toolbar.bmp";
//Toolbar
HBITMAP toolbmp=(HBITMAP)LoadImage(
0,tb.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_LOADMAP3DCOLORS );
BITMAP bm;
GetObject( toolbmp,sizeof(bm),&bm );
int n=0;
UINT toolbuts[]={ ID_STOP,ID_RUN,ID_STEPOVER,ID_STEPINTO,ID_STEPOUT,ID_END };
int toolcnt=sizeof(toolbuts)/sizeof(UINT);
for( int k=0;k<toolcnt;++k ) if( toolbuts[k]!=ID_SEPARATOR ) ++n;
SIZE imgsz,butsz;
imgsz.cx=bm.bmWidth/n;imgsz.cy=bm.bmHeight;
butsz.cx=imgsz.cx+7;butsz.cy=imgsz.cy+6;
toolBar.CreateEx( this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS );
toolBar.SetBitmap( toolbmp );
toolBar.SetSizes( butsz,imgsz );
toolBar.SetButtons( toolbuts,toolcnt );
//Tabber
tabber.Create(
WS_VISIBLE|WS_CHILD|
TCS_HOTTRACK,
CRect( 0,0,0,0 ),this,1 );
tabber.SetFont( &prefs.tabsFont );
//Second tabber
tabber2.Create(
WS_VISIBLE|WS_CHILD|
TCS_HOTTRACK,
CRect( 0,0,0,0 ),this,2 );
tabber2.SetFont( &prefs.tabsFont );
//Debug Log
debug_log.Create(
WS_CHILD|WS_HSCROLL|WS_VSCROLL|
ES_NOHIDESEL|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
CRect( 0,0,0,0 ),&tabber,1 );
tabber.insert( 0,&debug_log,"Debug log" );
//Debug trees
locals_tree.Create(
WS_VISIBLE|WS_CHILD|
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
CRect( 0,0,0,0 ),&tabber2,3 );
globals_tree.Create(
WS_VISIBLE|WS_CHILD|
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
CRect( 0,0,0,0 ),&tabber2,3 );
consts_tree.Create(
WS_VISIBLE|WS_CHILD|
TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS,
CRect( 0,0,0,0 ),&tabber2,3 );
tabber2.insert( 0,&locals_tree,"Locals" );
tabber2.insert( 1,&globals_tree,"Globals" );
tabber2.insert( 2,&consts_tree,"Consts" );
tabber2.setCurrent(0);
setState( STARTING );
return 0;
}
void MainFrame::setState( int n ){
state=n;
SendMessageToDescendants( WM_IDLEUPDATECMDUI,(WPARAM)TRUE,0,TRUE,TRUE );
if( shouldRun() ){
if( HWND app=::FindWindow( "Blitz Runtime Class",0 ) ){
::SetActiveWindow( app );
}
}else{
SetActiveWindow();
}
}
void MainFrame::OnClose(){
cmdEnd();
}
void MainFrame::OnSize( UINT type,int sw,int sh ){
CFrameWnd::OnSize( type,sw,sh );
CRect r,t;GetClientRect( &r );
int x=r.left,y=r.top,w=r.Width(),h=r.Height();
toolBar.GetWindowRect( &t );y+=t.Height();h-=t.Height();
tabber.MoveWindow( x,y,w-240,h );
tabber2.MoveWindow( x+w-240,y,240,h );
}
void MainFrame::setRuntime( void *mod,void *env ){
consts_tree.reset( (Environ*)env );
globals_tree.reset( (Module*)mod,(Environ*)env );
locals_tree.reset( (Environ*)env );
}
void MainFrame::showCurStmt(){
if( !cur_file ) return;
SourceFile *t=sourceFile(cur_file);
int row=(cur_pos>>16)&0xffff,col=cur_pos&0xffff;
t->highLight( row,col );
globals_tree.refresh();
locals_tree.refresh();
}
void MainFrame::debugRun(){
setState( RUNNING );
}
void MainFrame::debugStop(){
step_level=locals_tree.size();
setState( STOPPED );
showCurStmt();
}
void MainFrame::debugStmt( int pos,const char *file ){
cur_pos=pos;
cur_file=file;
if( shouldRun() ) return;
::PostMessage( 0,WM_STOP,0,0 );
}
void MainFrame::debugEnter( void *frame,void *env,const char *func ){
locals_tree.pushFrame( frame,env,func );
if( locals_tree.size()>1 ) return;
globals_tree.refresh();
locals_tree.refresh();
setState( RUNNING );
}
void MainFrame::debugLeave(){
locals_tree.popFrame();
}
void MainFrame::debugMsg( const char *msg,bool serious ){
if( serious ){
::MessageBox( 0,msg,"Runtime Error",MB_OK|MB_ICONWARNING|MB_TOPMOST|MB_SETFOREGROUND );
}else{
::MessageBox( 0,msg,"Runtime Message",MB_OK|MB_ICONINFORMATION|MB_TOPMOST|MB_SETFOREGROUND );
}
}
void MainFrame::debugLog( const char *msg ){
debug_log.ReplaceSel( msg );
debug_log.ReplaceSel( "\n" );
tabber.setCurrent( 0 );
setState( state );
}
void MainFrame::debugSys( void *m ){
}
void MainFrame::cmdStop(){
::PostMessage( 0,WM_STOP,0,0 );
}
void MainFrame::cmdRun(){
step_level=-1;
::PostMessage( 0,WM_RUN,0,0 );
}
void MainFrame::cmdEnd(){
::PostMessage( 0,WM_END,0,0 );
setState( ENDING );
}
void MainFrame::cmdStepOver(){
::PostMessage( 0,WM_RUN,0,0 );
}
void MainFrame::cmdStepInto(){
step_level=locals_tree.size()+1;
::PostMessage( 0,WM_RUN,0,0 );
}
void MainFrame::cmdStepOut(){
step_level=locals_tree.size()-1;
::PostMessage( 0,WM_RUN,0,0 );
}
SourceFile *MainFrame::sourceFile(const char *file){
if( !file ) file="<unknown>";
map<const char*,SourceFile*>::const_iterator it=files.find( file );
if( it!=files.end() ){
tabber.setCurrent( file_tabs[file] );
return it->second;
}
//crete new source file
SourceFile *t=new SourceFile();
it=files.insert( make_pair(file,t) ).first;
int tab=files.size();
t->Create(
WS_CHILD|WS_HSCROLL|WS_VSCROLL|
ES_NOHIDESEL|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
CRect( 0,0,0,0 ),&tabber,1 );
if( FILE *f=fopen( file,"rb" ) ){
fseek( f,0,SEEK_END );
int sz=ftell( f );
fseek( f,0,SEEK_SET );
char *buf=new char[sz+1];
fread( buf,sz,1,f );
buf[sz]=0;
t->ReplaceSel( buf );
delete[] buf;
fclose(f);
}
file_tabs.insert( make_pair(file,tab) );
if( char *p=strrchr(file,'/') ) file=p+1;
if( char *p=strrchr(file,'\\') ) file=p+1;
tabber.insert( tab,t,file );
tabber.setCurrent( tab );
return t;
}
void MainFrame::updateCmdUI( CCmdUI *ui ){
if( state!=RUNNING && state!=STOPPED ){
ui->Enable( false );
return;
}
switch( ui->m_nID ){
case ID_STOP:
ui->Enable( shouldRun() );
break;
case ID_RUN:
case ID_STEPOVER:
case ID_STEPINTO:
case ID_STEPOUT:
ui->Enable( !shouldRun() );
break;
case ID_END:
ui->Enable( true );
break;
}
}
void MainFrame::OnWindowPosChanging( WINDOWPOS *pos ){
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA,0,&rect,0 );
pos->x=rect.left;
pos->cx=rect.right-pos->x;
pos->cy=rect.bottom-pos->y;
}
+64
View File
@@ -0,0 +1,64 @@
#ifndef MAINFRAME_H
#define MAINFRAME_H
#include "tabber.h"
#include "debugger.h"
#include "sourcefile.h"
#include "debugtree.h"
class MainFrame : public CFrameWnd,public Debugger{
Tabber tabber;
Tabber tabber2;
CToolBar toolBar;
SourceFile debug_log;
ConstsTree consts_tree;
GlobalsTree globals_tree;
LocalsTree locals_tree;
map<const char*,int> file_tabs;
map<const char*,SourceFile*> files;
int state,step_level,cur_pos;
const char *cur_file;
bool shouldRun()const{ return step_level<locals_tree.size(); }
public:
MainFrame();
~MainFrame();
void debugRun();
void debugStop();
void debugStmt( int srcpos,const char *file );
void debugEnter( void *frame,void *env,const char *func );
void debugLeave();
void debugLog( const char *msg );
void debugMsg( const char *msg,bool serious );
void debugSys( void *msg );
void showCurStmt();
void setState( int n );
void setRuntime( void *mod,void *env );
SourceFile *sourceFile(const char*file);
DECLARE_DYNAMIC( MainFrame )
DECLARE_MESSAGE_MAP()
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnSize( UINT type,int w,int h );
afx_msg void OnClose();
afx_msg void cmdStop();
afx_msg void cmdRun();
afx_msg void cmdStepOver();
afx_msg void cmdStepInto();
afx_msg void cmdStepOut();
afx_msg void cmdEnd();
afx_msg void updateCmdUI( CCmdUI *ui );
afx_msg void OnWindowPosChanging( WINDOWPOS *pos );
};
#endif
+174
View File
@@ -0,0 +1,174 @@
#include "stdafx.h"
#include "prefs.h"
#include "debuggerapp.h"
#include <fstream>
#define SWAPRB(x) ( (((x)>>16)&0xff) | ((x)&0xff00) | (((x)&0xff)<<16) )
Prefs prefs;
void Prefs::open(){
homeDir=getenv( "blitzpath" );
AddFontResource( (homeDir+"/cfg/blitz.fon").c_str() );
setDefault();
bool prg_windowed;
ifstream in( (homeDir+"/cfg/blitzide.prefs").c_str() );
if( !in.good() ) return;
while( !in.eof() ){
string t;in>>t;
if( !t.size() ) continue;
while( in.peek()=='\t' ) in.ignore();
if( t=="prg_debug" ) in>>prg_debug;
else if( t=="prg_lastbuild" ) getline( in,prg_lastbuild );
else if( t=="prg_windowed" ) in>>prg_windowed;
else if( t=="win_maximized" ) in>>win_maximized;
else if( t=="win_notoolbar" ) in>>win_notoolbar;
else if( t=="win_rect" ){
in>>win_rect.left;in>>win_rect.top;
in>>win_rect.right;in>>win_rect.bottom;
}else if( t.substr( 0,5 )=="font_" ){
string s;int h;in>>s;in>>h;
t=t.substr( 5 );
if( t=="editor" ){
font_editor=s;font_editor_height=h;
}else if( t=="tabs" ){
font_tabs=s;font_tabs_height=h;
}else if( t=="debug" ){
font_debug=s;font_debug_height=h;
}
}else if( t.substr( 0,4 )=="rgb_" ){
t=t.substr(4);
string s;in>>s;int rgb=0;
for( int k=0;k<s.size();++k ){
int n=s[k];rgb=(rgb<<4)|(n<='9'?n-'0':(n&31)+9);
}
rgb=SWAPRB(rgb);
if( t=="bkgrnd" ) rgb_bkgrnd=rgb;
else if( t=="string" ) rgb_string=rgb;
else if( t=="ident" ) rgb_ident=rgb;
else if( t=="keyword" ) rgb_keyword=rgb;
else if( t=="comment" ) rgb_comment=rgb;
else if( t=="digit" ) rgb_digit=rgb;
else if( t=="default" ) rgb_default=rgb;
}else if( t=="edit_tabs" ){
in>>edit_tabs;
}else if( t=="edit_blkcursor" ){
in>>edit_blkcursor;
}else if( t=="edit_backup" ){
in>>edit_backup;
}else if( t=="img_toolbar" ){
getline( in,img_toolbar );
}else if( t=="cmd_line" ){
getline( in,cmd_line );
}else if( t=="file_recent" ){
string l;getline( in,l );
if( recentFiles.size()<10 ) recentFiles.push_back( l );
}else{
string s="Unrecognized option '"+t+"' in blitzide.prefs";
MessageBox( 0,s.c_str(),"Error in preferences",MB_OK );
setDefault();
return;
}
}
createFonts();
}
void Prefs::close(){
ofstream out( (homeDir+"cfg\\blitzide.prefs").c_str() );
if( !out.good() ) return;
out<<"prg_debug\t"<<prg_debug<<endl;
out<<"prg_lastbuild\t"<<prg_lastbuild<<endl;
out<<"win_maximized\t"<<win_maximized<<endl;
out<<"win_notoolbar\t"<<win_notoolbar<<endl;
out<<"win_rect\t"<<win_rect.left<<' '<<win_rect.top<<' '<<win_rect.right<<' '<<win_rect.bottom<<endl;
out<<"font_editor\t"<<font_editor<<' '<<font_editor_height<<endl;
out<<"font_tabs\t"<<font_tabs<<' '<<font_tabs_height<<endl;
out<<"font_debug\t"<<font_debug<<' '<<font_debug_height<<endl;
out<<hex;
out<<"rgb_bkgrnd\t"<<SWAPRB(rgb_bkgrnd)<<endl;
out<<"rgb_string\t"<<SWAPRB(rgb_string)<<endl;
out<<"rgb_ident\t"<<SWAPRB(rgb_ident)<<endl;
out<<"rgb_keyword\t"<<SWAPRB(rgb_keyword)<<endl;
out<<"rgb_comment\t"<<SWAPRB(rgb_comment)<<endl;
out<<"rgb_digit\t"<<SWAPRB(rgb_digit)<<endl;
out<<"rgb_default\t"<<SWAPRB(rgb_default)<<endl;
out<<"edit_tabs\t"<<edit_tabs<<endl;
out<<"edit_blkcursor\t"<<edit_blkcursor<<endl;
out<<"edit_backup\t"<<edit_backup<<endl;
out<<"img_toolbar\t"<<img_toolbar<<endl;
out<<"cmd_line\t"<<cmd_line<<endl;
for( int k=0;k<recentFiles.size();++k ){
out<<"file_recent\t"<<recentFiles[k]<<endl;
}
out<<dec;
RemoveFontResource( (homeDir+"cfg\\blitz.fon").c_str() );
}
void Prefs::setDefault(){
prg_debug=true;
win_rect.left=win_rect.top=0;
win_rect.right=640;win_rect.bottom=480;
win_maximized=false;
win_notoolbar=false;
font_editor="blitz";
font_editor_height=12;
font_tabs="verdana";
font_tabs_height=8;
font_debug="verdana";
font_debug_height=8;
#ifdef PRO
rgb_bkgrnd=RGB( 0x22,0x55,0x88 );
rgb_string=RGB( 0x00,0xff,0x66 );
rgb_ident=RGB( 0xff,0xff,0xff );
rgb_keyword=RGB( 0xaa,0xff,0xff );
rgb_comment=RGB( 0xff,0xee,0x00 );
rgb_digit=RGB( 0x33,0xff,0xdd );
rgb_default=RGB( 0xee,0xee,0xee );
rgb_unsel=RGB( 0x88,0x88,0x88 );
#else
rgb_bkgrnd=RGB( 32,96,96 );
rgb_string=RGB( 0,255,0 );
rgb_ident=RGB( 255,255,255 );
rgb_keyword=RGB( 255,231,95 );
rgb_comment=RGB( 0,255,255 );
rgb_digit=RGB( 200,240,255 );
rgb_default=RGB( 255,240,200 );
#endif
edit_tabs=4;
edit_blkcursor=false;
edit_backup=2;
img_toolbar="toolbar.bmp";
recentFiles.clear();
createFonts();
}
void Prefs::createFonts(){
editFont.Detach();
tabsFont.Detach();
debugFont.Detach();
conFont.Detach();
editFont.CreatePointFont( font_editor_height*10,font_editor.c_str() );
tabsFont.CreatePointFont( font_tabs_height*10,font_tabs.c_str() );
debugFont.CreatePointFont( font_debug_height*10,font_debug.c_str() );
conFont.CreatePointFont( 80,"courier" );
}
+51
View File
@@ -0,0 +1,51 @@
#ifndef PREFS_H
#define PREFS_H
class Prefs{
public:
bool prg_debug;
string prg_lastbuild;
RECT win_rect;
bool win_maximized;
bool win_notoolbar;
string font_editor,font_tabs,font_debug;
int font_editor_height,font_tabs_height,font_debug_height;
int rgb_bkgrnd; //0
int rgb_string; //1
int rgb_ident; //2
int rgb_keyword; //3
int rgb_comment; //4
int rgb_digit; //5
int rgb_default; //6
int rgb_unsel;
int edit_tabs;
bool edit_blkcursor;
int edit_backup;
string img_toolbar;
string homeDir;
CFont conFont,editFont,tabsFont,debugFont;
vector<string> recentFiles;
string cmd_line;
void open();
void close();
private:
void setDefault();
void createFonts();
};
extern Prefs prefs;
#endif
+23
View File
@@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by debugger.rc
//
#define IDB_BITMAP1 101
#define ID_STOP 1001
#define ID_RUN 1002
#define ID_STEPOVER 1003
#define ID_STEPINTO 1004
#define ID_STEPOUT 1005
#define ID_END 1006
#define ID_TRACE 1007
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 108
#endif
#endif
+63
View File
@@ -0,0 +1,63 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (New Zealand) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENZ)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_NZ
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (New Zealand) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+51
View File
@@ -0,0 +1,51 @@
#include "stdafx.h"
#include "sourcefile.h"
#include "prefs.h"
IMPLEMENT_DYNAMIC( SourceFile,CRichEditCtrl )
BEGIN_MESSAGE_MAP( SourceFile,CRichEditCtrl )
ON_WM_CREATE()
END_MESSAGE_MAP()
SourceFile::SourceFile(){
}
SourceFile::~SourceFile(){
}
int SourceFile::OnCreate( LPCREATESTRUCT lpCreateStruct ){
CRichEditCtrl::OnCreate( lpCreateStruct );
SetReadOnly( true );
SetFont( &prefs.editFont );
SetBackgroundColor( false,prefs.rgb_bkgrnd );
CHARFORMAT fmt={sizeof( fmt )};
fmt.dwMask=CFM_COLOR;
fmt.crTextColor=prefs.rgb_default;
SetSel( 0,-1 );
SetDefaultCharFormat( fmt );
SetSelectionCharFormat( fmt );
SetSel( 0,0 );
return 0;
}
void SourceFile::highLight( int row,int col ){
int pos=LineIndex( row )+col;
HideSelection( true,false );
bool quote=false;
int end=pos,len=GetTextLength();
while( end<len ){
char temp[8];
SetSel( end,end+1 );
GetSelText( temp );
if( temp[0]=='\"' ) quote=!quote;
if( !quote && (temp[0]==':' || !isprint( temp[0] )) ) break;
++end;
}
HideSelection( false,false );
SetSel( pos,end );
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef SOURCEFILE_H
#define SOURCEFILE_H
class SourceFile : public CRichEditCtrl{
public:
SourceFile();
~SourceFile();
void highLight( int row,int col );
DECLARE_DYNAMIC( SourceFile )
DECLARE_MESSAGE_MAP()
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
};
#endif
+2
View File
@@ -0,0 +1,2 @@
#include "stdafx.h"
+29
View File
@@ -0,0 +1,29 @@
#ifndef STDAFX_H
#define STDAFX_H
#pragma warning(disable:4786)
#include <afxwin.h> // Core
#include <afxcmn.h> // Common Controls
#include <afxrich.h> // CRich edit
#include <map>
#include <list>
#include <vector>
#include <string>
using namespace std;
//some stuff that should be in std libs
int atoi( const string &s );
double atof( const string &s );
string itoa( int n );
string ftoa( float n );
string tolower( const string &s );
string toupper( const string &s );
string fullfilename( const string &t );
string filenamepath( const string &t );
string filenamefile( const string &t );
#endif
+182
View File
@@ -0,0 +1,182 @@
#include "stdafx.h"
int atoi( const string &s ){
return atoi( s.c_str() );
}
double atof( const string &s ){
return atof( s.c_str() );
}
string itoa( int n ){
char buff[32];itoa( n,buff,10 );
return string( buff );
}
static int _finite( double n ){ // definition: exponent anything but 2047.
int e; // 11 bit exponent
const int eMax = 2047; // 0x7ff, all bits = 1
int *pn = (int *) &n;
e = *++pn; // Intel order!
e = ( e >> 20 ) & eMax;
return e != eMax;
}
static int _isnan( double n ){ // definition: exponent 2047, nonzero fraction.
int e; // 11 bit exponent
const int eMax = 2047; // 0x7ff, all bits = 1
int *pn = (int *) &n;
e = *++pn; // Intel order!
e = ( e >> 20 ) & eMax;
if ( e != 2047 ) return 0; // almost always return here
int fHi, fLo; // 52 bit fraction
fHi = ( *pn ) & 0xfffff; // first 20 bits
fLo = *--pn; // last 32 bits
return ( fHi | fLo ) != 0; // returns 0,1 not just 0,nonzero
}
/////////////
//By FLOYD!//
/////////////
string ftoa( float n ){
static const int digits=6;
int eNeg = -4, ePos = 8; // limits for e notation.
char buffer[50]; // from MSDN example, 25 would probably suffice
string t;
int dec, sign;
if ( _finite( n ) ){
// if ( digits < 1 ) digits = 1; // less than one digit is nonsense
// if ( digits > 8 ) digits = 8; // practical maximum for float
t = _ecvt( n, digits, &dec, &sign );
if ( dec <= eNeg + 1 || dec > ePos ){
_gcvt( n, digits, buffer );
t = buffer;
return t;
}
// Here is the tricky case. We want a nicely formatted
// number with no e-notation or multiple trailing zeroes.
if ( dec <= 0 ){
t = "0." + string( -dec, '0' ) + t;
dec = 1; // new location for decimal point
}
else if( dec < digits ){
t = t.substr( 0, dec ) + "." + t.substr( dec );
}
else{
t = t + string( dec - digits, '0' ) + ".0";
dec += dec - digits;
}
// Finally, trim off excess zeroes.
int dp1 = dec + 1, p = t.length();
while( --p > dp1 && t[p] == '0' );
t = string( t, 0, ++p );
return sign ? "-" + t : t;
} // end of finite case
if ( _isnan( n ) ) return "NaN";
if ( n > 0.0 ) return "Infinity";
if ( n < 0.0 ) return "-Infinity";
abort();
}
/*
string ftoa( float n ){
static const float min=.000001f,max=9999999.0f;
int i=*(int*)&n;
int e=(i>>23)&0xff;
int f=i&0x007fffff;
if( e==0xff && f ) return "NAN";
string t;
int s=(i>>31)&0x01;
if( e==0xff ){
t="INFINITY";
}else if( !e && !f ){
t="0.000000";
}else if( n>=min && n<=max ){
int dec,sgn;
t=_fcvt( fabs(n),6,&dec,&sgn );
if( dec<=0 ){
t="0."+string( -dec,'0' )+t;
}else if( dec<t.size() ){
t=t.substr( 0,dec )+"."+t.substr( dec );
}else{
t=t+string( '0',dec-t.size() )+".000000";
}
}else{
char buff[32];
_gcvt( fabs(n),7,buff );
t=buff;
}
return s ? "-"+t : t;
}
*/
string tolower( const string &s ){
string t=s;
for( int k=0;k<t.size();++k ) t[k]=tolower(t[k]);
return t;
}
string toupper( const string &s ){
string t=s;
for( int k=0;k<t.size();++k ) t[k]=toupper(t[k]);
return t;
}
string fullfilename( const string &t ){
char buff[MAX_PATH+1],*p;
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
return string(buff);
}
string filenamepath( const string &t ){
char buff[MAX_PATH+1],*p;
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
if( !p ) return "";
*p=0;return string(buff);
}
string filenamefile( const string &t ){
char buff[MAX_PATH+1],*p;
GetFullPathName( t.c_str(),MAX_PATH,buff,&p );
if( !p ) return "";
return string( p );
}
+161
View File
@@ -0,0 +1,161 @@
#include "stdafx.h"
#include "tabber.h"
IMPLEMENT_DYNAMIC( Tabber,CTabCtrl )
BEGIN_MESSAGE_MAP( Tabber,CTabCtrl )
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_NOTIFY_REFLECT( TCN_SELCHANGE,tcn_selChange )
END_MESSAGE_MAP()
static CRect tabsRect( CTabCtrl &t ){
CRect r(0,0,0,0);
int n=t.GetItemCount();
for( int k=0;k<n;++k ){
CRect c;
t.GetItemRect( k,&c );
if( c.left<r.left ) r.left=c.left;
if( c.right>r.right ) r.right=c.right;
if( c.top<r.top ) r.top=c.top;
if( c.bottom>r.bottom ) r.bottom=c.bottom;
}
return r;
}
CRect Tabber::getInnerRect(){
CRect r;
GetClientRect( &r );
int x=2,y=2,w=r.Width()-4,h=r.Height()-4;
r=tabsRect( *this );
h-=r.Height();y+=r.Height();
r.left=x;r.top=y;r.right=x+w;r.bottom=y+h;
return r;
}
Tabber::Tabber():
listener(0),curr(-1){
}
Tabber::~Tabber(){
for( ;tabs.size();tabs.pop_back() ) delete tabs.back();
}
void Tabber::OnSize( UINT type,int w,int h ){
CTabCtrl::OnSize( type,w,h );
refresh();
}
BOOL Tabber::OnEraseBkgnd( CDC *dc ){
CRect c;GetClientRect( &c );
HBRUSH hb=(HBRUSH)GetClassLong( m_hWnd,GCL_HBRBACKGROUND );
CBrush br;br.Attach( hb );
if( curr<0 ) dc->FillRect( &c,&br );
else{
CRect i=getInnerRect();
CRect t( c.left,c.top,i.right,i.top );dc->FillRect( &t,&br );
CRect r( i.right,c.top,c.right,i.bottom );dc->FillRect( &r,&br );
CRect b( i.left,i.bottom,c.right,c.bottom );dc->FillRect( &b,&br );
CRect l( c.left,i.top,i.left,c.bottom );dc->FillRect( &l,&br );
}
return true;
}
void Tabber::setListener( TabberListener *l ){
listener=l;
}
void Tabber::refresh(){
if( curr<0 ) return;
CRect r=getInnerRect();
CWnd *wnd=getTabWnd( curr );
wnd->MoveWindow( r.left,r.top,r.Width(),r.Height() );
wnd->ShowWindow( SW_SHOWNA );
}
Tabber::Tab *Tabber::getTab( int index )const{
if( index<0 || index>=tabs.size() ) return 0;
Tabs::const_iterator it=tabs.begin();
while( index-- ) ++it;
return *it;
}
void Tabber::tcn_selChange( NMHDR *p,LRESULT *result ){
setCurrent( GetCurSel() );
}
void Tabber::insert( int index,CWnd *w,const string &t ){
if( index<0 || index>tabs.size() ) return;
Tabs::iterator it=tabs.begin();
for( int k=0;k<index;++k ) ++it;
Tab *tab=new Tab( w,t );
tabs.insert( it,tab );
InsertItem( index,t.c_str() );
if( curr<0 ) setCurrent( index );
}
void Tabber::remove( int index ){
if( index<0 || index>=tabs.size() ) return;
CWnd *w=getTabWnd( index );
Tabs::iterator it=tabs.begin();
for( int k=0;k<index;++k ) ++it;
delete *it;tabs.erase( it );
DeleteItem( index );
if( curr>=tabs.size() ) curr=tabs.size()-1;
refresh();
if( curr>=0 ) SetCurSel( curr );
if( w ) w->ShowWindow( SW_HIDE );
if( listener ) listener->currentSet( this,curr );
}
void Tabber::setCurrent( int index ){
if( index<0 || index>=tabs.size() ) return;
if( index!=curr ){
CWnd *w=getTabWnd( curr );
curr=index;
refresh();
SetCurSel( curr );
if( w ) w->ShowWindow( SW_HIDE );
}
if( listener ) listener->currentSet( this,curr );
}
void Tabber::setTabText( int index,const string &t ){
if( index<0 || index>=tabs.size() ) return;
string s=t+'\0';
TCITEM tc={ TCIF_TEXT };
tc.pszText=(char*)s.data();
SetItem( index,&tc );
}
int Tabber::size()const{
return tabs.size();
}
int Tabber::getCurrent()const{
return curr;
}
CWnd *Tabber::getTabWnd( int index )const{
Tab *t=getTab( index );
return t ? t->wnd : 0;
}
string Tabber::getTabText( int index )const{
Tab *t=getTab( index );
return t ? t->text : "";
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef TABBER_H
#define TABBER_H
class Tabber;
class TabberListener{
public:
virtual void currentSet( Tabber *tabber,int index )=0;
};
class Tabber : public CTabCtrl{
public:
Tabber();
~Tabber();
void setListener( TabberListener *l );
void insert( int index,CWnd *wnd,const string &text );
void remove( int index );
void setCurrent( int index );
void setTabText( int index,const string &t );
int size()const;
int getCurrent()const;
CWnd *getTabWnd( int index )const;
string getTabText( int index )const;
DECLARE_DYNAMIC( Tabber )
DECLARE_MESSAGE_MAP()
afx_msg void OnSize( UINT type,int w,int h );
afx_msg BOOL OnEraseBkgnd( CDC *dc );
afx_msg void tcn_selChange( NMHDR *p,LRESULT *result );
private:
TabberListener *listener;
struct Tab{
CWnd *wnd;
string text;
Tab( CWnd *w,const string &t ):wnd(w),text(t){
}
};
typedef list<Tab*> Tabs;
Tabs tabs;
int curr;
void refresh();
CRect getInnerRect();
Tab *getTab( int index )const;
};
#endif