简体   繁体   English

在哪里可以找到 Delphi“编译器魔术”声明的完整列表?

[英]Where can I find a comprehensive list of Delphi "compiler magic" declarations?

A comment at the top of system.pas states: system.pas 顶部的评论指出:

{ Predefined constants, types, procedures, }
{ and functions (such as True, Integer, or }
{ Writeln) do not have actual declarations.}
{ Instead they are built into the compiler }
{ and are treated as if they were declared }
{ at the beginning of the System unit.     }

Obviously, that's nowhere near a comprehensive list.显然,这远不是一份完整的清单。 Does anyone know where I could find the complete list?有谁知道我在哪里可以找到完整的列表?

EDIT: The responses I've got so far seem to be a bit confused as to what I'm looking for.编辑:到目前为止,我得到的答复似乎对我正在寻找的内容有些困惑。 I'm trying to find a list of the built-in constants, types, procedures and functions that the compiler recognizes but are not declared in any unit.我试图找到编译器识别但未在任何单元中声明的内置常量、类型、过程和函数的列表。 Examples include High(), Writeln(), Assert(), string , etc.示例包括 High()、Writeln()、Assert()、 string等。

this is offical list of magic functions. 是魔术功能的官方列表。 Good luck about types and constants! 关于类型和常量的好运!

It seemed a shame that no one has decided to make one so I will. 似乎很遗憾,没有人决定制造一个,所以我会。 I can't claim this is a comprehensive list. 我不能说这是一个全面的清单。 Its merely what I've been able to glean from either the documentation or by examining the source for missing identifiers. 它仅仅是我从文档或通过检查缺少标识符的来源收集的内容。 If you notice an omission feel free to edit the answer. 如果您发现遗漏,请随时编辑答案。

Conditional Symbols 条件符号

Many conditional symbols vary depending on the compiler's version and targeted platform but the following should be defined regardless of version or platform: 许多条件符号根据编译器的版本和目标平台而有所不同,但无论版本或平台如何,都应定义以下内容:

  • DCC DCC
  • VER <nnn> VER <nnn>

Constants 常量

  • CompilerVersion CompilerVersion
  • MaxInt MAXINT
  • MaxLongint MaxLongint

Routines 例程

  • Abs 阿布斯
  • Addr 地址
  • Append 附加
  • Assert 断言
  • Assigned 分配
  • Assign 分配
  • AssignFile AssignFile
  • BlockRead BlockRead
  • BlockWrite BlockWrite命令
  • Break 打破
  • Chr CHR
  • Close
  • CloseFile CloseFile
  • Concat CONCAT
  • Continue 继续
  • Copy 复制
  • Dec 十二月
  • Dispose 部署
  • Eof EOF
  • Eoln EOLN
  • Erase 抹去
  • Exclude 排除
  • Exit 出口
  • FilePos FilePos
  • FileSize 文件大小
  • FillChar FillChar
  • Finalize 最终确定
  • Flush 红晕
  • FreeMem freemem在
  • Halt
  • Hi 你好
  • High
  • Inc 公司
  • Include 包括
  • Initialize 初始化
  • Insert 插入
  • Length 长度
  • Lo
  • Low
  • New
  • Odd
  • Pi
  • Pred 强的松
  • Ptr PTR
  • Read
  • Readln Readln
  • ReallocMem ReallocMem
  • Rename 改名
  • Reset 重启
  • Rewrite 改写
  • Round 回合
  • RunError RunError
  • Seek 寻求
  • SeekEof SeekEof
  • SeekEoln SeekEoln
  • SetLength SetLength
  • SetString 的SetString
  • SizeOf 中SizeOf
  • Slice 切片
  • Sqr SQR
  • Str STR
  • Succ SUCC
  • Swap 交换
  • Trunc TRUNC
  • TypeHandle 类型句柄
  • TypeInfo 所属类别
  • TypeOf 类型
  • Val 瓦尔
  • VarCast VarCast
  • VarCopy VarCopy
  • Write
  • Writeln Writeln

