Commit Graph

315 Commits

Author SHA1 Message Date
svenbarth
276f5bdef8 * ensure that nothing assembly related is generated for generics when a typed constant (this also includes local variable initializations) are parsed
git-svn-id: trunk@43534 -
2019-11-21 21:44:16 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Károly Balogh
464ecab542 huge syscall support refactor for Amiga-likes. removed large chunks of ancient duplicated code, and in general tried to make the entire thing more maintainable and cleaner. also added support for AROS EAXBase syscall convention
git-svn-id: trunk@34416 -
2016-09-03 07:57:23 +00:00
yury
e3d9dbbeef * Removed unused vars.
git-svn-id: trunk@34404 -
2016-09-01 19:55:45 +00:00
svenbarth
bf3c7144b0 * make not of public assembler symbols for variables and classes if necessary
git-svn-id: trunk@34291 -
2016-08-12 14:19:11 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
pierre
94d8d9927d Only add indirect symbol for constants if tf_supports_packages flag is set in target_info.flags
git-svn-id: trunk@33684 -
2016-05-12 07:05:58 +00:00
svenbarth
6722c611cf Generate indirect symbols for global variables and (typed) constants.
Note: It needs to be checked what adjustments will need to be done for JVM and LLVM

Note 2: The indirect symbols will always be generated even if the target won't use them so that assembler code can be consistent among the targets (e.g. i386-win32 needs them while i386-linux does not)

ptconst.pas, read_typed_const:
  * generate the indirect symbol in a read only data section
ngenutil.pas, tnodeutils:
  * insertbsssym: generate the indirect symbol in a read only data section

git-svn-id: trunk@33279 -
2016-03-18 21:40:11 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
sergei
6708b83a16 * Refactor tasmlisttypedconstbuilder so it emits string/PChar data, if any, into a second asmlist, instead of appending it directly to global asmlist.
git-svn-id: trunk@29513 -
2015-01-20 15:14:38 +00:00
sergei
8f1e058ac2 * Don't place symbols with vo_force_finalize flag into read-only sections, resolves #26691.
git-svn-id: trunk@28626 -
2014-09-08 19:41:24 +00:00
Jonas Maebe
6c45f9b3ee * converted most of the asmlist-based typed const parsing to use the new
typed const builder class

git-svn-id: branches/hlcgllvm@28118 -
2014-07-01 16:30:40 +00:00
Jonas Maebe
dc57f537d4 * fixed indentation
git-svn-id: branches/hlcgllvm@28106 -
2014-07-01 16:30:01 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
Jonas Maebe
289486346b * factored out code to decide when an asmsym for a staticvarsym has to be
global, and no longer make it global for all symbols when smartlinking
    is enabled on systems that use section-based smartlinking

git-svn-id: trunk@22241 -
2012-08-25 15:12:39 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
paul
a26bc50ca6 compiler: change ShortString->(Some)String and AnsiString->(Some)String overload precedence both for variables and string constants, change unicode constant type from widestring to unicodestring (Delphi compatibility)
new ShortString->(Some)String precedence: ShortString, UTF8String, AnsiString, AnsiString(CodePage) and RawByteString, UnicodeString, WideString and other string types
new AnsiString->(Some)String precedence: RawByteString, UTF8String, AnsiString, AnsiString(CodePage), UnicodeString, WideString, ShortString and other string types

The new logic makes UTF8String more preferrable than other AnsiString types, AnsiString more preferrable than other  AnsiStrings(codepage) and also makes UnicodeString more preferrable than WideString.

git-svn-id: trunk@21057 -
2012-04-26 02:33:57 +00:00
Jonas Maebe
d7247c9bd9 * prevent duplicate symbol errors when compiling code with debug info
on AIX due to the extra inserted local symbols (although in case e.g
   multiple procedures contain a typed constant with the same name, only
   one can be accessible)
  * removed '.' suffix of local symbols inserted for debug info of typed
    constants for AIX (gdb couldn't find those symbols; it seems the
    address calculated by gdb for typed constants is still not correct
    though)

git-svn-id: trunk@20966 -
2012-04-21 20:18:03 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
florian
ce845bf97c * introduction of in_generic in r20699 was unneeded, replaced by parse_generic
git-svn-id: trunk@20858 -
2012-04-12 21:53:10 +00:00
Jonas Maebe
247033cce1 + stabx support for AIX, which is a variant of stabs. Note that we only
support the stabx as understood by gdb, which is a mixture of regular
    stabs and stabx (e.g., class/object definitions are completely different
    in real stabx). This means that gdb can be used to debug aix programs,
    but the native dbx will complain about lots of debug information
    constructs

