|
@@ -79,6 +79,7 @@ const
|
|
nParserNoConstRangeAllowed = 2052;
|
|
nParserNoConstRangeAllowed = 2052;
|
|
nErrRecordVariablesNotAllowed = 2053;
|
|
nErrRecordVariablesNotAllowed = 2053;
|
|
nParserResourcestringsMustBeGlobal = 2054;
|
|
nParserResourcestringsMustBeGlobal = 2054;
|
|
|
|
+ nParserOnlyOneVariableCanBeAbsolute = 2055;
|
|
|
|
|
|
// resourcestring patterns of messages
|
|
// resourcestring patterns of messages
|
|
resourcestring
|
|
resourcestring
|
|
@@ -136,6 +137,7 @@ resourcestring
|
|
SParserExpectedExternalClassName = 'Expected external class name';
|
|
SParserExpectedExternalClassName = 'Expected external class name';
|
|
SParserNoConstRangeAllowed = 'Const ranges are not allowed';
|
|
SParserNoConstRangeAllowed = 'Const ranges are not allowed';
|
|
SParserResourcestringsMustBeGlobal = 'Resourcestrings can be only static or global';
|
|
SParserResourcestringsMustBeGlobal = 'Resourcestrings can be only static or global';
|
|
|
|
+ SParserOnlyOneVariableCanBeAbsolute = 'Only one variable can be absolute';
|
|
|
|
|
|
type
|
|
type
|
|
TPasScopeType = (
|
|
TPasScopeType = (
|
|
@@ -263,7 +265,7 @@ type
|
|
function GetCurrentModeSwitches: TModeSwitches;
|
|
function GetCurrentModeSwitches: TModeSwitches;
|
|
Procedure SetCurrentModeSwitches(AValue: TModeSwitches);
|
|
Procedure SetCurrentModeSwitches(AValue: TModeSwitches);
|
|
function GetVariableModifiers(Parent: TPasElement; Out VarMods: TVariableModifiers; Out LibName, ExportName: TPasExpr; ExternalClass : Boolean): string;
|
|
function GetVariableModifiers(Parent: TPasElement; Out VarMods: TVariableModifiers; Out LibName, ExportName: TPasExpr; ExternalClass : Boolean): string;
|
|
- function GetVariableValueAndLocation(Parent : TPasElement; Out Value : TPasExpr; Out Location: String): Boolean;
|
|
|
|
|
|
+ function GetVariableValueAndLocation(Parent : TPasElement; Out Value: TPasExpr; Out AbsoluteExpr: TPasExpr; Out Location: String): Boolean;
|
|
procedure HandleProcedureModifier(Parent: TPasElement; pm : TProcedureModifier);
|
|
procedure HandleProcedureModifier(Parent: TPasElement; pm : TProcedureModifier);
|
|
procedure HandleProcedureTypeModifier(ProcType: TPasProcedureType; ptm : TProcTypeModifier);
|
|
procedure HandleProcedureTypeModifier(ProcType: TPasProcedureType; ptm : TProcTypeModifier);
|
|
procedure ParseClassLocalConsts(AType: TPasClassType; AVisibility: TPasMemberVisibility);
|
|
procedure ParseClassLocalConsts(AType: TPasClassType; AVisibility: TPasMemberVisibility);
|
|
@@ -3764,28 +3766,31 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TPasParser.GetVariableValueAndLocation(Parent: TPasElement; out
|
|
function TPasParser.GetVariableValueAndLocation(Parent: TPasElement; out
|
|
- Value: TPasExpr; out Location: String): Boolean;
|
|
|
|
|
|
+ Value: TPasExpr; out AbsoluteExpr: TPasExpr; out Location: String): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Value:=Nil;
|
|
Value:=Nil;
|
|
|
|
+ AbsoluteExpr:=Nil;
|
|
|
|
+ Location:='';
|
|
NextToken;
|
|
NextToken;
|
|
Result:=CurToken=tkEqual;
|
|
Result:=CurToken=tkEqual;
|
|
if Result then
|
|
if Result then
|
|
begin
|
|
begin
|
|
NextToken;
|
|
NextToken;
|
|
Value := DoParseConstValueExpression(Parent);
|
|
Value := DoParseConstValueExpression(Parent);
|
|
-// NextToken;
|
|
|
|
end;
|
|
end;
|
|
if (CurToken=tkAbsolute) then
|
|
if (CurToken=tkAbsolute) then
|
|
begin
|
|
begin
|
|
Result:=True;
|
|
Result:=True;
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Location:=CurTokenText;
|
|
Location:=CurTokenText;
|
|
|
|
+ AbsoluteExpr:=CreatePrimitiveExpr(Parent,pekIdent,CurTokenText);
|
|
NextToken;
|
|
NextToken;
|
|
While CurToken=tkDot do
|
|
While CurToken=tkDot do
|
|
begin
|
|
begin
|
|
ExpectIdentifier;
|
|
ExpectIdentifier;
|
|
Location:=Location+'.'+CurTokenText;
|
|
Location:=Location+'.'+CurTokenText;
|
|
|
|
+ AbsoluteExpr:=CreateBinaryExpr(Parent,AbsoluteExpr,CreatePrimitiveExpr(Parent,pekIdent,CurTokenText),eopSubIdent);
|
|
NextToken;
|
|
NextToken;
|
|
end;
|
|
end;
|
|
UnGetToken;
|
|
UnGetToken;
|
|
@@ -3866,18 +3871,20 @@ procedure TPasParser.ParseVarList(Parent: TPasElement; VarList: TFPList;
|
|
|
|
|
|
var
|
|
var
|
|
i, OldListCount: Integer;
|
|
i, OldListCount: Integer;
|
|
- Value , aLibName, aExpName: TPasExpr;
|
|
|
|
|
|
+ Value , aLibName, aExpName, AbsoluteExpr: TPasExpr;
|
|
VarType: TPasType;
|
|
VarType: TPasType;
|
|
VarEl: TPasVariable;
|
|
VarEl: TPasVariable;
|
|
H : TPasMemberHints;
|
|
H : TPasMemberHints;
|
|
VarMods: TVariableModifiers;
|
|
VarMods: TVariableModifiers;
|
|
- D,Mods,Loc: string;
|
|
|
|
|
|
+ D,Mods,AbsoluteLocString: string;
|
|
OldForceCaret,ok,ExternalClass: Boolean;
|
|
OldForceCaret,ok,ExternalClass: Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Value:=Nil;
|
|
Value:=Nil;
|
|
aLibName:=nil;
|
|
aLibName:=nil;
|
|
aExpName:=nil;
|
|
aExpName:=nil;
|
|
|
|
+ AbsoluteExpr:=nil;
|
|
|
|
+ AbsoluteLocString:='';
|
|
OldListCount:=VarList.Count;
|
|
OldListCount:=VarList.Count;
|
|
ok:=false;
|
|
ok:=false;
|
|
try
|
|
try
|
|
@@ -3913,9 +3920,15 @@ begin
|
|
|
|
|
|
H:=CheckHint(Nil,False);
|
|
H:=CheckHint(Nil,False);
|
|
If Full then
|
|
If Full then
|
|
- GetVariableValueAndLocation(Parent,Value,Loc);
|
|
|
|
- if (Value<>nil) and (VarList.Count>OldListCount+1) then
|
|
|
|
- ParseExc(nParserOnlyOneVariableCanBeInitialized,SParserOnlyOneVariableCanBeInitialized);
|
|
|
|
|
|
+ GetVariableValueAndLocation(Parent,Value,AbsoluteExpr,AbsoluteLocString);
|
|
|
|
+ if (VarList.Count>OldListCount+1) then
|
|
|
|
+ begin
|
|
|
|
+ // multiple variables
|
|
|
|
+ if Value<>nil then
|
|
|
|
+ ParseExc(nParserOnlyOneVariableCanBeAbsolute,SParserOnlyOneVariableCanBeAbsolute);
|
|
|
|
+ if Value<>nil then
|
|
|
|
+ ParseExc(nParserOnlyOneVariableCanBeInitialized,SParserOnlyOneVariableCanBeInitialized);
|
|
|
|
+ end;
|
|
TPasVariable(VarList[OldListCount]).Expr:=Value;
|
|
TPasVariable(VarList[OldListCount]).Expr:=Value;
|
|
Value:=nil;
|
|
Value:=nil;
|
|
|
|
|
|
@@ -3953,22 +3966,28 @@ begin
|
|
VarEl.Hints:=H;
|
|
VarEl.Hints:=H;
|
|
VarEl.Modifiers:=Mods;
|
|
VarEl.Modifiers:=Mods;
|
|
VarEl.VarModifiers:=VarMods;
|
|
VarEl.VarModifiers:=VarMods;
|
|
- VarEl.AbsoluteLocation:=Loc;
|
|
|
|
|
|
+ VarEl.{%H-}AbsoluteLocation:=AbsoluteLocString;
|
|
|
|
+ if AbsoluteExpr<>nil then
|
|
|
|
+ begin
|
|
|
|
+ VarEl.AbsoluteExpr:=AbsoluteExpr;
|
|
|
|
+ AbsoluteExpr:=nil;
|
|
|
|
+ end;
|
|
if aLibName<>nil then
|
|
if aLibName<>nil then
|
|
begin
|
|
begin
|
|
VarEl.LibraryName:=aLibName;
|
|
VarEl.LibraryName:=aLibName;
|
|
- aLibName.AddRef;
|
|
|
|
|
|
+ aLibName:=nil;
|
|
end;
|
|
end;
|
|
if aExpName<>nil then
|
|
if aExpName<>nil then
|
|
begin
|
|
begin
|
|
VarEl.ExportName:=aExpName;
|
|
VarEl.ExportName:=aExpName;
|
|
- aExpName.AddRef;
|
|
|
|
|
|
+ aExpName:=nil;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
ok:=true;
|
|
ok:=true;
|
|
finally
|
|
finally
|
|
if aLibName<>nil then aLibName.Release;
|
|
if aLibName<>nil then aLibName.Release;
|
|
if aExpName<>nil then aExpName.Release;
|
|
if aExpName<>nil then aExpName.Release;
|
|
|
|
+ if AbsoluteExpr<>nil then AbsoluteExpr.Release;
|
|
if not ok then
|
|
if not ok then
|
|
begin
|
|
begin
|
|
if Value<>nil then Value.Release;
|
|
if Value<>nil then Value.Release;
|