Here's one that appears to apply only to linux (at least in the version I'm using): 这里似乎只适用于linux(至少在我使用的版本中):

  • open It is referenced in SysUtils.FileCreate but there is no open function with that signature defined anywhere in the code base. open它在SysUtils.FileCreate中引用,但没有在代码库中的任何位置定义该签名的open函数。 System.__open has the same signature and points to the libc open function but is not referenced outside the System unit so the compiler must be doing more "magic" to resolve open to __open . System.__open具有相同的签名并指向libc open函数,但未在System单元外部引用,因此编译器必须做更多“魔术”以解析对__open open

Types 类型

  • AnsiChar ANSIChar类型
  • Boolean 布尔
  • Byte 字节
  • ByteBool ByteBool
  • Cardinal 枢机主教
  • Char 烧焦
  • Comp 比较
  • Currency 货币
  • Double
  • Extended 扩展
  • Int64 Int64的
  • Integer 整数
  • LongBool LongBool这
  • Longint Longint型
  • Longword 长字
  • NativeInt NativeInt
  • NativeUInt NativeUInt
  • OleVariant OleVariant
  • Pointer 指针
  • Real 真实
  • Real48 Real48
  • ShortInt ShortInt
  • ShortString ShortString短
  • Single
  • SmallInt SMALLINT
  • string (reserved word but you can "Ctrl+Click" on it if you write System.string) string(保留字,但如果你编写System.string,你可以“Ctrl + Click”)
  • Text 文本
  • TextFile 文本文件
  • UInt64 答:64
  • UnicodeString 的UnicodeString
  • Variant 变种
  • WideChar WideChar
  • WideString WideString的
  • WordBool WordBool

Some of the internally defined types can be found a little further down in System.pas (around line 90 in the version shipped with Delphi 2010 Update 4). 在System.pas中可以找到一些内部定义的类型(Delphi 2010 Update 4附带的版本中的第90行)。 You can find them easily with a search on "built-in types"; 您可以通过搜索“内置类型”轻松找到它们; there's a list of {$EXTERNALSYM} declarations for C++Builder where things like String, AnsiString, etc. can be found. 有一个{$ EXTERNALSYM}的C ++ Builder声明列表,可以找到像String,AnsiString等的东西。

As far as the procedures and functions, I don't know of any list anywhere. 至于程序和功能,我不知道任何列表。 Allen Bauer or Barry Kelly might find this and be able to help, though. 尽管如此,Allen Bauer或Barry Kelly可能会发现这一点并能够提供帮助。

The list of types and consts is also not official, but can be deduced from the System.pas sources if you have them. 类型和内容列表也不是官方的,但如果您有,可以从System.pas源中推断出来。 It also depends on the kind of compiler (support for Unicode, Kylix, .NET, etc.). 它还取决于编译器的类型(支持Unicode,Kylix,.NET等)。

This is the relevant portion from the Delphi 2010 System.pas: 这是Delphi 2010 System.pas的相关部分:

{$EXTERNALSYM CompilerVersion}

