
1 // 2 // Copyright (c) 2007, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 5 May 07 Brian Frank Creation 7 // 8 9 using compiler 10 11 ** 12 ** DocCompilerSupport provides lots of convenience methods 13 ** for classes used during the documentation compiler pipeline. 14 ** 15 class DocCompilerSupport 16 { 17 18 ////////////////////////////////////////////////////////////////////////// 19 // Construction 20 ////////////////////////////////////////////////////////////////////////// 21 22 ** 23 ** Constructor takes the associated Compiler 24 ** 25 new make(DocCompiler compiler) 26 { 27 this.compiler = compiler 28 } 29 30 ////////////////////////////////////////////////////////////////////////// 31 // Convenience 32 ////////////////////////////////////////////////////////////////////////// 33 34 ** 35 ** Convenience for compiler.log 36 ** 37 CompilerLog log() 38 { 39 return compiler.log 40 } 41 42 ////////////////////////////////////////////////////////////////////////// 43 // Errors 44 ////////////////////////////////////////////////////////////////////////// 45 46 ** 47 ** Create, log, and return a CompilerErr. 48 ** 49 virtual CompilerErr err(Str msg, Location loc) 50 { 51 return errReport(CompilerErr.make(msg, loc)) 52 } 53 54 ** 55 ** Log, store, and return the specified CompilerErr. 56 ** 57 CompilerErr errReport(CompilerErr e) 58 { 59 if (compiler != null) 60 { 61 compiler.log.compilerErr(e) 62 compiler.errors.add(e) 63 } 64 return e 65 } 66 67 ** 68 ** If any errors are accumulated, then throw the last one 69 ** 70 Void bombIfErr() 71 { 72 if (!compiler.errors.isEmpty) 73 throw compiler.errors.last 74 } 75 76 ////////////////////////////////////////////////////////////////////////// 77 // Fields 78 ////////////////////////////////////////////////////////////////////////// 79 80 DocCompiler compiler 81 82 }