mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:27:56 +02:00
pastojs: fixed property index value path
git-svn-id: trunk@37391 -
This commit is contained in:
parent
cc44328109
commit
48024645f0
@ -4560,6 +4560,7 @@ var
|
||||
IndexExpr: TPasExpr;
|
||||
Func: TPasFunction;
|
||||
FuncScope: TPas2JSProcedureScope;
|
||||
Value: TResEvalValue;
|
||||
begin
|
||||
Result:=nil;
|
||||
if not (El.CustomData is TResolvedReference) then
|
||||
@ -4633,7 +4634,14 @@ begin
|
||||
Call.Expr:=CreateReferencePathExpr(Decl,AContext,false,Ref);
|
||||
IndexExpr:=AContext.Resolver.GetPasPropertyIndex(Prop);
|
||||
if IndexExpr<>nil then
|
||||
Call.AddArg(ConvertElement(IndexExpr,AContext));
|
||||
begin
|
||||
Value:=AContext.Resolver.Eval(IndexExpr,[refConst]);
|
||||
try
|
||||
Call.AddArg(ConvertConstValue(Value,AssignContext,El));
|
||||
finally
|
||||
ReleaseEvalValue(Value);
|
||||
end;
|
||||
end;
|
||||
Call.AddArg(AssignContext.RightSide);
|
||||
AssignContext.RightSide:=nil;
|
||||
Result:=Call;
|
||||
@ -4649,12 +4657,15 @@ begin
|
||||
if IndexExpr<>nil then
|
||||
begin
|
||||
// call function with index specifier
|
||||
Value:=nil;
|
||||
Call:=CreateCallExpression(El);
|
||||
try
|
||||
Call.Expr:=CreateReferencePathExpr(Decl,AContext,false,Ref);
|
||||
Call.AddArg(ConvertElement(IndexExpr,AContext));
|
||||
Value:=AContext.Resolver.Eval(IndexExpr,[refConst]);
|
||||
Call.AddArg(ConvertConstValue(Value,AContext.GetFunctionContext,El));
|
||||
Result:=Call;
|
||||
finally
|
||||
ReleaseEvalValue(Value);
|
||||
if Result=nil then
|
||||
Call.Free;
|
||||
end;
|
||||
@ -5397,6 +5408,7 @@ var
|
||||
AssignContext: TAssignContext;
|
||||
OldAccess: TCtxAccess;
|
||||
IndexExpr: TPasExpr;
|
||||
Value: TResEvalValue;
|
||||
begin
|
||||
Result:=nil;
|
||||
AssignContext:=nil;
|
||||
@ -5454,7 +5466,14 @@ var
|
||||
// add index specifier
|
||||
IndexExpr:=AContext.Resolver.GetPasPropertyIndex(Prop);
|
||||
if IndexExpr<>nil then
|
||||
Elements.AddElement.Expr:=ConvertElement(IndexExpr,ArgContext);
|
||||
begin
|
||||
Value:=AContext.Resolver.Eval(IndexExpr,[refConst]);
|
||||
try
|
||||
Elements.AddElement.Expr:=ConvertConstValue(Value,ArgContext,El);
|
||||
finally
|
||||
ReleaseEvalValue(Value);
|
||||
end;
|
||||
end;
|
||||
// finally add as last parameter the value
|
||||
if AssignContext<>nil then
|
||||
begin
|
||||
@ -9227,6 +9246,8 @@ begin
|
||||
Result:=CreateReferencePathExpr(TResEvalEnum(Value).GetEnumValue,AContext);
|
||||
revkInt:
|
||||
Result:=CreateLiteralNumber(El,TResEvalInt(Value).Int);
|
||||
revkUInt:
|
||||
Result:=CreateLiteralNumber(El,TResEvalUInt(Value).UInt);
|
||||
revkString:
|
||||
Result:=CreateLiteralString(El,TResEvalString(Value).S);
|
||||
revkUnicodeString:
|
||||
@ -11507,7 +11528,7 @@ var
|
||||
Src: TPasElement;
|
||||
begin
|
||||
{$IFDEF VerbosePas2JS}
|
||||
writeln('TPasToJSConverter.CreateReferencePathExpr El="',GetObjName(El),'" El.Parent=',GetObjName(El.Parent));
|
||||
writeln('TPasToJSConverter.CreateReferencePathExpr El="',GetObjName(El),'" El.Parent=',GetObjName(El.Parent),' ',GetObjName(AContext));
|
||||
{$ENDIF}
|
||||
Name:=CreateReferencePath(El,AContext,rpkPathAndName,Full,Ref);
|
||||
if Ref<>nil then
|
||||
|
@ -7429,7 +7429,8 @@ begin
|
||||
' procedure SetStrIntBool(A: String; I: longint; b: boolean); virtual; abstract;',
|
||||
' property B1: boolean index 1 read GetIntBool write SetIntBool;',
|
||||
' property B2: boolean index TEnum.blue read GetEnumBool write SetEnumBool;',
|
||||
' property I1[A: String]: boolean index 2 read GetStrIntBool write SetStrIntBool;',
|
||||
' property B3: boolean index ord(red) read GetIntBool write SetIntBool;',
|
||||
' property I1[A: String]: boolean index ord(blue) read GetStrIntBool write SetStrIntBool;',
|
||||
' end;',
|
||||
'procedure DoIt(b: boolean); begin end;',
|
||||
'var',
|
||||
@ -7437,6 +7438,7 @@ begin
|
||||
'begin',
|
||||
' o.B1:=o.B1;',
|
||||
' o.B2:=o.B2;',
|
||||
' o.B3:=o.B3;',
|
||||
' o.I1[''a'']:=o.I1[''b''];',
|
||||
' doit(o.b1);',
|
||||
' doit(o.b2);',
|
||||
@ -7463,11 +7465,12 @@ begin
|
||||
'']),
|
||||
LinesToStr([ // $mod.$main
|
||||
'$mod.o.SetIntBool(1, $mod.o.GetIntBool(1));',
|
||||
'$mod.o.SetEnumBool(TEnum.blue, $mod.o.GetEnumBool(TEnum.blue));',
|
||||
'$mod.o.SetStrIntBool("a", 2, $mod.o.GetStrIntBool("b", 2));',
|
||||
'$mod.o.SetEnumBool($mod.TEnum.blue, $mod.o.GetEnumBool($mod.TEnum.blue));',
|
||||
'$mod.o.SetIntBool(0, $mod.o.GetIntBool(0));',
|
||||
'$mod.o.SetStrIntBool("a", 1, $mod.o.GetStrIntBool("b", 1));',
|
||||
'$mod.DoIt($mod.o.GetIntBool(1));',
|
||||
'$mod.DoIt($mod.o.GetEnumBool(TEnum.blue));',
|
||||
'$mod.DoIt($mod.o.GetStrIntBool("c", 2));',
|
||||
'$mod.DoIt($mod.o.GetEnumBool($mod.TEnum.blue));',
|
||||
'$mod.DoIt($mod.o.GetStrIntBool("c", 1));',
|
||||
'']));
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user