Skip to content

Commit

Permalink
Boojay.Runtime => Boojay.Lang;
Browse files Browse the repository at this point in the history
basic generator support complete
  • Loading branch information
bamboo committed Jan 10, 2009
1 parent ae4d90c commit d0b1367
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 242 deletions.
4 changes: 2 additions & 2 deletions .settings/org.eclipse.core.resources.prefs
@@ -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
Expand Down
15 changes: 5 additions & 10 deletions boojay/build.xml
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion boojay/src/Boojay.Compilation/.monolipse
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion boojay/src/Boojay.Compilation/BoojayCompiler.boo
Expand Up @@ -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
20 changes: 15 additions & 5 deletions boojay/src/Boojay.Compilation/Steps/BoojayEmitter.boo
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions boojay/src/Boojay.Compilation/Steps/JavaTypeSystem.boo
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions boojay/src/Boojay.Lang/.monolipse
@@ -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, ' ')
Expand Down
4 changes: 4 additions & 0 deletions boojay/src/Boojay.Lang/Callable.boo
@@ -0,0 +1,4 @@
namespace Boojay.Lang

interface Callable:
def Call(args as (object)) as object
4 changes: 4 additions & 0 deletions boojay/src/Boojay.Lang/Disposable.boo
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions boojay/src/Boojay.Lang/Generator.boo
@@ -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
4 changes: 4 additions & 0 deletions boojay/src/Boojay.Lang/MulticastDelegate.boo
@@ -0,0 +1,4 @@
namespace Boojay.Lang

class MulticastDelegate:
pass
4 changes: 4 additions & 0 deletions boojay/src/Boojay.Lang/NotImplementedException.boo
@@ -0,0 +1,4 @@
namespace Boojay.Lang

class NotImplementedException(java.lang.RuntimeException):
pass
85 changes: 85 additions & 0 deletions boojay/src/Boojay.Lang/RuntimeServices.boo
@@ -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
14 changes: 0 additions & 14 deletions boojay/src/Boojay.Runtime/.monolipse

This file was deleted.

4 changes: 0 additions & 4 deletions boojay/src/Boojay.Runtime/Callable.boo

This file was deleted.

4 changes: 0 additions & 4 deletions boojay/src/Boojay.Runtime/Disposable.boo

This file was deleted.

4 changes: 0 additions & 4 deletions boojay/src/Boojay.Runtime/MulticastDelegate.boo

This file was deleted.

83 changes: 0 additions & 83 deletions boojay/src/Boojay.Runtime/RuntimeServices.boo

This file was deleted.

0 comments on commit d0b1367

Please sign in to comment.