gambas-source-code/main/lib/jit/gb.jit/.src/ClassStat.class
gambas 4e50dec11d Work continues on new JIT system. Translation is now done at runtime.
[INTERPRETER]
* OPT: String routines are now compiled with -O3.
* NEW: Don't display JIT debugging message unless GB_JIT_DEBUG is set to something different from zero.
* NEW: String whose length is greater than 256 now have a growth step of 256 bytes instead of 16.

[GB.JIT]
* NEW: Do many global optimizations as now the class metadata is fully available.
* NEW: Support for optional argument. Still buggy at the moment.
2018-06-09 22:42:35 +02:00

102 lines
2.1 KiB
Text

' Gambas class file
Static Public Name As String
Static Public Parent As String
Static Public HasFast As Boolean
Static Private $iSectionSize As Integer
Static Private $iSectionPos As Integer
Static Private Sub GotoNextSection(hFile As File)
$iSectionPos += $iSectionSize
Seek #hFile, $iSectionPos
$iSectionSize = Read #hFile As Integer
$iSectionPos += 4
End
Static Private Sub ReadZeroString(hFile As File) As String
Dim sStr As String
Dim iPos As Integer
Do
sStr &= Read #hFile, Min(16, Lof(hFile) - Seek(hFile))
iPos = InStr(sStr, Chr$(0))
If iPos Then Return Left(sStr, iPos - 1)
Loop
End
Static Public Sub Stat(sDir As String, sName As String)
Dim sPath As String
Dim hFile As File
Dim iVal As Integer
Dim iParent As Integer
Dim iFlag As Short
Dim bDebug As Boolean
Dim iStringPos As Integer
sPath = sDir &/ ".gambas" &/ UCase(sName)
If Not Exist(sPath) Then Error.Raise("Class not found: " & sPath)
$iSectionPos = 0
$iSectionSize = 0
hFile = Open sPath
Seek #hFile, 8
iVal = Read #hFile As Integer
If iVal <> &H12345678 Then hFile.ByteOrder = 1 - hFile.ByteOrder
Seek #hFile, 12
iVal = Read #hFile As Integer
bDebug = iVal And 1
$iSectionSize = 16
GotoNextSection(hFile) ' info
Seek #hFile, $iSectionPos
iParent = Read #hFile As Short
iFlag = Read #hFile As Short
'hStat.Exported = BTst(iFlag, 0)
'hStat.AutoCreate = BTst(iFlag, 1)
'hStat.Optional = BTst(iFlag, 2)
'hStat.NoCreate = BTst(iFlag, 3)
HasFast = BTst(iFlag, 4)
GotoNextSection(hFile) ' description
GotoNextSection(hFile) ' constant
GotoNextSection(hFile) ' reference
If iParent <> -1 Then
Seek #hFile, $iSectionPos + iParent * 4
iParent = Read #hFile As Integer
iParent = Abs(iParent)
Endif
Do
iStringPos = $iSectionPos
Try GotoNextSection(hFile)
If Error Then Break
Loop
Seek #hFile, iStringPos
Name = ReadZeroString(hFile)
If iParent > 0 Then
Seek #hFile, iStringPos + iParent
Parent = ReadZeroString(hFile)
Endif
Close hFile
End