Permalink
Browse files

Merge branch 'master' of github.com:redline-smalltalk/redline-smalltalk

  • Loading branch information...
2 parents 3c220e2 + 582eabe commit 43381b36170f6129ff82caf838cdc3607ddb611b @SeanTAllen SeanTAllen committed May 4, 2012
Showing with 10,050 additions and 8,715 deletions.
  1. +22 −0 CHANGES
  2. +1 −1 OBJECTS-AND-PROTOCOLS
  3. +86 −0 ROADMAP
  4. +7 −7 pom.xml
  5. +15 −10 src/main/antlr3/st/redline/compiler/PreProcLexer.g
  6. +155 −394 src/main/antlr3/st/redline/compiler/Smalltalk.g
  7. +0 −17 src/main/java/st/redline/BlockReturn.java
  8. +0 −131 src/main/java/st/redline/Bootstrapper.java
  9. +0 −167 src/main/java/st/redline/CommandLine.java
  10. +0 −63 src/main/java/st/redline/Compiler.java
  11. +0 −29 src/main/java/st/redline/Preprocessor.java
  12. +0 −922 src/main/java/st/redline/Primitives.java
  13. +0 −41 src/main/java/st/redline/ProtoBlock.java
  14. +0 −56 src/main/java/st/redline/ProtoMethod.java
  15. +0 −333 src/main/java/st/redline/ProtoObject.java
  16. +0 −33 src/main/java/st/redline/RedlineException.java
  17. +0 −90 src/main/java/st/redline/SmalltalkClassLoader.java
  18. +0 −17 src/main/java/st/redline/Source.java
  19. +0 −44 src/main/java/st/redline/SourceFile.java
  20. +0 −90 src/main/java/st/redline/SourceFileFinder.java
  21. +0 −47 src/main/java/st/redline/SourceFileReader.java
  22. +0 −62 src/main/java/st/redline/SourceFilesFinder.java
  23. +0 −79 src/main/java/st/redline/Stic.java
  24. +0 −73 src/main/java/st/redline/ThisContext.java
  25. +11 −0 src/main/java/st/redline/bootstrap/AccessClassMethod.java
  26. +26 −0 src/main/java/st/redline/bootstrap/AtSelectorPutMethod.java
  27. +0 −14 src/main/java/st/redline/bootstrap/CategoryMethod.java
  28. +0 −14 src/main/java/st/redline/bootstrap/ClassInstanceVariableNamesMethod.java
  29. +0 −23 src/main/java/st/redline/bootstrap/ClassSubclassMethod.java
  30. +0 −26 src/main/java/st/redline/bootstrap/ClassSubclassWithVariablesMethod.java
  31. +0 −14 src/main/java/st/redline/bootstrap/ClassVariableNamesMethod.java
  32. +28 −0 src/main/java/st/redline/bootstrap/CreateSubclassMethod.java
  33. +18 −23 src/main/java/st/redline/bootstrap/ImportMethod.java
  34. +4 −5 src/main/java/st/redline/bootstrap/InitializeMethod.java
  35. +15 −10 src/main/java/st/redline/bootstrap/InstanceVariableNamesMethod.java
  36. +0 −13 src/main/java/st/redline/bootstrap/PoolDictionariesMethod.java
  37. +0 −57 src/main/java/st/redline/compiler/AbstractMethod.java
  38. +81 −77 src/main/java/st/redline/compiler/AbstractPreProcLexer.java
  39. +270 −516 src/main/java/st/redline/compiler/Analyser.java
  40. +2 −1 src/main/java/st/redline/compiler/{Method.java → AnalyserDelegate.java}
  41. +0 −30 src/main/java/st/redline/compiler/AnswerExpression.java
  42. +32 −0 src/main/java/st/redline/compiler/AnswerStatement.java
  43. +57 −44 src/main/java/st/redline/compiler/Array.java
  44. +27 −0 src/main/java/st/redline/compiler/ArrayConstant.java
  45. +11 −0 src/main/java/st/redline/compiler/ArrayElement.java
  46. +46 −29 src/main/java/st/redline/compiler/AssignmentExpression.java
  47. +0 −27 src/main/java/st/redline/compiler/BaseLiteral.java
  48. +0 −17 src/main/java/st/redline/compiler/BasePrimary.java
  49. +43 −24 src/main/java/st/redline/compiler/BinaryExpression.java
  50. +55 −30 src/main/java/st/redline/compiler/BinaryObjectDescription.java
  51. +11 −10 src/main/java/st/redline/compiler/BinarySelector.java
  52. +24 −11 src/main/java/st/redline/compiler/BinarySelectorMessageElement.java
  53. +0 −22 src/main/java/st/redline/compiler/BinarySelectorMessagePattern.java
  54. +25 −11 src/main/java/st/redline/compiler/BinarySelectorUnaryObjectDescription.java
  55. +103 −65 src/main/java/st/redline/compiler/Block.java
  56. +79 −411 src/main/java/st/redline/compiler/BlockAnalyser.java
  57. +0 −71 src/main/java/st/redline/compiler/BlockAnalyserDelegate.java
  58. +0 −314 src/main/java/st/redline/compiler/BlockAnalyserNoOpDelegate.java
  59. +13 −0 src/main/java/st/redline/compiler/BlockArgument.java
  60. +33 −0 src/main/java/st/redline/compiler/BlockArguments.java
  61. +54 −9 src/main/java/st/redline/compiler/BlockBytecodeWriter.java
  62. +56 −0 src/main/java/st/redline/compiler/BlockReturnTypeCreator.java
  63. +0 −13 src/main/java/st/redline/compiler/BlockVariableName.java
  64. +7 −6 src/main/java/st/redline/compiler/Cascade.java
  65. +23 −17 src/main/java/st/redline/compiler/CharacterConstant.java
  66. +618 −448 src/main/java/st/redline/compiler/ClassBytecodeWriter.java
  67. +0 −17 src/main/java/st/redline/compiler/ClassInstanceVariableName.java
  68. +0 −15 src/main/java/st/redline/compiler/ClassMethod.java
  69. +0 −17 src/main/java/st/redline/compiler/ClassVariableName.java
  70. +5 −4 src/main/java/st/redline/compiler/Expression.java
  71. +8 −0 src/main/java/st/redline/compiler/False.java
  72. +0 −16 src/main/java/st/redline/compiler/FalseReservedWord.java
  73. +34 −10 src/main/java/st/redline/compiler/Identifier.java
  74. +0 −15 src/main/java/st/redline/compiler/InstanceMethod.java
  75. +0 −17 src/main/java/st/redline/compiler/InstanceVariableName.java
  76. +4 −1 src/main/java/st/redline/compiler/{Literal.java → JVM.java}
  77. +325 −0 src/main/java/st/redline/compiler/JVMAnalyser.java
  78. +0 −33 src/main/java/st/redline/compiler/JvmExpression.java
  79. +0 −21 src/main/java/st/redline/compiler/JvmFieldInsn.java
  80. +0 −19 src/main/java/st/redline/compiler/JvmIincInsn.java
  81. +0 −16 src/main/java/st/redline/compiler/JvmInsn.java
  82. +0 −17 src/main/java/st/redline/compiler/JvmIntInsn.java
  83. +0 −15 src/main/java/st/redline/compiler/JvmLdcInsn.java
  84. +0 −15 src/main/java/st/redline/compiler/JvmLoadJavaValue.java
  85. +0 −21 src/main/java/st/redline/compiler/JvmMethodInsn.java
  86. +0 −21 src/main/java/st/redline/compiler/JvmOpcode.java
  87. +0 −15 src/main/java/st/redline/compiler/JvmStoreJavaValue.java
  88. +0 −17 src/main/java/st/redline/compiler/JvmTypeInsn.java
  89. +0 −17 src/main/java/st/redline/compiler/JvmVarInsn.java
  90. +0 −17 src/main/java/st/redline/compiler/Keyword.java
  91. +0 −13 src/main/java/st/redline/compiler/KeywordAndVariableName.java
  92. +40 −23 src/main/java/st/redline/compiler/KeywordExpression.java
  93. +38 −23 src/main/java/st/redline/compiler/KeywordMessageElement.java
  94. +0 −34 src/main/java/st/redline/compiler/KeywordMessagePattern.java
  95. +0 −17 src/main/java/st/redline/compiler/LiteralArray.java
  96. +0 −15 src/main/java/st/redline/compiler/LiteralCharacter.java
  97. +0 −23 src/main/java/st/redline/compiler/LiteralNumber.java
  98. +0 −25 src/main/java/st/redline/compiler/LiteralString.java
  99. +0 −25 src/main/java/st/redline/compiler/LiteralSymbol.java
  100. +2 −1 src/main/java/st/redline/compiler/MessageElement.java
  101. +2 −1 src/main/java/st/redline/compiler/MessageExpression.java
  102. +0 −100 src/main/java/st/redline/compiler/MethodAnalyser.java
  103. +0 −89 src/main/java/st/redline/compiler/MethodBytecodeWriter.java
  104. +0 −11 src/main/java/st/redline/compiler/MethodFactory.java
  105. +0 −29 src/main/java/st/redline/compiler/Methods.java
  106. +4 −3 src/main/java/st/redline/compiler/{IndexedVisitableNode.java → Nil.java}
  107. +0 −15 src/main/java/st/redline/compiler/NilReservedWord.java
  108. +175 −0 src/main/java/st/redline/compiler/NoOpAnalyser.java
  109. +55 −82 src/main/java/st/redline/compiler/NodeVisitor.java
  110. +62 −0 src/main/java/st/redline/compiler/Number.java
  111. +0 −34 src/main/java/st/redline/compiler/NumberConstant.java
  112. +0 −17 src/main/java/st/redline/compiler/PoolVariableName.java
  113. +7 −4 src/main/java/st/redline/compiler/Primary.java
  114. +18 −13 src/main/java/st/redline/compiler/PrimaryExpression.java
  115. +17 −11 src/main/java/st/redline/compiler/PrimaryStatements.java
  116. +24 −10 src/main/java/st/redline/compiler/Primitive.java
  117. +22 −18 src/main/java/st/redline/compiler/Program.java
  118. +364 −0 src/main/java/st/redline/compiler/ProgramAnalyser.java
  119. +2 −2 src/main/java/st/redline/compiler/{MessagePattern.java → ReservedWord.java}
  120. +4 −4 src/main/java/st/redline/compiler/{ArrayConstantElement.java → Self.java}
  121. +0 −16 src/main/java/st/redline/compiler/SelfReservedWord.java
  122. +119 −94 src/main/java/st/redline/compiler/SimpleExpression.java
  123. +0 −15 src/main/java/st/redline/compiler/SmalltalkReservedWord.java
  124. +34 −27 src/main/java/st/redline/compiler/Statements.java
  125. +0 −13 src/main/java/st/redline/compiler/StringChunk.java
  126. +32 −34 src/main/java/st/redline/compiler/StringConstant.java
  127. +8 −0 src/main/java/st/redline/compiler/Super.java
  128. +0 −16 src/main/java/st/redline/compiler/SuperReservedWord.java
  129. +42 −38 src/main/java/st/redline/compiler/Symbol.java
  130. +13 −0 src/main/java/st/redline/compiler/SymbolConstant.java
  131. +22 −32 src/main/java/st/redline/compiler/Temporaries.java
  132. +7 −15 src/main/java/st/redline/compiler/Temporary.java
  133. +294 −0 src/main/java/st/redline/compiler/TracingAnalyser.java
  134. +42 −51 src/main/java/st/redline/compiler/TracingClassWriter.java
  135. +100 −100 src/main/java/st/redline/compiler/TracingMethodVisitor.java
  136. +4 −3 src/main/java/st/redline/compiler/{Generator.java → True.java}
  137. +0 −16 src/main/java/st/redline/compiler/TrueReservedWord.java
  138. +35 −32 src/main/java/st/redline/compiler/UnaryExpression.java
  139. +31 −18 src/main/java/st/redline/compiler/UnaryObjectDescription.java
  140. +7 −11 src/main/java/st/redline/compiler/UnarySelector.java
  141. +15 −7 src/main/java/st/redline/compiler/UnarySelectorMessageElement.java
  142. +0 −19 src/main/java/st/redline/compiler/UnarySelectorMessagePattern.java
  143. +29 −0 src/main/java/st/redline/compiler/ValuePrimary.java
  144. +0 −73 src/main/java/st/redline/compiler/VariableName.java
  145. +2 −2 src/main/java/st/redline/compiler/VisitableNode.java
  146. +16 −0 src/main/java/st/redline/core/BlockReturn.java
  147. +82 −0 src/main/java/st/redline/core/Bootstrapper.java
  148. +5 −1 src/main/java/st/redline/{ → core}/ClassPathUtilities.java
  149. +179 −0 src/main/java/st/redline/core/CommandLine.java
  150. +18 −0 src/main/java/st/redline/core/Evaluator.java
  151. +24 −0 src/main/java/st/redline/core/InMemorySourceFile.java
  152. +73 −0 src/main/java/st/redline/core/Kompiler.java
  153. +28 −0 src/main/java/st/redline/core/Preprocessor.java
  154. +41 −0 src/main/java/st/redline/core/PrimBasicDoesNotUnderstand.java
  155. +70 −0 src/main/java/st/redline/core/PrimContext.java
  156. +721 −0 src/main/java/st/redline/core/PrimObject.java
  157. +99 −0 src/main/java/st/redline/core/PrimObjectBlock.java
  158. +97 −0 src/main/java/st/redline/core/PrimObjectClass.java
  159. +132 −0 src/main/java/st/redline/core/PrimObjectMetaclass.java
  160. +33 −0 src/main/java/st/redline/core/RedlineException.java
  161. +102 −0 src/main/java/st/redline/core/SmalltalkClassLoader.java
  162. +17 −0 src/main/java/st/redline/core/Source.java
  163. +48 −0 src/main/java/st/redline/core/SourceFile.java
  164. +90 −0 src/main/java/st/redline/core/SourceFileFinder.java
  165. +47 −0 src/main/java/st/redline/core/SourceFileReader.java
  166. +62 −0 src/main/java/st/redline/core/SourceFilesFinder.java
  167. +80 −0 src/main/java/st/redline/core/Stic.java
  168. +8 −5 src/main/java/st/redline/stout/Main.java
  169. +4 −3 src/main/java/st/redline/stout/NoOpRouter.java
  170. +5 −1 src/main/java/st/redline/stout/ResponseSerializer.java
  171. +3 −3 src/main/java/st/redline/stout/Router.java
  172. +2 −2 src/main/java/st/redline/stout/RouterFactory.java
  173. +28 −9 src/main/java/st/redline/stout/RouterFactoryImpl.java
  174. +49 −21 src/main/java/st/redline/stout/RouterImpl.java
  175. +5 −6 src/main/java/st/redline/stout/RouterRegistry.java
  176. +16 −15 src/main/java/st/redline/stout/RouterRegistryImpl.java
  177. +99 −130 src/main/java/st/redline/stout/Run.java
  178. +1 −1 src/main/scripts/stic
  179. +1 −1 src/main/scripts/stic.bat
  180. +0 −5 src/main/smalltalk/st/redline/ArrayedCollection.st
  181. +0 −36 src/main/smalltalk/st/redline/Behavior.st
  182. +0 −91 src/main/smalltalk/st/redline/Boolean.st
  183. +0 −30 src/main/smalltalk/st/redline/Character.st
  184. +0 −197 src/main/smalltalk/st/redline/Collection.st
  185. +0 −58 src/main/smalltalk/st/redline/False.st
  186. +0 −64 src/main/smalltalk/st/redline/LinkedList.st
  187. +0 −55 src/main/smalltalk/st/redline/Number.st
  188. +0 −174 src/main/smalltalk/st/redline/Object.st
  189. +0 −32 src/main/smalltalk/st/redline/SequenceableCollection.st
  190. +0 −19 src/main/smalltalk/st/redline/TestCase.st
  191. +0 −21 src/main/smalltalk/st/redline/Transcript.st
  192. +0 −59 src/main/smalltalk/st/redline/True.st
  193. +0 −36 src/main/smalltalk/st/redline/UndefinedObject.st
  194. +3 −2 src/main/smalltalk/st/redline/{ → core}/Array.st
  195. +2 −1 src/main/smalltalk/st/redline/{Class.st → core/ArrayedCollection.st}
  196. +1 −1 src/main/smalltalk/st/redline/{ → core}/Bag.st
  197. +40 −0 src/main/smalltalk/st/redline/core/Behavior.st
  198. +7 −8 src/main/smalltalk/st/redline/{ → core}/BlockClosure.st
  199. +91 −0 src/main/smalltalk/st/redline/core/Boolean.st
  200. +27 −0 src/main/smalltalk/st/redline/core/Character.st
  201. +29 −0 src/main/smalltalk/st/redline/core/Class.st
  202. +1 −1 src/main/smalltalk/st/redline/{ → core}/ClassDescription.st
  203. +206 −0 src/main/smalltalk/st/redline/core/Collection.st
  204. +8 −0 src/main/smalltalk/st/redline/core/Compiler.st
  205. +3 −2 src/main/smalltalk/st/redline/{ → core}/Date.st
  206. +1 −1 src/main/smalltalk/st/redline/{ → core}/Dictionary.st
  207. +62 −0 src/main/smalltalk/st/redline/core/False.st
  208. +1 −1 src/main/smalltalk/st/redline/{ → core}/Float.st
  209. +1 −1 src/main/smalltalk/st/redline/{ → core}/Fraction.st
  210. +1 −1 src/main/smalltalk/st/redline/{ → core}/IdentityDictionary.st
  211. +17 −14 src/main/smalltalk/st/redline/{ → core}/Integer.st
  212. +5 −3 src/main/smalltalk/st/redline/{ → core}/Interval.st
  213. +1 −1 src/main/smalltalk/st/redline/{ → core}/LargeNegativeInteger.st
  214. +1 −1 src/main/smalltalk/st/redline/{ → core}/LargePositiveInteger.st
  215. +8 −5 src/main/smalltalk/st/redline/{ → core}/Link.st
  216. +73 −0 src/main/smalltalk/st/redline/core/LinkedList.st
  217. +6 −4 src/main/smalltalk/st/redline/{ → core}/Magnitude.st
  218. +1 −1 src/main/smalltalk/st/redline/{ → core}/MappedCollection.st
  219. +1 −1 src/main/smalltalk/st/redline/{ → core}/MetaClass.st
  220. +58 −0 src/main/smalltalk/st/redline/core/Number.st
  221. +167 −0 src/main/smalltalk/st/redline/core/Object.st
  222. +1 −1 src/main/smalltalk/st/redline/{ → core}/OrderedCollection.st
  223. +1 −1 src/main/smalltalk/st/redline/{ → core}/PositionableStream.st
  224. +1 −1 src/main/smalltalk/st/redline/{ → core}/ReadStream.st
  225. +49 −0 src/main/smalltalk/st/redline/core/SequenceableCollection.st
  226. +1 −1 src/main/smalltalk/st/redline/{ → core}/Set.st
  227. +1 −1 src/main/smalltalk/st/redline/{ → core}/SmallInteger.st
  228. +1 −1 src/main/smalltalk/st/redline/{ → core}/SmalltalkImage.st
  229. +1 −1 src/main/smalltalk/st/redline/{ → core}/SortedCollection.st
  230. +1 −1 src/main/smalltalk/st/redline/{ → core}/Stream.st
  231. +4 −1 src/main/smalltalk/st/redline/{ → core}/String.st
  232. +1 −1 src/main/smalltalk/st/redline/{ → core}/Symbol.st
  233. +21 −0 src/main/smalltalk/st/redline/core/TestCase.st
  234. +1 −1 src/main/smalltalk/st/redline/{ → core}/Time.st
  235. +15 −0 src/main/smalltalk/st/redline/core/Transcript.st
  236. +57 −0 src/main/smalltalk/st/redline/core/True.st
  237. +34 −0 src/main/smalltalk/st/redline/core/UndefinedObject.st
  238. +1 −1 src/main/smalltalk/st/redline/{ → core}/WriteStream.st
  239. +1 −1 src/main/smalltalk/st/redline/stout/HttpServletRequest.st
  240. +1 −1 src/main/smalltalk/st/redline/stout/HttpServletResponse.st
  241. +56 −34 src/main/smalltalk/st/redline/stout/Stout.st
  242. +0 −73 src/test/java/st/redline/ConstructionTest.java
  243. +0 −365 src/test/java/st/redline/PrimitivesTest.java
  244. +0 −276 src/test/java/st/redline/ProtoObjectTest.java
  245. +0 −28 src/test/java/st/redline/ResolvingTest.java
  246. +17 −0 src/test/java/st/redline/bootstrap/AccessClassMethodTest.java
  247. +30 −0 src/test/java/st/redline/bootstrap/AtSelectorPutMethodTest.java
  248. +23 −0 src/test/java/st/redline/bootstrap/CreateSubclassMethodTest.java
  249. +331 −0 src/test/java/st/redline/compiler/AnalyserTest.java
  250. +46 −0 src/test/java/st/redline/compiler/BlockAnalyserTest.java
  251. +49 −0 src/test/java/st/redline/compiler/BlockBytecodeWriterTest.java
  252. +70 −0 src/test/java/st/redline/compiler/ClassBytecodeWriterTest.java
  253. +116 −0 src/test/java/st/redline/compiler/JVMAnalyserTest.java
  254. +27 −0 src/test/java/st/redline/compiler/NoOpAnalyserTest.java
  255. +476 −0 src/test/java/st/redline/compiler/NodeTest.java
  256. +355 −0 src/test/java/st/redline/compiler/ProgramAnalyserTest.java
  257. +387 −0 src/test/java/st/redline/compiler/SmalltalkParserTest.java
  258. +71 −0 src/test/java/st/redline/core/PreprocessorTest.java
  259. +60 −0 src/test/java/st/redline/core/PrimBasicDoesNotUnderstandTest.java
  260. +27 −0 src/test/java/st/redline/core/PrimContextTest.java
  261. +29 −0 src/test/java/st/redline/core/PrimObjectBlockTest.java
  262. +111 −0 src/test/java/st/redline/core/PrimObjectClassTest.java
  263. +117 −0 src/test/java/st/redline/core/PrimObjectMetaclassTest.java
  264. +198 −0 src/test/java/st/redline/core/PrimObjectTest.java
  265. +9 −13 src/test/java/st/redline/stout/RouterImplTest.java
  266. +39 −30 src/test/java/st/redline/stout/RouterRegistryImplTest.java
  267. +0 −20 src/test/smalltalk/st/redline/ArrayTest.st
