Permalink
Browse files

Boojay.Runtime => Boojay.Lang;

basic generator support complete
  • Loading branch information...
1 parent ae4d90c commit d0b1367e4df7ee398da45e2a2a0316d6530fc11b @bamboo committed Jan 10, 2009
@@ -1,7 +1,7 @@
-#Sat Dec 20 12:16:41 BRST 2008
+#Sat Jan 10 17:41:51 BRST 2009
eclipse.preferences.version=1
+encoding//boojay/src/Boojay.Lang/.monolipse=utf-8
encoding//boojay/src/Boojay.Macros/.monolipse=utf-8
-encoding//boojay/src/Boojay.Runtime/.monolipse=utf-8
encoding//examples/expressions/.monolipse=utf-8
encoding//extensions/examples/ometa/calculator/.monolipse=utf-8
encoding//extensions/examples/ometa/metaboo/.monolipse=utf-8
View
@@ -2,34 +2,29 @@
<property name="dir.bin" location="../bin" />
<property name="dir.build" location="../bin" />
- <property name="dir.src" location="src/boojay.runtime" />
<property name="mono" value="mono" />
<macrodef name="boojay">
<attribute name="srcdir" />
- <attribute name="destdir" />
+ <attribute name="destdir" default="${dir.build}" />
<element name="args" optional="true" />
<sequential>
<exec taskname="boojay" executable="${mono}" dir="${dir.bin}">
<arg value="--debug" />
<arg file="${dir.bin}/boojay.exe" />
<arg value="-srcdir:@{srcdir}" />
<arg value="-output:@{destdir}" />
+ <arg value="-verbose" />
+ <arg value="-r:IKVM.OpenJDK.ClassLibrary" />
<args />
</exec>
</sequential>
</macrodef>
<target name="build" depends="init">
- <boojay srcdir="${dir.src}" destdir="${dir.build}">
- <args>
- <!--
- <arg value="-verbose+" />
- -->
- <arg value="-r:IKVM.OpenJDK.ClassLibrary" />
- </args>
- </boojay>
+ <property name="Boojay.Lang" location="src/Boojay.Lang" />
+ <boojay srcdir="${Boojay.Lang}" />
</target>
@@ -9,7 +9,7 @@
<path>/boo-extensions/boojay/src/Boojay.Macros</path>
</monolipse.core.internal.AssemblySourceReference-Remembrance>
<monolipse.core.internal.AssemblySourceReference-Remembrance>
- <path>/boo-extensions/boojay/src/Boojay.Runtime</path>
+ <path>/boo-extensions/boojay/src/Boojay.Lang</path>
</monolipse.core.internal.AssemblySourceReference-Remembrance>
</references>
<outputFolder>/boo-extensions/bin</outputFolder>
@@ -11,5 +11,5 @@ def newBoojayCompiler(pipeline as CompilerPipeline):
compiler.Parameters.Pipeline = pipeline
compiler.Parameters.References.Add(typeof(lang.Object).Assembly)
compiler.Parameters.References.Add(typeof(Boojay.Macros.PrintMacro).Assembly)
- compiler.Parameters.References.Add(typeof(Boojay.Runtime.BuiltinsModule).Assembly)
+ compiler.Parameters.References.Add(typeof(Boojay.Lang.BuiltinsModule).Assembly)
return compiler
@@ -34,12 +34,18 @@ class BoojayEmitter(AbstractVisitorCompilerStep):
typeSystem.ObjectType: "java/lang/Object",
Null.Default: "java/lang/Object",
typeSystem.StringType: "java/lang/String",
- typeSystem.ICallableType: "Boojay/Runtime/Callable",
+ typeSystem.ICallableType: "Boojay/Lang/Callable",
typeSystem.TypeType: "java/lang/Class",
- typeSystem.IEnumerableType: "Boojay/Runtime/Enumerable",
- typeSystem.IEnumeratorType: "Boojay/Runtime/Enumerator",
- typeSystem.RuntimeServicesType: "Boojay/Runtime/RuntimeServices",
- typeSystem.Map(typeof(System.IDisposable)): "Boojay/Runtime/Disposable",
+ typeSystem.IEnumerableType: "Boojay/Lang/Enumerable",
+ typeSystem.IEnumerableGenericType: "Boojay/Lang/Enumerable",
+ typeSystem.IEnumeratorType: "Boojay/Lang/Enumerator",
+ typeSystem.IEnumeratorGenericType: "Boojay/Lang/Enumerator",
+ typeSystem.Map(typeof(Boo.Lang.GenericGenerator[of*])): "Boojay/Lang/Generator",
+ typeSystem.Map(typeof(Boo.Lang.GenericGeneratorEnumerator[of*])): "Boojay/Lang/GeneratorEnumerator",
+ typeSystem.RuntimeServicesType: "Boojay/Lang/RuntimeServices",
+ typeSystem.Map(System.Exception): "java/lang/Exception",
+ typeSystem.Map(System.NotImplementedException): "Boojay/Lang/NotImplementedException",
+ typeSystem.Map(System.IDisposable): "Boojay/Lang/Disposable",
}
_primitiveMappings = {
@@ -159,6 +165,9 @@ class BoojayEmitter(AbstractVisitorCompilerStep):
def emitCondition(e as Expression):
emit e
ensureBool typeOf(e)
+
+ override def OnModule(node as Module):
+ emit node.Members
override def OnWhileStatement(node as WhileStatement):
@@ -1045,6 +1054,7 @@ class BoojayEmitter(AbstractVisitorCompilerStep):
def javaType(type as IType) as string:
if type in _typeMappings: return _typeMappings[type]
+ if type.ConstructedInfo is not null: return javaType(type.ConstructedInfo.GenericDefinition)
if type.DeclaringEntity is not null: return innerClassName(type)
return javaType(type.FullName)
@@ -8,12 +8,9 @@ class JavaTypeSystem(TypeSystemServices):
def constructor(context as CompilerContext):
super(context)
self.StringType = ReplaceMapping(System.String, JavaLangString)
- self.MulticastDelegateType = ReplaceMapping(System.MulticastDelegate, Boojay.Runtime.MulticastDelegate)
+ self.MulticastDelegateType = ReplaceMapping(System.MulticastDelegate, Boojay.Lang.MulticastDelegate)
self.AddPrimitiveType("string", self.StringType)
- override ExceptionType:
- get: return Map(java.lang.Exception)
-
def ReplaceMapping(existing as System.Type, new as System.Type):
mapping = Map(new)
Cache(existing, mapping)
@@ -0,0 +1,7 @@
+<settings>
+ <language>boo</language>
+ <outputType>library</outputType>
+ <references/>
+ <outputFolder>/boo-extensions/bin</outputFolder>
+ <additionalOptions></additionalOptions>
+</settings>
@@ -1,7 +1,7 @@
-namespace Boojay.Runtime
+namespace Boojay.Lang
import java.io
-import java.lang
+import java.lang from IKVM.OpenJdk.ClassLibrary
def join(items):
return join(items, ' ')
@@ -0,0 +1,4 @@
+namespace Boojay.Lang
+
+interface Callable:
+ def Call(args as (object)) as object
@@ -0,0 +1,4 @@
+namespace Boojay.Lang
+
+interface Disposable:
+ def Dispose()
@@ -1,4 +1,4 @@
-namespace Boojay.Runtime
+namespace Boojay.Lang
interface Enumerable:
def GetEnumerator() as Enumerator
@@ -0,0 +1,16 @@
+namespace Boojay.Lang
+
+abstract class Generator(Enumerable):
+ pass
+
+abstract class GeneratorEnumerator(Enumerator):
+ _current = null
+ _state = 0
+
+ Current:
+ get: return _current
+
+ protected def Yield(state as int, value):
+ _state = state
+ _current = value
+ return true
@@ -0,0 +1,4 @@
+namespace Boojay.Lang
+
+class MulticastDelegate:
+ pass
@@ -0,0 +1,4 @@
+namespace Boojay.Lang
+
+class NotImplementedException(java.lang.RuntimeException):
+ pass
@@ -0,0 +1,85 @@
+namespace Boojay.Lang
+
+import java.lang
+import java.util
+
+static class RuntimeServices:
+
+ def ToBool(o):
+ if o is null:
+ return false
+ boolean = o as Boolean
+ if boolean is not null:
+ return boolean.booleanValue()
+ return true
+
+ def UnboxChar(o):
+ return cast(Character, o).charValue()
+
+ def BoxChar(ch as char):
+ return Character(ch)
+
+ def UnboxInt32(o):
+ return cast(Number, o).intValue()
+
+ def EqualityOperator(x, y):
+ if x is y: return true
+ if x is null: return false
+ return x.Equals(y)
+
+ def GetEnumerable(source) as Enumerable:
+ if source isa Enumerable:
+ return source
+ if source isa Iterable:
+ return IterableEnumerable(source)
+ if source isa string:
+ return StringEnumerable(source)
+ raise IllegalArgumentException("source")
+
+ internal class StringEnumerable(Enumerable):
+ _string as string
+ def constructor(value as string):
+ _string = value
+ def GetEnumerator():
+ return StringEnumerator(_string)
+
+ internal class StringEnumerator(Enumerator):
+
+ _string as string
+ _current = -1
+
+ def constructor(value as string):
+ _string = value
+
+ def MoveNext():
+ next = _current + 1
+ if next >= len(_string):
+ return false
+ _current = next
+ return true
+
+ Current:
+ get: return _string[_current]
+
+ internal class IterableEnumerable(Enumerable):
+ _iterable as Iterable
+ def constructor(iterable as Iterable):
+ _iterable = iterable
+ def GetEnumerator() as Enumerator:
+ return IteratorEnumerator(_iterable.iterator())
+
+ internal class IteratorEnumerator(Enumerator):
+
+ _iterator as Iterator
+ _current
+
+ def constructor(iterator as Iterator):
+ _iterator = iterator
+
+ def MoveNext():
+ if not _iterator.hasNext(): return false
+ _current = _iterator.next()
+ return true
+
+ Current:
+ get: return _current
@@ -1,14 +0,0 @@
-<settings>
- <language>boo</language>
- <outputType>library</outputType>
- <references>
- <monolipse.core.internal.GlobalAssemblyCacheReference-Remembrance>
- <name>IKVM.OpenJDK.ClassLibrary</name>
- <version>0.36.0.11</version>
- <culture>neutral</culture>
- <token>13235d27fcbfff58</token>
- </monolipse.core.internal.GlobalAssemblyCacheReference-Remembrance>
- </references>
- <outputFolder>/boo-extensions/bin</outputFolder>
- <additionalOptions></additionalOptions>
-</settings>
@@ -1,4 +0,0 @@
-namespace Boojay.Runtime
-
-interface Callable:
- def Call(args as (object)) as object
@@ -1,4 +0,0 @@
-namespace Boojay.Runtime
-
-interface Disposable:
- def Dispose()
@@ -1,4 +0,0 @@
-namespace Boojay.Runtime
-
-class MulticastDelegate:
- pass
@@ -1,83 +0,0 @@
-namespace Boojay.Runtime
-
-import java.lang
-import java.util
-
-static class RuntimeServices:
-
- def ToBool(o):
- if o is null:
- return false
- boolean = o as Boolean
- if boolean is not null:
- return boolean.booleanValue()
- return true
-
- def UnboxChar(o):
- return cast(Character, o).charValue()
-
- def BoxChar(ch as char):
- return Character(ch)
-
- def UnboxInt32(o):
- return cast(Number, o).intValue()
-
- def EqualityOperator(x, y):
- if x is y: return true
- if x is null: return false
- return x.Equals(y)
-
- def GetEnumerable(source) as Enumerable:
- if source isa Iterable:
- return IterableEnumerable(source)
- if source isa string:
- return StringEnumerable(source)
- raise IllegalArgumentException("source")
-
-internal class StringEnumerable(Enumerable):
- _string as string
- def constructor(value as string):
- _string = value
- def GetEnumerator():
- return StringEnumerator(_string)
-
-internal class StringEnumerator(Enumerator):
-
- _string as string
- _current = -1
-
- def constructor(value as string):
- _string = value
-
- def MoveNext():
- next = _current + 1
- if next >= len(_string):
- return false
- _current = next
- return true
-
- Current:
- get: return _string[_current]
-
-internal class IterableEnumerable(Enumerable):
- _iterable as Iterable
- def constructor(iterable as Iterable):
- _iterable = iterable
- def GetEnumerator() as Enumerator:
- return IteratorEnumerator(_iterable.iterator())
-
-internal class IteratorEnumerator(Enumerator):
-
- _iterator as Iterator
- _current
-
- def constructor(iterator as Iterator):
- _iterator = iterator
-
- def MoveNext():
- if not _iterator.hasNext(): return false
- _current = _iterator.next()
- return true
-
- Current:
- get: return _current
Oops, something went wrong.

0 comments on commit d0b1367

Please sign in to comment.