
1 // 2 // Copyright (c) 2006, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 5 Jun 06 Brian Frank Creation 7 // 8 9 ** 10 ** PodDef models the pod being compiled. 11 ** 12 class PodDef : DefNode, CPod 13 { 14 15 ////////////////////////////////////////////////////////////////////////// 16 // Construction 17 ////////////////////////////////////////////////////////////////////////// 18 19 new make(Namespace ns, Location location, Str name) 20 : super(location) 21 { 22 this.ns = ns 23 this.name = name 24 } 25 26 ////////////////////////////////////////////////////////////////////////// 27 // CPod 28 ////////////////////////////////////////////////////////////////////////// 29 30 override Version version() { return null } 31 32 override CType resolveType(Str name, Bool checked) 33 { 34 t := typeDefs[name] 35 if (t != null) return t 36 if (checked) throw UnknownTypeErr.make("${this.name}::${name}") 37 return null 38 } 39 40 override CType[] types() 41 { 42 return typeDefs.values 43 } 44 45 ////////////////////////////////////////////////////////////////////////// 46 // Debug 47 ////////////////////////////////////////////////////////////////////////// 48 49 override Void print(AstWriter out) 50 { 51 out.nl 52 out.w("======================================").nl 53 out.w("pod $name").nl 54 out.w("======================================").nl 55 units.each |CompilationUnit unit| { unit.print(out) } 56 out.nl 57 } 58 59 override Str toStr() 60 { 61 return "pod $name" 62 } 63 64 ////////////////////////////////////////////////////////////////////////// 65 // Fields 66 ////////////////////////////////////////////////////////////////////////// 67 68 override readonly Namespace ns // compiler's namespace 69 override readonly Str name // simple pod name 70 CompilationUnit[] units // Tokenize 71 Str:TypeDef typeDefs // ScanForUsingsAndTypes 72 73 }