mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-18 21:29:04 +02:00
fcl-js: unit out dir
This commit is contained in:
parent
1df109333e
commit
a90481eb85
@ -87,6 +87,7 @@
|
|||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<OtherUnitFiles Value="../../fcl-json/src;../src"/>
|
<OtherUnitFiles Value="../../fcl-json/src;../src"/>
|
||||||
|
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
<Checks>
|
<Checks>
|
||||||
@ -102,9 +103,6 @@
|
|||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Other>
|
<Other>
|
||||||
<CustomOptions Value="-dVerboseSrcMap"/>
|
<CustomOptions Value="-dVerboseSrcMap"/>
|
||||||
<OtherDefines Count="1">
|
|
||||||
<Define0 Value="VerboseSrcMap"/>
|
|
||||||
</OtherDefines>
|
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveOnlyProjectUnits Value="True"/>
|
<SaveOnlyProjectUnits Value="True"/>
|
||||||
@ -21,14 +21,19 @@
|
|||||||
</BuildModes>
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
|
||||||
<CommandLineParams Value="--suite=TTestRecordTypeParser.TestFieldAndClassVar"/>
|
<CommandLineParams Value="--suite=TTestRecordTypeParser.TestFieldAndClassVar"/>
|
||||||
</local>
|
</local>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
<Modes Count="1">
|
||||||
|
<Mode0 Name="default">
|
||||||
|
<local>
|
||||||
|
<CommandLineParams Value="--suite=TTestRecordTypeParser.TestFieldAndClassVar"/>
|
||||||
|
</local>
|
||||||
|
</Mode0>
|
||||||
|
</Modes>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
<Item1>
|
<Item1>
|
||||||
|
@ -1218,7 +1218,7 @@ const
|
|||||||
btIntDouble,btUIntDouble,
|
btIntDouble,btUIntDouble,
|
||||||
btCurrency // in pas2js currency is more like an integer, instead of float
|
btCurrency // in pas2js currency is more like an integer, instead of float
|
||||||
];
|
];
|
||||||
btAllJSValueSrcTypes = [btNil,btUntyped,btPointer]+btAllJSInteger
|
btAllJSValueSrcTypes = [btNil,btUntyped,btPointer,btSet]+btAllJSInteger
|
||||||
+btAllJSStringAndChars+btAllJSFloats+btAllJSBooleans;
|
+btAllJSStringAndChars+btAllJSFloats+btAllJSBooleans;
|
||||||
btAllJSValueTypeCastTo = btAllJSInteger
|
btAllJSValueTypeCastTo = btAllJSInteger
|
||||||
+btAllJSStringAndChars+btAllJSFloats+btAllJSBooleans+[btPointer];
|
+btAllJSStringAndChars+btAllJSFloats+btAllJSBooleans+[btPointer];
|
||||||
@ -9808,8 +9808,6 @@ var
|
|||||||
Call: TJSCallExpression;
|
Call: TJSCallExpression;
|
||||||
NotExpr: TJSUnaryNotExpression;
|
NotExpr: TJSUnaryNotExpression;
|
||||||
AddExpr: TJSAdditiveExpressionPlus;
|
AddExpr: TJSAdditiveExpressionPlus;
|
||||||
TypeEl: TPasType;
|
|
||||||
C: TClass;
|
|
||||||
Int: TMaxPrecInt;
|
Int: TMaxPrecInt;
|
||||||
aResolver: TPas2JSResolver;
|
aResolver: TPas2JSResolver;
|
||||||
begin
|
begin
|
||||||
@ -10072,20 +10070,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
// type cast to jsvalue
|
// type cast to jsvalue
|
||||||
Result:=ConvertExpression(Param,AContext);
|
Result:=ConvertExpression(Param,AContext);
|
||||||
// Note: convert value first in case it raises an exception
|
|
||||||
if ParamResolved.BaseType=btContext then
|
|
||||||
begin
|
|
||||||
TypeEl:=ParamResolved.LoTypeEl;
|
|
||||||
C:=TypeEl.ClassType;
|
|
||||||
if (C=TPasClassType) or (C=TPasRecordType) then
|
|
||||||
begin
|
|
||||||
// TObject(jsvalue) -> rtl.getObject(jsvalue)
|
|
||||||
Call:=CreateCallExpression(El);
|
|
||||||
Call.Expr:=CreateMemberExpression([GetBIName(pbivnRTL),GetBIName(pbifnGetObject)]);
|
|
||||||
Call.AddArg(Result);
|
|
||||||
Result:=Call;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -48,6 +48,8 @@ procedure TPas2JSAnalyzer.UseExpr(El: TPasExpr);
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
ArgType: TPasType;
|
ArgType: TPasType;
|
||||||
ModScope: TPas2JSModuleScope;
|
ModScope: TPas2JSModuleScope;
|
||||||
|
aMod: TPasModule;
|
||||||
|
SystemVarRecs: TPasFunction;
|
||||||
begin
|
begin
|
||||||
if Args=nil then exit;
|
if Args=nil then exit;
|
||||||
for i:=0 to Args.Count-1 do
|
for i:=0 to Args.Count-1 do
|
||||||
@ -58,10 +60,13 @@ procedure TPas2JSAnalyzer.UseExpr(El: TPasExpr);
|
|||||||
and (TPasArrayType(ArgType).ElType=nil) then
|
and (TPasArrayType(ArgType).ElType=nil) then
|
||||||
begin
|
begin
|
||||||
// array of const
|
// array of const
|
||||||
ModScope:=NoNil(Resolver.RootElement.CustomData) as TPas2JSModuleScope;
|
aMod:=El.GetModule;
|
||||||
if ModScope.SystemVarRecs=nil then
|
ModScope:=NoNil(aMod.CustomData) as TPas2JSModuleScope;
|
||||||
|
SystemVarRecs:=ModScope.SystemVarRecs;
|
||||||
|
if SystemVarRecs=nil then
|
||||||
RaiseNotSupported(20190216104347,El);
|
RaiseNotSupported(20190216104347,El);
|
||||||
UseProcedure(ModScope.SystemVarRecs);
|
MarkImplScopeRef(El,SystemVarRecs,psraRead);
|
||||||
|
UseProcedure(SystemVarRecs);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -720,6 +720,7 @@ type
|
|||||||
// jsvalue
|
// jsvalue
|
||||||
Procedure TestJSValue_AssignToJSValue;
|
Procedure TestJSValue_AssignToJSValue;
|
||||||
Procedure TestJSValue_TypeCastToBaseType;
|
Procedure TestJSValue_TypeCastToBaseType;
|
||||||
|
Procedure TestJSValue_TypecastToJSValue;
|
||||||
Procedure TestJSValue_Equal;
|
Procedure TestJSValue_Equal;
|
||||||
Procedure TestJSValue_If;
|
Procedure TestJSValue_If;
|
||||||
Procedure TestJSValue_Not;
|
Procedure TestJSValue_Not;
|
||||||
@ -17428,7 +17429,7 @@ begin
|
|||||||
'$mod.v = $mod.IntfVar;',
|
'$mod.v = $mod.IntfVar;',
|
||||||
'$mod.IntfVar = rtl.getObject($mod.v);',
|
'$mod.IntfVar = rtl.getObject($mod.v);',
|
||||||
'if (rtl.isExt($mod.v, $mod.IBird, 1)) ;',
|
'if (rtl.isExt($mod.v, $mod.IBird, 1)) ;',
|
||||||
'$mod.v = rtl.getObject($mod.IntfVar);',
|
'$mod.v = $mod.IntfVar;',
|
||||||
'$mod.v = $mod.IBird;',
|
'$mod.v = $mod.IBird;',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
@ -24882,6 +24883,50 @@ begin
|
|||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestModule.TestJSValue_TypecastToJSValue;
|
||||||
|
begin
|
||||||
|
StartProgram(false);
|
||||||
|
Add([
|
||||||
|
'type',
|
||||||
|
' TArr = array of word;',
|
||||||
|
' TRec = record end;',
|
||||||
|
' TSet = set of boolean;',
|
||||||
|
'procedure Fly(v: jsvalue);',
|
||||||
|
'begin',
|
||||||
|
'end;',
|
||||||
|
'var',
|
||||||
|
' a: TArr;',
|
||||||
|
' r: TRec;',
|
||||||
|
' s: TSet;',
|
||||||
|
'begin',
|
||||||
|
' Fly(jsvalue(a));',
|
||||||
|
' Fly(jsvalue(r));',
|
||||||
|
' Fly(jsvalue(s));',
|
||||||
|
'']);
|
||||||
|
ConvertProgram;
|
||||||
|
CheckSource('TestJSValue_TypecastToJSValue',
|
||||||
|
LinesToStr([ // statements
|
||||||
|
'rtl.recNewT($mod, "TRec", function () {',
|
||||||
|
' this.$eq = function (b) {',
|
||||||
|
' return true;',
|
||||||
|
' };',
|
||||||
|
' this.$assign = function (s) {',
|
||||||
|
' return this;',
|
||||||
|
' };',
|
||||||
|
'});',
|
||||||
|
'this.Fly = function (v) {',
|
||||||
|
'};',
|
||||||
|
'this.a = [];',
|
||||||
|
'this.r = $mod.TRec.$new();',
|
||||||
|
'this.s = {};',
|
||||||
|
'']),
|
||||||
|
LinesToStr([ // $mod.$main
|
||||||
|
'$mod.Fly($mod.a);',
|
||||||
|
'$mod.Fly($mod.r);',
|
||||||
|
'$mod.Fly($mod.s);',
|
||||||
|
'']));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestModule.TestJSValue_Equal;
|
procedure TTestModule.TestJSValue_Equal;
|
||||||
begin
|
begin
|
||||||
StartProgram(false);
|
StartProgram(false);
|
||||||
|
@ -536,7 +536,7 @@ end;
|
|||||||
procedure TTestCLI_Precompile.TestPCU_CheckVersionSystem;
|
procedure TTestCLI_Precompile.TestPCU_CheckVersionSystem;
|
||||||
var
|
var
|
||||||
aFile: TCLIFile;
|
aFile: TCLIFile;
|
||||||
s, JSFilename, ExpectedSrc: string;
|
s, JSFilename, ExpectedSrc, VerStr: string;
|
||||||
begin
|
begin
|
||||||
AddUnit('src/system.pp',[
|
AddUnit('src/system.pp',[
|
||||||
'type integer = longint;'],
|
'type integer = longint;'],
|
||||||
@ -549,10 +549,11 @@ begin
|
|||||||
aFile:=FindFile(JSFilename);
|
aFile:=FindFile(JSFilename);
|
||||||
AssertNotNull('File not found '+JSFilename,aFile);
|
AssertNotNull('File not found '+JSFilename,aFile);
|
||||||
writeln('TTestCLI_Precompile.TestPCU_CheckVersionMain ',aFile.Source);
|
writeln('TTestCLI_Precompile.TestPCU_CheckVersionMain ',aFile.Source);
|
||||||
|
VerStr:=IntToStr((VersionMajor*100+VersionMinor)*100+VersionRelease);
|
||||||
ExpectedSrc:=LinesToStr([
|
ExpectedSrc:=LinesToStr([
|
||||||
UTF8BOM+'rtl.module("system",[],function () {',
|
UTF8BOM+'rtl.module("system",[],function () {',
|
||||||
' "use strict";',
|
' "use strict";',
|
||||||
' rtl.checkVersion(10301);',
|
' rtl.checkVersion('+VerStr+');',
|
||||||
' var $mod = this;',
|
' var $mod = this;',
|
||||||
'});']);
|
'});']);
|
||||||
if not CheckSrcDiff(ExpectedSrc,aFile.Source,s) then
|
if not CheckSrcDiff(ExpectedSrc,aFile.Source,s) then
|
||||||
|
@ -111,9 +111,6 @@
|
|||||||
</CodeGeneration>
|
</CodeGeneration>
|
||||||
<Other>
|
<Other>
|
||||||
<CustomOptions Value="-dVerbosePas2JS"/>
|
<CustomOptions Value="-dVerbosePas2JS"/>
|
||||||
<OtherDefines Count="1">
|
|
||||||
<Define0 Value="VerbosePas2JS"/>
|
|
||||||
</OtherDefines>
|
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
|
Loading…
Reference in New Issue
Block a user