1 Star 2 Fork 0

VB7编译器 / Newbie Compiler Visual Basic 7.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mAllType.bas 8.66 KB
一键复制 编辑 原始数据 按行查看 历史
Attribute VB_Name = "mAllType"
Option Explicit
'==========================================================
'重定位信息 描述数据
Public Type ty_RelocKey
offset As Long
pointOffset As Long
pointBase As Long
End Type
Public Type ty_Reloc
list() As ty_RelocKey
lCount As Long
thisBase As Long
name As String
End Type
''----------------------------
''输入表/导入表目录
'Public Type IMAGE_IMPORT_DESCRIPTOR
' Characteristics As Long 'or OriginalFirstThunk
' TimeDateStamp As Long '0:无联编,-1: (静态联编/动态联编)
' ForwarderChain As Long
' Name As Long
' FirstThunk As Long
'End Type
'Public Type IMPORT_dll
' dllName As String
' pFunName() As String
' pVirAddr() As Long
' pFunOrd() As Integer
' tagIndex() As Long 'call [tagindex]
'End Type
'============================树============================
Private Enum enCodeType
e_CoNull
e_CoCompi
e_CoFun
End Enum
'是函数/过程/变量/.......枚举,结构体等等等等
Public Enum enAreaType '描述变量
'独立
e_OnlyVarParamByval = 1 '函数内 参数 传值
e_OnlyVarParamByref = 2 '函数内 参数 传引用
e_OnlyVarStatic = 3 '函数内 静态变量
e_OnlyVarFun = 4 '函数内 普通变量
'组合模式 A
e_isVar = &H10
e_isDeclareFun = &H20 '
e_isDeclareSub = &H40
e_isFun = &H80
e_isSub = &H100
'组合模式 B
e_isPrivate = 0 'A OR B 得到最终效果
e_isPublic = &H80000 '
End Enum
Public Enum enMoudleType
en_Frm
en_Mod
en_cls
End Enum
'作用域/传值方式
'多维数组
Public Type tyVarArray
l As Long
u As Long
End Type
'变量
Public Type tyVariable
name As String
VarDataType As String '类型 "long","byte"
VarIsArray As Boolean
VarArray() As tyVarArray
VarArrayCount As Long
VarDefaultValue As String '默认值,这里可以是复杂表达式,所以最好后期改成数组
'遇到多重赋值的时候,最好在dim 判断的时候 自动加入未定义变量,避免出现
' dim xx as long = yy '使用了未定义的数据
' dim yy = 100 '应该报错:已经定义过
aAreaType As enAreaType
nameImp As String
DeclareDllName As String
'扩展
MemoryAddr As Long '内存地址
MemorySize As Long '内存大小
'变量访问方式??? 堆?栈?
'aType As enManagerVar '访问方式
End Type
Public Type tyTreeFunction '函数内部级
name As String '函数名
VarDataType As String '返回类型
VarIsArray As Boolean
VarArray() As tyVarArray
VarArrayCount As Long
VarDefaultValue As String
aAreaType As enAreaType
nameImp As String
DeclareDllName As String
param() As tyVariable '参数
paramCount As Long
'aType As enFunOrSub '函数/过程/变量/......
mCodeIndex As Long
mCodeSize As Long
MemoryAddr As Long '内存地址
MemorySize As Long '内存大小
AddressTagIndex As Long '外部互相访问跳转用,地址/和汇编类相关
End Type
Public Type tyTreeMoudle '类/模块级
name As String
aType As enMoudleType
OptionExplicit As Boolean '强制声明
pCode() As String
'列表
'函数/过程 声明函数/声明过程 变量/对象
ListFun() As tyTreeFunction
ListFunCount As Long
End Type
Public Type tyTree '工程内,全局 //全局树增加其他管理器....看在哪一级增加
name As String
aType As enMoudleType
aAreaType As enAreaType
pList() As tyTreeMoudle
lCount As Long
'工程级的重定位.整个工程级一块编译.(如果是文件级的就说明文件一起编译)
' CodeReloc As ty_Reloc
' VarReloc As ty_Reloc
End Type
'============================变量管理器==========================
'变量管理器的域
'文件级变量管理器
Public Type tyTManagerVar
name As String '文件名
list() As tyTreeFunction 'tyVariable
Count As Long
CountMemorySize As Long
bInFun As Boolean '函数内变量管理器标志
End Type
'---------------
'词/元素 类型
Public Enum enWordType
enWord_null
enWord_num
enWord_str
enWord_time
enWord_key
enWord_var '已经定义的 函数,对象.声明,结构体....
enWord_var_nodim
enWord_crlf
enWord_symbol
enWord_function
End Enum
'==========================================
'工程vbp解析->模块文件类型
'Public Enum en_MODEFILE
' en_Moudle
' en_cls
' en_Form
'End Enum
Public Enum en_BUILD
en_EXE
en_DLL
End Enum
Public Type ty_MODFILE
name As String
FileName As String
ltype As enMoudleType
End Type
Public Type ty_Project
list() As ty_MODFILE
lCount As Long
build As en_BUILD
ExeName32 As String '生成文件
Startup As String '启动函数
End Type
'--------------------------
Public Type ty_TagArray '这个地址配合编译对象使用......
pTag() As Long
pOffsetAddr() As Long
lCount As Long 'tag地址表
BlockSize As Long '块大小
BaseAddr As Long
a As clsASM
StartOffset As Long
EndOffset As Long '多个块合并的时候,这个存大小
End Type
Public Type ty_CompileBlock
asm As ty_TagArray '.text 代码区
data As ty_TagArray '.data 数据区
rdata As ty_TagArray '.rdata 只读数据区
End Type
'=============================================================
'*************************TAG使用管理器*************************
Public Const FUN_TAGINDEX_FUNC_L = &H1010000
Public Const FUN_TAGINDEX_FUNC_U = &H1FF0000
Public Const FUN_TAGINDEX_DATA_L = &H2010000
Public Const FUN_TAGINDEX_DATA_U = &H2FF0000
Public Const FUN_TAGINDEX_RDAT_L = &H3010000
Public Const FUN_TAGINDEX_RDAT_U = &H3FF0000
'TAG使用管理器,已经使用了哪些地址了(序号的管理现在看来没必要这么严格,可能以后用到)
Private Type ty_TagIndexManager
codeCount As Long
codelist() As Long '专门给代码中地址赋值 01 010000 - 01 FF 0000
' 先给每个函数地址初设定一个地址
' 编译的时候 再根据汇编给地址一个地址
DataCount As Long
DataList() As Long '专门给数据类型 02 010000 - 02 FF 0000
rdataCount As Long
rdataList() As Long
End Type
Dim MyProTagMagager As ty_TagIndexManager '这个用类更好,这样也可以
'--------------------------------------------------------------
'*************************TAG使用管理器*************************
Public Sub TagManagerInit()
MyProTagMagager.codeCount = 0
ReDim MyProTagMagager.codelist(MyProTagMagager.codeCount)
MyProTagMagager.DataCount = 0
ReDim MyProTagMagager.DataList(MyProTagMagager.DataCount)
MyProTagMagager.rdataCount = 0
ReDim MyProTagMagager.rdataList(MyProTagMagager.rdataCount)
End Sub
Public Function TagManagerCodeGetFreeIndex() As Long '
Dim i&, j&
For i = FUN_TAGINDEX_FUNC_L To FUN_TAGINDEX_FUNC_U
For j = 1 To MyProTagMagager.codeCount
If MyProTagMagager.codelist(j) = i Then
Exit For
End If
Next
If j > MyProTagMagager.codeCount Then '没找到,就用这个了
MyProTagMagager.codeCount = MyProTagMagager.codeCount + 1
ReDim Preserve MyProTagMagager.codelist(MyProTagMagager.codeCount)
MyProTagMagager.codelist(MyProTagMagager.codeCount) = i
TagManagerCodeGetFreeIndex = i
Exit Function
End If
Next
Debug.Assert False '序号总数不够
End Function
Public Function TagManagerDataGetFreeIndex() As Long '
Dim i&, j&
For i = FUN_TAGINDEX_DATA_L To FUN_TAGINDEX_DATA_U
For j = 1 To MyProTagMagager.DataCount
If MyProTagMagager.DataList(j) = i Then
Exit For
End If
Next
If j > MyProTagMagager.DataCount Then '没找到,就用这个了
MyProTagMagager.DataCount = MyProTagMagager.DataCount + 1
ReDim Preserve MyProTagMagager.DataList(MyProTagMagager.DataCount)
MyProTagMagager.DataList(MyProTagMagager.DataCount) = i
TagManagerDataGetFreeIndex = i
Exit Function
End If
Next
Debug.Assert False '序号总数不够
End Function
Public Function TagManagerRDataGetFreeIndex() As Long '
Dim i&, j&
For i = FUN_TAGINDEX_RDAT_L To FUN_TAGINDEX_RDAT_U
For j = 1 To MyProTagMagager.rdataCount
If MyProTagMagager.rdataList(j) = i Then
Exit For
End If
Next
If j > MyProTagMagager.rdataCount Then '没找到,就用这个了
MyProTagMagager.rdataCount = MyProTagMagager.rdataCount + 1
ReDim Preserve MyProTagMagager.rdataList(MyProTagMagager.rdataCount)
MyProTagMagager.rdataList(MyProTagMagager.rdataCount) = i
TagManagerRDataGetFreeIndex = i
Exit Function
End If
Next
Debug.Assert False '序号总数不够
End Function
'---------------------------------------------
Visual Basic
1
https://gitee.com/basic7/Newbie-Compiler-Visual-Basic-7.0.git
git@gitee.com:basic7/Newbie-Compiler-Visual-Basic-7.0.git
basic7
Newbie-Compiler-Visual-Basic-7.0
Newbie Compiler Visual Basic 7.0
master

搜索帮助