diff --git a/docs/Help/Topics/command_BEGIN-CHECKED.xml b/docs/Help/Topics/command_BEGIN-CHECKED.xml index 5f61924490..a567ce7fdd 100644 --- a/docs/Help/Topics/command_BEGIN-CHECKED.xml +++ b/docs/Help/Topics/command_BEGIN-CHECKED.xml @@ -19,7 +19,7 @@ Purpose The BEGIN (UN)CHECKED and END (UN)CHECKED keywords mark a block of statements that are compiled with overflow checking enabled or disabled. Syntax - BEGIN CHECKED
  statements
END CHECKED

BEGIN UNCHECKED
  statements
END CHECKED
+ BEGIN CHECKED
  statements
END CHECKED

BEGIN UNCHECKED
  statements
END UNCHECKED
Arguments statements One or more statements or expressions that are compiled with the specified overflow checking diff --git a/docs/Help/Topics/command_BEGIN-USING.xml b/docs/Help/Topics/command_BEGIN-USING.xml index fc9b3a2751..0135a44419 100644 --- a/docs/Help/Topics/command_BEGIN-USING.xml +++ b/docs/Help/Topics/command_BEGIN-USING.xml @@ -17,7 +17,7 @@ The BEGIN USING and END USING keyword declare a block of code that ensures the correct use of disposable objects. Syntax - BEGIN USING declaration
  statements
END USING
+ BEGIN USING [AWAIT] declaration
  statements
