Ada 程式設計/屬性
外觀
< Ada 程式設計
當宣告變數或子程式等實體時,其某些屬性通常由編譯器指定(例如變數的大小或地址、子程式的呼叫約定)。可以查詢的屬性稱為 *屬性*;可以指定的屬性稱為 方面。方面和屬性在 Ada 參考手冊的附件中定義 附件 K:語言定義的方面和屬性 [帶註釋的].
*屬性* 的概念對於 Ada 來說非常獨特。屬性允許您獲取 - 並且有時設定 - 關於物件或其他語言實體(如型別)的資訊。一個很好的例子是 Size 屬性。它描述了物件或型別的大小(以位為單位)。
A : Natural := Integer'Size; -- A is now 32 (with the GNAT compiler for the x86 architecture)
但是,與來自 C/C++ 的 sizeof 運算子不同,Size 屬性也可以設定。
typeByteisrange-128 .. 127; -- The range fits into 8 bits but the -- compiler is still free to choose.forByte'Sizeuse8; -- Now we force the compiler to use 8 bits.
當然,並非所有屬性都可以設定。屬性以一個 '(撇號)開頭,後跟屬性名稱。編譯器透過上下文確定撇號是屬性的開始,還是字元文字或量化表示式的開始。
A : Character := Character'Val (32); -- A is now a space B : Character := ' '; -- B is also a space S : String := Character'(')')'Image; -- an especially nice parsing exercise
- Ada 2022
- 這是一個新的 Ada 2022 屬性。
- 過時
- 這是一個已棄用的屬性,不應在新的程式碼中使用。
- 'Definite
- 'Delta
- 'Denorm
- 'Digits
- 'Emax (過時)
- 'Enum_Rep (Ada 2022)
- 'Enum_Val (Ada 2022)
- 'Exponent
- 'External_Tag
- 'Epsilon (過時)
- 'First
- 'First_Bit
- 'Floor
- 'Fore
- 'Fraction
- 'Has_Same_Storage (Ada 2012)
- 'Identity
- 'Image (Ada 2022 中已更改)
- 'Index (Ada 2022)
- 'Input
- 'Large (過時)
- 'Last
- 'Last_Bit
- 'Leading_Part
- 'Length
- 'Machine
- 'Machine_Emax
- 'Machine_Emin
- 'Machine_Mantissa
- 'Machine_Overflows
- 'Machine_Radix
- 'Machine_Rounding (Ada 2005)
- 'Machine_Rounds
- 'Mantissa (過時)
- 'Max
- 'Max_Alignment_For_Allocation (Ada 2012)
- 'Max_Size_In_Storage_Elements
- 'Min
- 'Mod (Ada 2005)
- 'Model
- 'Model_Emin
- 'Model_Epsilon
- 'Model_Mantissa
- 'Model_Small
- 'Modulus
- 'Object_Size (Ada 2022)
- 'Old (Ada 2012)
- 'Output
- 'Overlaps_Storage (Ada 2012)
- 'Parallel_Reduce (Ada 2022)
- 'Partition_ID
- 'Pos
- 'Position
- 'Pred
- 'Preelaborate_Initialization (Ada 2022)
- 'Priority (Ada 2005)
- 'Put_Image (Ada 2022)
- 'Range
- 'Read
- 'Reduce (Ada 2022)
- 'Relative Deadline (Ada 2022)
- 'Remainder
- 'Result (Ada 2012)
- 'Round
- 'Rounding
- 'Safe_Emax (過時)
- 'Safe_First
- 'Safe_Large (過時)
- 'Safe_Last
- 'Safe_Small (過時)
- 'Scale
- 'Scaling
- 'Signed_Zeros
- 'Size
- 'Small
- 'Storage_Pool
- 'Storage_Size
- 'Stream_Size (Ada 2005)
- 'Succ
- '寬影像 (Ada 2022 中更改)
- '寬值
- '寬寬影像 (Ada 2005,在 Ada 2022 中更改)
- '寬寬值 (Ada 2005)
- '寬寬寬度 (Ada 2005)
- '寬寬度
- '寬度
- '寫入
以下屬性並非所有 Ada 編譯器都提供,僅在實現過這些屬性的編譯器中提供。
目前,只列出了幾個編譯器的實現定義屬性。您可以幫助 Wikibooks 新增 其他編譯器的特定屬性。
- GNAT
- 實現定義屬性 來自 AdaCore/FSF 的 GNAT 編譯器。
- HP Ada
- HP Ada 編譯器(以前稱為“DEC Ada”)的實現定義屬性。
- ICC
- Irvine ICC 編譯器的實現定義屬性[1]。
- PowerAda
- 實現定義屬性 來自 OC Systems 的 PowerAda。
- SPARCompiler
- 實現定義屬性 來自 Sun 的 SPARCompiler Ada。
- '中止訊號 (GNAT)
- '地址大小 (GNAT)
- '體系結構 (ICC)
- '彙編輸入 (GNAT)
- '彙編輸出 (GNAT)
- 'AST 條目 (GNAT,HP Ada)
- '原子始終無鎖 (GNAT)
- '位 (GNAT,HP Ada)
- '位位置 (GNAT)
- 'CG 模式 (ICC)
- '程式碼地址 (GNAT)
- '編譯器金鑰 (SPARCompiler)
- '編譯器版本 (GNAT,SPARCompiler)
- '受限的 (GNAT)
- '已宣告的 (ICC)
- '預設位順序 (GNAT)
- '預設標量儲存順序 (GNAT)
- '解除引用 (GNAT)
- '描述符大小 (GNAT)
- 'Dope 地址 (SPARCompiler)
- 'Dope 大小 (SPARCompiler)
- '已詳細說明的 (GNAT)
- '詳細說明主體 (GNAT)
- '詳細說明規範 (GNAT)
- '詳細說明子程式主體 (GNAT)
- 'Emax (GNAT)
- '已啟用 (GNAT)
- '條目編號 (SPARCompiler)
- '列舉表示 (GNAT)
- '列舉值 (GNAT)
- 'Epsilon (GNAT)
- '異常地址 (ICC)
- '擴充套件字尾 (PowerAda)
- '擴充套件基數 (PowerAda)
- '擴充套件位數 (PowerAda)
- '擴充套件字首 (PowerAda)
- '擴充套件影像 (PowerAda)
- '擴充套件值 (PowerAda)
- '擴充套件寬度 (PowerAda)
- '擴充套件寬影像 (PowerAda)
- '擴充套件寬值 (PowerAda)
- '擴充套件寬寬度 (PowerAda)
- '快速數學 (GNAT)
- '終結大小 (GNAT)
- '固定值 (GNAT)
- '從任意型別轉換 (GNAT)
- '有訪問值 (GNAT)
- '有辨別式 (GNAT)
- '有標記值 (GNAT)
- '高位字 (ICC)
- '同構的 (SPARCompiler)
- 'Img (GNAT)
- '已初始化的 (GNAT)
- '整數值 (GNAT)
- '無效值 (GNAT)
- '線性地址 (ICC)
- '大尺寸的 (GNAT)
- '庫級別 (GNAT)
- '低位字 (ICC)
- '迴圈條目 (GNAT)
- '機器大小 (GNAT,HP Ada)
- '尾數 (GNAT)
- '最大整型大小 (GNAT)
- 'Max_Interrupt_Priority (GNAT)
- 'Max_Priority (GNAT)
- 'Maximum_Alignment (GNAT)
- 'Mechanism_Code (GNAT)
- 'Null_Parameter (GNAT, HP Ada)
O – T
[edit | edit source]- 'Object_Size (GNAT)
- 'Old (GNAT)
- 'Passed_By_Reference (GNAT)
- 'Pool_Address (GNAT)
- 'Range_Length (GNAT)
- 'Ref (SPARCompiler)
- 'Restriction_Set (GNAT)
- 'Result (GNAT)
- 'Round (GNAT)
- 'Safe_Emax (GNAT)
- 'Safe_Large (GNAT)
- 'Safe_Small (GNAT)
- 'Scalar_Storage_Order (GNAT)
- 'Simple_Storage_Pool (GNAT)
- 'Small (GNAT)
- 'Small_Denominator (GNAT)
- 'Small_Numerator (GNAT)
- 'Storage_Unit (GNAT)
- 'Stub_Type (GNAT)
- 'System_Allocator_Alignment (GNAT)
- 'Target (ICC)
- 'Target_Name (GNAT)
- 'Task_ID (SPARCompiler)
- 'Tick (GNAT)
- 'To_Address (GNAT)
- 'To_Any (GNAT)
- 'Type_Class (GNAT, HP Ada)
- 'TypeCode (GNAT)
- 'Type_Key (SPARCompiler)
U – Z
[edit | edit source]- 'UET_Address (GNAT)
- 'Unconstrained_Array (GNAT)
- 'Universal_Literal_String (GNAT)
- 'Unrestricted_Access (GNAT, ICC)
- 'Update (GNAT)
- 'VADS_Size (GNAT)
- 'Valid_Value (GNAT)
- 'Valid_Scalars (GNAT)
- 'Value_Size (GNAT)
- 'Wchar_T_Size (GNAT)
- 'Word_Size (GNAT)