{$EXTERNALSYM Boolean     'bool'             } {$OBJTYPENAME Boolean    'Bo'}
{$NODEFINE    ShortInt    'ShortInt'         } {$OBJTYPENAME ShortInt   'Bzc'} { signed char }
{-EXTERNALSYM ShortInt    'signed char'      } {-OBJTYPENAME ShortInt   'Bzc'}
{$EXTERNALSYM SmallInt    'short'            } {$OBJTYPENAME SmallInt   'Bs'}
{$EXTERNALSYM Integer     'int'              } {$OBJTYPENAME Integer    'Bi'}
{$NODEFINE    Byte        'Byte'             } {$OBJTYPENAME Byte       'Buc'} { unsigned char }
{$NODEFINE    Word        'Word'             } {$OBJTYPENAME Word       'Bus'} { unsigned short }
{$EXTERNALSYM Cardinal    'unsigned'         } {$OBJTYPENAME Cardinal   'Bui'}
{$EXTERNALSYM Int64       '__int64'          } {$OBJTYPENAME Int64      'Bj'}
{$EXTERNALSYM UInt64      'unsigned __int64' } {$OBJTYPENAME UInt64     'Buj'}
{$EXTERNALSYM NativeInt   'int'              } {$OBJTYPENAME NativeInt  'Bi'}
{$EXTERNALSYM NativeUInt  'unsigned'         } {$OBJTYPENAME NativeUInt 'Bui'}
{$EXTERNALSYM Single      'float'            } {$OBJTYPENAME Single     'Bf'}
{$EXTERNALSYM Double      'double'           } {$OBJTYPENAME Double     'Bd'}
{$NODEFINE    Extended    'Extended'         } {$OBJTYPENAME Extended   'Bg'} { long double }
{$NODEFINE    Currency    'Currency'    'CurrencyBase'    } {$OBJTYPENAME Currency    'NCurrency'}
{$NODEFINE    Comp        'Comp'        'CompBase'        } {$OBJTYPENAME Comp        'NComp'}
{$EXTERNALSYM Real        'double'                        } {$OBJTYPENAME Real        'Bd'}
{$NODEFINE    ShortString 'ShortString' 'ShortStringBase' } {$OBJTYPENAME ShortString 'N%SmallString$iuc$255%'}
{$NODEFINE    OpenString  'OpenString'       } {$OBJTYPENAME OpenString 'Bxpc'} { char * const }
{$NODEFINE    File        'file'             } {$OBJTYPENAME File       'Nfile'}
{$NODEFINE    Text        'TextFile'         } {$OBJTYPENAME Text       'NTextfile'}
{$NODEFINE    ByteBool    'ByteBool'         } {$OBJTYPENAME ByteBool   'Buc'} { unsigned char }
{$NODEFINE    WordBool    'WordBool'         } {$OBJTYPENAME WordBool   'Bus'} { unsigned short }
{$EXTERNALSYM LongBool    'BOOL'             } {$OBJTYPENAME LongBool   'Bi'}  { int } { from windef.h }
{$NODEFINE    Real48      } { not supported in C++ }
{$EXTERNALSYM Pointer     'void *'    }
{$NODEFINE    PWideChar   'WideChar *'}
{$EXTERNALSYM PAnsiChar   'char *'    }
{$NODEFINE    Variant     } { defined in sysvari.h }
{$NODEFINE    OleVariant  } { defined in sysvari.h }
{$NODEFINE    LongInt     } { alias of Integer     }
{$NODEFINE    LongWord    } { alias of Cardinal    }
{$NODEFINE    TextFile    } { alias of Text        }
{$IFDEF UNICODE}
  {$EXTERNALSYM AnsiChar     'char'          } {$OBJTYPENAME AnsiChar 'Bc'}
  {$IFDEF LINUX}
    {$NODEFINE  Char         'WideChar'      } {$OBJTYPENAME Char     'Bus'} { unsigned short }
                                               {-OBJTYPENAME Char     'BCs'} { char16_t }
  {$ELSE}
    {$NODEFINE  Char         'WideChar'      } {$OBJTYPENAME Char     'Bb'}  { wchar_t }
                                               {-OBJTYPENAME Char     'BCs'} { char16_t }
  {$ENDIF}
  {$NODEFINE    string       'UnicodeString' } {$OBJTYPENAME string   'NUnicodeString'} { defined in vcl/ustring.h }
  {-NODEFINE    string       'String'        } {$OBJTYPENAME string   'NUnicodeString'} { defined in vcl/ustring.h }
  {$NODEFINE    AnsiString   } { defined in vcl/dstring.h }
  {$NODEFINE    WideString   } { defined in vcl/wstring.h }
  {$NODEFINE    PChar        } { alias of PWideChar  }
  {$NODEFINE    WideChar     } { alias of Char       }
  {$NODEFINE    UnicodeString} { alias of string     }
{$ELSE}
  {$EXTERNALSYM Char         'char'          } {$OBJTYPENAME Char     'Bc'}
  {$IFDEF LINUX}
    {$NODEFINE  WideChar     'WideChar'      } {$OBJTYPENAME WideChar 'Bus'} { unsigned short }
                                               {-OBJTYPENAME WideChar 'BCs'} { char16_t }
  {$ELSE}
    {$NODEFINE  WideChar     'WideChar'      } {$OBJTYPENAME WideChar 'Bb'}  { wchar_t }
                                               {-OBJTYPENAME WideChar 'BCs'} { char16_t }
  {$ENDIF}
  {$NODEFINE    string       'AnsiString'    } { defined in vcl/dstring.h }
  {-NODEFINE    string       'String'        } { defined in vcl/dstring.h }
  {$NODEFINE    WideString   } { defined in vcl/wstring.h }
  {$NODEFINE    UnicodeString} { defined in vcl/ustring.h }
  {$NODEFINE    PChar        } { alias of PAnsiChar  }
  {$NODEFINE    AnsiChar     } { alias of Char       }
  {$NODEFINE    AnsiString   } { alias of string     }
{$ENDIF}