git-svn-id: trunk@20842 -
2012-04-11 18:06:38 +00:00
florian
7fe6c0d95d * handle currency constants correctly on non i386 platforms if they are given as integer constant, resolves #21091
git-svn-id: trunk@20734 -
2012-04-06 22:13:48 +00:00
florian
79a77ae7d6 + in_generic for testing if currently a generic declaration/definition is parsed/record
* omit several error messages when in_generic is true because the error can be checked only during specialisation, resolves the issue reported in #21592

git-svn-id: trunk@20699 -
2012-04-03 19:29:09 +00:00
Jonas Maebe
3589f90cf8 * also show the valid bounds in most cases when signalling a range check
warning/error while evaluating constants (mantis #21299)

git-svn-id: trunk@20507 -
2012-03-10 21:53:36 +00:00
paul
f685d67647 compiler: correctly traverse record fields while generating record constant (bug #0020594)
git-svn-id: trunk@19563 -
2011-10-31 02:54:19 +00:00
paul
c6ca9e5091 compiler:
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
  - add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
  - change tstoreddef.createnai constructor to allow set codepage in constructor
  - don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
  - don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
  + test which covers most of the cases

git-svn-id: trunk@19510 -
2011-10-19 02:45:52 +00:00
florian
4868b09844 * patch by alexvin to replace $ifopt by $push/$pop, resolves #20332
git-svn-id: trunk@19239 -
2011-09-25 21:19:50 +00:00
paul
4d3da666db compiler: replace string codepage comparison to numeric. store codepage as number in current settings
git-svn-id: trunk@19144 -
2011-09-19 00:48:43 +00:00
paul
aba0106366 compiler: manual merge some cpstrnew changes which was impossible to merge using regular tools due to the merge conflicts
git-svn-id: trunk@19131 -
2011-09-17 15:36:56 +00:00
paul
723f3424d4 merge r17484 from cpstrnew branch by michael:
* Patch from Inoussa:
* defcmp.pas
    ** ansistring to/from RawByteString are evaluated "te_equal"
    ** ansistring to UTF8string is evaluated (te_convert_l1,tc_string_2_string)

* ncnv.pas
    ** "ttypeconvnode.typecheck_char_to_string" : WideChar to AnsiString/ShortString
        is possible if the source code page is not utf8
    ** "ttypeconvnode.typecheck_char_to_char" : WideChar to AnsiChar
        is possible if the source code page is not utf8

* ncon.pas
    ** "tstringconstnode.changestringtype" : Unicode to utf8string bug fix(set the encoding),
       constants in the source code with code page set utf8 should be converted back to utf8

* nopt.pas
    ** "genmultistringadd" : fpc_<stringname>_concat_multi have a new parameter "cp"
        to indicate the "DestS" code page if the variable content is nil. This is required
        in order not to loose the declared code page.

* pinline.pas
    ** "inline_setlength" : a new parameter "cp" to indicate the code page if the variable content
       is nil. This is required in order not to loose the declared code page.
* ptconst.pas
    ** "parse_arraydef" : for string const to array of ansichar/widechar conversion check for wide string and
        convert if it is required. For char const to array of ansichar/widechar conversion check for wide char and
        convert if it is required.

git-svn-id: trunk@19113 -
2011-09-17 13:30:09 +00:00
paul
1db610ecbd merge r17434 from cpstrnew branch by michael:
* Patch from Inoussa to fix constant strings with codepage

git-svn-id: trunk@19109 -
2011-09-17 13:19:59 +00:00
sergei
a9515e9446 * Don't include ShortString constants into resourcestring reference table, because current design allows RTL to handle only a single string type.
git-svn-id: trunk@19038 -
2011-09-09 17:58:32 +00:00
sergei
689d4b3ecc + Mantis #19651: Generate table of typed string constants which are initialized with resourcestrings, so they are updated when SetResourceStrings or SetUnitResourceStrings is called.
git-svn-id: trunk@18968 -
2011-09-04 16:01:26 +00:00
Jonas Maebe
51095fdd28 * make it possible to override parts of the typed constant code generation
by platform-specific units

git-svn-id: branches/jvmbackend@18658 -
2011-08-20 08:21:59 +00:00
Jonas Maebe
43c5ed20c2 + support for initialising typed constants via compiler-generated
assignment-nodes. For global typed constants and typed constants/
    local variable initialisers in regular functions/procedurs, the
    assignments are performed in the unit initialisation code. For
    those in object/record definitions and their methods, it's done
    in the class constructor. Since we may not yet have parsed all
    method implementations when the class constructor is parsed, part
    of these may be initialised in a helper routine called from the
    class constructor. The ones known when the class constructor is
    parsed are inited there, because the ones marked as "final" and
    declared as static class fields must be initialised in the class
    constructor for Java
   o new set systems_typed_constants_node_init in systems unit that
     indicates that a target uses node trees to initialise typed consts
     instead of an initialised data section
   o mark typed constants in {$j-} mode as "final" for JVM
   o mangle the name of staticvarsyms inside localtables a bit to avoid
     name clashes (only with procedure names for now, no parameters yet
     so can still cause problems with overloaded routines)
   o after a routine has been parsed, it is now processed by
     cnodeutils.wrap_proc_body(), which can add extra nodes before code
     generation (used for injected the typed constant node trees)

git-svn-id: branches/jvmbackend@18475 -
2011-08-20 08:02:58 +00:00
Jonas Maebe
fa841f8011 * migrated most typed constant parsing code to separate methods so
that the actual generation of the data can be overridden

git-svn-id: branches/jvmbackend@18472 -
2011-08-20 08:02:43 +00:00
Jonas Maebe
d248b5992e * moved most code from ptconst to ngtcon; it will be generalised so
it can either generate an asmlist containing data definitions (like
    it does now), or a node tree with explicit initialisation statements
    (for the JVM target)

git-svn-id: branches/jvmbackend@18471 -
2011-08-20 08:02:38 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
0ee702b3a2 * tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
    it later (e.g. for a call or load of its address). The reason is that
    on the JVM both cases are different.
  + jvmdef unit to encode types according to the JVM rules
  + tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
    (the common part of defining/referencing it; tprocdef.mangledname
     afterwards adorns it as required)

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
sergei
fec5dde5b6 * Fix handling of Windows WideString typed constants, resolves #15842 and completes the related #14308:
* Do not initialize unused symbols, because finalization code is not generated for them either.
  * Always initialize/finalize such constants, even if they are declared in {$J-} state and cannot be modified by user code.

git-svn-id: trunk@18121 -
2011-08-06 18:11:39 +00:00
pierre
cfdc7c861d * Use public/global name 'name' section 'section' without semicolon for Windows TLS support
git-svn-id: trunk@17909 -
2011-07-01 19:29:38 +00:00
pierre
a45b29911c * Handle vo_has_section for constants
git-svn-id: trunk@17900 -
2011-07-01 14:26:21 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
florian
5abdfb6f7e * aint -> asizeint changes
git-svn-id: trunk@17018 -
2011-02-26 20:16:14 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00
Jonas Maebe
2222f2c44b * renamed is_class_or_interface_or_dispinterface_or_objc() into
is_implicit_pointer_object_type() to better indicate the purpose of
    that routine, and to avoid having to change its name every time
    a new object type with this property is added

git-svn-id: trunk@16664 -
2010-12-30 15:19:54 +00:00
paul
56bf42de57 compiler: implement record methods and class methods:
- rename tprocdef._class to tprocdef.struct and change the type from tobjectdef to tabstractrecorddef because methods can belong not to classes only now but to records too
  - replace in many places use of current_objectdef to current_structdef with typcast where is needed
  - add an argument to comp_expr, expr, factor, sub_expr to notify that we are searching type only symbol to solve the problem with records,objects,classes which contains fields with the same name as previosly declared type (like:
  HWND = type Handle;
  rec = record 
    hWnd: HWND;
  end;)
  - disable check in factor_read_id which was made for object that only static fields can be accessed as TObjectType.FieldName outside the object because it makes SizeOf(TObjectType.FieldName) imposible and since the same method was extended to handle records it also breaks a52 package compilation
  - rename tcallcandidates.collect_overloads_in_class to tcallcandidates.collect_overloads_in_struct and addapt the code to handle overloads in records too
  - fix searchsym_type to search also in object ancestors if we found an object symtable
  - add pd_record, pd_notrecord flags to mark procedure modifies which can or can't be used with records. Disallow the next modifiers for records: abstract, dynamic, export, external, far, far16, final, forward, internconst, internproc, interrupt, message, near, override, public, reintroduce, virtual, weakexternal,
Allow the next modifiers for records: static

git-svn-id: branches/paul/extended_records@16526 -
2010-12-09 02:24:46 +00:00
paul
8e36256bc9 compiler: add support for visibility blocks in records and type, const declarations:
- add parse_record_members function to parse record blocks based on parse_object_members code
  - disable published section in records
  - rename in_class argument in some functions to in_structure because the same code can work for records now which are not classes

git-svn-id: branches/paul/extended_records@16513 -
2010-12-07 07:40:34 +00:00
Jonas Maebe
14b95b3b9b * always force range checking for the upper and lower bounds of for-loops if
they are constants (instead of only on 32 bit systems), and always use the
    actual upper/lower bound of the loop variable instead of hardcoding the
    bounds of longint (mantis #17646)

git-svn-id: trunk@16213 -
2010-10-24 14:55:48 +00:00