END [USING]
Arguments declarationDeclaration of a variable and assignment that is visible only inside the statement block between BEGIN and END statements Code including one or more statements that may contain unsafe code. diff --git a/docs/Help/Topics/command_DELEGATE.xml b/docs/Help/Topics/command_DELEGATE.xml index be35d6d6e5..b5615d684c 100644 --- a/docs/Help/Topics/command_DELEGATE.xml +++ b/docs/Help/Topics/command_DELEGATE.xml @@ -18,6 +18,7 @@ [([<idParam> [AS | REF|OUT|IN <idType>] [, ...])] [AS <idType>] [TypeparameterConstraints] + [<idConvention>] Arguments <idDelegate>A valid identifier name for the delegate. Delegate names must be unique within a namespace. diff --git a/docs/Help/Topics/command_DO_WHILE.xml b/docs/Help/Topics/command_DO_WHILE.xml index d2917020a7..3eae663b77 100644 --- a/docs/Help/Topics/command_DO_WHILE.xml +++ b/docs/Help/Topics/command_DO_WHILE.xml @@ -26,7 +26,7 @@ <Statements>... [LOOP] <Statements>... - END[DO] + END [DO | WHILE] | ENDDO Arguments <lCondition>The logical control expression for the DO WHILE loop. diff --git a/docs/Help/Topics/command_ENUM.xml b/docs/Help/Topics/command_ENUM.xml index 63ce64501d..933efdac7d 100644 --- a/docs/Help/Topics/command_ENUM.xml +++ b/docs/Help/Topics/command_ENUM.xml @@ -15,8 +15,8 @@ Declare an enumeration to the compiler. Syntax [attributes] [Modifiers] - ENUM <idEnumName> [AS type]   - memberName [:= value] + ENUM <idEnumName> [AS | INHERIT type]   + [Attributes] [MEMBER] memberName [:= value]  [...] END [ENUM] diff --git a/docs/Help/Topics/command_FOR.xml b/docs/Help/Topics/command_FOR.xml index a48ad54b7f..b031005a35 100644 --- a/docs/Help/Topics/command_FOR.xml +++ b/docs/Help/Topics/command_FOR.xml @@ -19,7 +19,7 @@ Purpose Executes a block of statements a specified number of times. Syntax - FOR [<idCounter> := <nStart> | VAR <idCounter> := <nStart> | LOCAL <idCounter> := <nStart> AS <idType> ] [TO | UPTO | DOWNTO] <nEnd> [STEP <nDelta>]
  <Statements>...
  [EXIT]
  <Statements>...
  [LOOP]
NEXT
+ FOR <idCounter> := <nStart> | [LOCAL] IMPLIED <idCounter> := <nStart> | VAR <idCounter> := <nStart> | LOCAL <idCounter> := <nStart> [AS <idType>] TO | UPTO | DOWNTO <nEnd> [STEP <nDelta>]
  <Statements>...
  [EXIT]
  <Statements>...
  [LOOP]
NEXT | ENDFOR
Note In the FoxPro and Xbase++ dialect, ENDFOR is allowed as alternative for NEXT Arguments diff --git a/docs/Help/Topics/command_FOREACH.xml b/docs/Help/Topics/command_FOREACH.xml index 2d3e96902b..34e70173b4 100644 --- a/docs/Help/Topics/command_FOREACH.xml +++ b/docs/Help/Topics/command_FOREACH.xml @@ -19,7 +19,7 @@ Purpose Executes a block of statements for all elements in a collection. Syntax - FOREACH  [IMPLIED <idElement> | VAR <idElement> | <idElement> AS <idType>] IN <container>
  <Statements>...
  [EXIT]
  <Statements>...
  [LOOP]
NEXT
+ FOREACH [AWAIT] IMPLIED <idElement> | VAR <idElement> | <idElement> [AS <idType>] IN <container>
  <Statements>...
  [EXIT]
  <Statements>...
  [LOOP]
NEXT | ENDFOR
Note In the FoxPro dialect, FOR EACH is also allowed as two separate words. In the FoxPro and Xbase++ dialect, ENDFOR is allowed as an alternative for NEXT. diff --git a/docs/Help/Topics/command_IF.xml b/docs/Help/Topics/command_IF.xml index f70fb8f412..c00c574622 100644 --- a/docs/Help/Topics/command_IF.xml +++ b/docs/Help/Topics/command_IF.xml @@ -20,7 +20,7 @@ Purpose Conditionally executes a block of statements. Syntax - IF <lCondition> [THEN]
<Statements>...
[ELSEIF <lCondition>]
<Statements>...
[ELSE]
<Statements>...
END[IF]
+ IF <lCondition> [THEN]
<Statements>...
[ELSEIF <lCondition>]
<Statements>...
[ELSE]
<Statements>...
END [IF] | ENDIF
Arguments [THEN]The THEN keyword is optional and has been added because Visual FoxPro allows this keyword. diff --git a/docs/Help/Topics/command_NOP.xml b/docs/Help/Topics/command_NOP.xml index 638c3947e5..d05930deea 100644 --- a/docs/Help/Topics/command_NOP.xml +++ b/docs/Help/Topics/command_NOP.xml @@ -16,7 +16,7 @@ Purpose The NOP statement inserts an empty statement in the code Syntax - NOP + NOP [()] Remarks The NOP statement is an empty statement. It can be used to indicate that a certain code section is left intentionally empty Examples diff --git a/docs/Help/Topics/command_RETURN.xml b/docs/Help/Topics/command_RETURN.xml index aad7f5ba24..3c69fcb3a5 100644 --- a/docs/Help/Topics/command_RETURN.xml +++ b/docs/Help/Topics/command_RETURN.xml @@ -15,7 +15,7 @@ Purpose Terminates a routine by returning control to the calling routine or operating system if executed from the Start() routine. Syntax - RETURN [<uValue>] + RETURN [VOID | <uValue>] Arguments <uValue>May be specified in a function or method definition to designate its return value. Procedure definitions do not allow <uValue> as part of the RETURN statement. See the FUNCTION and METHOD entries in this guide for information about default return values if <uValue> is not specified. Description diff --git a/docs/Help/Topics/command_WITH.xml b/docs/Help/Topics/command_WITH.xml index 241272edd8..461e226c4e 100644 --- a/docs/Help/Topics/command_WITH.xml +++ b/docs/Help/Topics/command_WITH.xml @@ -9,7 +9,7 @@ Purpose Specifies multiple properties for an object. Syntax - WITH ObjectName
  [cStatements] or
[:Statements]
END WITH
+ WITH ObjectName [AS <idType>]
  [cStatements] or
[:Statements]
END [WITH] | ENDWITH
Arguments ObjectName Specifies the name of the object. ObjectName can be the name of the object or a reference to the object. diff --git a/src/Runtime/XSharp.RT/Functions/CompilerSupport.prg b/src/Runtime/XSharp.RT/Functions/CompilerSupport.prg index e21f7e1d17..06a0062f20 100644 --- a/src/Runtime/XSharp.RT/Functions/CompilerSupport.prg +++ b/src/Runtime/XSharp.RT/Functions/CompilerSupport.prg @@ -115,7 +115,8 @@ FUNCTION __FieldGetWa( area AS USUAL, fieldName AS STRING ) AS USUAL /// [NeedsAccessToLocals(FALSE)]; FUNCTION __FieldGetWa2(wa AS STRING, fldName AS STRING, lAllowUndeclared AS LOGIC) AS USUAL -LOCAL nArea := VoDbGetSelect(wa) AS DWORD + LOCAL nArea := VoDbGetSelect(wa) AS DWORD + LOCAL err := NULL as Error IF nArea != 0 RETURN __FieldGetWa(wa, fldName) ENDIF @@ -123,17 +124,24 @@ LOCAL nArea := VoDbGetSelect(wa) AS DWORD return IVarGet(uLocal, fldName) ENDIF local ok as LOGIC + local ex := NULL as Exception IF XSharp.MemVar.LocalFind("SELF", out uLocal, out var _) local oLocal := uLocal as object try var ivar := (OBJECT) IVarGet(oLocal, wa) // we do not use IVarGet because we also want to support static fields and properties var res := _GetValue(ivar:GetType(), ivar) - if ok - return res - endif - catch as Exception - nop + if ok + return res + endif + err := Error{EG_NOVAR, nameof(fldName), ErrString(EG_NOVAR) + ": " + fldName} + err:FuncSym := __function__ + err:ArgNum := 2 + err:Args := {wa, fldName} + THROW err + + catch e as Exception + ex := e end try ENDIF if (lAllowUndeclared) @@ -154,14 +162,26 @@ LOCAL nArea := VoDbGetSelect(wa) AS DWORD IF Globals.Get(wa, OUT var uGlobal) return IVarGet(uGlobal, fldName) ENDIF + if ex != null + throw ex + endif - VAR err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa} + err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa} err:FuncSym := __function__ err:ArgNum := 2 err:Args := {wa, fldName} THROW err LOCAL FUNCTION _GetValue(oType as System.Type, oObject as object) as USUAL ok := TRUE + if oObject is IDynamicProperties var oDynamic + try + return oDynamic:NoIvarGet(fldName) + CATCH as Exception + ok := FALSE + RETURN NIL + end try + endif + var mem := OOPHelpers.GetFieldOrProperty(oType, fldName) if mem is FieldInfo var fld if ! fld:IsPublic @@ -215,6 +235,7 @@ FUNCTION __FieldSetWa( area AS USUAL, fieldName AS STRING, uValue AS USUAL ) AS [NeedsAccessToLocals(FALSE)]; FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUndeclared AS LOGIC) AS USUAL LOCAL nArea := VoDbGetSelect(wa) AS DWORD + LOCAL err := NULL as Error IF nArea != 0 LOCAL nOldArea := RuntimeState.CurrentWorkarea AS DWORD TRY @@ -252,6 +273,13 @@ FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUn catch as Exception nop end try + err := Error{EG_NOVAR, nameof(fldName), ErrString(EG_NOVAR) + ": " + fldName} + err:FuncSym := __function__ + err:ArgNum := 2 + err:Args := {wa, fldName} + THROW err + + ENDIF if (lAllowUndeclared) @@ -271,13 +299,20 @@ FUNCTION __FieldSetWa2(wa AS STRING, fldName AS STRING, uValue AS USUAL,lAllowUn IF Globals.Get(wa, OUT var uGlobal) return IVarPut(uGlobal, fldName, uValue) ENDIF - - VAR err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa} + err := Error{EG_NOVAR, nameof(wa), ErrString(EG_NOVAR) + ": " + wa} err:FuncSym := __function__ err:ArgNum := 2 err:Args := {wa, fldName} THROW err LOCAL FUNCTION _SetValue(oType as System.Type, oObject as object, uValue as USUAL) as LOGIC + if oObject is IDynamicProperties var oDynamic + TRY + oDynamic:NoIvarPut(fldName, uValue) + return true + CATCH as Exception + return false + END TRY + endif var mem := OOPHelpers.GetFieldOrProperty(oType, fldName) if mem is FieldInfo var fld var oValue := OOPHelpers.ValueConvert(uValue, fld:FieldType)