mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 10:29:42 +02:00
pastojs: declarations: nicer srcmaps
git-svn-id: trunk@36681 -
This commit is contained in:
parent
627323b96e
commit
b11a0c4eab
@ -7429,13 +7429,14 @@ Var
|
|||||||
E : TJSElement;
|
E : TJSElement;
|
||||||
SLFirst, SLLast: TJSStatementList;
|
SLFirst, SLLast: TJSStatementList;
|
||||||
P: TPasElement;
|
P: TPasElement;
|
||||||
IsProcBody, IsFunction, IsAssembler: boolean;
|
IsProcBody, IsFunction, IsAssembler, HasResult: boolean;
|
||||||
I : Integer;
|
I : Integer;
|
||||||
PasProc: TPasProcedure;
|
PasProc: TPasProcedure;
|
||||||
ProcScope: TPasProcedureScope;
|
ProcScope: TPasProcedureScope;
|
||||||
ProcBody: TPasImplBlock;
|
ProcBody: TPasImplBlock;
|
||||||
|
ResultEl: TPasResultElement;
|
||||||
|
|
||||||
Procedure Add(NewEl: TJSElement);
|
Procedure Add(NewEl: TJSElement; PosEl: TPasElement);
|
||||||
begin
|
begin
|
||||||
if AContext is TObjectContext then
|
if AContext is TObjectContext then
|
||||||
begin
|
begin
|
||||||
@ -7443,7 +7444,7 @@ Var
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
AddToStatementList(SLFirst,SLLast,NewEl,El);
|
AddToStatementList(SLFirst,SLLast,NewEl,PosEl);
|
||||||
ConvertDeclarations:=SLFirst;
|
ConvertDeclarations:=SLFirst;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -7453,15 +7454,15 @@ Var
|
|||||||
VarSt: TJSVariableStatement;
|
VarSt: TJSVariableStatement;
|
||||||
PasFun: TPasFunction;
|
PasFun: TPasFunction;
|
||||||
FunType: TPasFunctionType;
|
FunType: TPasFunctionType;
|
||||||
ResultEl: TPasResultElement;
|
|
||||||
begin
|
begin
|
||||||
PasFun:=El.Parent as TPasFunction;
|
PasFun:=El.Parent as TPasFunction;
|
||||||
FunType:=PasFun.FuncType;
|
FunType:=PasFun.FuncType;
|
||||||
ResultEl:=FunType.ResultEl;
|
ResultEl:=FunType.ResultEl;
|
||||||
|
|
||||||
// add 'var result=initvalue'
|
// add 'var result=initvalue'
|
||||||
VarSt:=CreateVarStatement(ResolverResultVar,CreateValInit(ResultEl.ResultType,nil,El,aContext),El);
|
VarSt:=CreateVarStatement(ResolverResultVar,
|
||||||
Add(VarSt);
|
CreateValInit(ResultEl.ResultType,nil,El,aContext),ResultEl);
|
||||||
|
Add(VarSt,ResultEl);
|
||||||
Result:=SLFirst;
|
Result:=SLFirst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7471,7 +7472,7 @@ Var
|
|||||||
begin
|
begin
|
||||||
RetSt:=TJSReturnStatement(CreateElement(TJSReturnStatement,El));
|
RetSt:=TJSReturnStatement(CreateElement(TJSReturnStatement,El));
|
||||||
RetSt.Expr:=CreatePrimitiveDotExpr(ResolverResultVar);
|
RetSt.Expr:=CreatePrimitiveDotExpr(ResolverResultVar);
|
||||||
Add(RetSt);
|
Add(RetSt,ResultEl);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -7486,13 +7487,15 @@ begin
|
|||||||
TProcedureBody = class(TPasDeclarations)
|
TProcedureBody = class(TPasDeclarations)
|
||||||
}
|
}
|
||||||
|
|
||||||
SLFirst:=nil;
|
|
||||||
SLLast:=nil;
|
|
||||||
IsProcBody:=(El is TProcedureBody) and (TProcedureBody(El).Body<>nil);
|
IsProcBody:=(El is TProcedureBody) and (TProcedureBody(El).Body<>nil);
|
||||||
IsFunction:=IsProcBody and (El.Parent is TPasFunction);
|
IsFunction:=IsProcBody and (El.Parent is TPasFunction);
|
||||||
IsAssembler:=IsProcBody and (TProcedureBody(El).Body is TPasImplAsmStatement);
|
IsAssembler:=IsProcBody and (TProcedureBody(El).Body is TPasImplAsmStatement);
|
||||||
|
HasResult:=IsFunction and not IsAssembler;
|
||||||
|
SLFirst:=nil;
|
||||||
|
SLLast:=nil;
|
||||||
|
ResultEl:=nil;
|
||||||
|
|
||||||
if IsFunction and not IsAssembler then
|
if HasResult then
|
||||||
AddFunctionResultInit;
|
AddFunctionResultInit;
|
||||||
|
|
||||||
For I:=0 to El.Declarations.Count-1 do
|
For I:=0 to El.Declarations.Count-1 do
|
||||||
@ -7524,7 +7527,7 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
RaiseNotSupported(P as TPasElement,AContext,20161024191434);
|
RaiseNotSupported(P as TPasElement,AContext,20161024191434);
|
||||||
Add(E);
|
Add(E,P);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if IsProcBody then
|
if IsProcBody then
|
||||||
@ -7532,12 +7535,12 @@ begin
|
|||||||
ProcBody:=TProcedureBody(El).Body;
|
ProcBody:=TProcedureBody(El).Body;
|
||||||
if (ProcBody.Elements.Count>0) or IsAssembler then
|
if (ProcBody.Elements.Count>0) or IsAssembler then
|
||||||
begin
|
begin
|
||||||
E:=ConvertElement(TProcedureBody(El).Body,aContext);
|
E:=ConvertElement(ProcBody,aContext);
|
||||||
Add(E);
|
Add(E,ProcBody);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if IsFunction and not IsAssembler then
|
if HasResult then
|
||||||
AddFunctionResultReturn;
|
AddFunctionResultReturn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user