Skip to content

Commit

Permalink
[Runtime] Fix for ExecScript problem. ExecScript now calls the new sc…
Browse files Browse the repository at this point in the history
…ript compiler. Added ExecScriptSlow() to compile with Roslyn. Fixes #1646
  • Loading branch information
RobertvanderHulst committed Dec 3, 2024
1 parent 9b5e091 commit 6df43e3
Showing 1 changed file with 56 additions and 51 deletions.
107 changes: 56 additions & 51 deletions src/Runtime/XSharp.RT/Functions/Macro.prg
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ INTERNAL FUNCTION _IsIdentifierStartChar(cChar AS CHAR) AS LOGIC
ENDIF
VAR cat := CharUnicodeInfo.GetUnicodeCategory(cChar)
SWITCH cat
CASE UnicodeCategory.UppercaseLetter
CASE UnicodeCategory.LowercaseLetter
CASE UnicodeCategory.TitlecaseLetter
CASE UnicodeCategory.ModifierLetter
CASE UnicodeCategory.OtherLetter
CASE UnicodeCategory.LetterNumber
RETURN TRUE
CASE UnicodeCategory.UppercaseLetter
CASE UnicodeCategory.LowercaseLetter
CASE UnicodeCategory.TitlecaseLetter
CASE UnicodeCategory.ModifierLetter
CASE UnicodeCategory.OtherLetter
CASE UnicodeCategory.LetterNumber
RETURN TRUE
END SWITCH
RETURN FALSE

Expand All @@ -142,13 +142,13 @@ INTERNAL FUNCTION _IsIdentifierPartChar(cChar AS CHAR) AS LOGIC
ENDIF
VAR cat := CharUnicodeInfo.GetUnicodeCategory(cChar)
SWITCH cat
CASE UnicodeCategory.DecimalDigitNumber
CASE UnicodeCategory.ConnectorPunctuation
CASE UnicodeCategory.NonSpacingMark
CASE UnicodeCategory.SpacingCombiningMark
RETURN TRUE
CASE UnicodeCategory.Format
RETURN cChar > 127
CASE UnicodeCategory.DecimalDigitNumber
CASE UnicodeCategory.ConnectorPunctuation
CASE UnicodeCategory.NonSpacingMark
CASE UnicodeCategory.SpacingCombiningMark
RETURN TRUE
CASE UnicodeCategory.Format
RETURN cChar > 127
END SWITCH
RETURN FALSE

Expand Down Expand Up @@ -196,9 +196,9 @@ FUNCTION Type(cString AS STRING, nArray AS LONG) AS STRING

CATCH AS Exception
IF RuntimeState.Dialect == XSharpDialect.FoxPro
cRet := "U"
cRet := "U"
ELSE
cRet := "UE"
cRet := "UE"
ENDIF
END TRY
ENDIF
Expand Down Expand Up @@ -250,42 +250,42 @@ FUNCTION StrEvaluate( cString AS STRING ) AS STRING
FOREACH VAR cChar IN cString
lAddChar := TRUE
SWITCH cChar
CASE c'&'
IF lInVariable
evalMacro := TRUE
ELSE
cVariableName := ""
ENDIF
lInVariable := TRUE
CASE c'&'
IF lInVariable
evalMacro := TRUE
ELSE
cVariableName := ""
ENDIF
lInVariable := TRUE
lAddChar := FALSE
CASE c' '
CASE c'\t'
IF lInVariable
lInVariable := FALSE
evalMacro := TRUE
ENDIF
CASE c'.'
IF lInVariable
lInVariable := FALSE
evalMacro := TRUE
lAddChar := FALSE
CASE c' '
CASE c'\t'
IF lInVariable
lInVariable := FALSE
evalMacro := TRUE
ENDIF
CASE c'.'
IF lInVariable
ENDIF
OTHERWISE
IF lInVariable
LOCAL lIsNameChar AS LOGIC
IF cVariableName:Length == 0
lIsNameChar := _IsIdentifierStartChar(cChar)
ELSE
lIsNameChar := _IsIdentifierPartChar(cChar)
END IF
IF lIsNameChar
cVariableName += cChar:ToString()
lAddChar := FALSE
ELSE
lInVariable := FALSE
evalMacro := TRUE
lAddChar := FALSE
ENDIF
OTHERWISE
IF lInVariable
LOCAL lIsNameChar AS LOGIC
IF cVariableName:Length == 0
lIsNameChar := _IsIdentifierStartChar(cChar)
ELSE
lIsNameChar := _IsIdentifierPartChar(cChar)
END IF
IF lIsNameChar
cVariableName += cChar:ToString()
lAddChar := FALSE
ELSE
lInVariable := FALSE
evalMacro := TRUE
ENDIF
ENDIF
ENDIF
END SWITCH
IF evalMacro
VAR result := StrEvaluateMemVarGet(cVariableName)
Expand Down Expand Up @@ -313,9 +313,9 @@ INTERNAL FUNCTION StrEvaluateMemVarGet(cVariableName AS STRING) AS STRING
oMemVar := XSharp.MemVar.PublicFind(cVariableName)
ENDIF
IF oMemVar != NULL
IF oMemVar:Value:IsString
IF oMemVar:Value:IsString
RETURN oMemVar:Value:ToString()
ENDIF
ENDIF
ENDIF
CATCH
// Memvar not found ?
Expand Down Expand Up @@ -348,10 +348,14 @@ INTERNAL FUNCTION GetCompany(asm AS System.Reflection.Assembly) AS STRING
RETURN NULL


INTERNAL GLOBAL _fullMacroCompiler AS Assembly
INTERNAL GLOBAL _fullMacroCompiler AS Assembly

/// <include file="VFPDocs.xml" path="Runtimefunctions/execscript/*" />
FUNCTION ExecScript( cExpression, eParameter1, eParameter2, eParameterN ) AS USUAL CLIPPER
RETURN ExecScriptFast(cExpression, eParameter1, eParameter2, eParameterN )

/// <include file="VFPDocs.xml" path="Runtimefunctions/execscript/*" />
FUNCTION ExecScriptSlow( cExpression, eParameter1, eParameter2, eParameterN ) AS USUAL CLIPPER
LOCAL result := NIL AS USUAL
XSharp.RuntimeState.LastScriptError := NULL
TRY
Expand Down Expand Up @@ -428,3 +432,4 @@ FUNCTION ExecScriptFast( cExpression, eParameter1, eParameter2, eParameterN ) AS
RETURN result



0 comments on commit 6df43e3

Please sign in to comment.