[DEVELOPMENT ENVIRONMENT]
* BUG: Function signatures now support the new syntax that allows to put braces around arguments to let the compiler ignore them. git-svn-id: svn://localhost/gambas/trunk@5126 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
28c9d6d59b
commit
8059e72f19
1 changed files with 83 additions and 62 deletions
|
@ -230,20 +230,73 @@ End
|
||||||
|
|
||||||
Private Sub MakeSignature(sSign As String) As String
|
Private Sub MakeSignature(sSign As String) As String
|
||||||
|
|
||||||
|
Dim aSym As String[]
|
||||||
Dim iInd As Integer
|
Dim iInd As Integer
|
||||||
Dim aWait As New String[]
|
Dim aWait As New String[]
|
||||||
Dim bOptional As Boolean
|
Dim bOptional As Boolean
|
||||||
Dim sSym As String
|
Dim sSym As String
|
||||||
Dim sType As String
|
Dim sType As String
|
||||||
Dim sDefault As String
|
Dim sDefault As String
|
||||||
|
Dim bByRef As Boolean
|
||||||
|
Dim iPos, iPos2 As Integer
|
||||||
|
Dim sResult As String
|
||||||
|
|
||||||
Highlight.Analyze(sSign)
|
Highlight.Analyze(sSign)
|
||||||
sSign = ""
|
aSym = Highlight.Symbols
|
||||||
|
|
||||||
For iInd = 0 To Highlight.Symbols.Max
|
Do
|
||||||
|
|
||||||
sSym = Highlight.Symbols[iInd]
|
If iInd > aSym.Max Then Break
|
||||||
|
|
||||||
|
sSym = aSym[iInd]
|
||||||
|
|
||||||
|
If sSym = "..." Then
|
||||||
|
sResult &= "."
|
||||||
|
Break
|
||||||
|
Endif
|
||||||
|
|
||||||
|
If UCase(sSym) = "OPTIONAL" Then
|
||||||
|
If Not bOptional Then
|
||||||
|
sResult &= "["
|
||||||
|
bOptional = True
|
||||||
|
Endif
|
||||||
|
Inc iInd
|
||||||
|
sSym = aSym[iInd]
|
||||||
|
Endif
|
||||||
|
|
||||||
|
bByRef = False
|
||||||
|
If UCase(sSym) = "BYREF" Then
|
||||||
|
bByRef = True
|
||||||
|
Inc iInd
|
||||||
|
sSym = aSym[iInd]
|
||||||
|
Endif
|
||||||
|
|
||||||
|
If sSym = "(" And If aSym[iInd + 2] = ")" Then
|
||||||
|
sSym = aSym[iInd + 1]
|
||||||
|
iInd += 2
|
||||||
|
Endif
|
||||||
|
|
||||||
|
If bByRef Then sSym = "&" & sSym
|
||||||
|
|
||||||
|
Inc iInd
|
||||||
|
If aSym[iInd] <> "AS" Then Break
|
||||||
|
|
||||||
|
Inc iInd
|
||||||
|
sType = aSym[iInd]
|
||||||
|
If $cNameType.Exist(sType) Then
|
||||||
|
sType = $cNameType[sType]
|
||||||
|
Else
|
||||||
|
sType = UCase(Left(sType)) & Mid$(sType, 2) & ";"
|
||||||
|
Endif
|
||||||
|
sResult &= "(" & sSym & ")" & sType
|
||||||
|
|
||||||
|
If bOptional And If iInd < aSym.Max Then
|
||||||
|
If aSym[iInd + 1] = "=" Then
|
||||||
|
iInd += 2
|
||||||
|
sDefault = ""
|
||||||
|
iPos = Highlight.Positions[iInd]
|
||||||
|
While iInd < aSym.Max
|
||||||
|
sSym = aSym[iInd]
|
||||||
If sSym = "(" Then
|
If sSym = "(" Then
|
||||||
aWait.Push(")")
|
aWait.Push(")")
|
||||||
Else If sSym = "[" Then
|
Else If sSym = "[" Then
|
||||||
|
@ -253,62 +306,30 @@ Private Sub MakeSignature(sSign As String) As String
|
||||||
aWait.Pop
|
aWait.Pop
|
||||||
Endif
|
Endif
|
||||||
Else
|
Else
|
||||||
|
If sSym = ")" Or If sSym = "," Then
|
||||||
If iInd > 0 And If sSym <> "," Then Continue
|
iPos2 = Highlight.Positions[iInd]
|
||||||
|
sDefault = Trim(Mid$(sSign, iPos + 1, iPos2 - iPos))
|
||||||
If iInd Then
|
Dec iInd
|
||||||
Inc iInd
|
|
||||||
sSym = Highlight.Symbols[iInd]
|
|
||||||
Endif
|
|
||||||
|
|
||||||
If sSym = "..." Then
|
|
||||||
sSign &= "."
|
|
||||||
Break
|
Break
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If UCase(sSym) = "OPTIONAL" Then
|
|
||||||
If Not bOptional Then
|
|
||||||
sSign &= "["
|
|
||||||
bOptional = True
|
|
||||||
Endif
|
Endif
|
||||||
Inc iInd
|
Inc iInd
|
||||||
sSym = Highlight.Symbols[iInd]
|
Wend
|
||||||
|
sResult &= "=" & sDefault & "\t"
|
||||||
|
Endif
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If UCase(sSym) = "BYREF" Then
|
|
||||||
Inc iInd
|
Inc iInd
|
||||||
sSym = "&" & Highlight.Symbols[iInd]
|
If iInd > aSym.Max Then Break
|
||||||
Endif
|
sSym = aSym[iInd]
|
||||||
|
If sSym <> "," Then Break
|
||||||
|
Inc iInd
|
||||||
|
|
||||||
iInd += 2
|
Loop
|
||||||
sType = Highlight.Symbols[iInd]
|
|
||||||
If $cNameType.Exist(sType) Then
|
|
||||||
sType = $cNameType[sType]
|
|
||||||
Else
|
|
||||||
sType = UCase(Left(sType)) & Mid$(sType, 2) & ";"
|
|
||||||
Endif
|
|
||||||
sSign &= "(" & sSym & ")" & sType
|
|
||||||
|
|
||||||
If bOptional And If iInd < Highlight.Symbols.Max Then
|
If bOptional Then sResult &= "]"
|
||||||
If Highlight.Symbols[iInd + 1] = "=" Then
|
|
||||||
iInd += 2
|
|
||||||
sDefault = Highlight.Symbols[iInd]
|
|
||||||
If Highlight.Types[iInd] = Highlight.Keyword Then
|
|
||||||
If Not Settings["/Editor/KeywordsUseUpperCase"] Then
|
|
||||||
Mid$(sDefault, 2) = LCase(Mid$(sDefault, 2))
|
|
||||||
Endif
|
|
||||||
Endif
|
|
||||||
sSign &= "=" & sDefault & "\t"
|
|
||||||
Endif
|
|
||||||
Endif
|
|
||||||
|
|
||||||
Endif
|
Return sResult
|
||||||
|
|
||||||
Next
|
|
||||||
|
|
||||||
If bOptional Then sSign &= "]"
|
|
||||||
|
|
||||||
Return sSign
|
|
||||||
|
|
||||||
Catch
|
Catch
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue