ASIS表現を見る
package test is type t is record a : integer; b : integer := 10; end record; end test;
手始めにこれがASISでどう見えるのかを探りたいと思います。
asistant。
initialize("") set(c) associate(c,"test","-FS") open(c) set(u, Library_Unit_Declaration("Test", c)) print(u) set(d, unit_declaration(u)) print(d) set(n, names(d)) print(n) set(t, n(1)) print(t) print(Defining_Name_Image(t)) set(items, Visible_Part_Declarative_Items(d, false)) print(items) set(z, items(1)) print(z) set(x, names(z)) print(x) print(Defining_Name_Image(x(1))) print(Element_Kind(z)) print(Declaration_Kind(z)) print(Element_Kind(x(1))) print(Defining_Name_Kind(x(1))) set(v, Type_Declaration_View(z)) print(v) set(r, Record_Definition(v)) print(r) set(f, Record_Components(r, false)) print(f) print(names(f(1))) print(names(f(2))) set(i, names(f(1))) print(Defining_Name_Image(i(1))) close(c) dissociate(c) finalize("")
...>asistant test.scr ASIStant - ASIS Tester And iNTerpreter, v1.5 (C) 1997-2006, Free Software Foundation, Inc. Asis Version: ASIS 2.0.R initialize("") set(c) associate(c,"test","-FS") open(c) set(u, Library_Unit_Declaration("Test", c)) print(u) Compilation Unit Debug_Image: Unit Id: 3 Unit name: test Kind: A_PACKAGE Class: A_PUBLIC_DECLARATION Origin: AN_APPLICATION_UNIT Enclosing Context Id: 1 Is consistent: TRUE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
情報が取れていることはわかる。これでrecordのI/Oマッパー自動生成とかもできそうです。
asistantではまどろっこしいので、asis2xml。
...>gcc -c -gnatt test.ads ...>asis2xml test.adt Asis.Ada_Environments.Open: tree file test.adt is not compile-only
理由がわからないので、Avatox。
...>avatox test.ads > a
で出力結果。
<?xml version="1.0" encoding="UTF-8" ?> <codeRepresentation> <sourceLanguage name="Ada" languageVersion="95" compiler="GNAT 4.1.1"/> <pedigrees> <pedigree name="asis" xmlStyle="false"> <standardInfo name="Ada Semantic Interface Specification (ASIS)" implementor="AdaCore (http://www.adacore.com)" implementorVersion="ASIS 2.0.R for GNAT 4.1.1"/> </pedigree> <pedigree name="avatoxAsis" xmlStyle="false"> <processorInfo name="Avatox" implementor="McKae Technologies (www.mckae.com)" implementorVersion="1.1"/> </pedigree> </pedigrees> <A_PACKAGE pedigree="asis" unitName="test" startLine="1" endLine="6" startCol="1" endCol="9"> <A_DECLARATION pedigree="asis" startLine="1" endLine="6" startCol="1" endCol="9"> <A_PACKAGE_DECLARATION pedigree="asis" startLine="1" endLine="6" startCol="1" endCol="9"> </A_PACKAGE_DECLARATION> <A_DEFINING_NAME pedigree="asis" startLine="1" endLine="1" startCol="9" endCol="12"> <A_DEFINING_IDENTIFIER pedigree="asis" name="test" startLine="1" endLine="1" startCol="9" endCol="12"/> </A_DEFINING_NAME> <A_DECLARATION pedigree="asis" startLine="2" endLine="5" startCol="4" endCol="14"> <AN_ORDINARY_TYPE_DECLARATION pedigree="asis" startLine="2" endLine="5" startCol="4" endCol="14"> </AN_ORDINARY_TYPE_DECLARATION> <A_DEFINING_NAME pedigree="asis" startLine="2" endLine="2" startCol="9" endCol="9"> <A_DEFINING_IDENTIFIER pedigree="asis" name="t" startLine="2" endLine="2" startCol="9" endCol="9"/> </A_DEFINING_NAME> <A_DEFINITION pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"> <A_TYPE_DEFINITION pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"> <A_RECORD_TYPE_DEFINITION pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"> <AN_ORDINARY_TRAIT pedigree="asis" pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"/> </A_RECORD_TYPE_DEFINITION> </A_TYPE_DEFINITION> <A_DEFINITION pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"> <A_RECORD_DEFINITION pedigree="asis" startLine="2" endLine="5" startCol="14" endCol="13"> </A_RECORD_DEFINITION> <A_DECLARATION pedigree="asis" startLine="3" endLine="3" startCol="7" endCol="18"> <A_COMPONENT_DECLARATION pedigree="asis" startLine="3" endLine="3" startCol="7" endCol="18"> </A_COMPONENT_DECLARATION> <A_DEFINING_NAME pedigree="asis" startLine="3" endLine="3" startCol="7" endCol="7"> <A_DEFINING_IDENTIFIER pedigree="asis" name="a" startLine="3" endLine="3" startCol="7" endCol="7"/> </A_DEFINING_NAME> <A_DEFINITION pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"> <A_COMPONENT_DEFINITION pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"> <AN_ORDINARY_TRAIT pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"/> </A_COMPONENT_DEFINITION> <A_DEFINITION pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"> <A_SUBTYPE_INDICATION pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"> </A_SUBTYPE_INDICATION> <AN_EXPRESSION pedigree="asis" startLine="3" endLine="3" startCol="11" endCol="17"> <AN_IDENTIFIER pedigree="asis" ident="integer" startLine="3" endLine="3" startCol="11" endCol="17"/> </AN_EXPRESSION> </A_DEFINITION> </A_DEFINITION> </A_DECLARATION> <A_DECLARATION pedigree="asis" startLine="4" endLine="4" startCol="7" endCol="24"> <A_COMPONENT_DECLARATION pedigree="asis" startLine="4" endLine="4" startCol="7" endCol="24"> </A_COMPONENT_DECLARATION> <A_DEFINING_NAME pedigree="asis" startLine="4" endLine="4" startCol="7" endCol="7"> <A_DEFINING_IDENTIFIER pedigree="asis" name="b" startLine="4" endLine="4" startCol="7" endCol="7"/> </A_DEFINING_NAME> <A_DEFINITION pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"> <A_COMPONENT_DEFINITION pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"> <AN_ORDINARY_TRAIT pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"/> </A_COMPONENT_DEFINITION> <A_DEFINITION pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"> <A_SUBTYPE_INDICATION pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"> </A_SUBTYPE_INDICATION> <AN_EXPRESSION pedigree="asis" startLine="4" endLine="4" startCol="11" endCol="17"> <AN_IDENTIFIER pedigree="asis" ident="integer" startLine="4" endLine="4" startCol="11" endCol="17"/> </AN_EXPRESSION> </A_DEFINITION> </A_DEFINITION> <AN_EXPRESSION pedigree="asis" startLine="4" endLine="4" startCol="22" endCol="23"> <AN_INTEGER_LITERAL pedigree="asis" literal="10" startLine="4" endLine="4" startCol="22" endCol="23"/> </AN_EXPRESSION> </A_DECLARATION> </A_DEFINITION> </A_DEFINITION> </A_DECLARATION> </A_DECLARATION> </A_PACKAGE> </codeRepresentation>