|
@@ -499,6 +499,7 @@ Type
|
|
FArgumentTypes: String;
|
|
FArgumentTypes: String;
|
|
FIDType: TIdentifierType;
|
|
FIDType: TIdentifierType;
|
|
FName: ShortString;
|
|
FName: ShortString;
|
|
|
|
+ FVariableArgumentCount: Boolean;
|
|
FOnGetValue: TFPExprFunctionEvent;
|
|
FOnGetValue: TFPExprFunctionEvent;
|
|
FOnGetValueCB: TFPExprFunctionCallBack;
|
|
FOnGetValueCB: TFPExprFunctionCallBack;
|
|
function GetAsBoolean: Boolean;
|
|
function GetAsBoolean: Boolean;
|
|
@@ -544,6 +545,7 @@ Type
|
|
Property OnGetFunctionValue : TFPExprFunctionEvent Read FOnGetValue Write FOnGetValue;
|
|
Property OnGetFunctionValue : TFPExprFunctionEvent Read FOnGetValue Write FOnGetValue;
|
|
Property OnGetVariableValue : TFPExprVariableEvent Read FOnGetVarValue Write FOnGetVarValue;
|
|
Property OnGetVariableValue : TFPExprVariableEvent Read FOnGetVarValue Write FOnGetVarValue;
|
|
Property NodeType : TFPExprFunctionClass Read FNodeType Write FNodeType;
|
|
Property NodeType : TFPExprFunctionClass Read FNodeType Write FNodeType;
|
|
|
|
+ property VariableArgumentCount: Boolean read FVariableArgumentCount write FVariableArgumentCount;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -2272,7 +2274,11 @@ begin
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result.Name:=Aname;
|
|
Result.Name:=Aname;
|
|
Result.IdentifierType:=itFunctionCallBack;
|
|
Result.IdentifierType:=itFunctionCallBack;
|
|
- Result.ParameterTypes:=AParamTypes;
|
|
|
|
|
|
+ if (AParamTypes <> '') and (AParamTypes[Length(AParamTypes)] = '+') then begin
|
|
|
|
+ Result.ParameterTypes := Copy(AParamTypes, 1, Length(AParamTypes)-1);
|
|
|
|
+ Result.FVariableArgumentCount := true;
|
|
|
|
+ end else
|
|
|
|
+ Result.ParameterTypes := AParamTypes;
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.FOnGetValueCB:=ACallBack;
|
|
Result.FOnGetValueCB:=ACallBack;
|
|
end;
|
|
end;
|
|
@@ -2284,7 +2290,11 @@ begin
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result.Name:=Aname;
|
|
Result.Name:=Aname;
|
|
Result.IdentifierType:=itFunctionHandler;
|
|
Result.IdentifierType:=itFunctionHandler;
|
|
- Result.ParameterTypes:=AParamTypes;
|
|
|
|
|
|
+ if (AParamTypes <> '') and (AParamTypes[Length(AParamTypes)] = '+') then begin
|
|
|
|
+ Result.ParameterTypes := Copy(AParamTypes, 1, Length(AParamTypes)-1);
|
|
|
|
+ Result.FVariableArgumentCount := true;
|
|
|
|
+ end else
|
|
|
|
+ Result.ParameterTypes := AParamTypes;
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.FOnGetValue:=ACallBack;
|
|
Result.FOnGetValue:=ACallBack;
|
|
end;
|
|
end;
|
|
@@ -2296,7 +2306,11 @@ begin
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result:=Add as TFPExprIdentifierDef;
|
|
Result.Name:=Aname;
|
|
Result.Name:=Aname;
|
|
Result.IdentifierType:=itFunctionNode;
|
|
Result.IdentifierType:=itFunctionNode;
|
|
- Result.ParameterTypes:=AParamTypes;
|
|
|
|
|
|
+ if (AParamTypes <> '') and (AParamTypes[Length(AParamTypes)] = '+') then begin
|
|
|
|
+ Result.ParameterTypes := Copy(AParamTypes, 1, Length(AParamTypes)-1);
|
|
|
|
+ Result.FVariableArgumentCount := true;
|
|
|
|
+ end else
|
|
|
|
+ Result.ParameterTypes := AParamTypes;
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.ResultType:=CharToResultType(AResultType);
|
|
Result.FNodeType:=ANodeClass;
|
|
Result.FNodeType:=ANodeClass;
|
|
end;
|
|
end;
|
|
@@ -2364,7 +2378,10 @@ end;
|
|
|
|
|
|
function TFPExprIdentifierDef.ArgumentCount: Integer;
|
|
function TFPExprIdentifierDef.ArgumentCount: Integer;
|
|
begin
|
|
begin
|
|
- Result:=Length(FArgumentTypes);
|
|
|
|
|
|
+ if FVariableArgumentCount then
|
|
|
|
+ Result := -Length(FArgumentTypes)
|
|
|
|
+ else
|
|
|
|
+ Result:=Length(FArgumentTypes);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TFPExprIdentifierDef.Assign(Source: TPersistent);
|
|
procedure TFPExprIdentifierDef.Assign(Source: TPersistent);
|
|
@@ -2379,6 +2396,7 @@ begin
|
|
FStringValue:=EID.FStringValue;
|
|
FStringValue:=EID.FStringValue;
|
|
FValue:=EID.FValue;
|
|
FValue:=EID.FValue;
|
|
FArgumentTypes:=EID.FArgumentTypes;
|
|
FArgumentTypes:=EID.FArgumentTypes;
|
|
|
|
+ FVariableArgumentCount := EID.FVariableArgumentCount;
|
|
FIDType:=EID.FIDType;
|
|
FIDType:=EID.FIDType;
|
|
FName:=EID.FName;
|
|
FName:=EID.FName;
|
|
FOnGetValue:=EID.FOnGetValue;
|
|
FOnGetValue:=EID.FOnGetValue;
|
|
@@ -3791,11 +3809,14 @@ Var
|
|
rtp,rta : TResultType;
|
|
rtp,rta : TResultType;
|
|
|
|
|
|
begin
|
|
begin
|
|
- If Length(FArgumentNodes)<>FID.ArgumentCount then
|
|
|
|
|
|
+ If (Length(FArgumentNodes)<>FID.ArgumentCount) and not FID.VariableArgumentCount then
|
|
RaiseParserError(ErrInvalidArgumentCount,[FID.Name]);
|
|
RaiseParserError(ErrInvalidArgumentCount,[FID.Name]);
|
|
For I:=0 to Length(FArgumentNodes)-1 do
|
|
For I:=0 to Length(FArgumentNodes)-1 do
|
|
begin
|
|
begin
|
|
- rtp:=CharToResultType(FID.ParameterTypes[i+1]);
|
|
|
|
|
|
+ if (i < Length(FID.ParameterTypes)) then
|
|
|
|
+ rtp := CharToResultType(FID.ParameterTypes[i+1])
|
|
|
|
+ else if FID.VariableArgumentCount then
|
|
|
|
+ rtp := CharToResultType(FID.ParameterTypes[Length(FID.ParameterTypes)]);
|
|
rta:=FArgumentNodes[i].NodeType;
|
|
rta:=FArgumentNodes[i].NodeType;
|
|
If (rtp<>rta) then
|
|
If (rtp<>rta) then
|
|
FArgumentNodes[i]:=ConvertArgument(I+1,FArgumentNodes[i],rtp);
|
|
FArgumentNodes[i]:=ConvertArgument(I+1,FArgumentNodes[i],rtp);
|
|
@@ -4463,3 +4484,4 @@ initialization
|
|
finalization
|
|
finalization
|
|
FreeBuiltins;
|
|
FreeBuiltins;
|
|
end.
|
|
end.
|
|
|
|
+
|