mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 16:19:46 +02:00
codetools: added compiler type pas2js
git-svn-id: trunk@54488 -
This commit is contained in:
parent
0a36afd707
commit
52bcdebadd
@ -6431,6 +6431,7 @@ begin
|
||||
xtShortInt,
|
||||
xtByte: AddAssignment('0');
|
||||
xtVariant: begin AddAssignment('0'); AddAssignment(''''''); end;
|
||||
xtJSValue: begin AddAssignment('0'); AddAssignment(''''''); AddAssignment('nil'); AddAssignment('false'); end;
|
||||
end;
|
||||
if Statements.Count=0 then begin
|
||||
MoveCursorToAtomPos(IdentAtom);
|
||||
|
@ -262,6 +262,7 @@ type
|
||||
xtByte, // byte
|
||||
xtCompilerFunc,// SUCC, PREC, LOW, HIGH, ORD, LENGTH, COPY (1.1)
|
||||
xtVariant, // variant
|
||||
xtJSValue, // jsvalue only in Pas2JS, similar to variant
|
||||
xtNil // nil = pointer, class, procedure, method, ...
|
||||
);
|
||||
// Do not define: TExpressionTypeDescs = set of TExpressionTypeDesc;
|
||||
@ -310,6 +311,7 @@ var
|
||||
'Byte',
|
||||
'CompilerFunc',
|
||||
'Variant',
|
||||
'JSValue',
|
||||
'Nil'
|
||||
);
|
||||
|
||||
@ -329,7 +331,7 @@ const
|
||||
xtAllStringTypes = [xtConstString, xtShortString, xtString, xtAnsiString];
|
||||
xtAllWideStringTypes = [xtConstString, xtWideString, xtUnicodeString];
|
||||
xtAllPointerTypes = [xtPointer, xtNil];
|
||||
xtAllTypeHelperTypes = xtAllPredefinedTypes-[xtCompilerFunc,xtVariant,xtNil];
|
||||
xtAllTypeHelperTypes = xtAllPredefinedTypes-[xtCompilerFunc,xtVariant,xtJSValue,xtNil];
|
||||
|
||||
xtAllStringCompatibleTypes = xtAllStringTypes+[xtChar];
|
||||
xtAllWideStringCompatibleTypes = xtAllWideStringTypes+[xtWideChar,xtChar];
|
||||
@ -1083,7 +1085,7 @@ procedure FreeListOfPFindContext(var ListOfPFindContext: TFPList);
|
||||
function ListOfPFindContextToStr(const ListOfPFindContext: TFPList): string;
|
||||
function dbgsFC(const Context: TFindContext): string;
|
||||
|
||||
function PredefinedIdentToExprTypeDesc(Identifier: PChar): TExpressionTypeDesc;
|
||||
function PredefinedIdentToExprTypeDesc(Identifier: PChar; Compiler: TPascalCompiler): TExpressionTypeDesc;
|
||||
function dbgs(const Flags: TFindDeclarationFlags): string; overload;
|
||||
function dbgs(const Flags: TFoundDeclarationFlags): string; overload;
|
||||
function dbgs(const vat: TVariableAtomType): string; overload;
|
||||
@ -1232,7 +1234,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function PredefinedIdentToExprTypeDesc(Identifier: PChar): TExpressionTypeDesc;
|
||||
function PredefinedIdentToExprTypeDesc(Identifier: PChar;
|
||||
Compiler: TPascalCompiler): TExpressionTypeDesc;
|
||||
begin
|
||||
// predefined identifiers
|
||||
if CompareIdentifiers(Identifier,'NIL')=0 then
|
||||
@ -1296,6 +1299,8 @@ begin
|
||||
Result:=xtConstBoolean
|
||||
else if CompareIdentifiers(Identifier,'VARIANT')=0 then
|
||||
Result:=xtVariant
|
||||
else if (Compiler=pcPas2js) and (CompareIdentifiers(Identifier,'JSVALUE')=0) then
|
||||
Result:=xtJSValue
|
||||
else if IsWordBuiltInFunc.DoItCaseInsensitive(Identifier) then
|
||||
Result:=xtCompilerFunc
|
||||
|
||||
@ -9943,7 +9948,7 @@ var
|
||||
begin
|
||||
Result:=CleanExpressionType;
|
||||
IdentPos:=@Src[StartPos];
|
||||
Result.Desc:=PredefinedIdentToExprTypeDesc(IdentPos);
|
||||
Result.Desc:=PredefinedIdentToExprTypeDesc(IdentPos,Scanner.PascalCompiler);
|
||||
|
||||
{$IFDEF ShowExprEval}
|
||||
debugln('TFindDeclarationTool.FindExpressionTypeOfPredefinedIdentifier ',
|
||||
@ -11984,7 +11989,7 @@ begin
|
||||
// predefined identifier
|
||||
Params.Flags:=OldFlags;
|
||||
Result:=CleanExpressionType;
|
||||
Result.Desc:=PredefinedIdentToExprTypeDesc(Params.Identifier);
|
||||
Result.Desc:=PredefinedIdentToExprTypeDesc(Params.Identifier,Scanner.PascalCompiler);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -12165,6 +12170,7 @@ begin
|
||||
xtLongWord,
|
||||
xtCompilerFunc,
|
||||
xtVariant,
|
||||
xtJSValue,
|
||||
xtNil:
|
||||
RaiseTermHasNoIterator;
|
||||
xtString,
|
||||
|
@ -1364,7 +1364,7 @@ procedure TIdentCompletionTool.GatherPredefinedIdentifiers(CleanPos: integer;
|
||||
var
|
||||
NewItem: TIdentifierListItem;
|
||||
ProcNode: TCodeTreeNode;
|
||||
HidddnUnits: String;
|
||||
HiddenUnits: String;
|
||||
p: PChar;
|
||||
SystemTool: TFindDeclarationTool;
|
||||
I: TExpressionTypeDesc;
|
||||
@ -1497,6 +1497,8 @@ begin
|
||||
AddBaseType(PChar(ExpressionTypeDescNames[I]));
|
||||
end;
|
||||
end;
|
||||
if Scanner.PascalCompiler=pcPas2js then
|
||||
AddBaseType(PChar(ExpressionTypeDescNames[xtJSValue]));
|
||||
AddBaseConstant('True');
|
||||
AddBaseConstant('False');
|
||||
//the nil constant doesn't belong to system context, therefore it is added in next step
|
||||
@ -1505,9 +1507,9 @@ begin
|
||||
begin
|
||||
AddBaseConstant(PChar(ExpressionTypeDescNames[xtNil]));
|
||||
// system units
|
||||
HidddnUnits:=Scanner.GetHiddenUsedUnits;
|
||||
if HidddnUnits<>'' then begin
|
||||
p:=PChar(HidddnUnits);
|
||||
HiddenUnits:=Scanner.GetHiddenUsedUnits;
|
||||
if HiddenUnits<>'' then begin
|
||||
p:=PChar(HiddenUnits);
|
||||
while p^<>#0 do begin
|
||||
while p^=',' do inc(p);
|
||||
if GetIdentLen(p)>0 then
|
||||
|
@ -196,7 +196,7 @@ type
|
||||
ansistring; similarly, char becomes unicodechar rather than ansichar }
|
||||
cmsTypeHelpers,
|
||||
cmsBlocks,
|
||||
cmsExternalClass { allow class external [pkgname] name [symbol] }
|
||||
cmsExternalClass { allow class external [pkgname] name [symbol] }
|
||||
);
|
||||
TCompilerModeSwitches = set of TCompilerModeSwitch;
|
||||
const
|
||||
@ -261,7 +261,7 @@ const
|
||||
);
|
||||
|
||||
type
|
||||
TPascalCompiler = (pcFPC, pcDelphi);
|
||||
TPascalCompiler = (pcFPC, pcDelphi, pcPas2js);
|
||||
|
||||
type
|
||||
TLSSkippingDirective = (
|
||||
@ -533,6 +533,7 @@ type
|
||||
function GetDirectives(Index: integer): PLSDirective; inline;
|
||||
function GetDirectivesSorted(Index: integer): PLSDirective; inline;
|
||||
procedure SetCompilerMode(const AValue: TCompilerMode);
|
||||
procedure SetPascalCompiler(const AValue: TPascalCompiler);
|
||||
procedure SkipTillEndifElse(SkippingUntil: TLSSkippingDirective);
|
||||
procedure SortDirectives;
|
||||
function InternalIfDirective: boolean;
|
||||
@ -721,7 +722,7 @@ type
|
||||
property CompilerMode: TCompilerMode read FCompilerMode write SetCompilerMode;
|
||||
property CompilerModeSwitches: TCompilerModeSwitches
|
||||
read FCompilerModeSwitches write FCompilerModeSwitches;
|
||||
property PascalCompiler: TPascalCompiler read FPascalCompiler write FPascalCompiler;
|
||||
property PascalCompiler: TPascalCompiler read FPascalCompiler write SetPascalCompiler;
|
||||
property ScanTill: TLinkScannerRange read FScanTill write SetScanTill;
|
||||
|
||||
procedure Clear;
|
||||
@ -804,7 +805,7 @@ const
|
||||
|
||||
// upper case
|
||||
PascalCompilerNames: array[TPascalCompiler] of shortstring=(
|
||||
'FPC', 'DELPHI'
|
||||
'FPC', 'DELPHI', 'PAS2JS'
|
||||
);
|
||||
|
||||
const
|
||||
@ -2037,7 +2038,7 @@ begin
|
||||
SourceName:='';
|
||||
CommentStyle:=CommentNone;
|
||||
CommentLevel:=0;
|
||||
PascalCompiler:=pcFPC;
|
||||
FPascalCompiler:=pcFPC;
|
||||
CompilerMode:=cmFPC;
|
||||
FNestedComments:=cmsNested_comment in DefaultCompilerModeSwitches[CompilerMode];
|
||||
IfLevel:=0;
|
||||
@ -2052,9 +2053,14 @@ begin
|
||||
|
||||
// compiler
|
||||
s:=FInitValues.Variables[PascalCompilerDefine];
|
||||
for pc:=Low(TPascalCompiler) to High(TPascalCompiler) do
|
||||
if (s=PascalCompilerNames[pc]) then
|
||||
PascalCompiler:=pc;
|
||||
if s<>'' then begin
|
||||
for pc:=Low(TPascalCompiler) to High(TPascalCompiler) do
|
||||
if (s=PascalCompilerNames[pc]) then
|
||||
PascalCompiler:=pc;
|
||||
end else if InitialValues.IsDefined('pas2js') then
|
||||
PascalCompiler:=pcPas2js
|
||||
else if InitialValues.IsDefined('delphi') and not InitialValues.IsDefined('fpc') then
|
||||
PascalCompiler:=pcDelphi;
|
||||
|
||||
// compiler mode
|
||||
for cm:=Low(TCompilerMode) to High(TCompilerMode) do
|
||||
@ -3448,7 +3454,7 @@ function TLinkScanner.ModeSwitchDirective: boolean;
|
||||
var
|
||||
ValStart: LongInt;
|
||||
ModeSwitch: TCompilerModeSwitch;
|
||||
s: TCompilerModeSwitches;
|
||||
Switches: TCompilerModeSwitches;
|
||||
begin
|
||||
if StoreDirectives then
|
||||
FDirectives[FDirectivesCount-1].Kind:=lsdkModeSwitch;
|
||||
@ -3461,17 +3467,17 @@ begin
|
||||
if CompareUpToken(CompilerModeSwitchNames[ModeSwitch],Src,ValStart,SrcPos)
|
||||
then begin
|
||||
Result:=true;
|
||||
s:=[ModeSwitch];
|
||||
Switches:=[ModeSwitch];
|
||||
case ModeSwitch of
|
||||
cmsObjectiveC2: Include(s,cmsObjectiveC1);
|
||||
cmsObjectiveC2: Include(Switches,cmsObjectiveC1);
|
||||
end;
|
||||
if (SrcPos<=SrcLen) and (Src[SrcPos]='-') then begin
|
||||
FCompilerModeSwitches:=FCompilerModeSwitches-s;
|
||||
FCompilerModeSwitches:=FCompilerModeSwitches-Switches;
|
||||
case ModeSwitch of
|
||||
cmsDefault_unicodestring: Values.Undefine('FPC_UNICODESTRINGS');
|
||||
end;
|
||||
end else begin
|
||||
FCompilerModeSwitches:=FCompilerModeSwitches+s;
|
||||
FCompilerModeSwitches:=FCompilerModeSwitches+Switches;
|
||||
case ModeSwitch of
|
||||
cmsDefault_unicodestring: Values.Variables['FPC_UNICODESTRINGS'] := '1';
|
||||
end;
|
||||
@ -4528,6 +4534,15 @@ begin
|
||||
Values.Variables[CompilerModeVars[FCompilerMode]]:='1';
|
||||
end;
|
||||
|
||||
procedure TLinkScanner.SetPascalCompiler(const AValue: TPascalCompiler);
|
||||
begin
|
||||
if FPascalCompiler=AValue then Exit;
|
||||
FPascalCompiler:=AValue;
|
||||
case PascalCompiler of
|
||||
pcPas2js: ;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLinkScanner.SetDirectiveValueWithSequence(
|
||||
ADirective: TSequenceDirective; const ADirectiveValue: string);
|
||||
begin
|
||||
|
@ -2861,7 +2861,7 @@ begin
|
||||
if (Src[CurPos.StartPos-1]='@') then begin
|
||||
// allow anything behind @
|
||||
end else if (CurPos.Flag=cafWord) then begin
|
||||
if Scanner.Values.IsDefined('pas2js') then begin
|
||||
if Scanner.PascalCompiler=pcPas2js then begin
|
||||
if UnexpectedKeyWordInAsmPas2JSBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
||||
SaveRaiseUnexpectedKeyWordInBeginEndBlock;
|
||||
end else if UnexpectedKeyWordInAsmBlock.DoIdentifier(@Src[CurPos.StartPos]) then
|
||||
|
Loading…
Reference in New Issue
Block a user