Commit Graph

345 Commits

Author SHA1 Message Date
florian
0968d095ed * convert function like used new into a appropriate nodes only in pass_1 so proper error checking can be carried out, resolves #24495
git-svn-id: trunk@24667 -
2013-05-31 14:55:49 +00:00
nickysn
a86cb5c600 + far pointer fixes in the internal compiler handling of ptr(const,const)
git-svn-id: trunk@24567 -
2013-05-24 12:42:43 +00:00
nickysn
b0f7786782 + added support for special versions of near data pointers associated with a x86 segment register. They are supported on all x86 platforms: i8086, i386 and x86_64
git-svn-id: trunk@24453 -
2013-05-05 17:22:37 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
nickysn
3c6df5bedc * use is_nativeuint() in ninl.get_str_int_func(), instead of the ifdef sequence
git-svn-id: branches/i8086@24217 -
2013-04-09 20:39:58 +00:00
nickysn
526c3b9c9b * val, str and read/write(ln) now use is_oversizedint/ord to determine which helper function to use; this also clears the warnings that prevented compilation of the 64-bit targets
git-svn-id: branches/i8086@24092 -
2013-03-31 16:27:26 +00:00
nickysn
91038d6d0a * prevent compilation warning due to function result not being set in tinlinenode.first_seg
git-svn-id: branches/i8086@24084 -
2013-03-30 20:32:52 +00:00
nickysn
be761ba232 * sequences that check for cpu64bitaddr made to also check for cpu32bitaddr instead of cpu32bitalu. this fixes ppcjvm compilation
git-svn-id: branches/i8086@24083 -
2013-03-30 20:31:52 +00:00
nickysn
917a1eb0f2 * the default Seg() handling moved to virtual methods, so that they can be overriden in the i8086 code generator
git-svn-id: branches/i8086@24070 -
2013-03-30 12:08:24 +00:00
nickysn
615d6e4a51 * internal compiler handling of Val() fixed for 16/8-bit CPUs
git-svn-id: branches/i8086@24049 -
2013-03-29 01:38:21 +00:00
nickysn
53ad3fc662 + Str() handling in the compiler fixed for 16/8-bit CPU support
git-svn-id: branches/i8086@24009 -
2013-03-25 23:58:09 +00:00
nickysn
8fa9105151 + 16-bit and 8-bit CPU support added in the internal handling of read/readln/write/writeln
git-svn-id: branches/i8086@24007 -
2013-03-25 23:23:48 +00:00
Jonas Maebe
e1e11f81e3 * fixed using readstr/writestr inside routines called from the parameter
list of another readstr/writestr expression (mantis #23912)

git-svn-id: trunk@23888 -
2013-03-17 14:23:33 +00:00
florian
d5985b4f0e * patch by Christophe Staïesse to implement more ISO-like read behaviour in iso mode, resolves #24060
git-svn-id: trunk@23884 -
2013-03-17 08:27:21 +00:00
nickysn
573ea10ef3 * fixed val when the 'code' parameter is the same size as the native CPU int type, but unsigned
git-svn-id: branches/i8086@23859 -
2013-03-16 12:42:37 +00:00
nickysn
fdf831b4c6 * i8086 fix in tinlinenode.pass_typecheck for trunc and round
git-svn-id: branches/i8086@23849 -
2013-03-15 17:03:33 +00:00
florian
b43b4bb455 + pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned
git-svn-id: trunk@23310 -
2013-01-04 19:13:24 +00:00
florian
d140c5b4ee * handle inc/dec/pred/succ correctly with type parameters, resolves #23299
git-svn-id: trunk@23248 -
2012-12-29 10:01:54 +00:00
florian
761fcca4ec + is_dynamicstring
+ implement low/high for dynamic strings, resolves #15244 and #22936
+ basic support for $zerobasedstrings directive

git-svn-id: trunk@22933 -
2012-11-04 21:48:53 +00:00
sergei
12ad6704f6 - Removed a number of unused variables, reduces noise at compilation.
git-svn-id: trunk@22880 -
2012-10-30 11:55:59 +00:00
florian
9a5e64442f + support copy with two parameters, resolves #22964
git-svn-id: trunk@22575 -
2012-10-07 19:44:52 +00:00
florian
ff12d63248 + generic popcnt support
git-svn-id: trunk@22290 -
2012-09-02 20:59:44 +00:00
florian
b782918434 * first draft to support the popcnt instruction, works so far for x86 with a real popcnt instruction
git-svn-id: trunk@22289 -
2012-09-02 20:59:39 +00:00
florian
396a9cafa8 * use ptrsinttype instead of sinttype as code parameter for val: for "normal" 32/64 bit targets this does not matter,
for 8 bit targets like avr this makes code in theory useful for ansistrings etc.

git-svn-id: trunk@22161 -
2012-08-21 16:46:19 +00:00
sergei
684bf4fba2 + Reject object types without VMT as arguments of typeof(). Without this check, an undefined reference to VMT is generated which fails at the linking stage.
git-svn-id: trunk@21923 -
2012-07-17 05:46:55 +00:00
pierre
dd59db1bba * Set retun value of get_frame method to nil
git-svn-id: trunk@21904 -
2012-07-12 14:16:24 +00:00
Jonas Maebe
56fcc87cb2 * add get_frame as an internal symbol for the jvm target because that target
defines INTERNAL_BACKTRACE (which assumes get_frame to be internal rather
    than a system unit procedure)
  * changed fpc_assert() declaration for jvm to be the same as for other
    targets, so the same code can be used to call it in ninl now that's
    called from the first pass

git-svn-id: trunk@21903 -
2012-07-12 13:25:02 +00:00
Jonas Maebe
89c230c035 * moved assert handling from second to first pass, so that the code generator
knows that the frame pointer needs to be available (and the code is also
    much simpler this way), fixes test/units/system/tassert7 after r21843

git-svn-id: trunk@21869 -
2012-07-11 11:49:47 +00:00
svenbarth
7332a0f801 ninl.pas, tinlinenode.pass_typecheck: an intrinsic which has a generic type parameter as argument is left as is (e.g. a call) and thus this needs to be respected when typechecking a SizeOf. Fixes Mantis #21592.
git-svn-id: trunk@21497 -
2012-06-06 14:41:12 +00:00
Jonas Maebe
562b968b16 * now that copy() expressions are only translated into calls during the
first pass, we have to manually set the varstate of its parameters during
    the typecheck pass (mantis #21878)

git-svn-id: trunk@21106 -
2012-04-28 21:33:29 +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
florian
13e152f8a9 * even if currency is handle by an int64, it needs no extra handling in handle_default
git-svn-id: trunk@21025 -
2012-04-24 18:47:58 +00:00
Jonas Maebe
98609d4c3e * also create a realconstn for default(currency) on platforms where the
currency type is implemented via int64 (fixes tests/test/tdefault1 on
    platforms without an x87)

git-svn-id: trunk@20958 -
2012-04-21 18:38:27 +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
svenbarth
bd19a16be9 Add support for Default() intrinsic. For now this is only (fully) supported
in code and not in constants. In the case of primitive types constant nodes
are used while complex types like arrays, records and objects use a local
variable which is initialized to zero once at the entry of the method (the
variable is reused if Default() is used for the same type multiple times in
the same method). For this a new compilerproc was added which uses FillChar
to initialize the given memory area to zero.
This fixes Mantis #9420.

+ psystem.pas: Added Default symbol to system unit
+ htypechk.pas: Added function "is_valid_for_default" which checks recursively
                whether the given type can be used with Default at all. 
                Forbidden types are files, helpers, ObjC and C++ types. This
                check is used for records, arrays and objects only if the mode
                is a non-Delphi one, as Delphi ignores these types on lower
                levels.
+ msg/errore.msg: Added error message for unsupported types for Default()
+ symconst.pas: Added a new enum value vo_is_default_var which is used for the
                local variables utilized by Default() so their initalization
                and finalization can be avoided.
+ pexpr.pas: Add handling of Default() intrinsic to "statement_syssym"
+ ninl.pas: Extended tinlinenode by a method which returns the correct node for
            a Default() and used that method in handle_typecheck.
* ncgutil.pas: Check for new flag "vo_is_default_var" when initializing and
               finalizing local variables.
* ppu.pas: increase PPU version
+ psub.pas: 
  * Added a new routine which zeros defaultvars of a symtable.
  * Use this routine inside "initializevars".
  * Also use this routine to initialize the staticsymtable of the unit/program.
* Adjusted ppudump, because of the new enum value.
+ Added implementation of fpc_zeromem to system unit.
+ Added tests for Default()

git-svn-id: trunk@20629 -
2012-03-25 16:02:27 +00:00
florian
ca90260855 + fix duplicate internal error, resolves #21545
git-svn-id: trunk@20619 -
2012-03-25 09:18:45 +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
Jonas Maebe
34df763ab1 * allocate space for the explicitly allocated assert parameter
git-svn-id: trunk@20501 -
2012-03-10 19:20:07 +00:00
pierre
2e0a5facd2 * Fix str inline for booleans for 64 bit CPUs
git-svn-id: trunk@20423 -
2012-02-24 10:06:44 +00:00
Jonas Maebe
85ef5e109c + assert() support for the JVM target (currently ignores the Java classloader
assertionStatus setting)

git-svn-id: branches/jvmbackend@20388 -
2012-02-20 11:28:59 +00:00
paul
c1866d5c17 compiler:
- don't pass CP_NONE encoding to internal functions. They handled it as 0 encoding. This will optimize the generated code a bit.
  - convert all king of string/char/pchar constants to local ansistring def if they needs to be passed to rawbytestring type. They should not get a CP_NONE codepage (delphi compatible)
  - don't convert left and right arguments of string concatenation to ansistring type if they are already ansistrings but with different codepage - RTL already handles different codepages in concat routine
  - fix resultdef for ansistring concatenations inside assignments - return def of left assignment operand if it is already ansistring - this reduces amount of unneeded condepage conversions since concat functions can return result in any desired codepage
rtl: remove CP_NONE comparisions from most of RTL functions, replace 0 constant with CP_ACP
tests: add test to check various conversions to RawByteString type

git-svn-id: trunk@19519 -
2011-10-20 09:25:51 +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
paul
485695d4e6 compiler, rtl: pass codepage argument to all ansistring str() helpers to return result with correct codepage
git-svn-id: trunk@19287 -
2011-09-30 03:26:34 +00:00
florian
cb647d875c * avoid mistakes with unimplemented sqr function on architectures with no softfloat support
git-svn-id: trunk@19218 -
2011-09-24 21:17:09 +00:00
paul
7a998aec3a compiler, rtl: add a codepage argument fpc_Read_Text_AnsiStr to create new AnsiString with the codepage of passed AnsiString argument
git-svn-id: trunk@19210 -
2011-09-24 17:43:30 +00:00
Jonas Maebe
583c9a3360 * replace assigned(dynarray) and dynarray=/<>nil with length(dynarray)=/<>0
on the JVM target because empty dynarrays are not always nil there

git-svn-id: branches/jvmbackend@19154 -
2011-09-19 19:59:32 +00:00
Jonas Maebe
28c20cfc5e * the default string type for the JVM target is no longer automatically
unicodestring = java.lang.String. The reason this was the default in
    the past is that this was the first string type that was implemented,
    and without it being the default most code involving string operations
    would fail. Now the default strings types are the same as for other
    targets
  + new {$modeswitch unicodestrings} directive, that when activated
    *together* with {$h+},
   1) changes char into an alias for widechar
   2) changes string into an alias for unicodestring
   3) changes the preferred string evaluation type (in case of uncertainty)
      to unicodestring
    {$modeswitch unicodestrings} with {$h-} does not change anything at all
    regarding the string type (it still changes the char type)
  + new uuchar unit that redefines char as widechar, and which is automatically
    included by the compiler if {$modeswitch unicodestrings} is enabled

git-svn-id: branches/jvmbackend@18781 -
2011-08-20 08:35:47 +00:00
Jonas Maebe
67c2c7c166 * renamed cchartype to cansichartype
git-svn-id: branches/jvmbackend@18779 -
2011-08-20 08:35:24 +00:00
Jonas Maebe
d48fa1d7e2 * for all managed VM targets, reject ord->ptr typecasts (except for 0),
typeof(), typeinfo(), seg(), ofs(), settextbuf(), slice(), resourcestring,
    new(), dispose()

git-svn-id: branches/jvmbackend@18747 -
2011-08-20 08:32:21 +00:00