Switching to the new build system and to the new build system. This is a MAJOR commit, so be careful when updating.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@5390 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
dubochet 2005-12-19 13:49:03 +00:00
parent ee6fdbc1d0
commit f677c469bd
575 changed files with 621 additions and 4921 deletions

59
README Normal file
View File

@ -0,0 +1,59 @@
================================================================================
THE SCALA REPOSITRY
Structure and build system
================================================================================
Part I. The repository layout
--------------------------------------------------------------------------------
Follows the file layout of the Scala repository. Files marked with a † are not
part of the Subversion repository but are either automatically generated by the
build script or user-created if needed.
scala/
build/ † Temporary staging area for build products.
build.excludes † An optional build configuration file.
build.properties † An optional build configuration file.
build.xml The main Ant build script.
dist/ † The destination folder of Scala distributions.
docs/ Documentation of Scala. More in its own module.
development/ Developer documentation.
examples/ Scala example files.
man/ UNIX manual files.
lib/ Pre-compiled libraries for the build.
fjbg.jar The Java byte-code generation library.
jaco.jar The JaCo Java compiler.
msil.jar The CLR byte-code generation library.
scala-compiler.jar The last stable version of the Scala compiler.
scala-library.jar The last stable version of the Scala library.
scala.dll The Scala library for Windows.
README The file you are currently reading.
sandbox/ † A folder to test code etc.
src/ All the source files of Scala.
compiler/ The sources of the Scala compiler.
exec/ The sources of the executable wrapper-scripts.
library/ The sources of the Scala library.
test/ The Scala test suite.
Any change to this structure requires a modification of the 'build.xml' file.
Part II. Building Scala
--------------------------------------------------------------------------------
The Scala build system is based on Apache Ant. Most required pre-compiled libraries are part of the repository (in 'lib/'). The following however is assumed to be installed on the build machine:
- A Java SDK 1.4 or above (1.5 not supported).
- Apache Ant version 1.6.2 or above.
More to come ...
Part III. Creating distributions
--------------------------------------------------------------------------------
More to come ...
Part IV. Contributing to Scala
--------------------------------------------------------------------------------
More to come ...

View File

@ -1,9 +0,0 @@
############################################################-*-Makefile-*-####
# DO NOT EDIT. Automatically generated file!
#
# To modify the current version use the following command:
# make version-set VERSION=<version>
#
# DO NOT EDIT. Automatically generated file!
##############################################################################
1.4.0.4

View File

@ -1,114 +0,0 @@
BUILDING NEW SCALA WITH ANT
---------------------------
This is version 1.0 of the Scala Ant-based build system SABBUS.
QUICK START
-----------
- Copy the 'build.TEMPLATE.properties' file in 'build.support' to
'build.USER_NAME.properties'. Set all properties in this file.
- In a terminal window, type:
ANT_OPTS="-Xmx256M" ant distrib
USAGE GUIDE
-----------
PREREQUISITES
The new Scala Ant-based build system (SABBUS) requires the following elements:
- An old Scala distribution. The Scala tools ('tools.jar' must be of a version
that does contain the improved Scalac Ant task at
'scala.tools.scalac.ant.Scalac'. The scala library ('scala.jar') must contain
all classes required to build NSC.
- A PiCo/JaCo distribution. It must contain the improved PiCo task at
'jaco.pizza.ant.Pico'.
- Ant version 1.6 or above.
- Java version 1.4 or above (Java 1.5 might not be supported).
SETTING UP
The set-up of SABBUS is done entirely in the 'build.properties' file. Make sure
that all values in this file are set and correct.
Another configuration file exists ('build.support/build.default'). This file
should not be modified as any property declared in 'build.properties' will
override the value set in 'build.default'.
With a normal Java distribution, the standard memory allocated to the JVM in
insufficient for Scala compilation. The ANT_OPTS environment variable needs to
be set to increase the memory size (either each time as in the quick start
example above, or once and for all in the default shell environment).
Skipping parts of the build
In some cases, parts of the build process should be disabled for debug reasons:
- skip.doc will not build the LaTeX documentation.
- skip.nsc will not build anything with NSC. This will create a non-working
distribution.
BUILDING NEW SCALA
The 'build' target builds all the Scala library and tools. It is composed of the
following sub-targets:
- 'build.pico.nslib':
Builds the Java files in Scala (runtime, tools and scala root) with PiCo.
When both a Java file in sources and a Scala file in newsources exist, the
Java file is not compiled (it is considered to have been superseeded by the
Scala file).
- 'build.osc.nstools':
Builds NSC with an existing Scalac (found in path of property
'ostools.jar').
- 'build.nsc.nslib':
Builds the new Scala library with the compiler built at target
'build.osc.nstools'. Depends on 'build.osc.nstools' & 'build.pico.nslib'.
If files should not be compiled at that stage, they can be specified in the
'build.support/nsc.nslib.excludes'
- 'build.nsc.nstools':
Builds NSC with the compiler built at target 'build.osc.nstools'. Depends
on 'build.osc.nstools' & 'build.pico.nslib'. If files should not be
compiled at that stage, they can be specified in the
'build.support/nsc.nstools.excludes'
CONSTRUCTING A DISTRIBUTION
The 'distrib' target constructs a simple distribution of new Scala from the
latest build. The following steps will be done:
- Creates a standard distribution folder hierarchy.
- Create JAR packages for the library ('nslib.jar'), and the tools, both
compiled with Scalac ('osc-nstools.jar') and with NSC ('nstools.jar').
- Create script files (bash and bat) to execute the new Scala compiler.
- Adds man files and the documentation to the distribution.
- Generates some symbolic links to simplify navigation (only on UNIX). Amongst
other, a 'latest' link in the 'dist' folder will point to the latest
distribution folder (useful to refer in a permanent way to the latest
distribution on your system).
CLEANING
The 'clean' target removes all build and distribution files.
- 'clean.build' only removes build files and does not touch distribution files.
- 'clean.distrib' only removes distribution files.
DOCUMENTING
Not implemented yet
TESTING
Not implemented yet
KNOWN BUGS, LIMITATIONS AND PLANNED IMPROVEMENTS
------------------------------------------------
- Create NSC executable scripts for UNIX and Windows.
- Create Windows build system.
- Create documentation.
- Support testing.
HISTORY
-------
1.0
First functioning version. Supports clean, build and a limited distrib.

1208
build.xml

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +0,0 @@
##############################################################################
# USER PROPERTIES FOR SABBUS #
##############################################################################
# These are user-specific properties for SABBUS. Any property that has not
# been set here will take the value defined in 'build.default.properties'
# or 'build.base.properties'. Properties in the latter of these files can
# be refered to from within this file.
# $Id$
##############################################################################
# The path to the old Scala library JAR package and source directory.
oslib.jar=
oslib.src=
# The path to the old Scala tools.
ostools.jar=
# The path to the Jaco/Pico compiler.
jaco.jar=
# The path to the FJBG byte-code generation library.
fjbg.jar=
# The path to the MSIL byte-code generation library.
msil.jar=
# The path to the MSIL DLL library.
scala.dll=
# The path to the IzPack tool.
izpack.jar=
# Other custom properties come here
nsc.skip=

View File

@ -1,16 +0,0 @@
##############################################################################
# BASE PROPERTIES FOR SABBUS #
##############################################################################
# These are properties specific to the layout of the Scala distribution.
# DO NOT CHANGE them unless one of the mentioned directory is changed.
# $Id$
##############################################################################
bin.dir=${basedir}/bin
build.support.dir=${basedir}/build.support
config.dir=${basedir}/config
doc.dir=${basedir}/doc
newsources.dir=${basedir}/newsources
sources.dir=${basedir}/sources
support.dir=${basedir}/support
test.dir=${basedir}/test

View File

@ -1,133 +0,0 @@
##############################################################################
# DEFAULT PROPERTIES FOR SABBUS #
##############################################################################
# These are default values for all properties used by SABBUS. DO NOT CHANGE
# them in this file. All properties can be overriden in the
# build.USER_NAME.properties file.
# $Id$
##############################################################################
# CONFIGURATION OF NSC
##############################################################################
copyright.notice=(C) 2002-06 LAMP/EPFL
# What NSC should output during compilation. Either 'none', 'verbose', 'debug'.
nsc.logging=none
# After which compile phase NSC should stop. This will induce build errors.
nsc.stop=
# A comma-separated list of compile phases that NSC should skip.
nsc.skip=
# A comma-separated list of compile phases that NSC should log.
nsc.log=
# A comma-separated list of compile phases which result should be checked for
# consistency.
nsc.check=
# A comma-separated list of compile phases that NSC should print.
nsc.print=
# The name of a file that lists files that should be excluded when building
# the new Scala library. This file MUST EXIST.
nsc.nslib.excludes=${config.dir}/excludes/nsc.nslib.excludes
# The name of a file that lists files that should be excluded when building
# the new Scala tools. This file MUST EXIST.
nsc.nstools.excludes=${config.dir}/excludes/nsc.nstools.excludes
# The name of a file that lists files that should be excluded when building
# the new Scala tools. This file MUST EXIST.
nsc.osc-nstools.excludes=${config.dir}/excludes/nsc.osc-nstools.excludes
# Boolean flag that controls whether the NSC compiler will generate
# debug information in class files
nsc.debuginfo=true
# LOCATION OF PRE-COMPILED LIBRARIES
##############################################################################
# The path to the old Scala library ('scala.jar').
oslib.jar=/usr/local/lib/scala.jar
# The path to the old Scala library sources.
oslib.src=/usr/local/share/scala/src
# The path to the old Scala tools ('tools.jar').
ostools.jar=/usr/local/lib/tools.jar
# The path to the JaCo compiler ('jaco.jar').
jaco.jar=/usr/local/lib/jaco.jar
# The path to the FJBG byte-code generation library ('fjbg.jar').
fjbg.jar=/usr/local/lib/fjbg.jar
# The path to the MSIL byte-code generation library ('fjbg.jar').
msil.jar=/usr/local/lib/msil.jar
# The path to the MSIL DLL library ('scala.dll').
scala.dll=/usr/local/lib/scala.dll
# The path to the Java base classes ('rt.jar' or 'classes.jar').
java.jar=${java.home}/jre/lib/rt.jar
# The path to the Ant base classes ('ant.jar').
ant.jar=${ant.home}/lib/ant.jar
# The path to the IzPack tools ('standalone-compiler.jar').
izpack.home=/usr/local/
# LOCATION OF BUILD PRODUCTS
##############################################################################
# The directory in which all build products live.
build.dir=${basedir}/build
# The directory to which the new Scala library is compiled.
build.nslib.dir=${build.dir}/nslib
# The directory to which the part of the new Scala library built with PiCo
# is compiled. This should be different from ${build.nslib.dir}.
build.pico-nslib.dir=${build.dir}/pico-nslib
# The directory to which the new Scala tools (built with OSC) are compiled.
build.osc-nstools.dir=${build.dir}/osc-nstools
# The directory to which the new Scala tools are compiled.
build.nstools.dir=${build.dir}/nstools
# LOCATION AND STRUCTURE OF THE DISTRIBUTION
# Overriding these properties will produce a non-standard distribution that
# might not be useable.
##############################################################################
# The directory to which a new distribution will be added, both for UNIX and
# Windows. These directories MUST BE SEPARATE!
distrib.unix.dir=${basedir}/distribs/unix
distrib.win.dir=${basedir}/distribs/windows
# The name of the product to build.
distrib.name=nscala
# The name of the JAR file in which the new Scala library should be archived.
nslib.jar.name=nslib.jar
# The name of the JAR file in which the new Scala tools should be archived.
nstools.jar.name=nstools.jar
# The name of the JAR file in which the new Scala tools (built with OSC)
# should be archived.
osc-nstools.jar.name=osc-nstools.jar
# The name of the Scala executables
scala.exec.name=ns
scalac.exec.name=nsc
scalai.exec.name=nsi
scalap.exec.name=nsp
scalatok.exec.name=nsctok
##############################################################################

View File

@ -1,10 +0,0 @@
################################################################################
# NSLIB EXCLUDED FILES #
################################################################################
# A list of files to exclude when compiling the Scala library with NSC. All
# files can be defined using Ant's fileset wildcard notation; one statement per
# line.
# $Id$
################################################################################
scala/dbc/**

View File

@ -1,7 +0,0 @@
################################################################################
# NSTOOLS EXCLUDED FILES #
################################################################################
# A list of files to exclude when compiling the Scala tools with NSC. All files
# can be defined using Ant's fileset wildcard notation; one statement per line.
# $Id$
################################################################################

View File

@ -1,7 +0,0 @@
################################################################################
# OSC-NSTOOLS EXCLUDED FILES #
################################################################################
# A list of files to exclude when compiling the Scala tools with NSC. All files
# can be defined using Ant's fileset wildcard notation; one statement per line.
# $Id$
################################################################################

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

View File

@ -1,111 +0,0 @@
<?xml version=1.0" encoding="UTF-8" standalone="yes"?>
<!-- $Id$ -->
<installation version="1.0">
<info>
<appname>Scala</appname>
<appversion>@VERSION@</appversion>
<url>@URL@</url>
<javaversion>1.4</javaversion>
</info>
<native type="izpack" name="ShellLink.dll"/>
<guiprefs resizable="yes" height="400" width="600">
<laf name="metouia">
<os family="unix"/>
</laf>
<laf name="looks">
<os family="windows"/>
<param name="variant" value="extwin"/>
</laf>
</guiprefs>
<locale>
<langpack iso3="eng"/>
<langpack iso3="fra"/>
<langpack iso3="deu"/>
</locale>
<resources>
<res id="installer.langsel.img" src="@RESOURCEDIR@/images/Splash.png"/>
<res id="Installer.image" src="@RESOURCEDIR@/images/install.png"/>
<res id="HTMLInfoPanel.info_eng" src="@RESOURCEDIR@/locales/INFO_en.html"/>
<res id="HTMLInfoPanel.info_fra" src="@RESOURCEDIR@/locales/INFO_fr.html"/>
<res id="HTMLInfoPanel.info_deu" src="@RESOURCEDIR@/locales/INFO_de.html"/>
<res id="HTMLLicencePanel.licence_eng" src="@RESOURCEDIR@/locales/LICENSE_en.html"/>
<res id="HTMLLicencePanel.licence_fra" src="@RESOURCEDIR@/locales/LICENSE_fr.html"/>
<res id="HTMLLicencePanel.licence_deu" src="@RESOURCEDIR@/locales/LICENSE_de.html"/>
<res id="TargetPanel.dir.macosx" src="@RESOURCEDIR@/targets/path_macosx.txt"/>
<res id="TargetPanel.dir.unix" src="@RESOURCEDIR@/targets/path_unix.txt"/>
<res id="ProcessPanel.Spec.xml" src="@RESOURCEDIR@/izpack_process.xml"/>
<res id="shortcutSpec.xml" src="@RESOURCEDIR@/izpack_shortcut.xml"/>
</resources>
<panels>
<panel classname="HelloPanel"/>
<panel classname="HTMLInfoPanel"/>
<panel classname="HTMLLicencePanel"/>
<panel classname="TargetPanel"/>
<panel classname="InstallPanel"/>
<panel classname="ProcessPanel"/>
<panel classname="ShortcutPanel"/>
<panel classname="SimpleFinishPanel"/>
</panels>
<packs>
<pack name="Package Installation" required="yes">
<description>Installing the Scala software.</description>
<!-- unix -->
<fileset os="unix"
dir="distribs/unix/@PREFIX@-@VERSION@"
targetdir="$INSTALL_PATH"
includes="share/**"/>
<!-- The <singlefile> tag allows the file -->
<!-- to be renamed (unlike <file>). -->
<singlefile os="unix"
target="$INSTALL_PATH/bin/.nsc_symlink"
src="sources/bin/izpack.symlink.tmpl"/>
<executable os="unix"
targetfile="$INSTALL_PATH/bin/.nsc_symlink"/>
<singlefile os="unix"
target="$INSTALL_PATH/share/@PREFIX@/bin/.nsc_symlink"
src="sources/bin/izpack.symlink.tmpl"/>
<executable os="unix"
targetfile="$INSTALL_PATH/share/@PREFIX@/bin/.nsc_symlink"/>
<executable os="unix" keep="true"
targetfile="$INSTALL_PATH/share/@PREFIX@/bin/.scala_wrapper"/>
<!-- windows -->
<!-- we share common resources doc/*.pdf and lib/** -->
<fileset os="windows"
dir="distribs/windows/@PREFIX@-@VERSION@"
targetdir="$INSTALL_PATH"
excludes="doc/*.pdf, lib/**"/>
<fileset os="windows"
dir="distribs/unix/@PREFIX@-@VERSION@/share/doc/@PREFIX@"
targetdir="$INSTALL_PATH/doc"
includes="*.pdf"/>
<fileset os="windows"
dir="distribs/unix/@PREFIX@-@VERSION@/share/@PREFIX@"
targetdir="$INSTALL_PATH"
includes="lib/**"/>
<fileset os="windows"
dir="config/izpack/registry/bin"
targetdir="$INSTALL_PATH/Uninstaller"/>
<executable os="windows" stage="uninstall"
targetfile="$JAVA_HOME\bin\java">
<arg>-Djava.library.path=$INSTALL_PATH\Uninstaller</arg>
<arg>-cp</arg>
<arg>$INSTALL_PATH\Uninstaller\registry.jar;$INSTALL_PATH\Uninstaller\setenv.jar</arg>
<arg>Main</arg>
<arg>@VERSION@</arg>
</executable>
</pack>
</packs>
</installation>

View File

@ -1,44 +0,0 @@
<!-- $Id$ -->
<processing>
<logfiledir>$INSTALL_PATH/Uninstaller</logfiledir>
<!-- unix jobs -->
<job name="Create symbolic links for Scala commands">
<description>Create symbolic links</description>
<os family="unix"/>
<executefile name="$INSTALL_PATH/bin/.nsc_symlink">
<arg>../share/@PREFIX@/bin/.scala_wrapper</arg>
</executefile>
<executefile name="$INSTALL_PATH/share/@PREFIX@/bin/.nsc_symlink">
<arg>.scala_wrapper</arg>
</executefile>
</job>
<job name="Remote helper script">
<description>Clean up</description>
<os family="unix"/>
<executefile name="/bin/rm">
<arg>-f</arg>
<arg>$INSTALL_PATH/bin/.nsc_symlink</arg>
<arg>$INSTALL_PATH/share/@PREFIX@/bin/.nsc_symlink</arg>
</executefile>
</job>
<!-- windows jobs -->
<job name="Update the Windows registry">
<description>Add the SCALA_HOME variable to the user environment</description>
<os family="windows"/>
<executefile name="$JAVA_HOME\bin\java">
<arg>-Djava.library.path=$INSTALL_PATH\Uninstaller</arg>
<arg>-cp</arg>
<arg>$INSTALL_PATH\Uninstaller\registry.jar;$INSTALL_PATH\Uninstaller\setenv.jar</arg>
<arg>Main</arg>
<arg>@VERSION@</arg>
<arg>$INSTALL_PATH</arg>
</executefile>
</job>
</processing>

View File

@ -1,96 +0,0 @@
<?xml version=1.0" encoding="UTF-8" standalone="yes" ?>
<installation version="1.0">
<info>
<appname>Scala</appname>
<appversion>1.4.0.1</appversion>
<!--
<authors>
<author name="Martin Odersky" email="martin.odersky@epfl.ch" />
<author name="Vincent Cremet" email="vincent.cremet@epfl.ch" />
<author name="Iulian Dragos" email="Iulian.Dragos@epfl.ch" />
<author name="Gilles Dubochet" email="gilles.dubochet@epfl.ch" />
<author name="Burak Emir" email="burak.emir@epfl.ch" />
<author name="Stephane Micheloud" email="stephane.micheloud@epfl.ch" />
<author name="Nikolay Mihaylov" email="nikolay.mihaylov@epfl.ch" />
<author name="Philippe Altherr (past member)" email="philippe.alther@epfl.ch" />
<author name="Michel Schinz (past member)" email="michel.schinz@epfl.ch" />
<author name="Erik Stenmann (past member)" email="happi@home.se" />
<author name="Matthias Zenger (past member)" email="matthias.zenger@google.com" />
</authors>
-->
<url>http://scala.epfl.ch/</url>
<javaversion>1.4</javaversion>
</info>
<variables>
<variable name="JDKPathPanel.minVersion" value="1.4.0" />
<variable name="JDKPathPanel.maxVersion" value="1.5.0" />
<variable name="JDKPathPanel.skipIfValid" value="yes" />
</variables>
<native type="izpack" name="ShellLink.dll" />
<guiprefs resizable="yes" height="480" width="640">
<laf name="metouia">
<os family="unix" />
</laf>
<laf name="looks">
<os family="windows" />
<param name="variant" value="extwin" />
</laf>
</guiprefs>
<locale>
<langpack iso3="eng" />
<langpack iso3="fra" />
<langpack iso3="deu" />
</locale>
<resources>
<res id="installer.langsel.img" src="images/Splash.png" />
<res id="Installer.image" src="images/install.png" />
<res id="HTMLInfoPanel.info_eng" src="locales/INFO_en.html" />
<res id="HTMLInfoPanel.info_fra" src="locales/INFO_fr.html" />
<res id="HTMLInfoPanel.info_deu" src="locales/INFO_de.html" />
<res id="HTMLLicencePanel.licence_eng" src="locales/LICENSE_en.html" />
<res id="HTMLLicencePanel.licence_fra" src="locales/LICENSE_fr.html" />
<res id="HTMLLicencePanel.licence_deu" src="locales/LICENSE_de.html" />
<res id="TargetPanel.dir.macosx" src="targets/path_macosx.txt" />
<res id="TargetPanel.dir.unix" src="targets/path_unix.txt" />
<res id="ProcessPanel.Spec.xml" src="izpack_process.xml" />
<res id="shortcutSpec.xml" src="izpack_shortcut.xml" />
</resources>
<panels>
<panel classname="HelloPanel" />
<panel classname="HTMLInfoPanel" />
<panel classname="HTMLLicencePanel" />
<panel classname="JDKPathPanel" />
<!--
<panel classname="PacksPanel" />
-->
<panel classname="TargetPanel" />
<panel classname="InstallPanel" />
<panel os="unix" classname="ProcessPanel" />
<panel classname="ShortcutPanel" />
<panel classname="SimpleFinishPanel" />
</panels>
<packs>
<pack name="Installing..." required="yes">
<description>Installing the Scala software.</description>
<fileset os="unix" dir="unix" targetdir="$INSTALL_PATH" />
<fileset os="unix" dir="lib" targetdir="$INSTALL_PATH/share/scala-$APP_VER/lib" />
<fileset os="unix" dir="pdf" targetdir="$INSTALL_PATH/share/doc/scala-$APP_VER" />
<fileset os="windows" dir="windows" targetdir="$INSTALL_PATH" />
<fileset os="windows" dir="lib" targetdir="$INSTALL_PATH/lib" />
<fileset os="windows" dir="pdf" targetdir="$INSTALL_PATH/doc" />
<singlefile os="unix" target="$INSTALL_PATH/bin/.create_wrappers" src="create_wrappers.sh" />
<executable os="unix" targetfile="$INSTALL_PATH/bin/.create_wrappers" />
<executable os="unix" targetfile="$INSTALL_PATH/bin/.scala_wrapper" keep="true" />
</pack>
</packs>
</installation>

View File

@ -1,42 +0,0 @@
<?xml version=1.0" encoding="UTF-8" standalone="yes" ?>
<shortcuts>
<programGroup defaultName="Scala 1.4.0.1" location="applications" />
<skipIfNotSupported />
<shortcut
os="windows"
name="Scala Interpreter"
target="$INSTALL_PATH\bin\scalaint.bat"
workingDirectory="$SYSTEM_user_home"
commandLine=""
terminal="true"
programGroup="yes" />
<shortcut
os="windows"
name="Scala API Documentation"
target="$INSTALL_PATH\doc\api\index.html"
commandLine=""
programGroup="yes" />
<shortcut
os="windows"
name="ScalaByExample.pdf"
target="$INSTALL_PATH\doc\ScalaByExample.pdf"
programGroup="yes" />
<shortcut
os="windows"
name="ScalaReference.pdf"
target="$INSTALL_PATH\doc\ScalaReference.pdf"
programGroup="yes" />
<shortcut
os="windows"
name="ScalaTutorial.pdf"
target="$INSTALL_PATH\doc\ScalaTutorial.pdf"
programGroup="yes" />
</shortcuts>

View File

@ -1,23 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
p { font-family:Helvetica,Arial,Sans-Serif; font-size:small; }
-->
</style>
</head>
<body>
<p>
<a href="http://www.izforge.com/">IzPack</a> f&uuml;hrt Sie durch
die Installation von Scala @VERSION@.
</p>
<p>
Scala erfordert Sun <a href="http://java.sun.com/j2se/">JDK/JRE</a>
version 1.4 oder neuer.
</p>
<p>
Sie k&ouml;nnen die Installation jederzeit abbrechen, indem
Sie auf 'Beenden' klicken.
</p>
</body>
</html>

View File

@ -1,23 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
p { font-family:Helvetica,Arial,Sans-Serif; font-size:small; }
-->
</style>
</head>
<body>
<p>
<a href="http://www.izforge.com/">IzPack</a> will guide you through
the installation of Scala @VERSION@.
</p>
<p>
Scala requires Sun <a href="http://java.sun.com/j2se/">JDK/JRE</a>
version 1.4 or newer.
</p>
<p>
You may cancel this installation at any time by clicking the
'Quit' button.
</p>
</body>
</html>

View File

@ -1,23 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
p { font-family:Helvetica,Arial,Sans-Serif; font-size:small; }
-->
</style>
</head>
<body>
<p>
<a href="http://www.izforge.com/">IzPack</a> will guide you through
the installation of Scala @VERSION@.
</p>
<p>
Scala requiert Sun <a href="http://java.sun.com/j2se/">JDK/JRE</a>
version 1.4 ou plus r&eacute;cent.
</p>
<p>
Vous pouvez abandonner l'installation &agrave; tout moment
en cliquant sur 'Quitter'.
</p>
</body>
</html>

View File

@ -1,76 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
body { font-family:Helvetica,Arial,Sans-Serif; }
div.title { font-weight:bold; }
p { font-size:small; }
li { font-size:small; margin:0px 0px 6px 0px; }
-->
</style>
</head>
<body>
<div class="title">
SCALA LIZENZ
</div>
<p>
Copyright &copy; 2002-05 <a href="http://www.epfl.ch/">EPFL</a>, Lausanne.
Alle Rechte vorbehalten.
</p>
<p>
Diese Software wurde von der Gruppe Methoden der Programmierung an
der Eidgen&ouml;ssiche Technische Hochschule von Lausanne, Schweiz,
entwickelt.
</p>
<p>
Die Genehmigung zum Verwenden, Kopieren, &Auml;ndern and Weitervertreiben
dieser Software im Quell- und Bin&auml;rformat zu einem beliebigen Zweck
wird hiermit ohne Geb&uuml;hr erteilt, sofern folgende Konditionen
erf&uuml;llt sind:
</p>
<ol>
<li>
Bei Weitervertrieb des Quellcodes m&uuml;ssen vorstehender
Urheberrechtshinweis, diese Liste der Konditionen und die folgende
Verzichtserkl&auml;rung beibehalten werden.
</li>
<li>
Bei Weitervertrieb im Bin&auml;rformat müssen in der Dokumentation
und/oder anderen Materialien, die vertrieben werden, vorstehender
Urheberrechtshinweis, diese Liste der Konditionen und die folgende
Verzichtserkl&auml;rung reproduziert werden.
</li>
<li>
Neither the name of the EPFL nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
</li>
</ol>
<p>
DIESE SOFTWARE WIRD VON DEN AUTOREN WIE BESEHEN UND UNTER AUSSCHLUSS ALLER
AUSDR&Uuml;CKLICHEN ODER KONKLUDENTEN GARANTIEN ZUR VERFÜGUNG GESTELLT,
EINSCHLIESSLICH, ABER NICHT BESCHR&Auml;NKT AUF KONKLUDENTE GARANTIEN DER
HANDELS&Uuml;BLICHKEIT UND/ODER EIGNUNG F&Uuml;R EINEN BESTIMMTEN ZWECK.
UNTER KEINEN UMST&Auml;NDEN KÖNNEN DIE AUTOREN F&Uuml;R DIREKTE, INDIREKTE,
ZUF&Auml;LLIGE, BESONDERE, EXEMPLARISCHE ODER FOLGESCH&Auml;DEN (EINSCHLIESSLICH
VON, ABER NICHT BESCHR&Auml;NKT AUF, BESCHAFFUNG VON ERSATZWAREN ODER
ERSATZLEISTUNGEN, ENTGANGENEM NUTZEN, VERLUST VON DATEN, ENTGANGENEM GEWINN
ODER GESCH&Auml;FTSAUSFALL) HAFTBAR GEMACHT WERDEN, DIE AUS EINER BELIEBIGEN
URSACHE UND AUF GRUNDLAGE IRGENDEINES HAFTBARKEITSVERST&Auml;NDNISSES ENTSTEHEN,
UNABH&Auml;NGIG VON VERTR&Auml;GEN, DER GEFÄHRDUNGSHAFTUNG ODER UNERLAUBTEN
HANDLUNGEN (EINSCHLIESSLICH FAHRL&Auml;SSIGKEIT ODER ANDERWEITIG), DIE IN
IRGENDEINER WEISE DURCH DIE VERWENDUNG DIESER SOFTWARE ENTSTEHEN, AUCH DANN,
WENN DIE AUTOREN &Uuml;BER DIE M&Ouml;GLICHKEIT SOLCHER SCH&Auml;DEN UNTERRICHTET WURDEN.
</p>
</body>
</html>

View File

@ -1,68 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
body { font-family:Helvetica,Arial,Sans-Serif; }
div.title { font-weight:bold; }
p { font-size:small; }
li { font-size:small; margin:0px 0px 6px 0px; }
-->
</style>
</head>
<body>
<div class="title">
SCALA LICENSE
</div>
<p>
Copyright &copy; 2002-05 <a href="http://www.epfl.ch/">EPFL</a>, Lausanne.
All rights reserved.
</p>
<p>
This software was developed by the Programming Methods Laboratory of
the Swiss Federal Institute of Technology, Lausanne, Switzerland.
</p>
<p>
Permission to use, copy, modify, and distribute this software in source
or binary form for any purpose with or without fee is hereby granted,
provided that the following conditions are met:
</p>
<ol>
<li>
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
</li>
<li>
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
</li>
<li>
Neither the name of the EPFL nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
</li>
</ol>
<p>
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
</p>
</body>
</html>

View File

@ -1,82 +0,0 @@
<html>
<head>
<style type="text/css">
<!--
body { font-family:Helvetica,Arial,Sans-Serif; }
div.title { font-weight:bold; }
p { font-size:small; }
li { font-size:small; margin:0px 0px 6px 0px; }
-->
</style>
</head>
<body>
<div class="title">
LICENCE SCALA
</div>
<p>
Copyright &copy; 2002-05 <a href="http://www.epfl.ch/">EPFL</a>, Lausanne.
Tous droits r&eacute;serv&eacute;s.
</p>
<p>
Ce logiciel a &eacute;t&eacute; d&eacute;velopp&eacute; par le Laboratoire
des M&eacute;thodes de Programmation de l'Ecole Polytechnique
F&eacute;d&eacute;rale de Lausanne (EPFL), Suisse.
</p>
<p>
L'utilisation, la modification et la redistribution de ce logiciel sous forme
de code source et/ou binaire, dans un but commercial ou non, sont permis
&eacute;tant entendu que les conditions suivantes sont satisfaites:
</p>
<ol>
<li>
Toute redistribution du code source doit contenir la notice de droits
d'auteur ci-dessus, la pr&eacute;sente liste des conditions
d'utilisation et l'avis de non-responsabilit&eacute; mentionn&eacute;
plus bas.
</li>
<li>
Toute redistribution du code binaire doit contenir la notice de droits
d'auteur ci-dessus, la pr&eacute;sente liste des conditions d'utilisation
et l'avis de non-responsabilit&eacute; mentionn&eacute; plus bas dans
la documentation et/ou tout autre support fourni dans la distribution.
</li>
<li>
Ni le nom de l'EPFL, ni celui des personnes qui ont
contribu&eacute; au d&eacute;veloppement de ce logiciel ne peuvent
&ecirc;tre utilis&eacute;s dans le but de promouvoir des produits
d&eacute;riv&eacute;s de ce logiciel sans permission &eacute;crite
pr&eacute;alable.
</li>
</ol>
<p>
CE LOGICIEL EST FOURNI "EN L'&Eacute;TAT" SANS GARANTIE AUCUNE QUANT
&Agrave; SON UTILISATION, Y COMPRIS, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. EN AUCUN CAS L'UNIVERSIT&Eacute; OU QUICONQUE AYANT
CONTRIBU&Eacute; AU D&Eacute;VELOPPEMENT DU LOGICIEL NE SAURAIT &Ecirc;TRE
TENU RESPONSABLE DE TOUS DOMMAGES DIRECTS OU INDIRECTS, CONS&Eacute;CUTIFS
&Agrave; L'UTILISATION DU LOGICIEL ET, NOTAMMENT DE TOUTES PERTES DE PROFITS
OU MANQUES &Agrave; GAGNER, PERTE D'INFORMATION, D&Eacute;FAILLANCE
D'ORDINATEUR, INTERRUPTION DE TRAVAIL OU AUTRES D&Eacute;G&Acirc;TS, ET
CELA QUAND BIEN M&Ecirc;ME UN REPR&Eacute;SENTANT DE L'UNIVERSIT&Eacute;
AURAIT &Eacute;T&Eacute; INFORM&Eacute; DE LA POSSIBILIT&Eacute; DE TELS
DOMMAGES.
</p>
<p>
Seule la version anglaise de ce contrat fait foi juridiquement.
Les traductions en d'autres langues sont fournies aux usagers &agrave;
titre indicatif, mais elles ne sont pas n&eacute;cessairement exactes
d'un point de vue juridique.
</p>
</body>
</html>

View File

@ -1,50 +0,0 @@
Windows Registry API Native Interface
*Release 3.1.3, September 11, 2003*
The com.ice.jni.registry package is a Java native interface for the
Windows Registry API. This allows Java program to access, modify, and
export Windows Registry resources.
The com.ice.jni.registry package has been placed into the public domain.
Thus, you have absolutely no licensing issues to consider. You may do
anything you wish with the code. Of course, I always appreciate it when
you properly credit my work.
The package will work only with Java 1.1 and greater, and uses the
Javasoft native interface, not the Netscape interface. The package also
includes a DLL that implements the interface. The package has been used
with JDK1.2, and JDK1.3, JDK1.4, as well as JDK1.1.8.
The package includes the pre-built DLL (debug and release), source code
(both the Java and the DLL's C code), as well as the compiled Java classes.
The original release was posted on November 17, 1997. The current
release is 3.1.3, which was posted on September 11, 2003.
Email me if you have questions. <mailto:time@gjt.org>
View The Source Code
You can now directly view the JNIRegistry source code
<http://www.gjt.org/servlets/JCVSlet/list/ice/com/ice/jni/registry/> and
source code documentation
<http://www.gjt.org/javadoc/com/ice/jni/registry/package-summary.html>
online via the Giant Java Tree. <http://www.gjt.org>
Downloads
Download the WinZip-ed package. (FTP)
<ftp://ftp.gjt.org/pub/users/time/java/registry-3.1.3.zip>
Download the WinZip-ed package. (HTTP)
<http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip>
------------------------------------------------------------------------
* All contents are copyrighted (c) by ICE Engineering, Inc. *
http://www.trustice.com/ --- http://www.icetoo.com/

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Created-By: 1.4.2_09 (Sun Microsystems Inc.)
Main-Class: Main

View File

@ -1,120 +0,0 @@
// File : Main.java
// Project : Scala
// Author(s) : Stephane Micheloud (mics)
// Environment: JNI Registry 3.1.3, Sun JDK 1.4.2_09
// Version : 01
// Created : 25.09.2005/mics
// Modified : -
import com.ice.jni.registry.NoSuchKeyException;
import com.ice.jni.registry.NoSuchValueException;
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryException;
import com.ice.jni.registry.RegistryKey;
import com.ice.jni.registry.RegistryValue;
import com.ice.jni.registry.RegMultiStringValue;
import com.ice.jni.registry.RegStringValue;
public class Main {
private static final String PATH = "PATH";
private static final String SCALA_HOME = "SCALA_HOME";
private static final String SCALA_BIN = "%" + SCALA_HOME + "%\\bin";
private static void updateRegistry(String homePath, String fullName) throws RegistryException {
// HKEY_CURRENT_USER\Environment
RegistryKey envKey = Registry.openSubkey(
Registry.HKEY_CURRENT_USER,
"Environment",
RegistryKey.ACCESS_ALL);
if (homePath != null) {
// set home directory
RegStringValue data = new RegStringValue(envKey, SCALA_HOME, homePath);
envKey.setValue(data);
// update user path
String path = envKey.getStringValue(PATH);
if (path.indexOf(SCALA_BIN) < 0) {
int inx = path.lastIndexOf(";");
StringBuffer buf = new StringBuffer(path);
if (0 < inx && inx < path.length()-1)
buf.append(";");
buf.append(SCALA_BIN);
data = new RegStringValue(envKey, PATH, buf.toString());
envKey.setValue(data);
}
}
else { // uninstall
// remove home directory
try {
envKey.deleteValue(SCALA_HOME);
}
catch (NoSuchValueException e) {
// do nothing
}
String path = envKey.getStringValue(PATH);
int inx1 = path.indexOf(SCALA_BIN);
if (inx1 >= 0) {
int inx2 = path.indexOf(";", inx1);
StringBuffer buf = new StringBuffer(path.substring(0, inx1));
if (inx2 >= 0)
buf.append(path.substring(inx2));
RegStringValue data = new RegStringValue(envKey, PATH, buf.toString());
envKey.setValue(data);
}
}
// HKEY_CURRENT_USER\Software
RegistryKey softwareKey = Registry.openSubkey(
Registry.HKEY_CURRENT_USER,
"Software",
RegistryKey.ACCESS_WRITE);
if (homePath != null) {
RegistryKey productKey = softwareKey.createSubKey(
fullName,
"java.lang.String",
RegistryKey.ACCESS_WRITE);
RegStringValue data = new RegStringValue(productKey, "Location", homePath);
productKey.setValue(data);
}
else { // uninstall
try {
softwareKey.deleteSubKey(fullName);
String name = fullName;
int inx = name.lastIndexOf("\\");
while (inx != -1) {
String parentName = name.substring(0, inx);
RegistryKey key = softwareKey.openSubKey(parentName, RegistryKey.ACCESS_READ);
int n = key.getNumberSubkeys();
if (n == 0) softwareKey.deleteSubKey(parentName);
name = parentName;
inx = name.lastIndexOf("\\");
}
}
catch (NoSuchKeyException e) {
// do nothing
}
}
}
public static void main(String[] args) {
int argc = args.length;
if (argc != 1 && argc != 2) {
System.out.println("Usage: java Main <version> [ <installpath> ]\n");
System.out.println("\tversion number (e.g. 1.4.0.1)");
System.out.println("\tinstall path (e.g. c:\\\\Program Files\\\\Scala)");
System.out.println();
System.exit((argc > 0) ? 1 : 0);
}
String homePath = (argc == 2) ? args[1] : null; // e.g. "C:\\Program Files\\Scala"
String fullName = "EPFL\\Scala\\" + args[0]; // e.g. "EPFL\\Scala\\1.4.0.1"
try {
updateRegistry(homePath, fullName);
}
catch (RegistryException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
}

View File

@ -1 +0,0 @@
/usr/local/

View File

@ -1 +0,0 @@
/usr/local/

View File

@ -1,32 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** $Id$
\* */
package scala;
/** defines an access function for instances of case classes
*
* @author Burak Emir
*/
trait CaseClass extends AnyRef {
/** for a case class A(x_0,...,x_(k-1)), returns x_i for 0 &lt;= i &lt; k,
** null otherwise
*/
def caseElement(n: Int): Any ;
/** need also, for reflection
def setCaseElement(n: Int, v: Any): unit
*/
/** for a case class A(x_0,...,x_(k-1)), returns k
*/
def caseArity: Int;
def caseName: String;
}

View File

@ -1,11 +0,0 @@
#!/bin/sh
DIRNAME="dirname"
LN="/bin/ln -sf"
COMMANDS="scala scalac scaladoc scalap"
cd `$DIRNAME $0` && \
for cmd in $COMMANDS; do $LN $1 $cmd; done
# $Id$

View File

@ -1,21 +0,0 @@
--- scala_part2.il 2005-09-21 16:19:30.676754000 +0200
+++ scala_part2.il.new 2005-09-21 16:21:58.522947000 +0200
@@ -1,18 +1,3 @@
-.assembly extern 'mscorlib'
-{
- .ver 1:0:3300:0
- .publickeytoken = (b7 7a 5c 56 19 34 e0 89)
-}
-.assembly extern 'scala_part1'
-{
- .ver SCALA_VERSION
- .publickeytoken = (80 07 fc 78 8a 2e 53 08)
-}
-.assembly 'scala_part2'
-{
-}
-.module 'scala_part2.dll'
-
.namespace 'scala'
{
.class public auto ansi interface 'Tuple1'

View File

@ -1,35 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
using System;
using scala.runtime;
namespace scala
{
[Meta("class [?T] extends scala.AnyRef;")]
[Serializable]
public abstract class Array /*: Cloneable*/
{
[Meta("constr (scala.Int);")]
public Array() {}
[Meta("method []scala.Array[?T];")]
public abstract object value();
[Meta("method []scala.Int;")]
public abstract int length();
[Meta("method (scala.Int)?T;")]
public abstract object apply(int i);
[Meta("method (scala.Int,?T)scala.Unit;")]
public abstract void update(int i, object x);
}
}

View File

@ -1,29 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala;
/** @meta class [?T] extends scala.AnyRef with java.lang.Cloneable with java.io.Serializable; */
public abstract class Array implements Cloneable, java.io.Serializable {
/** @meta constr (scala.Int); */
public Array() {}
/** @meta method []scala.Array[?T]; */
public abstract Object value();
/** @meta method []scala.Int; */
public abstract int length();
/** @meta method (scala.Int)?T; */
public abstract Object apply(int i);
/** @meta method (scala.Int,?T)scala.Unit; */
public abstract void update(int i, Object x);
}

View File

@ -1,62 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** **
** $Id$
\* */
using System;
using scala.runtime;
namespace scala
{
/** This class implements errors which are thrown whenever an
* object doesn't match any pattern of a pattern matching
* expression.
*
* @author Matthias Zenger
* @version 1.1, 05/03/2004
*/
public sealed class MatchError : ApplicationException
{
[Meta("constr (System.String, scala.Int);")]
private MatchError(string source, int line) :
base(" in '" + source + "' at line " + line)
{
}
[Meta("constr (System.String, scala.Int, System.String);")]
private MatchError(string source, int line, string obj) :
base("for object " + obj + " in '" + source + "' at line " + line)
{
}
[Meta("method [?T](System.String, scala.Int) ?T;")]
public static object fail(string source, int line)
{
throw new MatchError(source, line);
}
[Meta("method [?T](System.String, scala.Int, scala.Any) ?T;")]
public static object report(string source, int line, object obj)
{
try
{
throw new MatchError(source, line, obj.ToString());
}
catch (MatchError e)
{
throw e;
}
catch (Exception e)
{
throw new MatchError(source, line);
}
}
}
}

View File

@ -1,52 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** **
** $Id$
\* */
package scala;
/** This class implements errors which are thrown whenever an
* object doesn't match any pattern of a pattern matching
* expression.
*
* @author Matthias Zenger
* @version 1.1, 05/03/2004
*/
public final class MatchError extends Error {
/** @meta constr (java.lang.String, scala.Int);
*/
private MatchError(java.lang.String source, int line) {
super(" in '" + source + "' at line " + line);
}
/** @meta constr (java.lang.String, scala.Int, java.lang.String);
*/
private MatchError(java.lang.String source, int line, String obj) {
super("for object " + obj + " in '" + source + "' at line " + line);
}
/** @meta method [?T](java.lang.String, scala.Int) ?T;
*/
public static java.lang.Object fail(java.lang.String source, int line) {
throw new MatchError(source, line);
}
/** @meta method [?T](java.lang.String, scala.Int, scala.Any) ?T;
*/
public static java.lang.Object report(java.lang.String source, int line, java.lang.Object obj) {
try {
throw new MatchError(source, line, obj.toString());
} catch (MatchError e) {
throw e;
} catch (Throwable e) {
throw new MatchError(source, line);
}
}
}

View File

@ -1,27 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala;
import scala.runtime.types.ClassType;
/** @meta class extends scala.AnyRef;
*/
public interface ScalaObject {
/**
* Return the Scala type of the object.
*/
public ClassType getScalaType();
/** This method is needed for optimizing pattern matching expressions
* which match on constructors of case classes.
*/
public int $tag();
}

View File

@ -1,160 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala;
import scala.runtime.RunTime;
import scala.runtime.types.ScalaClassType;
import scala.runtime.types.JavaClassType;
import scala.runtime.types.TypeBoolean;
import scala.runtime.types.TypeByte;
import scala.runtime.types.TypeChar;
import scala.runtime.types.TypeDouble;
import scala.runtime.types.TypeFloat;
import scala.runtime.types.TypeInt;
import scala.runtime.types.TypeLong;
import scala.runtime.types.TypeShort;
import scala.runtime.types.TypeUnit;
import scala.runtime.types.TypeAll;
import scala.runtime.types.TypeAllRef;
import scala.runtime.types.TypeAny;
import scala.runtime.types.TypeAnyVal;
import scala.runtime.types.Statistics;
import scala.runtime.FNV_Hash;
/**
* Run-time types for Scala.
*
* @author Michel Schinz
* @version 1.0
*/
abstract public class Type implements java.io.Serializable {
public Type() {
assert Statistics.incInstances(getClass().getName(), this);
}
protected static ThreadLocal unsafeArraysAllowed = new BooleanThreadLocal();
/*
* Allow (or not) the creation of "unsafe" arrays for the current
* thread.
*/
public static void allowUnsafeArrays(boolean allow) {
unsafeArraysAllowed.set(allow
? java.lang.Boolean.TRUE
: java.lang.Boolean.FALSE);
}
/** @meta method [?T](scala.Int) scala.Array[?T]; */
abstract public Array newArray(int size);
/** Return the default value for the type (_ in Scala) */
abstract public Object defaultValue();
/**
* Return true iff the given object is an instance of a subtype of
* this type (implement Scala's isInstanceOf operation).
*/
abstract public boolean isInstance(Object o);
abstract public boolean isSameType(Type that);
abstract public boolean isSubType(Type that);
public boolean isSameAsJavaType(Class that) {
throw new Error("cannot compare Scala type " + this
+ " with Java type " + that);
}
public boolean equals(Object that) {
return (that instanceof Type) && this.isSameType((Type)that);
}
public int hashCode() {
throw new Error("missing hashCode implementation in class "
+ this.getClass());
}
/**
* Check that the given object can be cast to this type, and throw
* an exception if this is not possible (implement Scala's
* asInstanceOf operation).
*/
public Object cast(Object o) {
assert Statistics.incTypeCast();
if (o == null) {
if (this.isSubType(JavaLangObject))
return null;
else
throw new ClassCastException();
} else {
assert Statistics.decInstanceOf();
if (isInstance(o))
return o;
else
throw new ClassCastException("\n" + ((ScalaObject)o).getScalaType()
+ "\n" + this.toString());
}
}
// Value types
public static final TypeDouble Double = TypeDouble.INSTANCE;
public static final TypeFloat Float = TypeFloat.INSTANCE;
public static final TypeLong Long = TypeLong.INSTANCE;
public static final TypeInt Int = TypeInt.INSTANCE;
public static final TypeShort Short = TypeShort.INSTANCE;
public static final TypeChar Char = TypeChar.INSTANCE;
public static final TypeByte Byte = TypeByte.INSTANCE;
public static final TypeBoolean Boolean = TypeBoolean.INSTANCE;
public static final TypeUnit Unit = TypeUnit.INSTANCE;
// "Special" types
public static final TypeAny Any = TypeAny.INSTANCE;
public static final TypeAnyVal AnyVal = TypeAnyVal.INSTANCE;
public static final TypeAllRef AllRef = TypeAllRef.INSTANCE;
public static final TypeAll All = TypeAll.INSTANCE;
private static JavaClassType JavaLangObject;
static {
try {
JavaLangObject = new JavaClassType("java.lang.Object");
} catch (ClassNotFoundException e) {
throw new Error(e);
}
}
public static boolean isSameType(Type[] these, Type[] those) {
if (these.length != those.length)
return false;
for (int i = 0; i < these.length; ++i) {
if (!these[i].isSameType(those[i]))
return false;
}
return true;
}
public static int hashCode(Type[] types) {
final int len = types.length;
int h = FNV_Hash.INIT;
for (int i = 0; i < len; ++i)
h = FNV_Hash.hashStep32(h, types[i].hashCode());
return h;
}
}
class BooleanThreadLocal extends ThreadLocal {
protected Object initialValue() {
return java.lang.Boolean.TRUE;
}
}

View File

@ -1,513 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $OldId: RunTime.java,v 1.13 2002/11/19 12:01:40 paltherr Exp $
// $Id$
using System;
using scala;
namespace scala.runtime
{
public abstract class RunTime
{
//########################################################################
// Private Constants
private static readonly int BITS = 8;
private static readonly int ARRAY_SIZE = 2 << BITS;
private static readonly int INDEX_MASK = ARRAY_SIZE - 1;
private static readonly int CHECK_MASK = ~(ARRAY_SIZE / 2 - 1);
private static readonly UValue uvalue = new UValue();
private static readonly ZValue zvalue_f = new ZValue(false);
private static readonly ZValue zvalue_t = new ZValue(true);
private static readonly BValue[] bvalue = new BValue[256];
private static readonly SValue[] svalue = new SValue[ARRAY_SIZE];
private static readonly CValue[] cvalue = new CValue[ARRAY_SIZE / 2];
private static readonly IValue[] ivalue = new IValue[ARRAY_SIZE];
private static readonly LValue[] lvalue = new LValue[ARRAY_SIZE];
static RunTime()
{
for (int i = 0; i < bvalue.Length; i++)
bvalue[i] = new BValue((sbyte)i);
for (int i = 0; i < ARRAY_SIZE / 2; i++)
{
svalue[i] = new SValue((short)i);
cvalue[i] = new CValue((char )i);
ivalue[i] = new IValue((int )i);
lvalue[i] = new LValue((long )i);
svalue[i + ARRAY_SIZE / 2] = new SValue((short)(CHECK_MASK | i));
ivalue[i + ARRAY_SIZE / 2] = new IValue((int )(CHECK_MASK | i));
lvalue[i + ARRAY_SIZE / 2] = new LValue((long )(CHECK_MASK | i));
}
}
//########################################################################
// Private Variables
//private static ClassLoader loader = ClassLoader.getSystemClassLoader();
//########################################################################
// Public Functions - Getting & setting class loader
// public static ClassLoader getClassLoader()
// {
// return loader;
// }
//
// public static void setClassLoader(ClassLoader loader)
// {
// RunTime.loader = loader;
// }
//########################################################################
// Public Functions - Catching exceptions
public interface Runnable {
void run();
}
public static Exception tryCatch(Runnable runnable)
{
try
{
runnable.run();
return null;
}
catch (Exception exception)
{
return exception;
}
}
//########################################################################
// Public Functions - Boxing primitives
public static Unit box_uvalue( )
{
return uvalue;
}
public static Boolean box_zvalue(bool x)
{
return x ? zvalue_t : zvalue_f;
}
public static Byte box_bvalue(sbyte x)
{
return bvalue[x & 0x000000FF];
}
public static Short box_svalue(short x)
{
int c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return svalue[x & INDEX_MASK];
return new SValue(x);
}
public static Char box_cvalue(char x)
{
int c = (int)x & CHECK_MASK;
if (c == 0) return cvalue[(int)x & INDEX_MASK];
return new CValue(x);
}
public static Int box_ivalue(int x)
{
int c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return ivalue[x & INDEX_MASK];
return new IValue(x);
}
public static Long box_lvalue(long x)
{
long c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return lvalue[(int)x & INDEX_MASK];
return new LValue(x);
}
public static Float box_fvalue(float x)
{
return new FValue(x);
}
public static Double box_dvalue(double x)
{
return new DValue(x);
}
/** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/
public static Array box_zarray(bool[] xs)
{
return new ZArray(xs);
}
/** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */
public static Array box_barray(sbyte [] xs)
{
return new BArray(xs);
}
/** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */
public static Array box_sarray(short [] xs)
{
return new SArray(xs);
}
/** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */
public static Array box_carray(char [] xs)
{
return new CArray(xs);
}
/** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */
public static Array box_iarray(int [] xs)
{
return new IArray(xs);
}
/** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */
public static Array box_larray(long [] xs)
{
return new LArray(xs);
}
/** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */
public static Array box_farray(float [] xs)
{
return new FArray(xs);
}
/** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */
public static Array box_darray(double [] xs)
{
return new DArray(xs);
}
/** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[?T]; */
public static Array box_oarray(object [] xs)
{
return new OArray(xs);
}
/** @meta method [?T](scala.Array[?T]) scala.Array[?T]; */
public static Array box__array(object xs)
{
if (xs == null ) return box_oarray((object [])xs);
if (xs is bool[]) return box_zarray((bool[])xs);
if (xs is sbyte []) return box_barray((sbyte [])xs);
if (xs is short []) return box_sarray((short [])xs);
if (xs is char []) return box_carray((char [])xs);
if (xs is int []) return box_iarray((int [])xs);
if (xs is long []) return box_larray((long [])xs);
if (xs is float []) return box_farray((float [])xs);
if (xs is double []) return box_darray((double [])xs);
if (xs is object []) return box_oarray((object [])xs);
throw new InvalidCastException(xs.GetType() + " is not an array class");
}
//########################################################################
// Public Functions - Unboxing primitives
public static void unbox_uvalue(Unit x) { x.value(); }
public static bool unbox_zvalue(Boolean x) { return x.value ; }
public static sbyte unbox_bvalue(Byte x) { return x.value ; }
public static short unbox_svalue(Short x) { return x.value ; }
public static char unbox_cvalue(Char x) { return x.value ; }
public static int unbox_ivalue(Int x) { return x.value ; }
public static long unbox_lvalue(Long x) { return x.value ; }
public static float unbox_fvalue(Float x) { return x.value ; }
public static double unbox_dvalue(Double x) { return x.value ; }
/** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/
public static bool[] unbox_zarray(Array xs)
{
return xs == null ? null : ((ZArray)xs)._value;
}
/** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */
public static sbyte [] unbox_barray(Array xs)
{
return xs == null ? null : ((BArray)xs)._value;
}
/** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */
public static short [] unbox_sarray(Array xs)
{
return xs == null ? null : ((SArray)xs)._value;
}
/** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */
public static char [] unbox_carray(Array xs)
{
return xs == null ? null : ((CArray)xs)._value;
}
/** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */
public static int [] unbox_iarray(Array xs)
{
return xs == null ? null : ((IArray)xs)._value;
}
/** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */
public static long [] unbox_larray(Array xs)
{
return xs == null ? null : ((LArray)xs)._value;
}
/** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */
public static float [] unbox_farray(Array xs)
{
return xs == null ? null : ((FArray)xs)._value;
}
/** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */
public static double [] unbox_darray(Array xs)
{
return xs == null ? null : ((DArray)xs)._value;
}
/** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[scala.AnyRef]; */
public static object [] unbox_oarray(Array xs)
{
return xs == null ? null : ((OArray)xs)._value;
}
/** @meta method [?T](scala.Array[?T]) scala.AnyRef; */
public static object unbox__array(Array xs)
{
return xs == null ? null : xs.value();
}
//########################################################################
// Public Functions - Conversion primitives
public static sbyte b2b(sbyte x) { return (sbyte )x; }
public static short b2s(sbyte x) { return (short )x; }
public static char b2c(sbyte x) { return (char )x; }
public static int b2i(sbyte x) { return (int )x; }
public static long b2l(sbyte x) { return (long )x; }
public static float b2f(sbyte x) { return (float )x; }
public static double b2d(sbyte x) { return (double)x; }
public static sbyte s2b(short x) { return (sbyte )x; }
public static short s2s(short x) { return (short )x; }
public static char s2c(short x) { return (char )x; }
public static int s2i(short x) { return (int )x; }
public static long s2l(short x) { return (long )x; }
public static float s2f(short x) { return (float )x; }
public static double s2d(short x) { return (double)x; }
public static sbyte c2b(char x) { return (sbyte )x; }
public static short c2s(char x) { return (short )x; }
public static char c2c(char x) { return (char )x; }
public static int c2i(char x) { return (int )x; }
public static long c2l(char x) { return (long )x; }
public static float c2f(char x) { return (float )x; }
public static double c2d(char x) { return (double)x; }
public static sbyte i2b(int x) { return (sbyte )x; }
public static short i2s(int x) { return (short )x; }
public static char i2c(int x) { return (char )x; }
public static int i2i(int x) { return (int )x; }
public static long i2l(int x) { return (long )x; }
public static float i2f(int x) { return (float )x; }
public static double i2d(int x) { return (double)x; }
public static sbyte l2b(long x) { return (sbyte )x; }
public static short l2s(long x) { return (short )x; }
public static char l2c(long x) { return (char )x; }
public static int l2i(long x) { return (int )x; }
public static long l2l(long x) { return (long )x; }
public static float l2f(long x) { return (float )x; }
public static double l2d(long x) { return (double)x; }
public static sbyte f2b(float x) { return (sbyte )x; }
public static short f2s(float x) { return (short )x; }
public static char f2c(float x) { return (char )x; }
public static int f2i(float x) { return (int )x; }
public static long f2l(float x) { return (long )x; }
public static float f2f(float x) { return (float )x; }
public static double f2d(float x) { return (double)x; }
public static sbyte d2b(double x) { return (sbyte )x; }
public static short d2s(double x) { return (short )x; }
public static char d2c(double x) { return (char )x; }
public static int d2i(double x) { return (int )x; }
public static long d2l(double x) { return (long )x; }
public static float d2f(double x) { return (float )x; }
public static double d2d(double x) { return (double)x; }
//########################################################################
// Public Functions - Array primitives
public static bool[] zarray(int length) { return new bool[length]; }
public static sbyte [] barray(int length) { return new sbyte [length]; }
public static short [] sarray(int length) { return new short [length]; }
public static char [] carray(int length) { return new char [length]; }
public static int [] iarray(int length) { return new int [length]; }
public static long [] larray(int length) { return new long [length]; }
public static float [] farray(int length) { return new float [length]; }
public static double [] darray(int length) { return new double [length]; }
public static object oarray(int length, string classname)
{
try
{
Type clasz = Type.GetType(classname);
return System.Array.CreateInstance(clasz, length);
}
catch (Exception exception)
{
//throw new Error(exception.ToString());
throw new ApplicationException(exception.ToString());
}
}
public static int zarray_length(bool[] xs) { return xs.Length; }
public static int barray_length(sbyte [] xs) { return xs.Length; }
public static int sarray_length(short [] xs) { return xs.Length; }
public static int carray_length(char [] xs) { return xs.Length; }
public static int iarray_length(int [] xs) { return xs.Length; }
public static int larray_length(long [] xs) { return xs.Length; }
public static int farray_length(float [] xs) { return xs.Length; }
public static int darray_length(double [] xs) { return xs.Length; }
public static int oarray_length(object [] xs) { return xs.Length; }
public static bool zarray_get(bool[] xs, int i) { return xs[i]; }
public static sbyte barray_get(sbyte [] xs, int i) { return xs[i]; }
public static short sarray_get(short [] xs, int i) { return xs[i]; }
public static char carray_get(char [] xs, int i) { return xs[i]; }
public static int iarray_get(int [] xs, int i) { return xs[i]; }
public static long larray_get(long [] xs, int i) { return xs[i]; }
public static float farray_get(float [] xs, int i) { return xs[i]; }
public static double darray_get(double [] xs, int i) { return xs[i]; }
public static object oarray_get(object [] xs, int i) { return xs[i]; }
public static void zarray_set(bool[] xs, int i, bool x) { xs[i] = x;}
public static void barray_set(sbyte [] xs, int i, sbyte x) { xs[i] = x;}
public static void sarray_set(short [] xs, int i, short x) { xs[i] = x;}
public static void carray_set(char [] xs, int i, char x) { xs[i] = x;}
public static void iarray_set(int [] xs, int i, int x) { xs[i] = x;}
public static void larray_set(long [] xs, int i, long x) { xs[i] = x;}
public static void farray_set(float [] xs, int i, float x) { xs[i] = x;}
public static void darray_set(double [] xs, int i, double x) { xs[i] = x;}
public static void oarray_set(object [] xs, int i, object x) { xs[i] = x;}
//########################################################################
}
// These classes may not be defined in class RunTime because inner
// classes confuse pico which then attributes the metadata to the
// wrong members.
sealed class UValue : Unit { public UValue( ) : base( ) { } }
sealed class ZValue : Boolean { public ZValue(bool x ) : base(x) { } }
sealed class BValue : Byte { public BValue(sbyte x) : base(x) { } }
sealed class SValue : Short { public SValue(short x) : base(x) { } }
sealed class CValue : Char { public CValue(char x) : base(x) { } }
sealed class IValue : Int { public IValue(int x) : base(x) { } }
sealed class LValue : Long { public LValue(long x) : base(x) { } }
sealed class FValue : Float { public FValue(float x) : base(x) { } }
sealed class DValue : Double { public DValue(double x) : base(x) { } }
/** @meta class extends scala.Array[scala.Boolean]; */
sealed class ZArray : Array
{
internal readonly bool[] _value;
public ZArray(bool[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_zvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Boolean)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Byte];")]
sealed class BArray : Array
{
internal readonly sbyte[] _value;
public BArray(sbyte[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_bvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Byte)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Short];")]
sealed class SArray : Array
{
internal readonly short[] _value;
public SArray(short[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_svalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Short)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Char];")]
sealed class CArray : Array
{
internal readonly char[] _value;
public CArray(char[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_cvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Char)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return ((object)_value).ToString(); }
}
[Meta("class extends scala.Array[scala.Int];")]
sealed class IArray : Array
{
internal readonly int[] _value;
public IArray(int[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_ivalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Int)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Long];")]
sealed class LArray : Array
{
internal readonly long[] _value;
public LArray(long[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_lvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Long)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Float];")]
sealed class FArray : Array
{
internal readonly float[] _value;
public FArray(float[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_fvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Float)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class extends scala.Array[scala.Double];")]
sealed class DArray : Array
{
internal readonly double[] _value;
public DArray(double[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return RunTime.box_dvalue(_value[i]); }
public override void update(int i, object x) { _value[i] = ((Double)x).value; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
[Meta("class [?T < scala.AnyRef] extends scala.Array[?T];")]
sealed class OArray : Array
{
internal readonly object[] _value;
public OArray(object[] _value) { this._value = _value; }
public override object value() { return _value; }
public override object apply(int i) { return _value[i]; }
public override void update(int i, object x) { _value[i] = x; }
public override int length() { return _value.Length; }
public override string ToString() { return _value.ToString(); }
}
}

View File

@ -1,473 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $OldId: RunTime.java,v 1.13 2002/11/19 12:01:40 paltherr Exp $
// $Id$
package scala.runtime;
import scala.Unit;
import scala.Boolean;
import scala.Byte;
import scala.Short;
import scala.Char;
import scala.Int;
import scala.Long;
import scala.Float;
import scala.Double;
import scala.Array;
public abstract class RunTime {
//########################################################################
// Private Constants
private static final int BITS = 8;
private static final int ARRAY_SIZE = 2 << BITS;
private static final int INDEX_MASK = ARRAY_SIZE - 1;
private static final int CHECK_MASK = ~(ARRAY_SIZE / 2 - 1);
private static final UValue uvalue = new UValue();
private static final ZValue zvalue_f = new ZValue(false);
private static final ZValue zvalue_t = new ZValue(true);
private static final BValue bvalue[] = new BValue[256];
private static final SValue svalue[] = new SValue[ARRAY_SIZE];
private static final CValue cvalue[] = new CValue[ARRAY_SIZE / 2];
private static final IValue ivalue[] = new IValue[ARRAY_SIZE];
private static final LValue lvalue[] = new LValue[ARRAY_SIZE];
static {
for (int i = 0; i < bvalue.length; i++)
bvalue[i] = new BValue((byte)i);
for (int i = 0; i < ARRAY_SIZE / 2; i++) {
svalue[i] = new SValue((short)i);
cvalue[i] = new CValue((char )i);
ivalue[i] = new IValue((int )i);
lvalue[i] = new LValue((long )i);
svalue[i + ARRAY_SIZE / 2] = new SValue((short)(CHECK_MASK | i));
ivalue[i + ARRAY_SIZE / 2] = new IValue((int )(CHECK_MASK | i));
lvalue[i + ARRAY_SIZE / 2] = new LValue((long )(CHECK_MASK | i));
}
}
//########################################################################
// Private Variables
private static ClassLoader loader = ClassLoader.getSystemClassLoader();
//########################################################################
// Public Functions - Getting & setting class loader
public static ClassLoader getClassLoader() {
return loader;
}
public static void setClassLoader(ClassLoader loader) {
RunTime.loader = loader;
}
//########################################################################
// Public Functions - Catching exceptions
public static Throwable tryCatch(Runnable runnable) {
try {
runnable.run();
return null;
} catch (Throwable exception) {
return exception;
}
}
//########################################################################
// Public Functions - Boxing primitives
public static Unit box_uvalue( ) {
return uvalue;
}
public static Boolean box_zvalue(boolean x) {
return x ? zvalue_t : zvalue_f;
}
public static Byte box_bvalue(byte x) {
return bvalue[x & 0x000000FF];
}
public static Short box_svalue(short x) {
int c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return svalue[x & INDEX_MASK];
return new SValue(x);
}
public static Char box_cvalue(char x) {
int c = (int)x & CHECK_MASK;
if (c == 0) return cvalue[(int)x & INDEX_MASK];
return new CValue(x);
}
public static Int box_ivalue(int x) {
int c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return ivalue[x & INDEX_MASK];
return new IValue(x);
}
public static Long box_lvalue(long x) {
long c = x & CHECK_MASK;
if (c == 0 || c == CHECK_MASK) return lvalue[(int)x & INDEX_MASK];
return new LValue(x);
}
public static Float box_fvalue(float x) {
return new FValue(x);
}
public static Double box_dvalue(double x) {
return new DValue(x);
}
/** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/
public static Array box_zarray(boolean[] xs) {
return new ZArray(xs);
}
/** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */
public static Array box_barray(byte [] xs) {
return new BArray(xs);
}
/** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */
public static Array box_sarray(short [] xs) {
return new SArray(xs);
}
/** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */
public static Array box_carray(char [] xs) {
return new CArray(xs);
}
/** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */
public static Array box_iarray(int [] xs) {
return new IArray(xs);
}
/** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */
public static Array box_larray(long [] xs) {
return new LArray(xs);
}
/** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */
public static Array box_farray(float [] xs) {
return new FArray(xs);
}
/** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */
public static Array box_darray(double [] xs) {
return new DArray(xs);
}
/** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[?T]; */
public static Array box_oarray(Object [] xs) {
return new OArray(xs);
}
/** @meta method [?T](scala.Array[?T]) scala.Array[?T]; */
public static Array box__array(Object xs) {
if (xs == null ) return box_oarray((Object [])xs);
if (xs instanceof boolean[]) return box_zarray((boolean[])xs);
if (xs instanceof byte []) return box_barray((byte [])xs);
if (xs instanceof short []) return box_sarray((short [])xs);
if (xs instanceof char []) return box_carray((char [])xs);
if (xs instanceof int []) return box_iarray((int [])xs);
if (xs instanceof long []) return box_larray((long [])xs);
if (xs instanceof float []) return box_farray((float [])xs);
if (xs instanceof double []) return box_darray((double [])xs);
if (xs instanceof Object []) return box_oarray((Object [])xs);
throw new ClassCastException(xs.getClass() + " is not an array class");
}
//########################################################################
// Public Functions - Unboxing primitives
public static void unbox_uvalue(Unit x) { x.value(); }
public static boolean unbox_zvalue(Boolean x) { return x.value ; }
public static byte unbox_bvalue(Byte x) { return x.value ; }
public static short unbox_svalue(Short x) { return x.value ; }
public static char unbox_cvalue(Char x) { return x.value ; }
public static int unbox_ivalue(Int x) { return x.value ; }
public static long unbox_lvalue(Long x) { return x.value ; }
public static float unbox_fvalue(Float x) { return x.value ; }
public static double unbox_dvalue(Double x) { return x.value ; }
/** @meta method (scala.Array[scala.Boolean]) scala.Array[scala.Boolean];*/
public static boolean[] unbox_zarray(Array xs) {
return xs == null ? null : ((ZArray)xs).value;
}
/** @meta method (scala.Array[scala.Byte]) scala.Array[scala.Byte]; */
public static byte [] unbox_barray(Array xs) {
return xs == null ? null : ((BArray)xs).value;
}
/** @meta method (scala.Array[scala.Short]) scala.Array[scala.Short]; */
public static short [] unbox_sarray(Array xs) {
return xs == null ? null : ((SArray)xs).value;
}
/** @meta method (scala.Array[scala.Char]) scala.Array[scala.Char]; */
public static char [] unbox_carray(Array xs) {
return xs == null ? null : ((CArray)xs).value;
}
/** @meta method (scala.Array[scala.Int]) scala.Array[scala.Int]; */
public static int [] unbox_iarray(Array xs) {
return xs == null ? null : ((IArray)xs).value;
}
/** @meta method (scala.Array[scala.Long]) scala.Array[scala.Long]; */
public static long [] unbox_larray(Array xs) {
return xs == null ? null : ((LArray)xs).value;
}
/** @meta method (scala.Array[scala.Float]) scala.Array[scala.Float]; */
public static float [] unbox_farray(Array xs) {
return xs == null ? null : ((FArray)xs).value;
}
/** @meta method (scala.Array[scala.Double]) scala.Array[scala.Double]; */
public static double [] unbox_darray(Array xs) {
return xs == null ? null : ((DArray)xs).value;
}
/** @meta method [?T < scala.AnyRef](scala.Array[?T]) scala.Array[scala.AnyRef]; */
public static Object [] unbox_oarray(Array xs) {
return xs == null ? null : ((OArray)xs).value;
}
/** @meta method [?T](scala.Array[?T]) scala.AnyRef; */
public static Object unbox__array(Array xs) {
return xs == null ? null : xs.value();
}
//########################################################################
// Public Functions - Conversion primitives
public static byte b2b(byte x) { return (byte )x; }
public static short b2s(byte x) { return (short )x; }
public static char b2c(byte x) { return (char )x; }
public static int b2i(byte x) { return (int )x; }
public static long b2l(byte x) { return (long )x; }
public static float b2f(byte x) { return (float )x; }
public static double b2d(byte x) { return (double)x; }
public static byte s2b(short x) { return (byte )x; }
public static short s2s(short x) { return (short )x; }
public static char s2c(short x) { return (char )x; }
public static int s2i(short x) { return (int )x; }
public static long s2l(short x) { return (long )x; }
public static float s2f(short x) { return (float )x; }
public static double s2d(short x) { return (double)x; }
public static byte c2b(char x) { return (byte )x; }
public static short c2s(char x) { return (short )x; }
public static char c2c(char x) { return (char )x; }
public static int c2i(char x) { return (int )x; }
public static long c2l(char x) { return (long )x; }
public static float c2f(char x) { return (float )x; }
public static double c2d(char x) { return (double)x; }
public static byte i2b(int x) { return (byte )x; }
public static short i2s(int x) { return (short )x; }
public static char i2c(int x) { return (char )x; }
public static int i2i(int x) { return (int )x; }
public static long i2l(int x) { return (long )x; }
public static float i2f(int x) { return (float )x; }
public static double i2d(int x) { return (double)x; }
public static byte l2b(long x) { return (byte )x; }
public static short l2s(long x) { return (short )x; }
public static char l2c(long x) { return (char )x; }
public static int l2i(long x) { return (int )x; }
public static long l2l(long x) { return (long )x; }
public static float l2f(long x) { return (float )x; }
public static double l2d(long x) { return (double)x; }
public static byte f2b(float x) { return (byte )x; }
public static short f2s(float x) { return (short )x; }
public static char f2c(float x) { return (char )x; }
public static int f2i(float x) { return (int )x; }
public static long f2l(float x) { return (long )x; }
public static float f2f(float x) { return (float )x; }
public static double f2d(float x) { return (double)x; }
public static byte d2b(double x) { return (byte )x; }
public static short d2s(double x) { return (short )x; }
public static char d2c(double x) { return (char )x; }
public static int d2i(double x) { return (int )x; }
public static long d2l(double x) { return (long )x; }
public static float d2f(double x) { return (float )x; }
public static double d2d(double x) { return (double)x; }
//########################################################################
// Public Functions - Array primitives
public static boolean[] zarray(int length) { return new boolean[length]; }
public static byte [] barray(int length) { return new byte [length]; }
public static short [] sarray(int length) { return new short [length]; }
public static char [] carray(int length) { return new char [length]; }
public static int [] iarray(int length) { return new int [length]; }
public static long [] larray(int length) { return new long [length]; }
public static float [] farray(int length) { return new float [length]; }
public static double [] darray(int length) { return new double [length]; }
public static Object oarray(int length, String classname) {
try {
Class clasz = Class.forName(classname, false, loader);
return java.lang.reflect.Array.newInstance(clasz, length);
} catch (ClassNotFoundException exception) {
throw new Error(exception.toString());
}
}
public static int zarray_length(boolean[] xs) { return xs.length; }
public static int barray_length(byte [] xs) { return xs.length; }
public static int sarray_length(short [] xs) { return xs.length; }
public static int carray_length(char [] xs) { return xs.length; }
public static int iarray_length(int [] xs) { return xs.length; }
public static int larray_length(long [] xs) { return xs.length; }
public static int farray_length(float [] xs) { return xs.length; }
public static int darray_length(double [] xs) { return xs.length; }
public static int oarray_length(Object [] xs) { return xs.length; }
public static boolean zarray_get(boolean[] xs, int i) { return xs[i]; }
public static byte barray_get(byte [] xs, int i) { return xs[i]; }
public static short sarray_get(short [] xs, int i) { return xs[i]; }
public static char carray_get(char [] xs, int i) { return xs[i]; }
public static int iarray_get(int [] xs, int i) { return xs[i]; }
public static long larray_get(long [] xs, int i) { return xs[i]; }
public static float farray_get(float [] xs, int i) { return xs[i]; }
public static double darray_get(double [] xs, int i) { return xs[i]; }
public static Object oarray_get(Object [] xs, int i) { return xs[i]; }
public static void zarray_set(boolean[] xs, int i, boolean x) { xs[i] = x;}
public static void barray_set(byte [] xs, int i, byte x) { xs[i] = x;}
public static void sarray_set(short [] xs, int i, short x) { xs[i] = x;}
public static void carray_set(char [] xs, int i, char x) { xs[i] = x;}
public static void iarray_set(int [] xs, int i, int x) { xs[i] = x;}
public static void larray_set(long [] xs, int i, long x) { xs[i] = x;}
public static void farray_set(float [] xs, int i, float x) { xs[i] = x;}
public static void darray_set(double [] xs, int i, double x) { xs[i] = x;}
public static void oarray_set(Object [] xs, int i, Object x) { xs[i] = x;}
//########################################################################
}
// These classes may not be defined in class RunTime because inner
// classes confuse pico which then attributes the metadata to the
// wrong members.
final class UValue extends Unit implements java.io.Serializable
{ public UValue( ) { super( ); } }
final class ZValue extends Boolean implements java.io.Serializable
{ public ZValue(boolean x) { super(x); } }
final class BValue extends Byte implements java.io.Serializable
{ public BValue(byte x) { super(x); } }
final class SValue extends Short implements java.io.Serializable
{ public SValue(short x) { super(x); } }
final class CValue extends Char implements java.io.Serializable
{ public CValue(char x) { super(x); } }
final class IValue extends Int implements java.io.Serializable
{ public IValue(int x) { super(x); } }
final class LValue extends Long implements java.io.Serializable
{ public LValue(long x) { super(x); } }
final class FValue extends Float implements java.io.Serializable
{ public FValue(float x) { super(x); } }
final class DValue extends Double implements java.io.Serializable
{ public DValue(double x) { super(x); } }
/** @meta class extends scala.Array[scala.Boolean]; */
final class ZArray extends Array implements java.io.Serializable {
public final boolean[] value;
public ZArray(boolean[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_zvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Boolean)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Byte]; */
final class BArray extends Array implements java.io.Serializable {
public final byte[] value;
public BArray(byte[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_bvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Byte)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Short]; */
final class SArray extends Array implements java.io.Serializable {
public final short[] value;
public SArray(short[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_svalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Short)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Char]; */
final class CArray extends Array implements java.io.Serializable {
public final char[] value;
public CArray(char[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_cvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Char)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf((Object)value); }
}
/** @meta class extends scala.Array[scala.Int]; */
final class IArray extends Array implements java.io.Serializable {
public final int[] value;
public IArray(int[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_ivalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Int)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Long]; */
final class LArray extends Array implements java.io.Serializable {
public final long[] value;
public LArray(long[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_lvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Long)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Float]; */
final class FArray extends Array implements java.io.Serializable {
public final float[] value;
public FArray(float[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_fvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Float)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class extends scala.Array[scala.Double]; */
final class DArray extends Array implements java.io.Serializable {
public final double[] value;
public DArray(double[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return RunTime.box_dvalue(value[i]); }
public void update(int i, Object x) { value[i] = ((Double)x).value; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}
/** @meta class [?T < scala.AnyRef] extends scala.Array[?T]; */
final class OArray extends Array implements java.io.Serializable {
public final Object[] value;
public OArray(Object[] value) { this.value = value; }
public Object value() { return value; }
public Object apply(int i) { return value[i]; }
public void update(int i, Object x) { value[i] = x; }
public int length() { return value.length; }
public String toString() { return String.valueOf(value); }
}

View File

@ -1,94 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
import scala.runtime.RunTime;
public abstract class ClassType extends Type {
public final Class clazz;
public final boolean isTrivial;
public ClassType(Class clazz, boolean isTrivial) {
this.clazz = clazz;
this.isTrivial = isTrivial;
}
public Array newArray(int size) {
Object[] array =
(Object[])java.lang.reflect.Array.newInstance(clazz, size);
return RunTime.box_oarray(array);
}
public Object defaultValue() {
return null;
}
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return clazz.isInstance(o);
}
public boolean isNonTrivialInstance(Object o) {
assert isTrivial; // must be overridden for non-trivial types
return true;
}
public boolean isSubType(Type that) {
return (that == Type.Any)
|| (that instanceof ClassType
&& isSubClassType((ClassType)that))
|| (that instanceof CompoundType
&& isSubCompoundType((CompoundType)that));
}
protected boolean isSubClassType(ClassType that) {
return that.clazz.isAssignableFrom(this.clazz);
}
public boolean isNonTrivialSubClassType(ClassType that) {
assert isTrivial; // must be overridden for non-trivial types
return true;
}
protected final boolean isSubCompoundType(CompoundType that) {
// TODO? check refinement
for (int i = 0; i < that.components.length; ++i) {
if (!isSubType(that.components[i]))
return false;
}
return true;
}
public boolean isSameType(Type that) {
return (that instanceof ClassType)
&& (((ClassType)that).clazz == this.clazz);
}
public boolean isSameAsJavaType(Class that) {
if (this.isTrivial)
return clazz == that;
else if (clazz != that)
return false;
else
throw new Error("uncomparable types");
}
public int hashCode() {
return clazz.hashCode();
}
public String toString() {
return clazz.getName();
}
}

View File

@ -1,109 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
import scala.ScalaObject;
import scala.runtime.RunTime;
/**
* Run-time representation for compound types.
*
* @author Michel Schinz
* @version 1.0
*/
public class CompoundType extends Type {
public final ClassType[] components;
public final boolean emptyRefinement;
public CompoundType(ClassType[] components, boolean emptyRefinement) {
this.components = components;
this.emptyRefinement = emptyRefinement;
}
public Array newArray(int size) {
if (Type.unsafeArraysAllowed.get() == java.lang.Boolean.TRUE)
return (Array)
java.lang.reflect.Array.newInstance(components[0].clazz, size);
else
throw new Error("cannot create arrays of compound types");
}
public Object defaultValue() {
return null;
}
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
for (int i = 0; i < components.length; ++i) {
if (!components[i].isInstance(o))
return false;
}
return true;
}
public boolean isSubType(Type that) {
if (!emptyRefinement)
throw new Error("cannot compute isSubType (non-empty refinement)");
if (that instanceof CompoundType) {
CompoundType thatCT = (CompoundType)that;
ClassType[] thatComponents = thatCT.components;
for (int i = 0; i < thatComponents.length; ++i) {
if (!this.isSubType(thatComponents[i]))
return false;
}
return true;
} else {
for (int i = 0; i < components.length; ++i) {
if (components[i].isSubType(that))
return true;
}
return false;
}
}
public boolean isSameType(Type that) {
if (!emptyRefinement)
throw new Error("cannot compute isSameType (non-empty refinement)");
if (that instanceof CompoundType) {
CompoundType thatCT = (CompoundType)that;
if (components.length != thatCT.components.length)
return false;
for (int i = 0; i < components.length; ++i) {
if (!components[i].isSameType(thatCT.components[i]))
return false;
}
return true;
} else
return false;
}
public int hashCode() {
return Type.hashCode(components);
}
public String toString() {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < components.length; ++i) {
if (i > 0) buf.append(" with ");
buf.append(components[i]);
}
return buf.toString();
}
}

View File

@ -1,53 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import java.util.HashMap;
public class JavaClassType extends ClassType {
private static final ClassLoader loader =
ClassLoader.getSystemClassLoader();
private static ThreadLocal cacheLocal = new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
}
};
public static JavaClassType javaClassType(String fullName) {
HashMap/*<String, JavaClassType>*/ cache = (HashMap)cacheLocal.get();
JavaClassType jct = (JavaClassType)cache.get(fullName);
if (jct == null) {
try {
jct = new JavaClassType(fullName);
cache.put(fullName, jct);
} catch (ClassNotFoundException e) {
throw new Error(e);
}
}
return jct;
}
public static JavaClassType javaArrayType(String elemFullName, int dimen) {
StringBuffer fullName = new StringBuffer();
for (int i = 0; i < dimen; ++i)
fullName.append('[');
if (elemFullName.length() == 1 && "ZBCDFIJS".indexOf(elemFullName) >= 0)
fullName.append(elemFullName);
else
fullName.append('L').append(elemFullName).append(';');
return javaClassType(fullName.toString());
}
public JavaClassType(String fullName) throws ClassNotFoundException {
super(Class.forName(fullName, false, loader), true);
}
}

View File

@ -1,80 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
/**
* Type for Java arrays of references.
*
* @author Michel Schinz
* @version 1.0
*/
public class JavaRefArrayType extends Type {
public final int dimensions;
public final Type elemType;
public static JavaRefArrayType javaRefArrayType(Type elemType,
int dimensions) {
if (elemType instanceof JavaRefArrayType) {
JavaRefArrayType other = (JavaRefArrayType)elemType;
return new JavaRefArrayType(other.elemType,
dimensions + other.dimensions);
} else
return new JavaRefArrayType(elemType, dimensions);
}
private JavaRefArrayType(Type elemType, int dimensions) {
this.elemType = elemType;
this.dimensions = dimensions;
}
public Array newArray(int size) {
throw new Error(); // TODO
}
public Object defaultValue() {
return null;
}
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return this.isSameAsJavaType(o.getClass());
}
public boolean isSameType(Type that) {
return (that instanceof JavaRefArrayType)
&& (elemType.isSameType(((JavaRefArrayType)that).elemType));
}
public boolean isSameAsJavaType(Class that) {
Class thatElemType = that;
for (int i = 0; i < dimensions && thatElemType != null; ++i)
thatElemType = thatElemType.getComponentType();
return (thatElemType != null)
&& (elemType.isSameAsJavaType(thatElemType));
}
public boolean isSubType(Type that) {
return isSameType(that);
}
public String toString() {
return elemType.toString() + "[]";
}
public int hashCode() {
return elemType.hashCode() * 11;
}
}

View File

@ -1,271 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
import scala.ScalaObject;
import scala.runtime.RunTime;
import scala.runtime.FNV_Hash;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
* Provides a run-time representation of the Scala types.
*
* @author Michel Schinz
* @version 1.0
*/
public class ScalaClassType extends ClassType {
public static final ScalaClassType[] EMPTY_ARRAY =
new ScalaClassType[0];
private static final ScalaClassType[][] EMPTY_ANCESTORS =
new ScalaClassType[0][];
private final TypeConstructor constr;
private final Type[] inst;
private final Object parents;
private ScalaClassType[][] ancestors = null;
private final int hashCode;
public ScalaClassType(TypeConstructor constr, Type[] inst, Object parents) {
super(constr.clazz, constr.isTrivial);
this.constr = constr;
this.inst = inst;
int hash = FNV_Hash.hashStep32(FNV_Hash.INIT, constr.hashCode());
for (int i = 0; i < inst.length; ++i) {
hash = FNV_Hash.hashStep32(hash, inst[i].hashCode());
}
this.hashCode = hash;
this.parents = parents;
}
public boolean isInstance(Object o) {
return super.isInstance(o)
&& (isTrivial
|| ((ScalaObject)o).getScalaType().isNonTrivialSubClassType(this));
}
public boolean isNonTrivialInstance(Object o) {
assert Statistics.incWeakInstanceOf();
return ((ScalaObject)o).getScalaType().isNonTrivialSubClassType(this);
}
protected boolean isSubClassType(ClassType that) {
return (this == that)
|| (super.isSubClassType(that)
&& (that.isTrivial
|| isNonTrivialSubClassType((ScalaClassType)that)));
}
public boolean isNonTrivialSubClassType(ClassType that) {
ScalaClassType thatCT = (ScalaClassType)that;
ScalaClassType parentCT = myInstantiationFor(thatCT);
// At this stage, if parentCT is null, it means that the
// constructors had different prefixes, hence we return false.
return (parentCT != null)
&& (parentCT == thatCT || parentCT.hasSubInstantiation(thatCT));
}
// Return true iff the instantiation of THIS is "smaller" than the
// one of THAT.
private boolean hasSubInstantiation(ScalaClassType that) {
assert this.constr == that.constr;
final Type[] thisInst = this.inst;
final Type[] thatInst = that.inst;
int i = 0;
// invariant parameters
final int firstM = this.constr.zCount;
while (i < firstM) {
Type thisTp = thisInst[i], thatTp = thatInst[i];
if (!(thisTp == thatTp || thisTp.isSameType(thatTp)))
return false;
++i;
}
// contravariant parameters
final int firstP = firstM + this.constr.mCount;
while (i < firstP) {
Type thisTp = thisInst[i], thatTp = thatInst[i];
if (!(thisTp == thatTp || thatTp.isSubType(thisTp)))
return false;
++i;
}
// covariant parameters
final int firstOutside = firstP + this.constr.pCount;
while (i < firstOutside) {
Type thisTp = thisInst[i], thatTp = thatInst[i];
if (!(thisTp == thatTp || thisTp.isSubType(thatTp)))
return false;
++i;
}
return true;
}
public boolean isSameType(Type that) {
return this == that;
}
private ScalaClassType myInstantiationFor(ScalaClassType that) {
// Find our instantiation for the other type, if any.
ScalaClassType[] thisSlice = getAncestors()[that.constr.level];
for (int i = 0; i < thisSlice.length; ++i) {
if (thisSlice[i].constr == that.constr) {
assert Statistics.addAncestorSearchIterations(i + 1);
return thisSlice[i];
}
}
assert Statistics.addAncestorSearchIterations(thisSlice.length);
return null;
}
public String toString() {
StringBuffer buf = new StringBuffer();
int firstM = constr.zCount;
int firstP = firstM + constr.mCount;
buf.append(constr);
if (inst.length > 0) {
buf.append("[");
for (int i = 0; i < inst.length; ++i) {
if (i > 0) buf.append(", ");
if (i >= firstP)
buf.append('+');
else if (i >= firstM)
buf.append('-');
buf.append(inst[i]);
}
buf.append("]");
}
return buf.toString();
}
public int hashCode() {
return hashCode;
}
public ScalaClassType[] getParents() {
if (parents instanceof LazyParents)
return ((LazyParents)parents).force();
else
return (ScalaClassType[])parents;
}
private ScalaClassType[][] getAncestors() {
if (ancestors == null)
computeAncestors();
return ancestors;
}
private void computeAncestors() {
final int level = constr.level;
final int ancestorDepth = constr.ancestorCacheDepth;
final int[] ancestorCode = constr.ancestorCode;
ScalaClassType[] parents = getParents();
ScalaClassType[][] ancestors = new ScalaClassType[ancestorDepth][];
ScalaClassType[][] initialAncestors = parents.length > 0
? parents[0].getAncestors()
: EMPTY_ANCESTORS;
for (int l = 0, dci = 0; l < ancestorDepth; ++l) {
int toAddParents = 0;
if (dci < ancestorCode.length && ancestorCode[dci] == l) {
dci++;
toAddParents = ancestorCode[dci++];
}
int toAddSelf = (l == level) && (!constr.isTrivial) ? 1 : 0;
int toAdd = toAddParents + toAddSelf;
ScalaClassType[] initialRow;
if (l < initialAncestors.length)
initialRow = initialAncestors[l];
else
initialRow = ScalaClassType.EMPTY_ARRAY;
if (toAdd == 0) {
ancestors[l] = initialRow;
} else {
int initialLen = initialRow.length;
ScalaClassType[] newRow =
new ScalaClassType[initialLen + toAdd];
if (toAddSelf == 1)
newRow[0] = this;
System.arraycopy(initialRow, 0, newRow, toAddSelf, initialLen);
for (int i = 0; i < toAddParents; ++i) {
int p = ancestorCode[dci++];
int o = ancestorCode[dci++];
newRow[toAddSelf + initialLen + i] =
parents[p].getAncestors()[l][o];
}
ancestors[l] = newRow;
}
}
this.ancestors = ancestors;
}
private static final ClassLoader loader =
ClassLoader.getSystemClassLoader();
// Must match value defined in class scalac.util.Names !
private static final String INSTANTIATE_PREFIX = "instantiate$";
// Enforces uniqueness of the instance when serializing and
// deserializing the same Scala type object many times.
private Object readResolve() {
if (constr.clazz == null)
return this; // TODO: check why clazz may be null
String fullName = constr.clazz.getName();
Class instClazz = constr.clazz;
if (constr.clazz.isInterface()) {
try {
instClazz = Class.forName(fullName + "$class", false, loader);
}
catch (ClassNotFoundException e) {
throw new Error(e);
}
}
try {
int inx = fullName.lastIndexOf('.');
String className = (inx < 0) ? fullName : fullName.substring(inx + 1);
String name = INSTANTIATE_PREFIX + className + "$";
Class[] paramTypes = new Class[]{ Type[].class };
Method instMeth = instClazz.getDeclaredMethod(name, paramTypes);
assert Modifier.isStatic(instMeth.getModifiers());
return instMeth.invoke(null, new Object[]{ inst });
}
catch (NoSuchMethodException e) {
throw new Error(e);
}
catch (IllegalAccessException e) {
throw new Error(e);
}
catch (InvocationTargetException e) {
throw new Error(e);
}
}
}

View File

@ -1,52 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
public class SingleType extends Type {
private final Object instance;
public SingleType(Object instance) {
this.instance = instance;
}
public Array newArray(int size) {
if (Type.unsafeArraysAllowed.get() == java.lang.Boolean.TRUE)
return (Array)
java.lang.reflect.Array.newInstance(instance.getClass(), size);
else
throw new Error("cannot create array of single types");
}
public Object defaultValue() {
return null;
}
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return o == instance;
}
public boolean isSubType(Type that) {
return that.isInstance(instance);
}
public boolean isSameType(Type that) {
return (that instanceof SingleType)
&& (this.instance == ((SingleType)that).instance);
}
public int hashCode() {
return System.identityHashCode(instance);
}
}

View File

@ -1,42 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
import scala.runtime.RunTime;
/**
* Abstract superclass for all "special" types, which are types
* existing in Scala but not in Java: Any, AnyVal, All and AllRef.
*
* @author Michel Schinz
* @version 1.0
*/
abstract public class SpecialType extends Type {
public Array newArray(int size) {
if (Type.unsafeArraysAllowed.get() == java.lang.Boolean.TRUE)
return (Array)
java.lang.reflect.Array.newInstance(Object.class, size);
else
throw new Error("cannot create arrays of special type "
+ "(" + getClass().getName() + ")");
}
public Object defaultValue() {
return null;
}
public boolean isSameType(Type that) {
return this == that;
}
}

View File

@ -1,155 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.ArrayList;
import scala.Type;
/**
* Collect various statistics about run time types, and output them to
* a file as s-expressions.
*
* Notice that all methods return true, in order to be usable as
* assertions and disabled easily.
*
* @author Michel Schinz
* @version 1.0
*/
public class Statistics {
private static long instantiationsCount = 0;
private static long uniqueInstantiationsCount = 0;
private static long instanceOfCount = 0;
private static long weakInstanceOfCount = 0;
private static long typeCastCount = 0;
private static long ancestorSearchIterations = 0;
private static long ancestorSearches = 0;
private static HashMap instances = new HashMap();
static {
assert addWriteFileHook();
}
public static boolean addWriteFileHook() {
Thread writeFileHook = new Thread() {
public void run() {
try {
writeToFile();
} catch (Throwable t) {
throw new Error(t);
}
}
};
Runtime.getRuntime().addShutdownHook(writeFileHook);
return true;
}
public static synchronized boolean incInstantiations(boolean unique) {
++instantiationsCount;
if (unique) ++uniqueInstantiationsCount;
return true;
}
public static synchronized boolean incInstanceOf() {
++instanceOfCount;
return true;
}
public static synchronized boolean incWeakInstanceOf() {
++weakInstanceOfCount;
return true;
}
public static synchronized boolean decInstanceOf() {
--instanceOfCount;
return true;
}
public static synchronized boolean incTypeCast() {
++typeCastCount;
return true;
}
public static synchronized boolean incInstances(String className,
Type tp) {
ArrayList currInst = (ArrayList)instances.get(className);
if (currInst == null) {
currInst = new ArrayList();
instances.put(className, currInst);
}
currInst.add(tp);
return true;
}
public static synchronized boolean addAncestorSearchIterations(int n) {
ancestorSearchIterations += n;
ancestorSearches++;
return true;
}
/**
* Output statistics to a file, as an a-list associating numbers
* to tags.
*/
public static boolean writeToFile() throws java.io.FileNotFoundException {
String fileName = System.getProperty("scala.runtime.types.statfile");
assert fileName != null
: "property scala.runtime.types.statfile not set";
System.out.println("Writing RTT statistics to file " + fileName);
PrintStream stream = new PrintStream(new FileOutputStream(fileName));
stream.println("(");
stream.println("(instantiations . "
+ instantiationsCount + ")");
stream.println("(unique-instantiations . "
+ uniqueInstantiationsCount + ")");
stream.println("(instance-of . "
+ instanceOfCount + ")");
stream.println("(weak-instance-of . "
+ weakInstanceOfCount + ")");
stream.println("(type-cast . "
+ typeCastCount + ")");
if (ancestorSearches > 0) {
stream.println("(ancestor-searches . "
+ ancestorSearches + ")");
stream.println("(ancestor-search-iterations . "
+ ancestorSearchIterations + ")");
}
stream.println("(instances . (");
Iterator instIt = instances.entrySet().iterator();
while (instIt.hasNext()) {
Map.Entry entry = (Map.Entry)instIt.next();
String name = (String)entry.getKey();
ArrayList instances = (ArrayList)entry.getValue();
HashSet uniqueInstances = new HashSet(instances);
stream.println("(\"" + name + "\" . "
+ instances.size() + ")");
stream.println("(\"Unique" + name + "\" . "
+ uniqueInstances.size() + ")");
}
stream.print("))");
stream.println(")");
stream.close();
return true;
}
}

View File

@ -1,34 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeAll extends SpecialType {
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return false;
}
public boolean isSubType(Type that) {
return true;
}
public String toString() { return "scala.All"; }
public int hashCode() { return 0xAAAAAAAA; }
// Make TypeAll a serializable singleton
public static TypeAll INSTANCE = new TypeAll();
protected TypeAll() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,35 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeAllRef extends SpecialType {
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return false;
}
public boolean isSubType(Type that) {
return !that.isSubType(Type.AnyVal);
}
public String toString() { return "scala.AllRef"; }
public int hashCode() { return 0xDDDDDDDD; }
// Make TypeAllRef a serializable singleton
public static TypeAllRef INSTANCE = new TypeAllRef();
protected TypeAllRef() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,35 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeAny extends SpecialType {
public boolean isInstance(Object o) {
assert Statistics.incInstanceOf();
return true;
}
public boolean isSubType(Type that) {
return that == this;
}
public String toString() { return "scala.Any"; }
public int hashCode() { return 0xBBBBBBBB; }
// Make TypeAny a serializable singleton
public static TypeAny INSTANCE = new TypeAny();
protected TypeAny() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,34 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeAnyVal extends SpecialType {
public boolean isInstance(Object o) {
throw new UnsupportedOperationException();
}
public boolean isSubType(Type that) {
return that == Type.Any || that == this;
}
public String toString() { return "scala.AnyVal"; }
public int hashCode() { return 0xCCCCCCCC; }
// Make TypeAnyVal a serializable singleton
public static TypeAnyVal INSTANCE = new TypeAnyVal();
protected TypeAnyVal() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,37 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
import scala.Boolean;
public class TypeBoolean extends ValueType {
private final Boolean ZERO = RunTime.box_zvalue(false);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (! (o == null || o instanceof scala.Boolean))
throw new ClassCastException(); // TODO error message
return o;
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Boolean.TYPE;
}
public String toString() { return "scala.Boolean"; }
public int hashCode() { return 0x88888888; }
// Make TypeBoolean a serializable singleton
public static TypeBoolean INSTANCE = new TypeBoolean();
protected TypeBoolean() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,50 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
import scala.Byte;
public class TypeByte extends ValueType {
private final Byte ZERO = RunTime.box_bvalue((byte)0);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Byte)
return o;
else if (o instanceof scala.Double)
return RunTime.box_bvalue((byte)((scala.Double)o).value);
else if (o instanceof scala.Float)
return RunTime.box_bvalue((byte)((scala.Float)o).value);
else if (o instanceof scala.Long)
return RunTime.box_bvalue((byte)((scala.Long)o).value);
else if (o instanceof scala.Int)
return RunTime.box_bvalue((byte)((scala.Int)o).value);
else if (o instanceof scala.Short)
return RunTime.box_bvalue((byte)((scala.Short)o).value);
else if (o instanceof scala.Char)
return RunTime.box_bvalue((byte)((scala.Char)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Byte.TYPE;
}
public String toString() { return "scala.Byte"; }
public int hashCode() { return 0x77777777; }
// Make TypeByte a serializable singleton
public static TypeByte INSTANCE = new TypeByte();
protected TypeByte() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,50 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
import scala.Char;
public class TypeChar extends ValueType {
private final Char ZERO = RunTime.box_cvalue((char)0);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Char)
return o;
else if (o instanceof scala.Double)
return RunTime.box_cvalue((char)((scala.Double)o).value);
else if (o instanceof scala.Float)
return RunTime.box_cvalue((char)((scala.Float)o).value);
else if (o instanceof scala.Long)
return RunTime.box_cvalue((char)((scala.Long)o).value);
else if (o instanceof scala.Int)
return RunTime.box_cvalue((char)((scala.Int)o).value);
else if (o instanceof scala.Short)
return RunTime.box_cvalue((char)((scala.Short)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_cvalue((char)((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == char.class;
}
public String toString() { return "scala.Char"; }
public int hashCode() { return 0x66666666; }
// Make TypeChar a serializable singleton
public static TypeChar INSTANCE = new TypeChar();
protected TypeChar() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,157 +0,0 @@
/* __ * \
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
import scala.runtime.AtomicReference;
import scala.runtime.IOMap;
/**
* Class modelling a type constructor (this includes non-polymorphic
* types, which are handled as polymorphic types with zero arguments).
*
* @author Michel Schinz
* @version 1.0
*/
public final class TypeConstructor implements java.io.Serializable {
public final static TypeConstructor[] EMPTY_ARRAY =
new TypeConstructor[0];
private static class Outer implements java.io.Serializable {}
public final static Object FUNCTION_OUTER = new Outer();
/** Java class corresponding to this constructor. */
public Class clazz;
/**
* Number of invariant (z), contravariant (m) and covariant (p)
* type arguments.
*/
public final int zCount, mCount, pCount;
/**
* Level of this type in the hierarchy (scala.AnyRef is at 0, its
* direct children at 1, and so on).
*/
public final int level;
/**
* Indication of triviality: a constructor is trivial iff it has
* no enclosing class, and no type arguments.
*/
public final boolean isTrivial;
public final int ancestorCacheDepth;
/**
* "Code" to compute the ancestors for an instance of this
* constructor, based on the ancestors of its not-strongly-trivial
* parents. This code is structured as follows:
*
* l1 n1 p1,0 o1,0 p1,1 o1,1 ... l2 n2 p2,0 o2,0 ...
*
* where all l, n, p and o are integers. ni gives the number of
* additional entries to add to the ancestors of the first parent
* at level li. pi gives the index of the parent in which to pick
* this additional entry, and oi gives the offset of this entry in
* the parent's ancestors.
*/
public final int[] ancestorCode;
/** Enclosing class for this type constructor */
private final Object outer;
private final InstantiationMap instMapModule = new InstantiationMap();
private final AtomicReference/*<InstantiationMap.T>*/ instances =
new AtomicReference(IOMap.EMPTY);
private static final ClassLoader loader =
ClassLoader.getSystemClassLoader();
private static final int[] EMPTY_ANCESTOR_CODE = new int[0];
public TypeConstructor(int level,
String fullName,
Object outer,
int zCount,
int mCount,
int pCount,
int ancestorCacheDepth,
int[] ancestorCode) {
this.level = level;
this.outer = outer;
this.zCount = zCount;
this.mCount = mCount;
this.pCount = pCount;
this.ancestorCacheDepth = ancestorCacheDepth;
this.ancestorCode =
(ancestorCode == null ? EMPTY_ANCESTOR_CODE : ancestorCode);
this.isTrivial = (outer == null) && (zCount + pCount + mCount == 0);
try {
this.clazz = Class.forName(fullName, false, loader);
} catch (ClassNotFoundException e) {
throw new Error(e);
}
assert (zCount >= 0) && (mCount >= 0) && (pCount >= 0);
}
public String toString() {
if (outer == null)
return clazz.getName();
else if (outer == FUNCTION_OUTER)
return "<function>." + clazz.getName();
else
return outer.toString() + "." + clazz.getName();
}
public ScalaClassType getInstantiation(Type[] args) {
ScalaClassType inst =
instMapModule.get((InstantiationMap.T)instances.get(), args);
assert Statistics.incInstantiations(inst == null);
return inst;
}
public ScalaClassType instantiate(Type[] args, Object parents) {
ScalaClassType tp = new ScalaClassType(this, args, parents);
try {
InstantiationMap.T oldMap, newMap;
do {
oldMap = (InstantiationMap.T)instances.get();
newMap = instMapModule.put(oldMap, args, tp);
} while (!instances.compareAndSet(oldMap, newMap));
} catch (IOMap.ConflictException e) {
return (ScalaClassType)e.oldValue;
}
return tp;
}
//////////////////////////////////////////////////////////////////////
private static class InstantiationMap
extends IOMap
implements java.io.Serializable {
public T put(T map, Type[] inst, ScalaClassType value)
throws ConflictException {
return super.put(map, Type.hashCode(inst), value);
}
public ScalaClassType get(T map, Type[] inst) {
return (ScalaClassType)super.get(map, Type.hashCode(inst));
}
}
}

View File

@ -1,49 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public public class TypeDouble extends ValueType {
private final scala.Double ZERO = RunTime.box_dvalue(0.0);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Double)
return o;
else if (o instanceof scala.Float)
return RunTime.box_dvalue(((scala.Float)o).value);
else if (o instanceof scala.Long)
return RunTime.box_dvalue(((scala.Long)o).value);
else if (o instanceof scala.Int)
return RunTime.box_dvalue(((scala.Int)o).value);
else if (o instanceof scala.Short)
return RunTime.box_dvalue(((scala.Short)o).value);
else if (o instanceof scala.Char)
return RunTime.box_dvalue(((scala.Char)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_dvalue(((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Double.TYPE;
}
public String toString() { return "scala.Double"; }
public int hashCode() { return 0x11111111; }
// Make TypeDouble a serializable singleton
public static TypeDouble INSTANCE = new TypeDouble();
protected TypeDouble() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,49 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeFloat extends ValueType {
private final scala.Float ZERO = RunTime.box_fvalue(0.0f);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Float)
return o;
else if (o instanceof scala.Double)
return RunTime.box_fvalue((float)((scala.Double)o).value);
else if (o instanceof scala.Long)
return RunTime.box_fvalue(((scala.Long)o).value);
else if (o instanceof scala.Int)
return RunTime.box_fvalue(((scala.Int)o).value);
else if (o instanceof scala.Short)
return RunTime.box_fvalue(((scala.Short)o).value);
else if (o instanceof scala.Char)
return RunTime.box_fvalue(((scala.Char)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_fvalue(((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Float.TYPE;
}
public String toString() { return "scala.Float"; }
public int hashCode() { return 0x22222222; }
// Make TypeFloat a serializable singleton
public static TypeFloat INSTANCE = new TypeFloat();
protected TypeFloat() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,50 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
import scala.Int;
public class TypeInt extends ValueType {
private final Int ZERO = RunTime.box_ivalue(0);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Int)
return o;
else if (o instanceof scala.Double)
return RunTime.box_ivalue((int)((scala.Double)o).value);
else if (o instanceof scala.Float)
return RunTime.box_ivalue((int)((scala.Float)o).value);
else if (o instanceof scala.Long)
return RunTime.box_ivalue((int)((scala.Long)o).value);
else if (o instanceof scala.Short)
return RunTime.box_ivalue(((scala.Short)o).value);
else if (o instanceof scala.Char)
return RunTime.box_ivalue(((scala.Char)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_ivalue(((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Integer.TYPE;
}
public String toString() { return "scala.Int"; }
public int hashCode() { return 0x44444444; }
// Make TypeInt a serializable singleton
public static TypeInt INSTANCE = new TypeInt();
protected TypeInt() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,49 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeLong extends ValueType {
private final scala.Long ZERO = RunTime.box_lvalue(0l);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Long)
return o;
else if (o instanceof scala.Double)
return RunTime.box_lvalue((long)((scala.Double)o).value);
else if (o instanceof scala.Float)
return RunTime.box_lvalue((long)((scala.Float)o).value);
else if (o instanceof scala.Int)
return RunTime.box_lvalue(((scala.Int)o).value);
else if (o instanceof scala.Short)
return RunTime.box_lvalue(((scala.Short)o).value);
else if (o instanceof scala.Char)
return RunTime.box_lvalue(((scala.Char)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_lvalue(((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Long.TYPE;
}
public String toString() { return "scala.Long"; }
public int hashCode() { return 0x33333333; }
// Make TypeLong a serializable singleton
public static TypeLong INSTANCE = new TypeLong();
protected TypeLong() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,49 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
public class TypeShort extends ValueType {
private final scala.Short ZERO = RunTime.box_svalue((short)0);
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (o == null || o instanceof scala.Short)
return o;
else if (o instanceof scala.Double)
return RunTime.box_svalue((short)((scala.Double)o).value);
else if (o instanceof scala.Float)
return RunTime.box_svalue((short)((scala.Float)o).value);
else if (o instanceof scala.Long)
return RunTime.box_svalue((short)((scala.Long)o).value);
else if (o instanceof scala.Int)
return RunTime.box_svalue((short)((scala.Int)o).value);
else if (o instanceof scala.Char)
return RunTime.box_svalue((short)((scala.Char)o).value);
else if (o instanceof scala.Byte)
return RunTime.box_svalue(((scala.Byte)o).value);
else
throw new ClassCastException();
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Short.TYPE;
}
public String toString() { return "scala.Short"; }
public int hashCode() { return 0x55555555; }
// Make TypeShort a serializable singleton
public static TypeShort INSTANCE = new TypeShort();
protected TypeShort() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,37 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.runtime.RunTime;
import scala.Type;
import scala.Array;
import scala.Unit;
public class TypeUnit extends ValueType {
private final Unit ZERO = RunTime.box_uvalue();
public Object cast(Object o) {
assert scala.runtime.types.Statistics.incTypeCast();
if (! (o == null || o instanceof scala.Unit))
throw new ClassCastException(); // TODO error message
return o;
}
public Object defaultValue() { return ZERO; }
public boolean isSameAsJavaType(Class that) {
return that == java.lang.Void.TYPE;
}
public String toString() { return "scala.Unit"; }
public int hashCode() { return 0x99999999; }
// Make TypeUnit a serializable singleton
public static TypeUnit INSTANCE = new TypeUnit();
protected TypeUnit() { /* exists only to that instantiation */ }
private Object readResolve() { return INSTANCE; }
}

View File

@ -1,38 +0,0 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.runtime.types;
import scala.Type;
import scala.Array;
/**
* Abstract superclass for all value types.
*
* @author Michel Schinz
* @version 1.0
*/
abstract public class ValueType extends Type {
public boolean isInstance(Object o) {
throw new UnsupportedOperationException();
}
public boolean isSubType(Type that) {
return that == Type.Any
|| that == Type.AnyVal
|| that == this;
}
public boolean isSameType(Type that) {
return this == that;
}
public Array newArray(int size) {
throw new Error("internal error (Scala runtime)");
}
}

Some files were not shown because too many files have changed in this diff Show More