--jeroen --jeroen

Your best option for a ready-made list is the System documentation . 现成列表的最佳选择是系统文档 It lists many types and functions, and it has a separate link to a list of constants , although the list is shorter than I could have expected. 它列出了许多类型和函数,它有一个单独的常量列表链接,尽管列表比我预期的要短。 The list isn't entirely magic, though. 不过,这份名单并非完全神奇。 For example, there's nothing special about TInterfacedObject , but it comes from the System unit, so it's on the list. 例如, TInterfacedObject并没有什么特别之处,但它来自系统单元,所以它在列表中。

You can't actually get a list of all compiler-magic declarations. 您实际上无法获得所有编译器魔术声明的列表。 They're magic because they can't be declared. 他们是神奇的,因为他们无法宣布。 You can't have a declaration for the High function because it works on types that haven't even been invented yet (ie, any enumeration type). 您不能拥有High函数的声明,因为它适用于尚未发明的类型(即任何枚举类型)。 And you can't declare Writeln because it takes an arbitrary number of parameters and it supports a syntax not allowed anywhere else in the language. 而且你不能声明Writeln因为它需要任意数量的参数,并且它支持语言中其他地方不允许的语法。

What you can do is have a list of identifiers. 可以做的是有一个标识符列表。 They're identifiers that the compiler knows to treat specially if they resolve to the things designated as belonging to the System unit, but which we can still use to make our own declarations elsewhere in a program. 它们是编译器知道如果它们解析为指定属于系统单元的东西而特别处理的标识符,但我们仍然可以使用它来在程序的其他地方进行我们自己的声明。 You could declare your own Writeln function if you wanted. 如果需要,您可以声明自己的Writeln函数。 Your question mentions string , but that's a reserved word; 你的问题提到了string ,但这是一个保留字; you can't declare your own things called string . 你不能声明你自己的东西叫做string So although it's certainly special, I don't think it's special in quite the same way that Integer and Assert are special. 因此虽然它确实很特别,但我认为它的特殊性与IntegerAssert特别相同。

For Procedures and Functions, go into the System Unit and look for the comment: 对于程序和功能,进入系统单元并查找注释:

{ Procedures and functions that need compiler magic }

Below that is probably a fairly complete list. 下面可能是一个相当完整的清单。 Just remove the leading underscore from each routine name. 只需从每个例程名称中删除前导下划线即可。

For Keywords, the list at Delphi Basics: 对于关键字,Delphi基础知识列表:

are mostly "compiler magic", undeclared in any unit. 主要是“编译器魔法”,在任何单位都未声明。

For Constants, a short list includes: MaxInt, MaxLongInt, Nil and Pi. 对于常数,短名单包括:MaxInt,MaxLongInt,Nil和Pi。

And as Ken said, you can find most of the Types near the top of the System unit. 正如肯所说,你可以找到靠近系统单元顶部的大多数类型。

I came here looking for the magic surrounding the leading underscore of functions and procedures in System.pas.我来到这里是为了寻找围绕 System.pas 中函数和过程的前导下划线的魔法。

I found the utility tool DCU32INT (that parses *.dcu file and converts it into a close to Pascal form), also on github .我发现实用工具DCU32INT (即解析* .dcu文件,并将其转换成一个接近帕斯卡形式),也github上 It allows you to see both the buildin compiler defined functions that you are looking for, for example例如,它允许您查看您正在寻找的内置编译器定义的函数

function BlockRead功能块读取

as well as the magic ones seen in the sources of system.pas, like以及在 system.pas 源中看到的魔法,比如

function _BlockRead函数_BlockRead

The functions which shows up from the .dcu file with a leading "@" sign (local symbol?) as:从 .dcu 文件中显示的带有前导“@”符号(本地符号?)的函数为:

function @BlockRead函数@BlockRead

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM