"상자 형"(인터프리터 용) 구현에서는 원래 하위 패키지에 벡터가 있고 System.Address에서 Vector_Ptr로 변환 할 때 System.Access_To_Address_Conversions를 사용하여 주기적 종속성으로 인해 극복 할 수없는 문제를 피하십시오. (적어도, 모든 사람에게 제한된 사용은 나를 위해 속임수를 쓰지 않았습니다.) 그것은 효과가 있었지만 불쾌한 해킹처럼 보였습니다. 그래서 컨테이너 유형을 주 패키지 Types.Boxed에 넣기로 결정했습니다. 이제 GNAT는 불완전한 타입의 보이는 부분에 "벡터"라는 라인 12 '에 정의 된 선언을하지 않습니다.상호 의존형 선언 및 Ada.Containers
이 문제를 해결할 방법이 있습니까? 아니면 내가 불쾌한 해킹으로 돌아 가야 하나? 플래그 GNAT 4.6을 사용하여
에이다 2005
는 -gnat05with Interfaces; use Interfaces;
with Ada.Strings.Wide_Unbounded; use Ada.Strings.Wide_Unbounded;
with Ada.Containers.Vectors;
with Green_Tasks; use Green_Tasks;
package Types.Boxed is
type Type_T is (T_Null, T_Unsigned_64, T_String, T_Boolean,
T_Green_Task, T_Vector);
type String_Ptr is access all Unbounded_Wide_String;
type Vector;
type Vector_Ptr is access all Vector;
type Item (IType : Type_T := T_Null) is record
case IType is
when T_Null => null;
when T_Unsigned_64 => Value_Unsigned_64 : Unsigned_64;
when T_String => Value_String : String_Ptr;
when T_Boolean => Value_Boolean : Boolean;
when T_Green_Task => Value_Green_Task : Green_Task_Ptr;
when T_Vector => Value_Vector : Vector_Ptr;
end case;
end record;
procedure Free (Datum : in out Item);
procedure Box (Datum : out Item; Value : in Unsigned_64);
function Unbox (Datum : Item) return Unsigned_64;
procedure Box (Datum : out Item; Value : String_Ptr);
function Unbox (Datum : Item) return String_Ptr;
procedure Box (Datum : out Item; Value : in Boolean);
function Unbox (Datum : Item) return Boolean;
procedure Box (Datum : out Item; Value : in Green_Task_Ptr);
function Unbox (Datum : Item) return Green_Task_Ptr;
function Get_Boxed_Type (Datum : Item) return Type_T;
-- vectors
package Item_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Item
);
use Item_Vectors;
function Vector_New (Size_Hint : Positive) return Item;
function Unbox (Datum : Item) return Vector_Ptr;
procedure Vector_Free (V : in out Vector_Ptr);
function Vector_Copy (V : Vector_Ptr) return Item;
pragma Inline (Box);
pragma Inline (Unbox);
pragma Pure_Function (Unbox);
pragma Pure_Function (Get_Boxed_Type);
end Types.Boxed;
컨테이너를 확장하는 문제는 컨테이너 유형 (Vector has 7)을 반환하는 함수의 수이며 따라서 오버라이드해야합니다. –
@SimonWright 아니요, 2005 년 Ada에서 유형 확장이 _ 내선 확장 인 경우 함수를 재정의 할 필요가 없습니다. – ajb
O 예, 이제는 그 라인에서 * my * 시도의 요점은 확장이 추가 내용을 가지고 있다는 것입니다. 죄송합니다. –