Sorry, we could not display the entire diff because it was too big.
View
22 CHANGES
@@ -1,3 +1,25 @@
+04/05/2012
+
+Added Smalltalk Compiler class to expose ability to evaluate strings of smalltalk source and answer the result of that
+evaluation.
+
+03/05/2012
+
+Added capture of result of sending messages that embody a file, so direct evaluation of a string can be returned into Smalltalk.
+This is a WIP for exposing the Compiler and the ability to evaluate Smalltalk strings.
+
+20/01/2012
+
+In response to feedback - I did the following:
+Rewrote the grammar to make it cleaner and remove some grammar bugs that were hindering us.
+Rewrote Analyser that walks the Abstract Syntax tree, since grammar nodes changed, and we
+learnt a lot from previous attempts which means we can have a smaller better Analyser.
+Rewrote Bytecode generator to be cleaner.
+Rewrote Java layer of classes to more closely reflect the "meta" nature of Smalltalk. Making
+a class correctly requires the creation and population of a Metaclass and then asking it for
+an instance of the class.
+Added tests, tests and more tests.
+
01/01/2012
Added check for null in superclass call. Answers nil if null.
View
2 OBJECTS-AND-PROTOCOLS
@@ -586,4 +586,4 @@ subclass: classNameString
poolDictionaries: stringOfPoolNames
category: categoryNameString
-*END*
+*END!*
View
86 ROADMAP
@@ -0,0 +1,86 @@
+- Redline Smalltalk feature ROADMAP -
+
+-- Release 1.0 / Version 1.0 --
+
+Goal: Provide a base that can be used for developing tools or applications without a UI in Smalltalk to be run on the Java Virtual Machine.
+
+001. Smalltalk Compiler
+
+ A compiler that supports the full Smalltalk language, compiling both classes and scripts (files without classes) into JVM bytecode for execution.
+
+ The compiler should output debug information such that JVM debuggers can set break points and debug the code line by line. The debug information
+ should also be included in exceptions to show which Smalltalk source lines were involved in any exceptions.
+
+ The compiler should handle the dispatch of control to primitive methods.
+
+ The compiler should handle the integration of non-Smalltalk libraries with Smalltalk code. This has been achieved with the JVM pseudo variable
+ and the ability to directly emit bytecodes. Anything the JVM can call you can call.
+
+ The compiler should create JVM Classes in such a way that those classes are usable from non-Smalltalk languages. For example, it should be possible
+ to use a Smalltalk class from Java.
+
+ ** Status **: The Smalltalk Compiler is complete.
+
+002. Smalltalk Runtime
+
+ A Smalltalk rumtime should be provided that includes all the classes defined in the "Blue Book" (Smalltalk-80 the language and its implementation)
+ with the exception of the graphical classes and those related to threading and scheduling that won't fit the JVM's model of those same concepts.
+
+ The runtime should have a corresponding test suite that covers the functionality of each class to provide some confidence that the runtime is
+ tested and working as expected, and that changes to the runtime do not break existing functionality.
+
+ ** Status **: Underway. Several community members signed up during the class adoption drive to implement a runtime class or two. This process is
+ continuing. We need more contributors and or a bigger push to get this completed.
+
+003. Smart Classloader
+
+ A smart classloader which should reload classes when the associated source file changes, and should also 'reload' all classes on request.
+ This functionality is essential to enable a quick development feeback loop where source is changed and on next invocation the changed source
+ is executed.
+
+ The smart classloader should also be lockable, whereby it will not reload classes nor perform checks to see if the source has changed. The smart
+ classloader is expected to be locked in Production environments.
+
+ There is a current classloader that fits the JVM classloader model, however, these additional features are not 'standard' and will have to be built.
+
+ ** Status **: Underway.
+
+-- Release 2 / Version 1.0
+
+Goal: Provide tools and frameworks that help people get started with building apps in Smalltalk.
+
+004. Light weight Web Framework
+
+ A light weight Web Framework that supports the development of server side functionality in Smalltalk.
+
+ ** Status **: Underway. This sub-project is called "Stout" and is currently part of the main source tree but will be separated out shortly.
+
+005. Smalltalk Interactive Command Line (REPL)
+
+ An interactive command line should be provided to enable developers to quickly try out Smalltalk code experiments or to interact with existing
+ application or classes.
+
+ ** Status **: Underway. This sub-project is called "Stir" and it is available in a separate git repo. Stir has a dependency on Stout.
+
+006. IDE integration
+
+ Integration into the two leading Java IDE's should be provided. These two IDE's are Eclipse and IntelliJ.
+
+ IDE Integration should provide as a minimum the ability to:
+ a. Create a Redline Smalltalk project, where the folder structure is consistent and in keeping with Redline expectations.
+ b. Enable the execution of Smalltalk code from the IDE.
+ c. Integrate with Stout and Stir.
+
+ ** Status **: Underway. These projects are being undertaken by community members. When usable modules are available then the associated git repo's will
+ be linked to from the main Redline Repo.
+
+007. Test Framework
+
+ A test framework and classes should be provided to enable developers to write descriptive and effective Tests for their code.
+
+ Something a little more advanced than SUnit is expected here, although an SUnit port would be work while as well.
+
+ ** Status **: Unknown - Steven R. Baker who wrote Ruby rspec said he would write a Test framework for Redline. Need to follow him up on this.
+
+*end*
+
View
14 pom.xml
@@ -17,13 +17,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.0</version>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -34,7 +34,7 @@
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
- <version>3.2</version>
+ <version>3.3.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
@@ -173,13 +173,13 @@
</goals>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
- <mainClass>st.redline.Stic</mainClass>
+ <mainClass>st.redline.core.Stic</mainClass>
<arguments>
<argument>-r</argument>
<argument>${project.basedir}${path.separator}src${path.separator}main${path.separator}smalltalk</argument>
<argument>-s</argument>
<argument>${project.basedir}${path.separator}src${path.separator}test${path.separator}smalltalk</argument>
- <argument>st.redline.TestRunner</argument>
+ <argument>st.redline.core.TestRunner</argument>
</arguments>
</configuration>
</execution>
View
25 src/main/antlr3/st/redline/compiler/PreProcLexer.g
@@ -47,14 +47,14 @@ PREPROC
| v = ( '+'| '-') // Only these are predicted.
{
if (!firstMethod()) {
- sb.append("] "); // DONT append this if this is first +/- seen.
+ sb.append("]. "); // DONT append this if this is first +/- seen.
}
sb.append(methodName);
if ($v == '+') {
- sb.append(" _class_");
+ sb.append(" class");
}
- sb.append(" >> ");
+ sb.append(" atSelector: #");
haveMethods();
}
@@ -85,9 +85,9 @@ PREPROC
// Write out the parts of the keyword Selector
//
sb.append($w1.text); // First element of the selector
- sb.append(": ");
- sb.append($w2.text); // Second element of the selector
- sb.append(' ');
+ sb.append(":");
+ args.append(" :");
+ args.append($w2.text); // Second element of the selector
}
| // *** ERROR - Malformed keyword selector ***
@@ -114,8 +114,8 @@ PREPROC
// Write out the parts of the binary selector
//
sb.append($b.text);
- sb.append(" ");
- sb.append($w1.text);
+ args.append(" :");
+ args.append($w1.text);
}
| // *** ERROR - Malformed binary selector ***
@@ -131,8 +131,13 @@ PREPROC
{
// Closing info
- //
- sb.append(" [");
+ //
+ sb.append(" put: [");
+ if (args.length()>0) {
+ sb.append(args);
+ sb.append(" |");
+ args = new StringBuilder();
+ }
}
(
View
549 src/main/antlr3/st/redline/compiler/Smalltalk.g
@@ -2,403 +2,164 @@
grammar Smalltalk;
options {
- language = Java;
+ language = Java;
+ backtrack = false;
}
-
@header {
- package st.redline.compiler;
+ package st.redline.compiler;
}
-
@lexer::header {
- package st.redline.compiler;
+ package st.redline.compiler;
+}
+@lexer::members {
+ List<RecognitionException> exceptions = new ArrayList<RecognitionException>();
+ public List<RecognitionException> getExceptions() { return exceptions; }
+ public void reportError(RecognitionException e) { super.reportError(e); exceptions.add(e); }
}
-program returns [Program n]
- : temporaries? statements methods {$n = new Program($temporaries.n, $statements.n, $methods.n);}
- ;
-
-methods returns [Methods n]
- : {$n = new Methods();}
- ( method {$n.add($method.n);} )*
- ;
-
-method returns [Method n]
- : o = NAME c= '_class_'? '>>' messagePattern '[' primitive? temporaries? statements ']' {$n = MethodFactory.create($o.text, $c.text, $messagePattern.n, $primitive.n, $temporaries.n, $statements.n);}
- ;
-
-messagePattern returns [MessagePattern n]
- : unarySelector {$n = new UnarySelectorMessagePattern($unarySelector.n);}
- | binarySelector variableName {$n = new BinarySelectorMessagePattern($binarySelector.n, $variableName.n);}
- | ( keyword variableName {if ($n != null) ((KeywordMessagePattern)$n).add(new KeywordAndVariableName($keyword.n, $variableName.n)); else $n = new KeywordMessagePattern(new KeywordAndVariableName($keyword.n, $variableName.n));} )+
- ;
-
-primitive returns [Primitive n]
- : '<primitive:' DIGITS '>' {$n = new Primitive($DIGITS.text, $DIGITS.line);}
- ;
-
-temporaries returns [Temporaries n]
- : {$n = new Temporaries();}
- l = '|' {$n.line($l.line);} ( variableName {$n.add(new Temporary($variableName.n));} )* '|'
- ;
-
-statements returns [Statements n]
- : ( nonEmptyStatements {$n = $nonEmptyStatements.n;} )?
- ;
-
-nonEmptyStatements returns [Statements n]
- : '^' expression {$n = new Statements(new AnswerExpression($expression.n));} '.'?
- | expression ( '.' statements )? {$n = new Statements($expression.n, $statements.n);}
- ;
-
-expression returns [Expression n]
- : variableName (':=' | '_') e = expression {$n = new AssignmentExpression($variableName.n, $e.n);}
- | simpleExpression {$n = $simpleExpression.n;}
- | jvmExpression {$n = $jvmExpression.n;}
- ;
-
-jvmExpression returns [JvmExpression n]
- : visitInsn {$n = $visitInsn.n;}
- ;
-
-visitInsn returns [JvmExpression n]
- : '<insn:' jvmOpcode '>' {$n = new JvmInsn($jvmOpcode.n);}
- | '<ldcInsn:' stringConstant '>' {$n = new JvmLdcInsn($stringConstant.n);}
- | '<varInsn:' jvmOpcode ',' DIGITS '>' {$n = new JvmVarInsn($jvmOpcode.n, $DIGITS.text);}
- | '<methodInsn:' jvmOpcode ',' o=stringConstant ',' a=stringConstant ',' d=stringConstant '>' {$n = new JvmMethodInsn($jvmOpcode.n, $o.n, $a.n, $d.n);}
- | '<typeInsn:' jvmOpcode ',' stringConstant '>' {$n = new JvmTypeInsn($jvmOpcode.n, $stringConstant.n);}
- | '<iincInsn:' v=DIGITS ',' i=DIGITS '>' {$n = new JvmIincInsn($v.text, $i.text, $v.line);}
- | '<intInsn:' jvmOpcode ',' DIGITS '>' {$n = new JvmIntInsn($jvmOpcode.n, $DIGITS.text);}
- | '<fieldInsn:' jvmOpcode ',' x=stringConstant ',' y=stringConstant ',' z=stringConstant '>' {$n = new JvmFieldInsn($jvmOpcode.n, $x.n, $y.n, $z.n);}
- | l = '<loadJavaValue>' {$n = new JvmLoadJavaValue($l.line);}
- | l = '<storeJavaValue>' {$n = new JvmStoreJavaValue($l.line);}
- ;
-
-jvmOpcode returns [JvmOpcode n]
- : c = 'ACC_PUBLIC' {$n = new JvmOpcode(1, $c.line);}
- | c = 'ACC_PRIVATE' {$n = new JvmOpcode(2, $c.line);}
- | c = 'ACC_PROTECTED' {$n = new JvmOpcode(4, $c.line);}
- | c = 'ACC_STATIC' {$n = new JvmOpcode(8, $c.line);}
- | c = 'ACC_FINAL' {$n = new JvmOpcode(16, $c.line);}
- | c = 'ACC_SUPER' {$n = new JvmOpcode(32, $c.line);}
- | c = 'ACC_SYNCHRONIZED' {$n = new JvmOpcode(32, $c.line);}
- | c = 'ACC_VOLATILE' {$n = new JvmOpcode(64, $c.line);}
- | c = 'ACC_BRIDGE' {$n = new JvmOpcode(64, $c.line);}
- | c = 'ACC_VARARGS' {$n = new JvmOpcode(128, $c.line);}
- | c = 'ACC_TRANSIENT' {$n = new JvmOpcode(128, $c.line);}
- | c = 'ACC_NATIVE' {$n = new JvmOpcode(256, $c.line);}
- | c = 'ACC_INTERFACE' {$n = new JvmOpcode(512, $c.line);}
- | c = 'ACC_ABSTRACT' {$n = new JvmOpcode(1024, $c.line);}
- | c = 'ACC_STRICT' {$n = new JvmOpcode(2048, $c.line);}
- | c = 'ACC_SYNTHETIC' {$n = new JvmOpcode(4096, $c.line);}
- | c = 'ACC_ANNOTATION' {$n = new JvmOpcode(8192, $c.line);}
- | c = 'ACC_ENUM' {$n = new JvmOpcode(16384, $c.line);}
- | c = 'ACC_DEPRECATED' {$n = new JvmOpcode(131072, $c.line);}
- | c = 'T_BOOLEAN' {$n = new JvmOpcode(4, $c.line);}
- | c = 'T_CHAR' {$n = new JvmOpcode(5, $c.line);}
- | c = 'T_FLOAT' {$n = new JvmOpcode(6, $c.line);}
- | c = 'T_DOUBLE' {$n = new JvmOpcode(7, $c.line);}
- | c = 'T_BYTE' {$n = new JvmOpcode(8, $c.line);}
- | c = 'T_SHORT' {$n = new JvmOpcode(9, $c.line);}
- | c = 'T_INT' {$n = new JvmOpcode(10, $c.line);}
- | c = 'T_LONG' {$n = new JvmOpcode(11, $c.line);}
- | c = 'F_NEW' {$n = new JvmOpcode(-1, $c.line);}
- | c = 'F_FULL' {$n = new JvmOpcode(0, $c.line);}
- | c = 'F_APPEND' {$n = new JvmOpcode(1, $c.line);}
- | c = 'F_CHOP' {$n = new JvmOpcode(2, $c.line);}
- | c = 'F_SAME' {$n = new JvmOpcode(3, $c.line);}
- | c = 'F_SAME1' {$n = new JvmOpcode(4, $c.line);}
- | c = 'NOP' {$n = new JvmOpcode(0, $c.line);}
- | c = 'ACONST_NULL' {$n = new JvmOpcode(1, $c.line);}
- | c = 'ICONST_M1' {$n = new JvmOpcode(2, $c.line);}
- | c = 'ICONST_0' {$n = new JvmOpcode(3, $c.line);}
- | c = 'ICONST_1' {$n = new JvmOpcode(4, $c.line);}
- | c = 'ICONST_2' {$n = new JvmOpcode(5, $c.line);}
- | c = 'ICONST_3' {$n = new JvmOpcode(6, $c.line);}
- | c = 'ICONST_4' {$n = new JvmOpcode(7, $c.line);}
- | c = 'ICONST_5' {$n = new JvmOpcode(8, $c.line);}
- | c = 'LCONST_0' {$n = new JvmOpcode(9, $c.line);}
- | c = 'LCONST_1' {$n = new JvmOpcode(10, $c.line);}
- | c = 'FCONST_0' {$n = new JvmOpcode(11, $c.line);}
- | c = 'FCONST_1' {$n = new JvmOpcode(12, $c.line);}
- | c = 'FCONST_2' {$n = new JvmOpcode(13, $c.line);}
- | c = 'DCONST_0' {$n = new JvmOpcode(14, $c.line);}
- | c = 'DCONST_1' {$n = new JvmOpcode(15, $c.line);}
- | c = 'BIPUSH' {$n = new JvmOpcode(16, $c.line);}
- | c = 'SIPUSH' {$n = new JvmOpcode(17, $c.line);}
- | c = 'LDC' {$n = new JvmOpcode(18, $c.line);}
- | c = 'ILOAD' {$n = new JvmOpcode(21, $c.line);}
- | c = 'LLOAD' {$n = new JvmOpcode(22, $c.line);}
- | c = 'FLOAD' {$n = new JvmOpcode(23, $c.line);}
- | c = 'DLOAD' {$n = new JvmOpcode(24, $c.line);}
- | c = 'ALOAD' {$n = new JvmOpcode(25, $c.line);}
- | c = 'IALOAD' {$n = new JvmOpcode(46, $c.line);}
- | c = 'LALOAD' {$n = new JvmOpcode(47, $c.line);}
- | c = 'FALOAD' {$n = new JvmOpcode(48, $c.line);}
- | c = 'DALOAD' {$n = new JvmOpcode(49, $c.line);}
- | c = 'AALOAD' {$n = new JvmOpcode(50, $c.line);}
- | c = 'BALOAD' {$n = new JvmOpcode(51, $c.line);}
- | c = 'CALOAD' {$n = new JvmOpcode(52, $c.line);}
- | c = 'SALOAD' {$n = new JvmOpcode(53, $c.line);}
- | c = 'ISTORE' {$n = new JvmOpcode(54, $c.line);}
- | c = 'LSTORE' {$n = new JvmOpcode(55, $c.line);}
- | c = 'FSTORE' {$n = new JvmOpcode(56, $c.line);}
- | c = 'DSTORE' {$n = new JvmOpcode(57, $c.line);}
- | c = 'ASTORE' {$n = new JvmOpcode(58, $c.line);}
- | c = 'IASTORE' {$n = new JvmOpcode(79, $c.line);}
- | c = 'LASTORE' {$n = new JvmOpcode(80, $c.line);}
- | c = 'FASTORE' {$n = new JvmOpcode(81, $c.line);}
- | c = 'DASTORE' {$n = new JvmOpcode(82, $c.line);}
- | c = 'AASTORE' {$n = new JvmOpcode(83, $c.line);}
- | c = 'BASTORE' {$n = new JvmOpcode(84, $c.line);}
- | c = 'CASTORE' {$n = new JvmOpcode(85, $c.line);}
- | c = 'SASTORE' {$n = new JvmOpcode(86, $c.line);}
- | c = 'POP' {$n = new JvmOpcode(87, $c.line);}
- | c = 'POP2' {$n = new JvmOpcode(88, $c.line);}
- | c = 'DUP' {$n = new JvmOpcode(89, $c.line);}
- | c = 'DUP_X1' {$n = new JvmOpcode(90, $c.line);}
- | c = 'DUP_X2' {$n = new JvmOpcode(91, $c.line);}
- | c = 'DUP2' {$n = new JvmOpcode(92, $c.line);}
- | c = 'DUP2_X1' {$n = new JvmOpcode(93, $c.line);}
- | c = 'DUP2_X2' {$n = new JvmOpcode(94, $c.line);}
- | c = 'SWAP' {$n = new JvmOpcode(95, $c.line);}
- | c = 'IADD' {$n = new JvmOpcode(96, $c.line);}
- | c = 'LADD' {$n = new JvmOpcode(97, $c.line);}
- | c = 'FADD' {$n = new JvmOpcode(98, $c.line);}
- | c = 'DADD' {$n = new JvmOpcode(99, $c.line);}
- | c = 'ISUB' {$n = new JvmOpcode(100, $c.line);}
- | c = 'LSUB' {$n = new JvmOpcode(101, $c.line);}
- | c = 'FSUB' {$n = new JvmOpcode(102, $c.line);}
- | c = 'DSUB' {$n = new JvmOpcode(103, $c.line);}
- | c = 'IMUL' {$n = new JvmOpcode(104, $c.line);}
- | c = 'LMUL' {$n = new JvmOpcode(105, $c.line);}
- | c = 'FMUL' {$n = new JvmOpcode(106, $c.line);}
- | c = 'DMUL' {$n = new JvmOpcode(107, $c.line);}
- | c = 'IDIV' {$n = new JvmOpcode(108, $c.line);}
- | c = 'LDIV' {$n = new JvmOpcode(109, $c.line);}
- | c = 'FDIV' {$n = new JvmOpcode(110, $c.line);}
- | c = 'DDIV' {$n = new JvmOpcode(111, $c.line);}
- | c = 'IREM' {$n = new JvmOpcode(112, $c.line);}
- | c = 'LREM' {$n = new JvmOpcode(113, $c.line);}
- | c = 'FREM' {$n = new JvmOpcode(114, $c.line);}
- | c = 'DREM' {$n = new JvmOpcode(115, $c.line);}
- | c = 'INEG' {$n = new JvmOpcode(116, $c.line);}
- | c = 'LNEG' {$n = new JvmOpcode(117, $c.line);}
- | c = 'FNEG' {$n = new JvmOpcode(118, $c.line);}
- | c = 'DNEG' {$n = new JvmOpcode(119, $c.line);}
- | c = 'ISHL' {$n = new JvmOpcode(120, $c.line);}
- | c = 'LSHL' {$n = new JvmOpcode(121, $c.line);}
- | c = 'ISHR' {$n = new JvmOpcode(122, $c.line);}
- | c = 'LSHR' {$n = new JvmOpcode(123, $c.line);}
- | c = 'IUSHR' {$n = new JvmOpcode(124, $c.line);}
- | c = 'LUSHR' {$n = new JvmOpcode(125, $c.line);}
- | c = 'IAND' {$n = new JvmOpcode(126, $c.line);}
- | c = 'LAND' {$n = new JvmOpcode(127, $c.line);}
- | c = 'IOR' {$n = new JvmOpcode(128, $c.line);}
- | c = 'LOR' {$n = new JvmOpcode(129, $c.line);}
- | c = 'IXOR' {$n = new JvmOpcode(130, $c.line);}
- | c = 'LXOR' {$n = new JvmOpcode(131, $c.line);}
- | c = 'IINC' {$n = new JvmOpcode(132, $c.line);}
- | c = 'I2L' {$n = new JvmOpcode(133, $c.line);}
- | c = 'I2F' {$n = new JvmOpcode(134, $c.line);}
- | c = 'I2D' {$n = new JvmOpcode(135, $c.line);}
- | c = 'L2I' {$n = new JvmOpcode(136, $c.line);}
- | c = 'L2F' {$n = new JvmOpcode(137, $c.line);}
- | c = 'L2D' {$n = new JvmOpcode(138, $c.line);}
- | c = 'F2I' {$n = new JvmOpcode(139, $c.line);}
- | c = 'F2L' {$n = new JvmOpcode(140, $c.line);}
- | c = 'F2D' {$n = new JvmOpcode(141, $c.line);}
- | c = 'D2I' {$n = new JvmOpcode(142, $c.line);}
- | c = 'D2L' {$n = new JvmOpcode(143, $c.line);}
- | c = 'D2F' {$n = new JvmOpcode(144, $c.line);}
- | c = 'I2B' {$n = new JvmOpcode(145, $c.line);}
- | c = 'I2C' {$n = new JvmOpcode(146, $c.line);}
- | c = 'I2S' {$n = new JvmOpcode(147, $c.line);}
- | c = 'LCMP' {$n = new JvmOpcode(148, $c.line);}
- | c = 'FCMPL' {$n = new JvmOpcode(149, $c.line);}
- | c = 'FCMPG' {$n = new JvmOpcode(150, $c.line);}
- | c = 'DCMPL' {$n = new JvmOpcode(151, $c.line);}
- | c = 'DCMPG' {$n = new JvmOpcode(152, $c.line);}
- | c = 'IFEQ' {$n = new JvmOpcode(153, $c.line);}
- | c = 'IFNE' {$n = new JvmOpcode(154, $c.line);}
- | c = 'IFLT' {$n = new JvmOpcode(155, $c.line);}
- | c = 'IFGE' {$n = new JvmOpcode(156, $c.line);}
- | c = 'IFGT' {$n = new JvmOpcode(157, $c.line);}
- | c = 'IFLE' {$n = new JvmOpcode(158, $c.line);}
- | c = 'IF_ICMPEQ' {$n = new JvmOpcode(159, $c.line);}
- | c = 'IF_ICMPNE' {$n = new JvmOpcode(160, $c.line);}
- | c = 'IF_ICMPLT' {$n = new JvmOpcode(161, $c.line);}
- | c = 'IF_ICMPGE' {$n = new JvmOpcode(162, $c.line);}
- | c = 'IF_ICMPGT' {$n = new JvmOpcode(163, $c.line);}
- | c = 'IF_ICMPLE' {$n = new JvmOpcode(164, $c.line);}
- | c = 'IF_ACMPEQ' {$n = new JvmOpcode(165, $c.line);}
- | c = 'IF_ACMPNE' {$n = new JvmOpcode(166, $c.line);}
- | c = 'GOTO' {$n = new JvmOpcode(167, $c.line);}
- | c = 'JSR' {$n = new JvmOpcode(168, $c.line);}
- | c = 'RET' {$n = new JvmOpcode(169, $c.line);}
- | c = 'TABLESWITCH' {$n = new JvmOpcode(170, $c.line);}
- | c = 'LOOKUPSWITCH' {$n = new JvmOpcode(171, $c.line);}
- | c = 'IRETURN' {$n = new JvmOpcode(172, $c.line);}
- | c = 'LRETURN' {$n = new JvmOpcode(173, $c.line);}
- | c = 'FRETURN' {$n = new JvmOpcode(174, $c.line);}
- | c = 'DRETURN' {$n = new JvmOpcode(175, $c.line);}
- | c = 'ARETURN' {$n = new JvmOpcode(176, $c.line);}
- | c = 'RETURN' {$n = new JvmOpcode(177, $c.line);}
- | c = 'GETSTATIC' {$n = new JvmOpcode(178, $c.line);}
- | c = 'PUTSTATIC' {$n = new JvmOpcode(179, $c.line);}
- | c = 'GETFIELD' {$n = new JvmOpcode(180, $c.line);}
- | c = 'PUTFIELD' {$n = new JvmOpcode(181, $c.line);}
- | c = 'INVOKEVIRTUAL' {$n = new JvmOpcode(182, $c.line);}
- | c = 'INVOKESPECIAL' {$n = new JvmOpcode(183, $c.line);}
- | c = 'INVOKESTATIC' {$n = new JvmOpcode(184, $c.line);}
- | c = 'INVOKEINTERFACE' {$n = new JvmOpcode(185, $c.line);}
- | c = 'INVOKEDYNAMIC' {$n = new JvmOpcode(186, $c.line);}
- | c = 'NEW' {$n = new JvmOpcode(187, $c.line);}
- | c = 'NEWARRAY' {$n = new JvmOpcode(188, $c.line);}
- | c = 'ANEWARRAY' {$n = new JvmOpcode(189, $c.line);}
- | c = 'ARRAYLENGTH' {$n = new JvmOpcode(190, $c.line);}
- | c = 'ATHROW' {$n = new JvmOpcode(191, $c.line);}
- | c = 'CHECKCAST' {$n = new JvmOpcode(192, $c.line);}
- | c = 'INSTANCEOF' {$n = new JvmOpcode(193, $c.line);}
- | c = 'MONITORENTER' {$n = new JvmOpcode(194, $c.line);}
- | c = 'MONITOREXIT' {$n = new JvmOpcode(195, $c.line);}
- | c = 'MULTIANEWARRAY' {$n = new JvmOpcode(197, $c.line);}
- | c = 'IFNULL' {$n = new JvmOpcode(198, $c.line);}
- | c = 'IFNONNULL' {$n = new JvmOpcode(199, $c.line);}
- ;
-
-simpleExpression returns [SimpleExpression n]
- : {$n = new SimpleExpression();}
- primary {$n.add($primary.n);} ( messageExpression {$n.add($messageExpression.n);} ( ';' messageElement {$n.add($messageElement.n);} )* )?
- ;
-
-messageElement returns [MessageElement n]
- : unarySelector {$n = new UnarySelectorMessageElement($unarySelector.n);}
- | binarySelector unaryObjectDescription {$n = new BinarySelectorMessageElement($binarySelector.n, $unaryObjectDescription.n);}
- | ( keyword binaryObjectDescription {if ($n != null) ((KeywordMessageElement)$n).add($keyword.n, $binaryObjectDescription.n); else $n = new KeywordMessageElement($keyword.n, $binaryObjectDescription.n);} )+
- ;
-
-messageExpression returns [MessageExpression n]
- : unaryExpression {$n = $unaryExpression.n;}
- | binaryExpression {$n = $binaryExpression.n;}
- | keywordExpression {$n = $keywordExpression.n;}
- ;
-
-unaryExpression returns [UnaryExpression n]
- : {$n = new UnaryExpression();}
- ( unarySelector {$n.add($unarySelector.n);} )+ (binaryExpression {$n.add($binaryExpression.n);} | keywordExpression {$n.add($keywordExpression.n);})?
- ;
-
-binaryExpression returns [BinaryExpression n]
- : {$n = new BinaryExpression();}
- ( binarySelector unaryObjectDescription {$n.add($binarySelector.n, $unaryObjectDescription.n);} )+ (keywordExpression {$n.add($keywordExpression.n);})?
- ;
-
-keywordExpression returns [KeywordExpression n]
- : {$n = new KeywordExpression();}
- ( keyword binaryObjectDescription {$n.add($keyword.n, $binaryObjectDescription.n);} )+
- ;
-
-unaryObjectDescription returns [UnaryObjectDescription n]
- : primary {$n = new UnaryObjectDescription($primary.n);} ( unarySelector {$n.add($unarySelector.n);} )*
- ;
-
-binaryObjectDescription returns [BinaryObjectDescription n]
- : primary {$n = new BinaryObjectDescription($primary.n);} ( unarySelector {$n.add($unarySelector.n);} )* ( binarySelector unaryObjectDescription {$n.add($binarySelector.n, $unaryObjectDescription.n);} )*
- ;
-
-primary returns [Primary n]
- : literal {$n = $literal.n;}
- | variableName {$n = $variableName.n;}
- | block {$n = $block.n;}
- | '(' expression {$n = new PrimaryExpression($expression.n);} ')'
- | '{' statements {$n = new PrimaryStatements($statements.n);} '}'
- ;
-
-literal returns [Literal n]
- : numberConstant {$n = new LiteralNumber($numberConstant.n);}
- | characterConstant {$n = new LiteralCharacter($characterConstant.n);}
- | stringConstant {$n = new LiteralString($stringConstant.n);}
- | stringChunk {$n = new LiteralString($stringChunk.n);}
- | '#' ( symbol {$n = new LiteralSymbol($symbol.n);} | array {$n = new LiteralArray($array.n);} )
- | ('self' | 'super' | 'true' | 'false' | 'nil' | 'Smalltalk' ) => reservedWordLiteral {$n = $reservedWordLiteral.n;}
- ;
-
-reservedWordLiteral returns [Literal n]
- : l = 'self' {$n = new SelfReservedWord($l.line);}
- | l = 'super' {$n = new SuperReservedWord($l.line);}
- | l = 'true' {$n = new TrueReservedWord($l.line);}
- | l = 'false' {$n = new FalseReservedWord($l.line);}
- | l = 'nil' {$n = new NilReservedWord($l.line);}
- | l = 'Smalltalk' {$n = new SmalltalkReservedWord($l.line);}
- ;
-
-block returns [Block n]
- : {$n = new Block();}
- '[' ((':' variableName {$n.add(new BlockVariableName($variableName.n));})+ '|')? ( temporaries {$n.add($temporaries.n);} )? statements {$n.add($statements.n);} ']'
- ;
-
-array returns [Array n]
- : {$n = new Array();}
- o = '(' {$n.line($o.line);} ( arrayConstantElement {$n.add($arrayConstantElement.n);})* ')'
- ;
-
-arrayConstantElement returns [IndexedVisitableNode n]
- : numberConstant {$n = $numberConstant.n;}
- | characterConstant {$n = $characterConstant.n;}
- | stringConstant {$n = $stringConstant.n;}
- | symbol {$n = $symbol.n;}
- | array {$n = $array.n;}
- ;
-
-symbol returns [Symbol n]
- : identifier {$n = new Symbol($identifier.n);}
- | binarySelector {$n = new Symbol($binarySelector.n);}
- | keyword {$n = new Symbol($keyword.n);}
- ;
-
-unarySelector returns [UnarySelector n]
- : NAME {$n = new UnarySelector($NAME.text, $NAME.line);}
- ;
-
-binarySelector returns [BinarySelector n]
- : BINARY_SYMBOL {$n = new BinarySelector($BINARY_SYMBOL.text, $BINARY_SYMBOL.line);}
- ;
-
-variableName returns [VariableName n]
- : NAME {$n = new VariableName($NAME.text, $NAME.line);}
- ;
-
-keyword returns [Keyword n]
- : KEYWORD {$n = new Keyword($KEYWORD.text, $KEYWORD.line);}
- ;
-
-identifier returns [Identifier n]
- : NAME {$n = new Identifier($NAME.text, $NAME.line);}
- ;
-
-characterConstant returns [CharacterConstant n]
- : CHARACTER {$n = new CharacterConstant($CHARACTER.text, $CHARACTER.line);}
- ;
-
-stringConstant returns [StringConstant n]
- : STRING_LITERAL {$n = new StringConstant($STRING_LITERAL.text, $STRING_LITERAL.line);}
- ;
-
-stringChunk returns [StringChunk n]
- : STRING_CHUNK {$n = new StringChunk($STRING_CHUNK.text, $STRING_CHUNK.line);}
- ;
-
-numberConstant returns [NumberConstant n]
- : DIGITS {$n = new NumberConstant($DIGITS.text, $DIGITS.line);}
- ;
-
-DIGITS: ('+'|'-') ? ('0'..'9')+;
-NAME: ('a'..'z' | 'A'..'Z')('a'..'z' | 'A'..'Z' | '0'..'9')*;
-KEYWORD: NAME ':';
-STRING_LITERAL: '\'' (~'\''|'\'\'')* '\'';
-STRING_CHUNK: '`' .* '`';
-BINARY_SYMBOL: ('~'|'!'|'@'|'%'|'&'|'*'|'-'|'+'|'='|'\\'|'|'|'?'|'/'|'>'|'<'|',') ('~'|'!'|'@'|'%'|'&'|'*'|'-'|'+'|'='|'\\'|'|'|'?'|'/'|'>'|'<'|',')*;
-CHARACTER: '$' . ;
-COMMENT: '"' .* '"' {$channel = HIDDEN;};
-WHITESPACE: (' ' | '\t' | '\n' | '\r' | '\f' )+ {$channel = HIDDEN;};
-
+program returns [Program program]
+ : temporaries? statements WHITESPACE? EOF {program = new Program(new Temporaries($temporaries.temporaries), $statements.statements);}
+ ;
+
+primary returns [Primary primary]
+ : WHITESPACE?
+ ( IDENTIFIER {primary = new Identifier($IDENTIFIER.text, $IDENTIFIER.line);}
+ | number {primary = $number.number;}
+ | symbol_constant {primary = $symbol_constant.symbolConstant;}
+ | CHARACTER_CONSTANT {primary = new CharacterConstant($CHARACTER_CONSTANT.text.substring(1), $CHARACTER_CONSTANT.line);}
+ | STRING {primary = new StringConstant($STRING.text, $STRING.line);}
+ | array_constant {primary = $array_constant.arrayConstant; }
+ | block {primary = $block.block;}
+ | '(' expression WHITESPACE? ')' {primary = new PrimaryExpression($expression.expression);}
+ | '{' statements WHITESPACE? '}' {primary = new PrimaryStatements($statements.statements);}
+ | '<' KEYWORD WHITESPACE DIGITS '>' {primary = new Primitive($KEYWORD.text, $KEYWORD.line, $DIGITS.text);}
+ )
+ ;
+
+statements returns [Statements statements]
+ : non_empty_statements? { statements = $non_empty_statements.statements; }
+ ;
+
+non_empty_statements returns [Statements statements]
+ : WHITESPACE? a='^' expression '.'? {statements = new AnswerStatement($a.line, $expression.expression);}
+ | expression ( '.' WHITESPACE statements )? {statements = new Statements($expression.expression, $statements.statements);}
+ ;
+
+expression returns [Expression expression]
+ : WHITESPACE? IDENTIFIER WHITESPACE? ':=' e=expression {expression = new AssignmentExpression(new Identifier($IDENTIFIER.text, $IDENTIFIER.line), $e.expression);}
+ | simple_expression {expression = $simple_expression.simpleExpression;}
+ ;
+
+simple_expression returns [SimpleExpression simpleExpression]
+ @init { simpleExpression = new SimpleExpression(); }
+ : primary {simpleExpression.add($primary.primary);} ( message_expression {$simpleExpression.add($message_expression.messageExpression);}
+ ( ';' WHITESPACE message_element {$simpleExpression.add($message_element.messageElement);} )* )?
+ ;
+
+message_element returns [MessageElement messageElement]
+ : IDENTIFIER {$messageElement = new UnarySelectorMessageElement(new UnarySelector($IDENTIFIER.text, $IDENTIFIER.line));}
+ | binary_selector unary_object_description {$messageElement = new BinarySelectorMessageElement($binary_selector.binarySelector, $unary_object_description.unaryObjectDescription);}
+ | (KEYWORD binary_object_description {
+ if ($messageElement != null) {
+ ((KeywordMessageElement)$messageElement).add($KEYWORD.text, $KEYWORD.line, $binary_object_description.binaryObjectDescription);
+ } else {
+ $messageElement = new KeywordMessageElement($KEYWORD.text, $KEYWORD.line, $binary_object_description.binaryObjectDescription);
+ }
+ } WHITESPACE? )+
+ ;
+
+message_expression returns [MessageExpression messageExpression]
+ : unary_expression {$messageExpression = $unary_expression.unaryExpression;}
+ | binary_expression {$messageExpression = $binary_expression.binaryExpression;}
+ | keyword_expression {$messageExpression = $keyword_expression.keywordExpression;}
+ ;
+
+unary_expression returns [UnaryExpression unaryExpression]
+ @init { unaryExpression = new UnaryExpression(); }
+ : (WHITESPACE IDENTIFIER {$unaryExpression.add(new UnarySelector($IDENTIFIER.text, $IDENTIFIER.line));} )+
+ (binary_expression {$unaryExpression.add($binary_expression.binaryExpression);} | keyword_expression {$unaryExpression.add($keyword_expression.keywordExpression);})?
+ ;
+
+binary_expression returns [BinaryExpression binaryExpression]
+ @init { binaryExpression = new BinaryExpression(); }
+ : (WHITESPACE binary_selector unary_object_description {$binaryExpression.add($binary_selector.binarySelector, $unary_object_description.unaryObjectDescription);} )+
+ (keyword_expression {$binaryExpression.add($keyword_expression.keywordExpression);})?
+ ;
+
+keyword_expression returns [KeywordExpression keywordExpression]
+ @init { keywordExpression = new KeywordExpression(); }
+ : (WHITESPACE KEYWORD binary_object_description {$keywordExpression.add($KEYWORD.text, $KEYWORD.line, $binary_object_description.binaryObjectDescription);} )+
+ ;
+
+unary_object_description returns [UnaryObjectDescription unaryObjectDescription]
+ : primary {$unaryObjectDescription = new UnaryObjectDescription($primary.primary);} (WHITESPACE IDENTIFIER {$unaryObjectDescription.add(new UnarySelector($IDENTIFIER.text, $IDENTIFIER.line));})*
+ ;
+
+binary_object_description returns [BinaryObjectDescription binaryObjectDescription]
+: primary {$binaryObjectDescription = new BinaryObjectDescription($primary.primary);} (WHITESPACE IDENTIFIER {$binaryObjectDescription.add(new UnarySelector($IDENTIFIER.text, $IDENTIFIER.line));})*
+ (WHITESPACE binary_selector unary_object_description {$binaryObjectDescription.add($binary_selector.binarySelector, $unary_object_description.unaryObjectDescription);})*
+;
+
+block returns [Block block]
+ : o= '[' block_arguments? temporaries? statements WHITESPACE? ']' {block = new Block($o.line, new BlockArguments($block_arguments.blockArguments), new Temporaries($temporaries.temporaries), $statements.statements);}
+ ;
+
+temporaries returns [List<Temporary> temporaries]
+ @init { temporaries = new ArrayList<Temporary>(); }
+ : WHITESPACE? '|' (WHITESPACE? IDENTIFIER {temporaries.add(new Temporary($IDENTIFIER.text, $IDENTIFIER.line));})+ WHITESPACE? '|'
+ ;
+
+block_arguments returns [List<BlockArgument> blockArguments]
+ @init { blockArguments = new ArrayList<BlockArgument>(); }
+ : WHITESPACE? (':' IDENTIFIER WHITESPACE? {blockArguments.add(new BlockArgument($IDENTIFIER.text, $IDENTIFIER.line));})+ '|'
+ ;
+
+array_constant returns [ArrayConstant arrayConstant]
+ : h='#' array {arrayConstant = new ArrayConstant($array.array, $h.line);}
+ ;
+
+array returns [Array array]
+ @init { array = new Array(); }
+ : '(' (WHITESPACE? array_element {array.add($array_element.arrayElement);})* WHITESPACE? ')'
+ ;
+
+array_element returns [ArrayElement arrayElement]
+ : number {arrayElement = $number.number;}
+ | symbol {arrayElement = $symbol.symbol;}
+ | STRING {arrayElement = new StringConstant($STRING.text, $STRING.line);}
+ | CHARACTER_CONSTANT {arrayElement = new CharacterConstant($CHARACTER_CONSTANT.text.substring(1), $CHARACTER_CONSTANT.line);}
+ | array {arrayElement = $array.array;}
+ ;
+
+symbol_constant returns [SymbolConstant symbolConstant]
+ : '#' symbol {symbolConstant = new SymbolConstant($symbol.symbol.value(), $symbol.symbol.line());}
+ ;
+
+symbol returns [Symbol symbol]
+ @init { symbol = new Symbol(); }
+ : binary_selector {symbol.valueAndLine($binary_selector.binarySelector.value(), $binary_selector.binarySelector.line());}
+ | IDENTIFIER {symbol.valueAndLine($IDENTIFIER.text, $IDENTIFIER.line); }
+ | (KEYWORD {symbol.addValueAndLine($KEYWORD.text, $KEYWORD.line);} )+ // Decision can match input such as "KEYWORD" using multiple alternatives: 1, 2
+ ;
+
+binary_selector returns [BinarySelector binarySelector]
+ @init { binarySelector = new BinarySelector(); }
+ : (s=('-'|'+'|'/'|'\\'|'*'|'~'|'<'|'>'|'='|'@'|'%'|'|'|'&'|'?'|'!'|',') {binarySelector.add($s.text,$s.line);} )+
+ ;
+
+number returns [Number number]
+ : (d1=DIGITS r='r')? (m1='-')? d2=DIGITS ('.' d3=DIGITS)? (e='e' (m2='-')? d4=DIGITS)? {number = new Number($d1.text, $r.text, $m1.text, $d2.text, $d2.line,$d3.text, $e.text, $m2.text, $d4.text);}
+ ;
+
+WHITESPACE: (' '|'\t'|'\r'|'\n')+;
+COMMENT: '"' .* '"' WHITESPACE {$channel = HIDDEN;};
+KEYWORD: IDENTIFIER ':';
+IDENTIFIER: LETTER (LETTER | DIGIT)*;
+CHARACTER_CONSTANT: '$' ('\'' | '"' | SPECIAL_CHAR | NORMAL_CHAR | DIGIT | LETTER);
+STRING: '\'' (~'\''|'\'\'')* '\'';
+DIGITS: DIGIT+;
+
+fragment LETTER: ('a'..'z' | 'A'..'Z');
+fragment DIGIT: '0'..'9';
+fragment SPECIAL_CHAR: '+'|'/'|'\\'|'*'|'~'|'<'|'>'|'='|'@'|'%'|'|'|'&'|'?'|'!'|',';
+fragment NORMAL_CHAR: '['|']'|'{'|'}'|'('|')'|'^'|'_'|';'|'$'|'#'|':'|'.'|'\'';
View
17 src/main/java/st/redline/BlockReturn.java
@@ -1,17 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-public class BlockReturn extends RuntimeException {
-
- private ProtoObject answer = ProtoObject.NIL;
-
- public BlockReturn(ProtoObject answer) {
- System.out.println("BlockReturn() " + answer);
- if (answer != null)
- this.answer = answer;
- }
-
- public ProtoObject answer() {
- return answer;
- }
-}
View
131 src/main/java/st/redline/Bootstrapper.java
@@ -1,131 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-import st.redline.bootstrap.*;
-import st.redline.bootstrap.InitializeMethod;
-
-import java.io.File;
-
-public class Bootstrapper {
-
- private ProtoObject protoObject;
-
- protected Bootstrapper(ProtoObject protoObject) {
- this.protoObject = protoObject;
- }
-
- public void bootstrap() throws ClassNotFoundException {
- markBootstrapping(true);
- mapPackages();
- registerRootClasses();
- instantiateBootstrappedSingletons();
- createClasses();
- makeClassSuperclassOfObjectsClass();
- makeClassDescriptionSuperclassOfMetaclassClass();
- reclassBootstrappedSingletons();
- markBootstrapping(false);
- instantiateNonBootstrappedSingletons();
- }
-
- private void reclassBootstrappedSingletons() throws ClassNotFoundException {
- ProtoObject.NIL.cls(Primitives.resolveObject(protoObject, "UndefinedObject"));
- }
-
- private void makeClassSuperclassOfObjectsClass() throws ClassNotFoundException {
- ProtoObject cls = Primitives.resolveObject(protoObject, "Class");
- ProtoObject object = Primitives.resolveObject(protoObject, "Object");
- object.cls().superclass(cls);
- }
-
- private void makeClassDescriptionSuperclassOfMetaclassClass() throws ClassNotFoundException {
- ProtoObject classDescription = Primitives.resolveObject(protoObject, "ClassDescription");
- ProtoObject.METACLASS_INSTANCE.superclass0(classDescription);
- }
-
- private void tearDownProtoObject() {
- protoObject.cls(null);
- }
-
- private void setupProtoObject() {
- protoObject.cls(protoObject);
- protoObject.methodAtPut("<", new ClassSubclassMethod());
- protoObject.methodAtPut("instanceVariableNames:", new InstanceVariableNamesMethod());
- protoObject.methodAtPut("classVariableNames:", new ClassVariableNamesMethod());
- protoObject.methodAtPut("classInstanceVariableNames:", new ClassInstanceVariableNamesMethod());
- protoObject.methodAtPut("poolDictionaries:", new PoolDictionariesMethod());
- protoObject.methodAtPut("category:", new CategoryMethod());
- protoObject.methodAtPut("import:", new ImportMethod());
- protoObject.methodAtPut("initialize", new InitializeMethod());
- protoObject.methodAtPut("subclass:instanceVariableNames:classVariableNames:poolDictionaries:", new ClassSubclassWithVariablesMethod());
- }
-
- private void markBootstrapping(boolean bootstrapping) {
- Primitives.bootstrapping = bootstrapping;
- }
-
- private void loadUsing(String name, SmalltalkClassLoader smalltalk) {
- try {
- smalltalk.findClass(name).newInstance();
- } catch (Exception e) {
- markBootstrapping(false);
- throw RedlineException.withCauseAndMessage(String.format("Unable to load class %s", name), e);
- }
- }
-
- private void instantiateBootstrappedSingletons() {
- ProtoObject.METACLASS_INSTANCE = createMetaclassInstance();
- Primitives.registerAs(ProtoObject.METACLASS_INSTANCE, "st.redline.MetaClass");
- ProtoObject.NIL = createUndefinedObjectInstance();
- }
-
- private void instantiateNonBootstrappedSingletons() throws ClassNotFoundException {
- ProtoObject trueClass = Primitives.resolveObject(protoObject, "st.redline.True");
- ProtoObject.TRUE = Primitives.send(trueClass, "new", null);
- ProtoObject falseClass = Primitives.resolveObject(protoObject, "st.redline.False");
- ProtoObject.FALSE = Primitives.send(falseClass, "new", null);
- }
-
- private ProtoObject createMetaclassInstance() {
- ProtoObject classClass = new ProtoObject();
- classClass.name("Metaclass-classclass");
- ProtoObject cls = new ProtoObject(classClass);
- cls.name("Metaclass");
- return cls;
- }
-
- private ProtoObject createUndefinedObjectInstance() {
- ProtoObject classClass = new ProtoObject();
- ProtoObject cls = new ProtoObject(classClass);
- cls.name("UndefinedObject");
- return new ProtoObject(cls);
- }
-
- private void createClasses() {
- SmalltalkClassLoader smalltalk = currentClassLoader();
- setupProtoObject();
- loadUsing("st.redline.Object", smalltalk);
- tearDownProtoObject();
- loadUsing("st.redline.UndefinedObject", smalltalk);
- loadUsing("st.redline.Symbol", smalltalk);
- loadUsing("st.redline.Class", smalltalk);
- loadUsing("st.redline.True", smalltalk);
- loadUsing("st.redline.False", smalltalk);
- }
-
- private SmalltalkClassLoader currentClassLoader() {
- return (SmalltalkClassLoader) Thread.currentThread().getContextClassLoader();
- }
-
- private void registerRootClasses() {
- Primitives.registerAs(protoObject, "st.redline.ProtoObject");
- }
-
- private void mapPackages() {
- ProtoObject.packageMap.put("ProtoObject", "st.redline.ProtoObject");
- for (String sourceFile : SourceFileFinder.findIn("st" + File.separator + "redline")) {
- String packageName = ClassPathUtilities.filenameWithExtensionToPackageName(sourceFile);
- String name = ClassPathUtilities.filenameToClassName(sourceFile);
- ProtoObject.packageMap.put(name, packageName + "." + name);
- }
- }
-}
View
167 src/main/java/st/redline/CommandLine.java
@@ -1,167 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-import org.apache.commons.cli.*;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Processes the raw arguments given in String[] format.
- *
- * Command line options are different to command line arguments.
- * Arguments is the list of <source files>
- */
-public class CommandLine {
-
- private static final String SOURCEPATH_OPTION = "s";
- private static final String EXECUTE_NOW_OPTION = "e";
- private static final String RUNTIMEPATH_OPTION = "r";
- private static final String REDLINE_HOME_ENVVAR = "REDLINE_HOME";
-
- private final String[] rawArguments;
- private org.apache.commons.cli.CommandLine commandLine;
-
- public CommandLine(String[] rawArguments) {
- this.rawArguments = rawArguments;
- tryParseArguments();
- }
-
- String userPath() {
- return System.getProperty("user.dir");
- }
-
- public void printHelp(PrintWriter printWriter) {
- helpFormatter().printHelp(printWriter, 80, "stic [options] <source files>", "", commandLineOptions(), 1, 4, "");
- printWriter.flush();
- }
-
- public List arguments() {
- return commandLine.getArgList();
- }
-
- public boolean verboseRequested() {
- return haveVerboseOption();
- }
-
- boolean helpRequested() {
- return haveHelpOption() || haveNoArguments();
- }
-
- public boolean executeNowRequested() {
- return commandLine.hasOption('e');
- }
-
- public boolean haveNoArguments() {
- return commandLine.getArgList().isEmpty();
- }
-
- boolean haveHelpOption() {
- return commandLine.hasOption('?');
- }
-
- boolean haveVerboseOption() {
- return commandLine.hasOption('v');
- }
-
- void tryParseArguments() {
- try {
- commandLine = commandLineParser().parse(commandLineOptions(), rawArguments);
- } catch (ParseException e) {
- throw new IllegalStateException(e);
- }
- }
-
- Options commandLineOptions() {
- return new CommandLineOptions();
- }
-
- String input() {
- System.out.println(commandLine.getOptionValue(EXECUTE_NOW_OPTION));
- return commandLine.getOptionValue(EXECUTE_NOW_OPTION);
- }
-
- List<String> sourcePaths() {
- List<String> paths = pathsSpecifiedFor(SOURCEPATH_OPTION);
- paths.add(userPath());
- return paths;
- }
-
- List<String> runtimePaths() {
- List<String> paths = pathsSpecifiedFor(RUNTIMEPATH_OPTION);
- if (paths.isEmpty() && System.getenv(REDLINE_HOME_ENVVAR) != null) {
- String redlineHome = System.getenv(REDLINE_HOME_ENVVAR);
- if (!redlineHome.endsWith("rt"))
- redlineHome = redlineHome + File.separator + "rt";
- paths.add(redlineHome);
- }
- return paths;
- }
-
- private List<String> pathsSpecifiedFor(String commandLineOption) {
- List<String> paths = new ArrayList<String>();
- if (commandLine.hasOption(commandLineOption))
- for (String path : commandLine.getOptionValue(commandLineOption).split(File.pathSeparator))
- paths.add(stripTrailingSlash(path));
- return paths;
- }
-
- private String stripTrailingSlash(String path) {
- if (path.endsWith(File.separator))
- return path.substring(0, path.length() - 1);
- return path;
- }
-
- CommandLineParser commandLineParser() {
- return new GnuParser();
- }
-
- HelpFormatter helpFormatter() {
- return new HelpFormatter();
- }
-
- private class CommandLineOptions extends Options {
-
- public CommandLineOptions() {
- addOption(help());
- addOption(sourcePath());
- addOption(runtimePath());
- addOption(executeNow());
- addOption(verbose());
- }
-
- private Option verbose() {
- return new Option("v", "verbose", false, "output messages about what Redline is doing.");
- }
-
- private Option help() {
- return new Option("?", "help", false, "print this message.");
- }
-
- private Option sourcePath() {
- return OptionBuilder.withArgName("paths")
- .hasArg()
- .withDescription("where to find input source files. Separate each path with " + File.pathSeparator
- + ". The paths src" + File.separator + "main" + File.separator + "smalltalk and src"
- + File.separator + "test" + File.separator + "smalltalk are included by default. Ignored if -e specified.")
- .create(SOURCEPATH_OPTION);
- }
-
- private Option runtimePath() {
- return OptionBuilder.withArgName("path")
- .hasArg()
- .withDescription("where to find Redline. Defaults to environment " + REDLINE_HOME_ENVVAR + ".")
- .create(RUNTIMEPATH_OPTION);
- }
-
- private Option executeNow() {
- return OptionBuilder.withArgName("input")
- .hasArg()
- .withDescription("execute the Smalltalk code (enclosed in \"\" double quotes).")
- .create(EXECUTE_NOW_OPTION);
- }
- }
-}
View
63 src/main/java/st/redline/Compiler.java
@@ -1,63 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-
-import st.redline.compiler.*;
-
-public class Compiler {
-
- private final SourceFile sourceFile;
-
- public Compiler(SourceFile sourceFile) {
- this.sourceFile = sourceFile;
- }
-
- protected byte[] compile() {
- return compileSource(preprocessSource());
- }
-
- private byte[] compileSource(Source source) {
- Program program = parse(source.source());
- Analyser analyser = analyse(program);
- return analyser.classBytes();
- }
-
- private Analyser analyse(Program program) {
- Analyser analyser = analyser();
- program.accept(analyser);
- return analyser;
- }
-
- private Analyser analyser() {
- return new Analyser(sourceFile.shortName(), sourceFile.packageName());
- }
-
- private Program parse(String sourceCode) {
- SmalltalkLexer smalltalkLexer = lexorOn(sourceCode);
- SmalltalkParser smalltalkParser = parserUsing(smalltalkLexer);
- try {
- return smalltalkParser.program();
- } catch (RecognitionException e) {
- throw RedlineException.withCause(e);
- }
- }
-
- private SmalltalkParser parserUsing(SmalltalkLexer smalltalkLexer) {
- return new SmalltalkParser(new CommonTokenStream(smalltalkLexer));
- }
-
- private SmalltalkLexer lexorOn(String sourceCode) {
- return new SmalltalkLexer(new ANTLRStringStream(sourceCode));
- }
-
- private Source preprocessSource() {
- return preprocessor().parse(sourceFile);
- }
-
- private Preprocessor preprocessor() {
- return new Preprocessor();
- }
-}
View
29 src/main/java/st/redline/Preprocessor.java
@@ -1,29 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-import org.antlr.runtime.*;
-import st.redline.compiler.*;
-
-public class Preprocessor {
-
- public Source parse(SourceFile sourceFile) {
- String preprocessedSource = parseFrom(sourceFile.contents(), sourceFile.shortName());
-// System.out.println(preprocessedSource);
- return new Source(preprocessedSource, sourceFile);
- }
-
- private String parseFrom(String source, String name) {
- try {
- PreProcLexer lexer = new PreProcLexer();
- lexer.setCharStream(new ANTLRStringStream(source));
- lexer.initPreProc(name);
- new CommonTokenStream(lexer);
- while (lexer.nextToken().getType() != Token.EOF) {
- }
- return lexer.getOutput();
- } catch (Exception e) {
- System.err.println("Preprocessor threw an exception:\n\n");
- throw RedlineException.withCause(e);
- }
- }
-}
View
922 src/main/java/st/redline/Primitives.java
@@ -1,922 +0,0 @@
-/* Redline Smalltalk, Copyright (c) James C. Ladd. All rights reserved. See LICENSE in the root of this distribution */
-package st.redline;
-
-import st.redline.compiler.*;
-
-import java.math.BigInteger;
-import java.util.*;
-
-public class Primitives {
-
- protected static boolean bootstrapping = false;
-
- private static final ThreadLocal<Stack<String>> packageRegistry = new ThreadLocal<Stack<String>>();
- private static final Map<String, AbstractMethod> methodsToBeCompiled = new HashMap<String, AbstractMethod>();
- private static final Map<String, Block> blocksToBeCompiled = new HashMap<String, Block>();
- private static final Map<String, ProtoBlock> blocksRegistry = new HashMap<String, ProtoBlock>();
- private static final ThreadLocal<Stack<ProtoObject>> classInitialisationRegistry = new ThreadLocal<Stack<ProtoObject>>();
-
- public static ProtoObject p1(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).add((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p2(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).subtract((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p3(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) < 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p4(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) > 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p5(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- int result = ((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue());
- if (result <= 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p6(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- int result = ((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue());
- if (result >= 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p7(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) == 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p8(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) != 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p9(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).multiply((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p10(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).divide((BigInteger) arg1.javaValue()));
- }
-
-
- public static ProtoObject p21(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).add((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p22(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).subtract((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p23(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) < 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p24(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) > 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p25(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- int result = ((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue());
- if (result <= 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p26(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- int result = ((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue());
- if (result >= 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p27(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) == 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p28(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- if (((BigInteger) receiver.javaValue()).compareTo((BigInteger) arg1.javaValue()) != 0)
- return ProtoObject.TRUE;
- return ProtoObject.FALSE;
- }
-
- public static ProtoObject p29(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).multiply((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p30(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- return instanceLike(receiver).javaValue(((BigInteger) receiver.javaValue()).divide((BigInteger) arg1.javaValue()));
- }
-
- public static ProtoObject p60(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // basicAt: / at:
-// System.out.println("** p60 at: " + arg1.javaValue());
- ProtoObject[] slots = (ProtoObject[]) receiver.javaValue();
- if (slots == null)
- throw new IllegalStateException("Receivers slots are null! " + receiver);
- int index = ((BigInteger) arg1.javaValue()).intValue();
- if (index == 0)
- throw new IllegalStateException("Index to slot cannot be zero!");
- return slots[index];
- }
-
- public static ProtoObject p61(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
-// System.out.println("** p61 at: " + arg1.javaValue() + " put: " + arg2);
- // basicAt:put: / at:put:
- ProtoObject[] slots = (ProtoObject[]) receiver.javaValue();
- if (slots == null)
- throw new IllegalStateException("Receivers slots are null! " + receiver);
- int index = ((BigInteger) arg1.javaValue()).intValue();
- if (index == 0)
- throw new IllegalStateException("Index to slot cannot be zero!");
- slots[index] = arg2;
- return arg2; // <- returns stored value according to BlueBook.
- }
-
- public static ProtoObject p62(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- Object value = receiver.javaValue();
- try {
- int length = (value instanceof ProtoObject[]) ? ((ProtoObject[]) value).length - 1 : 0;
- return createInteger(receiver, (length < 0) ? 0 : length);
- } catch (ClassNotFoundException e) {
- throw new RedlineException(e);
- }
- }
-
- public static ProtoObject p68(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- return ProtoObject.NIL;
- }
-
- public static ProtoObject p69(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- return receiver;
- }
-
- public static ProtoObject p70(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // create a new instance of the receiver (a class).
- return new ProtoObject(receiver);
- }
-
- public static ProtoObject p71(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // create a new instance of the receiver (a class) with the number of indexable fields specified by the size argument.
- ProtoObject instance = p70(receiver, thisContext, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
- int size = ((BigInteger) arg1.javaValue()).intValue();
- instance.javaValue(new ProtoObject[size + 1]); // <- +1 because Smalltalk indexes from 1.
- return instance;
- }
-
- public static ProtoObject p73(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- return ProtoObject.NIL;
- }
-
- public static ProtoObject p74(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- return receiver;
- }
-
- public static ProtoObject p75(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // does this primitive make sense for Redline?
- try {
- return createInteger(receiver, receiver.hashCode());
- } catch (ClassNotFoundException e) {
- throw new RedlineException(e);
- }
- }
-
- public static ProtoObject p110(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // ==
- return receiver.equals(arg1) ? ProtoObject.TRUE : ProtoObject.FALSE;
- }
-
- public static ProtoObject p111(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // Object >> class
- return receiver.cls();
- }
-
- //
- // Redline specific primitives
- //
-
- public static ProtoObject p201(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // [] value
- return ((ProtoBlock) receiver).applyTo(receiver, thisContext);
- }
-
- public static ProtoObject p202(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // [] value: arg
- return ((ProtoBlock) receiver).applyTo(receiver, thisContext, arg1);
- }
-
- public static ProtoObject p203(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // [] value: arg1 value: arg2
- return ((ProtoBlock) receiver).applyTo(receiver, thisContext, arg1, arg2);
- }
-
- public static ProtoObject p204(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // [] value: arg1 value: arg2 value: arg3
- return ((ProtoBlock) receiver).applyTo(receiver, thisContext, arg1, arg2, arg3);
- }
-
- public static ProtoObject p205(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // [] value: arg1 value: arg2 value: arg3 value: arg4
- return ((ProtoBlock) receiver).applyTo(receiver, thisContext, arg1, arg2, arg3, arg4);
- }
-
- public static ProtoObject p210(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- ProtoBlock aBlock = callback210(receiver, thisContext, arg1);
- send(send(receiver, "value", thisContext), aBlock, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
-
- private static ProtoBlock callback210(final ProtoObject receiver, final ThisContext thisContext, final ProtoObject trueBlock) {
- return new ProtoBlock() {
- public ProtoObject applyTo(ProtoObject r, ThisContext t) {
-// System.out.println("callback210() evaluating true block.");
- Primitives.send(trueBlock, "value", thisContext);
- Primitives.send(Primitives.send(receiver, "value", thisContext), this, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
- };
- }
-
- public static ProtoObject p211(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- ProtoBlock aBlock = callback211(receiver, thisContext, arg1);
- send(send(receiver, "value", thisContext), aBlock, "ifFalse:", thisContext);
- return ProtoObject.NIL;
- }
-
- private static ProtoBlock callback211(final ProtoObject receiver, final ThisContext thisContext, final ProtoObject falseBlock) {
- return new ProtoBlock() {
- public ProtoObject applyTo(ProtoObject r, ThisContext t) {
- System.out.println("callback210() evaluating false block.");
- Primitives.send(falseBlock, "value", thisContext);
- Primitives.send(Primitives.send(receiver, "value", thisContext), this, "ifFalse:", thisContext);
- return ProtoObject.NIL;
- }
- };
- }
-
- public static ProtoObject p212(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- ProtoBlock aBlock = callback212(receiver, thisContext, arg1);
- send(send(send(receiver, "value", thisContext), "notNil", thisContext), aBlock, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
-
- private static ProtoBlock callback212(final ProtoObject receiver, final ThisContext thisContext, final ProtoObject trueBlock) {
- return new ProtoBlock() {
- public ProtoObject applyTo(ProtoObject r, ThisContext t) {
- System.out.println("callback212() evaluating true block.");
- Primitives.send(trueBlock, "value", thisContext);
- Primitives.send(Primitives.send(Primitives.send(receiver, "value", thisContext), "notNil", thisContext), this, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
- };
- }
-
- public static ProtoObject p213(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- ProtoBlock aBlock = callback213(receiver, thisContext, arg1);
- send(send(send(receiver, "value", thisContext), "isNil", thisContext), aBlock, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
-
- private static ProtoBlock callback213(final ProtoObject receiver, final ThisContext thisContext, final ProtoObject trueBlock) {
- return new ProtoBlock() {
- public ProtoObject applyTo(ProtoObject r, ThisContext t) {
- System.out.println("callback213() evaluating true block.");
- Primitives.send(trueBlock, "value", thisContext);
- Primitives.send(Primitives.send(Primitives.send(receiver, "value", thisContext), "isNil", thisContext), this, "ifTrue:", thisContext);
- return ProtoObject.NIL;
- }
- };
- }
-
- public static ProtoObject p214(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // whileFalse
- return p211(receiver, thisContext, arg1, noOpBlock(), arg3, arg4, arg5, arg6, arg7);
- }
-
- public static ProtoObject p215(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // whileTrue
- return p210(receiver, thisContext, arg1, noOpBlock(), arg3, arg4, arg5, arg6, arg7);
- }
-
- public static ProtoBlock noOpBlock() {
- return new ProtoBlock() {
- public ProtoObject applyTo(ProtoObject r, ThisContext t) {
- return ProtoObject.NIL;
- }
- };
- }
-
- public static ProtoObject p216(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- throw RedlineException.withMessage(arg1.javaValue().toString());
- }
-
- public static ProtoObject p217(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // create a new character
- ProtoObject result = new ProtoObject(receiver);
-
- result.javaValue((char)(((BigInteger)arg1.javaValue()).intValue()));
-
- return result;
- }
-
- public static ProtoObject p218(ProtoObject receiver, ThisContext thisContext, ProtoObject arg1, ProtoObject arg2, ProtoObject arg3, ProtoObject arg4, ProtoObject arg5, ProtoObject arg6, ProtoObject arg7) {
- // name
- try {
- String name = receiver.name();
- return createString(receiver, name != null ? name : "unnamed");
- } catch (ClassNotFoundException e) {