📄 modmain.bas
字号:
StringToStore = StringToStore & "--" & FunctionToExecute
Else
StringToStore = StringToStore & FunctionToExecute & "=" & FunctionToExecute & FunctionParm
End If
End Select
Else
StringToStore = StringToStore & FunctionToExecute & "=" & FunctionToExecute & "+" & FunctionParm
End If
WriteTerm StringToStore & ")" & vbNewLine & AddNested & "{" & vbNewLine
Nested = Nested + 1
Case "NEXT"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
Nested = Nested - 1
WriteTerm AddNested & "}" & vbNewLine
Case "DECLARE"
' APIs declaration already handled in Pass 1
Case "DIM"
GoTo PassLine
Case "GOTO"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetEntity
' Branch to line numbers
If IsNumeric(CurrentEntity) Then CurrentEntity = CurrentNested & "_" & CurrentEntity
WriteTerm AddNested & GetGoto(CurrentEntity) & vbNewLine
Case "GOSUB"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetEntity
' Branch to line numbers
If IsNumeric(CurrentEntity) Then CurrentEntity = CurrentNested & "_" & CurrentEntity
' Write an assembly call to subroutine
WriteTerm AddNested & GetAsmCall(CurrentEntity) & vbNewLine
OldGoSubLabel(UBound(OldGoSubLabel())) = CurrentEntity
ReDim Preserve OldGoSubLabel(UBound(OldGoSubLabel()) + 1)
Case "RETURN"
If UBound(OldGoSubLabel()) <= 0 Then
DisplayWarning "Return without GoSub"
Else
WriteTerm AddNested & GetAsmReturn & vbNewLine
ReDim Preserve OldGoSubLabel(UBound(OldGoSubLabel()) - 1)
End If
Case "EXIT"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetEntity
Select Case UCase(CurrentEntity)
Case "FUNCTION"
WriteTerm AddNested & GetGoto(CurrentNested & "_return;") & vbNewLine
Case "SUB"
WriteTerm AddNested & GetGoto(CurrentNested & "_return;") & vbNewLine
Case "FOR"
WriteTerm AddNested & GetBreak & vbNewLine
Case "DO"
WriteTerm AddNested & GetBreak & vbNewLine
End Select
Case "ELSEIF"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
If ElseIfCase = False Then
Nested = Nested - 1
WriteTerm AddNested & "}" & vbNewLine
End If
WriteTerm AddNested & "else " & vbNewLine
WriteTerm AddNested & "{" & vbNewLine
Nested = Nested + 1
ElseIfCase = True ' Involving elseif
GoTo EmulIf
Case "IF"
ElseIfCase = False
EmulIf: If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetExpressionHunt " THEN"
IfCommand = "if"
PerformIf: InvertedIF = False
PerformIfInverted: ArgumentsConversion = ""
FunctionToExecute = "if"
InStringComp = 0
InStringSelectSave = InStringSelect
InStringSelect = 0
InStringSelectCase = False
WasStringCmp = False
FunctionParm = Parse(FunctionToExecute, CurrentExpr, True, False, False, False, False, False, False, False, False, InvertedIF, False)
InStringSelect = InStringSelectSave
IfString = ""
WriteTerm ArgumentsConversion
IfString = IfString & FunctionParm
' Still something on the line ?
If lstrcmpi(CurrentChar, "N") = 0 Then
ReadChar
StripBlank
If IsComment(CurrentChar) Then
ReadChar
GetExpression
CurrentExpr = GetSingleLineComment & CurrentExpr
WriteTerm AddNested & IfCommand & CorrectParentheses("(" & IfString & ")") & " " & CurrentExpr & vbNewLine & AddNested & "{" & vbNewLine
Nested = Nested + 1
GoTo PassLine
End If
If lstrlen(CurrentChar) <> 0 Then
StripBlank
GetExpression
OutModuleString = CurrentExpr
WriteTerm AddNested & IfCommand & CorrectParentheses("(" & IfString & ")") & vbNewLine & AddNested & "{" & vbNewLine
SingleIf = SingleIf + 1
Nested = Nested + 1
' Push to next instruction
GoTo PushBack
End If
End If
WriteTerm AddNested & IfCommand & CorrectParentheses("(" & IfString & ")") & vbNewLine & AddNested & "{" & vbNewLine
Nested = Nested + 1
Case "ELSE"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
If ElseIfCase = False Then
If Nested > 1 Then Nested = Nested - 1
WriteTerm AddNested & "}" & vbNewLine
End If
WriteTerm AddNested & "else" & vbNewLine
WriteTerm AddNested & "{" & vbNewLine
Nested = Nested + 1
Case "WITH"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetExpression
OldWithVar(UBound(OldWithVar())) = CurrentExpr
ReDim Preserve OldWithVar(UBound(OldWithVar()) + 1)
CurrentWith = CurrentExpr
WithNumber = WithNumber + 1
Case "SELECT"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
StripBlank
GetEntity
If lstrcmpi(CurrentEntity, "CASE") <> 0 Then
If StopAtError = True Then
Panic "*** Error: CASE statement expected at line: " & CurrentModLine & ".\n"
WriteText "*** " & CurrentModuleLine & "\n"
GoTo StopAll
Else
DisplayError "CASE statement expected"
GoTo PassLine
End If
End If
StripBlank
GetExpression
ArgumentsConversion = ""
FunctionToExecute = "if"
InStringComp = 0
InStringSelect = 0
InStringSelectCase = False
InStringSelectVar = CurrentExpr
WasStringCmp = False
FunctionParm = Parse(FunctionToExecute, CurrentExpr, True, False, False, False, False, False, False, False, False, False, False)
WriteTerm ArgumentsConversion
OldSelectCaseVar(UBound(OldSelectCaseVar())) = CorrectParentheses(FunctionParm)
ReDim Preserve OldSelectCaseVar(UBound(OldSelectCaseVar()) + 1)
OldSelectCase(UBound(OldSelectCase())) = False
ReDim Preserve OldSelectCase(UBound(OldSelectCase()) + 1)
CaseNumber = 0
CurrentSelectCaseFunc = CurrentNested
Nested = Nested + 1
Case "CASE"
If InTypeDef = True Then GoTo PassLine
If InEnumDef = True Then GoTo PassLine
If OldSelectCase(UBound(OldSelectCase()) - 1) = True Then
Nested = Nested - 1
WriteTerm AddNested & "}" & vbNewLine
Else
Nested = Nested - 1
End If
InSelectCase = True
StripBlank
CaseNumber = CaseNumber + 1
GetEntity
CaseIs = "=" ' Default comparison
If lstrcmpi(CurrentEntity, "IS") = 0 Then
StripBlank
GetEntity
CaseIs = CurrentEntity
CurrentEntity = ""
End If
If UCase(left(CurrentEntity, 4)) = "ELSE" Then
WriteTerm AddNested & "else" & vbNewLine & AddNested & "{" & vbNewLine
Nested = Nested + 1
GoTo PassLine
End If
GetExpression
If UCase(left(CurrentExpr, 4)) = "ELSE" Then
WriteTerm AddNested & "else" & vbNewLine & AddNested & "{" & vbNewLine
Nested = Nested + 1
GoTo PassLine
End If
If OldSelectCase(UBound(OldSelectCase()) - 1) = False Then
TemporarySelectsSave = OldSelectCaseVar(UBound(OldSelectCaseVar()) - 1)
OldSelectCaseVar(UBound(OldSelectCaseVar()) - 1) = "SelectTempVar" & TemporarySelects
End If
CurrentExpr = OldSelectCaseVar(UBound(OldSelectCaseVar()) - 1) & " " & CaseIs & " " & CurrentEntity & CurrentExpr
ArgumentsConversion = ""
FunctionToExecute = "if"
InStringSelectCase = True
FunctionParm = Parse(FunctionToExecute, CurrentExpr, True, False, False, False, False, False, False, False, False, False, False)
If OldSelectCase(UBound(OldSelectCase()) - 1) = False Then
If InStr(1, FunctionParm, "(VBComp)", vbTextCompare) <> 0 Then
ForceCaseString: WriteInVar "char *SelectTempVar" & TemporarySelects & "=0;" & vbNewLine
WriteTerm AddNested & "if (" & "SelectTempVar" & TemporarySelects & ") { free((void *)" & "SelectTempVar" & TemporarySelects & "); }" & vbNewLine
WriteTerm AddNested & "SelectTempVar" & TemporarySelects & "=" & "strdup(" & TemporarySelectsSave & ");" & vbNewLine
AddVariable "SelectTempVar" & TemporarySelects, VAR_STRING, "", "", False, VARTYPE_NORM, False, "", False, ""
' Register it as temporary variable
'VarToFree(UBound(VarToFree())) = "SelectTempVar" & TemporarySelects
'ReDim Preserve VarToFree(UBound(VarToFree()) + 1)
Else
CaseVarFound = IsVariable(TemporarySelectsSave, 0, VARSEARCH_LOCALGLOBAL)
If CaseVarFound <> -1 Then If VariablesTypes(CaseVarFound) = VAR_STRING Then GoTo ForceCaseString
CaseVarFound = IsSimpleElement(TemporarySelectsSave, True)
If CaseVarFound = VAR_STRING Then GoTo ForceCaseString
If CaseVarFound = VAR_INSIDEDOUBLE Then GoTo ForceCaseString
If CaseVarFound = VAR_INSIDEL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -