mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 09:06:02 +02:00
+ support for formal constants (= not typed constants) in Java interfaces,
like in Java (mainly for header translations) git-svn-id: branches/jvmbackend@18399 -
This commit is contained in:
parent
37b5c061e3
commit
30a6290aac
@ -375,7 +375,7 @@ scanner_e_illegal_alignment_directive=02088_E_Illegal alignment directive
|
||||
#
|
||||
# Parser
|
||||
#
|
||||
# 03315 is the last used one
|
||||
# 03316 is the last used one
|
||||
#
|
||||
% \section{Parser messages}
|
||||
% This section lists all parser messages. The parser takes care of the
|
||||
@ -1407,6 +1407,10 @@ parser_e_final_only_const_var=03314_E_Only fields (var-sections) and constants c
|
||||
parser_e_final_only_external=03315_E_Final fields are currently only supported for external classes
|
||||
% Support for final fields in non-external classes requires a full data flow
|
||||
% analysis implementation in FPC, which it currently still lacks.
|
||||
parser_e_no_typed_const=03316_E_Typed constants are not allowed here, only formal constants are
|
||||
% Java interfaces define a namespace in which formal constant can be defined,
|
||||
% but since they define no storage it is not possible to define typed constants
|
||||
% in them (those are more or less the same as initialised class fields).
|
||||
% \end{description}
|
||||
# Type Checking
|
||||
#
|
||||
|
@ -407,6 +407,7 @@ const
|
||||
parser_e_implements_no_mapping=03313;
|
||||
parser_e_final_only_const_var=03314;
|
||||
parser_e_final_only_external=03315;
|
||||
parser_e_no_typed_const=03316;
|
||||
type_e_mismatch=04000;
|
||||
type_e_incompatible_types=04001;
|
||||
type_e_not_equal_types=04002;
|
||||
@ -904,9 +905,9 @@ const
|
||||
option_info=11024;
|
||||
option_help_pages=11025;
|
||||
|
||||
MsgTxtSize = 61281;
|
||||
MsgTxtSize = 61353;
|
||||
|
||||
MsgIdxMax : array[1..20] of longint=(
|
||||
26,89,316,105,85,54,111,23,202,63,
|
||||
26,89,317,105,85,54,111,23,202,63,
|
||||
49,20,1,1,1,1,1,1,1,1
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,7 +38,7 @@ interface
|
||||
function readconstant(const orgname:string;const filepos:tfileposinfo):tconstsym;
|
||||
|
||||
procedure const_dec;
|
||||
procedure consts_dec(in_structure: boolean);
|
||||
procedure consts_dec(in_structure, allow_typed_const: boolean);
|
||||
procedure label_dec;
|
||||
procedure type_dec;
|
||||
procedure types_dec(in_structure: boolean);
|
||||
@ -164,10 +164,10 @@ implementation
|
||||
procedure const_dec;
|
||||
begin
|
||||
consume(_CONST);
|
||||
consts_dec(false);
|
||||
consts_dec(false,true);
|
||||
end;
|
||||
|
||||
procedure consts_dec(in_structure: boolean);
|
||||
procedure consts_dec(in_structure, allow_typed_const: boolean);
|
||||
var
|
||||
orgname : TIDString;
|
||||
hdef : tdef;
|
||||
@ -212,6 +212,11 @@ implementation
|
||||
|
||||
_COLON:
|
||||
begin
|
||||
if not allow_typed_const then
|
||||
begin
|
||||
Message(parser_e_no_typed_const);
|
||||
consume_all_until(_SEMICOLON);
|
||||
end;
|
||||
{ set the blocktype first so a consume also supports a
|
||||
caret, to support const s : ^string = nil }
|
||||
block_type:=bt_const_type;
|
||||
|
@ -763,7 +763,7 @@ implementation
|
||||
|
||||
procedure parse_const;
|
||||
begin
|
||||
if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass]) then
|
||||
if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper,odt_javaclass,odt_interfacejava]) then
|
||||
Message(parser_e_type_var_const_only_in_records_and_classes);
|
||||
consume(_CONST);
|
||||
object_member_blocktype:=bt_const;
|
||||
@ -975,7 +975,7 @@ implementation
|
||||
typedconstswritable:=cs_typed_const_writable in current_settings.localswitches;
|
||||
exclude(current_settings.localswitches,cs_typed_const_writable);
|
||||
end;
|
||||
consts_dec(true);
|
||||
consts_dec(true,not is_javainterface(current_structdef));
|
||||
if final_fields and
|
||||
typedconstswritable then
|
||||
include(current_settings.localswitches,cs_typed_const_writable);
|
||||
|
@ -828,7 +828,7 @@ implementation
|
||||
else if member_blocktype=bt_type then
|
||||
types_dec(true)
|
||||
else if member_blocktype=bt_const then
|
||||
consts_dec(true)
|
||||
consts_dec(true,true)
|
||||
else
|
||||
internalerror(201001110);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user