class NoSourceGenerationException inherits Exception cue init(blt as FakeLibraryType) base.init('Not expecting to generate code with BasicLibraryType ([blt])') class Compiler is partial var _moduleFileName_to_curlyToCobraLineNum as Dictionary?>? def cobraLineNumForCurly(fileName as String, lineNum as int) as int """ Returns the source cobra line number given a filename (sans ".cs") and line number in the generated C#. Used by SharpCompilationMessage. """ # for some reason the C# filenames come in with a lower case drive letter, # and in 2006 strings are *still* case sensitive. # *sigh* if fileName.length>=2 and fileName[1]==c':' fileName = fileName.capitalized # TODO: handle relative paths like ..\foo.cobra which C# spells out as absolute paths if not _moduleFileName_to_curlyToCobraLineNum.containsKey(fileName) return lineNum map = _moduleFileName_to_curlyToCobraLineNum[fileName] # sometimes the line numbers are one off. that's not ideal, but keep chugging: if not map.containsKey(lineNum) and map.containsKey(lineNum-1) lineNum -= 1 if map.containsKey(lineNum) return map[lineNum] else # TODO: take this out someday. was put in 2006-11-12 print '<> Cannot map C# location back to cobra.' print ' fileName = [fileName]' print ' lineNum = [lineNum]' print ' sharpToCobraLineNum = [CobraCore.toTechString(map)]' return lineNum # map[lineNum] def _deleteIntermediateFiles # remove intermediate files such as *.cobra.cs and *.cobra.java if _intermediateFileNames.count == 0 if _verbosity >= 1, print 'No intermediate files to keep or delete.' else if .options.getDefault('keep-intermediate-files', 0) if _verbosity >= 1, print 'Keeping intermediate files.' else if _verbosity >= 1, print 'Deleting intermediate files.' retry = __deleteIntermediateFiles(1) if retry System.Threading.Thread.sleep(500) __deleteIntermediateFiles(2) def __deleteIntermediateFiles(attempt as int) as bool retry = false for fileName in _intermediateFileNames if _verbosity >= 3, print 'Deleting', fileName try if Directory.exists(fileName), Directory.delete(fileName, true) else if File.exists(fileName), File.delete(fileName) catch ioExc as IOException if ioExc.message.toLower.contains('not empty') # this sometimes happens on Windows if attempt > 1, .warning(CobraWarning(nil, nil, 'Cannot delete intermediate file: [fileName]')) retry = true else throw catch UnauthorizedAccessException # sometimes happens on Windows if attempt > 1, .warning(CobraWarning(nil, nil, 'Cannot delete intermediate file: [fileName]')) retry = true return retry interface IVar is partial get useBackEndNameStack as Stack class BoxVar is partial var _useBackEndNameStack as Stack get useBackEndNameStack from var class AbstractMethod is partial var _backEndResultVarName = '' get backEndResultVarName from var class Stmt is partial shared var _inInitCall as bool pro inInitCall from var class ReturnStmt is partial var _backEndResultVarName as String? pro backEndResultVarName from var