Ticket #275: java-fix.patch
File java-fix.patch, 4.1 KB (added by hopscc, 12 years ago) |
---|
-
Source/BackEndJvm/JavaGenerator.cobra
38 38 _fullJarFileName = outName 39 39 return outName 40 40 41 def createJavaFile(fileName as String, contents as String) 42 #print 'output: ', contents 43 File.writeAllText(fileName, contents) 44 .addIntermediateFile(fileName) 45 41 46 def writeJava 42 47 Node.setCompiler(this) 43 48 try … … 56 61 57 62 def writeJavaTestInvocation 58 63 # TODO 64 #fileName = 'test-[dt.year][dt.month][dt.day][dt.hour][dt.minute].java' # to-do: format the numbers to have leading zeros 65 #w = CodeCommentLineWriter() 66 # ... 67 #.createJavaFile(fileName, w.output) 59 68 print 'TODO: writeJavaTestInvocation' 60 69 61 70 def compileJava … … 276 285 def newJavaFile( cobraModuleName as String, javaFileName as String) as CurlyWriter 277 286 #print 'newJavaFile [javaFileName]' 278 287 sw = CodeCommentLineWriter() 279 .addIntermediateFile(javaFileName)280 288 sw.start(cobraModuleName) 281 289 sw.write('// [javaFileName] from [cobraModuleName]\n') 282 290 sw.write('// Generated by Cobra-[CommandLine.versionString]\n') 283 291 sw.write('// on [DateTime.now]\n') 284 292 # TODO: list op sys 285 293 sw.write('\n') 286 File.writeAllText(javaFileName, sw.output)287 294 return sw 288 295 289 296 … … 417 424 else 418 425 .topNameSpace.writeJavaDef(sw) 419 426 d = sw.curlyToCobraLineNum 427 (.compiler to Compiler).createJavaFile(.javaFileName, sw.output) 420 428 return d 421 429 422 430 def writeJavaTestInvocation(sw as CurlyWriter) is override … … 627 635 decl.writeJavaDef(sw) 628 636 javaToCobraLineNum = sw.curlyToCobraLineNum 629 637 compiler.storeJavaFileInfo(cobraModName, javaToCobraLineNum) 638 (.compiler to Compiler).createJavaFile(javaFileName, sw.output) 630 639 631 640 if decl inherits Box, .compiler.boxStack.pop 632 641 … … 1309 1318 base.writeJavaDef(sw) 1310 1319 # TODO 1311 1320 #if .type.isReference and not .type inherits NilableType 1312 # sw.write(r'[Cobra.Core.NotNull] ') 1321 # sw.write(r'[Cobra.Core.NotNull] ') # TODO: annotations on params avail in Java8 1313 1322 branch .direction 1314 1323 on Direction.In, pass 1315 1324 on Direction.InOut, sw.write('/*inOut*/') # default 1316 1325 on Direction.Out, sw.write('/*out*/') # TODO 1317 1326 sw.write('[.type.javaParamRef] [.javaName]') 1327 # if .optValue # Net4 optional param 1328 # detail='For java at the moment you will need to recode the optional parameter method as a set of overloaded (possibly cascaded) methods with the desired number of parameters.' 1329 # .compiler.warning(this, 'Java does not support optional parameters. Default parameter value setting is ignored. [detail]') 1330 # #sw.write('=') 1331 # #_optValue.writeSharpDef(sw) 1318 1332 1319 1333 def writeJavaDefSansReferenceLabels(sw as CurlyWriter) 1320 1334 """ 1321 1335 Writes the parameter declaration but without Java "out" or "ref"--these are not available for 1322 1336 contract methods (require_foo and ensure_foo) because contracts cannot modify arguments. 1323 1337 """ 1324 # skip the [NotNull] as well since it's not really needed1325 1338 sw.write('[.type.javaRef] [.javaName]') 1326 1339 1327 1340 … … 3523 3539 on + 8, s = 'short' # unsigned Byte uint8 3524 3540 on -16, s = 'short' #'Int16' 3525 3541 on +16, s = 'int' # unsigned short UInt16' 3526 on -32, s = ' int'# int323542 on -32, s = '' # int32 3527 3543 on +32, s = 'long' # unsigned int32 3528 on -64, s = ' long'3544 on -64, s = 'L' #'long' 3529 3545 on +64, s = 'long' # unsigned int64 3530 3546 else, throw FallThroughException(info) 3531 3547 if s.length <= 2 -
Source/BackEndCommon/CurlyWriter.cobra
5 5 6 6 7 7 8 class CurlyWriter is abstract 8 class CurlyWriter is abstract implements IDisposable 9 9 10 10 var _sb as StringBuilder 11 11 … … 140 140 141 141 def output as String 142 142 return _sb.toString 143 144 def dispose is new 145 pass 146 143 147 144 148 145 149 class CodePoundLineWriter inherits CurlyWriter