├── oz ├── Rakefile ├── lib ├── x-oz │ └── system │ │ └── images ├── main │ ├── images │ │ ├── stop.xbm │ │ ├── mini-down.xbm │ │ ├── browserIcon.xbm │ │ ├── browserMIcon.xbm │ │ ├── mini-dec.xbm │ │ └── mini-inc.xbm │ ├── cp │ │ ├── Schedule.oz │ │ └── par │ │ │ ├── ParServer.oz │ │ │ ├── ParGetColor.oz │ │ │ └── ParFindLimit.oz │ ├── sp │ │ ├── EventSIGCHLD.oz │ │ ├── Guardian.oz │ │ ├── WeakPointer.oz │ │ ├── EventSIGUSR2.oz │ │ └── Timer.oz │ ├── dp │ │ └── DPStatistics.oz │ ├── base │ │ ├── Unit.oz │ │ ├── Literal.oz │ │ ├── SiteProperty.oz │ │ ├── Name.oz │ │ ├── ForeignPointer.oz │ │ ├── Chunk.oz │ │ ├── Procedure.oz │ │ ├── Cell.oz │ │ ├── Bool.oz │ │ ├── VirtualByteString.oz │ │ ├── Number.oz │ │ ├── Functor.oz │ │ ├── Exception.oz │ │ ├── Atom.oz │ │ ├── Tuple.oz │ │ ├── Port.oz │ │ └── Int.oz │ ├── ap │ │ ├── Custom.oz │ │ └── CustomGroup.oz │ ├── init │ │ └── ModuleAbstractions.oz │ └── support │ │ └── Listener.oz ├── tools │ ├── inspector │ │ └── images │ │ │ ├── depth.jpg │ │ │ ├── width.jpg │ │ │ ├── sep.xbm │ │ │ ├── depth.xbm │ │ │ ├── width.xbm │ │ │ └── stop.xbm │ ├── browser │ │ └── images │ │ │ └── stop.xbm │ └── panel │ │ ├── panel │ │ └── errors.oz │ │ └── Panel.oz └── compiler │ ├── WhileLoop.oz │ ├── Doc │ ├── StepPoints │ ├── Functor │ ├── SlowMeths │ └── FDCompare │ ├── ForNotes.txt │ ├── BackquoteMacro.oz │ ├── Abstractions.oz │ └── Compiler.oz ├── opi ├── emacs │ ├── windows │ │ ├── oz.rc │ │ ├── oz.ico │ │ ├── getenv.cc │ │ ├── path.cc │ │ ├── startup.hh │ │ ├── ppid.cc │ │ ├── registry.cc │ │ └── panic.cc │ ├── oz │ └── oz-extra.el ├── opi │ ├── .gitignore │ └── README.md └── README.md ├── bootcompiler ├── project │ ├── build.properties │ └── plugins.sbt ├── sbt-launch.jar ├── .gitignore ├── src │ └── main │ │ └── scala │ │ └── org │ │ └── mozartoz │ │ └── bootcompiler │ │ ├── BootCompilerOptions.scala │ │ ├── SourceInterface.scala │ │ ├── symtab │ │ ├── SystemModules.scala │ │ └── Builtin.scala │ │ ├── ParserToVM.scala │ │ ├── transform │ │ ├── VariableDeduplication.scala │ │ └── TransformUtils.scala │ │ ├── util │ │ ├── WrapperUtil.scala │ │ └── Counter.scala │ │ ├── fastparse │ │ └── Tokens.scala │ │ ├── ProgramBuilder.scala │ │ └── ast │ │ ├── UtilNodes.scala │ │ └── package.scala ├── sbt.bat ├── sbt └── build.sbt ├── tool ├── .rubocop.yml ├── cleanup-imports.rb ├── intellijinit.rb └── gen_builtins.rb ├── examples ├── panel.oz ├── hello.oz ├── exit.oz ├── backtrace.oz ├── browser.oz ├── fib.oz └── pingpong.oz ├── platform-test ├── dp │ ├── url.oz │ └── template.oz ├── fd │ ├── boundsdistinct.oz │ ├── safe.oz │ ├── grocery.oz │ ├── kalotan.oz │ ├── pythagoras.oz │ ├── fraction.oz │ ├── divmod.oz │ ├── change.oz │ ├── buildhouse.oz │ ├── hubert.oz │ └── family.oz ├── scheduling │ ├── enum.oz │ ├── order.oz │ └── resourceConstraints.oz ├── lib │ ├── passed.oz │ ├── failed.oz │ ├── help-bench.oz │ └── help-string.oz ├── bench │ ├── port.oz │ ├── rec.oz │ ├── fd.oz │ ├── compiler.oz │ └── tak.oz ├── README ├── base │ ├── gcsusplist.cc │ ├── smallbuf.cc │ ├── weakdictionaryGC.oz │ ├── proc.oz │ ├── gc2.oz │ ├── instruction.oz │ └── float.oz ├── debug │ └── gc.oz ├── dp-bench │ └── Makefile.in ├── fs │ ├── manuel.oz │ └── knapsack.oz └── test-opi.oz ├── .gitmodules ├── mx.mozart-graal ├── oz-native ├── native-image.properties └── mx_mozart_graal.py ├── vm ├── src │ └── org │ │ └── mozartoz │ │ └── truffle │ │ ├── runtime │ │ ├── OzValue.java │ │ ├── MutableInt.java │ │ ├── OzFuture.java │ │ ├── OnHeapSearchState.java │ │ ├── OzString.java │ │ ├── ArrayUtils.java │ │ ├── BoolLibraries.java │ │ ├── SelfTailCallException.java │ │ ├── OzChunk.java │ │ ├── AtomLibraries.java │ │ ├── OzReadOnly.java │ │ ├── Unit.java │ │ ├── OzPort.java │ │ ├── OzCell.java │ │ ├── TailCallException.java │ │ ├── Metrics.java │ │ ├── RecordFactory.java │ │ ├── SourceWrapper.java │ │ ├── DeoptimizingException.java │ │ ├── GetBacktraceException.java │ │ ├── OzFailedValue.java │ │ ├── OzName.java │ │ ├── OzVar.java │ │ ├── OzIO.java │ │ ├── OzArray.java │ │ ├── StacktraceThread.java │ │ ├── ExitException.java │ │ ├── OzObject.java │ │ ├── ParserToVMImpl.java │ │ ├── OzDict.java │ │ ├── GarbageCollectionNotifier.java │ │ ├── OzUniqueName.java │ │ ├── IdentityPair.java │ │ ├── OzRecord.java │ │ └── OzArguments.java │ │ ├── nodes │ │ ├── local │ │ │ ├── FrameSlotNode.java │ │ │ ├── WriteNode.java │ │ │ ├── InitializeVarNode.java │ │ │ ├── ReadLocalVariableNode.java │ │ │ ├── InitializeArgNode.java │ │ │ ├── InitializeTmpNode.java │ │ │ ├── WriteCapturedVariableNode.java │ │ │ ├── ResetSlotsNode.java │ │ │ └── CopyVariableToFrameNode.java │ │ ├── control │ │ │ ├── SkipNode.java │ │ │ ├── AndNode.java │ │ │ ├── OrElseNode.java │ │ │ ├── AndThenNode.java │ │ │ ├── NoElseNode.java │ │ │ ├── IfNode.java │ │ │ └── TryNode.java │ │ ├── call │ │ │ ├── CallableNode.java │ │ │ ├── GetThreadProcNode.java │ │ │ ├── ReadArgumentNode.java │ │ │ ├── TailCallThrowerNode.java │ │ │ └── SelfTailCallThrowerNode.java │ │ ├── literal │ │ │ ├── UnboundLiteralNode.java │ │ │ ├── LiteralNode.java │ │ │ ├── LongLiteralNode.java │ │ │ ├── BooleanLiteralNode.java │ │ │ ├── EnsureOzLiteralNode.java │ │ │ ├── ProcDeclarationNode.java │ │ │ ├── ListLiteralNode.java │ │ │ ├── ConsLiteralNode.java │ │ │ └── RecordLiteralNode.java │ │ ├── ExecuteValuesNode.java │ │ ├── RunMainNode.java │ │ ├── OzTypes.java │ │ ├── pattern │ │ │ ├── PatternMatchIdentityNode.java │ │ │ ├── PatternMatchConsNode.java │ │ │ ├── PatternMatchRecordNode.java │ │ │ ├── PatternMatchOpenRecordNode.java │ │ │ ├── PatternMatchDynamicArityNode.java │ │ │ └── PatternMatchEqualNode.java │ │ ├── builtins │ │ │ ├── ForeignPointerBuiltins.java │ │ │ ├── LiteralBuiltins.java │ │ │ ├── AtomBuiltins.java │ │ │ ├── ListBuiltins.java │ │ │ ├── WeakReferenceBuiltins.java │ │ │ ├── Builtin.java │ │ │ └── ChunkBuiltins.java │ │ ├── NodeHelpers.java │ │ └── DerefIfBoundNode.java │ │ └── translator │ │ ├── BuiltinsRegistry.java │ │ ├── Loader.java │ │ ├── ApplyFunctor.java │ │ └── FrameSlotAndDepth.java ├── pom.xml └── jvmci │ ├── Dockerfile │ └── README.md ├── .gitignore ├── bench ├── bench_map.oz ├── bench_add.oz ├── bench_flatten.oz └── harness.oz ├── .travis.yml ├── .idea └── libraries │ ├── sbt__com_lihaoyi_fastparse_2_11_0_3_7_jar.xml │ ├── sbt__com_lihaoyi_sourcecode_2_11_0_1_1_jar.xml │ ├── sbt__org_scala_lang_scala_reflect_2_11_7_jar.xml │ ├── sbt__com_lihaoyi_fastparse_utils_2_11_0_3_7_jar.xml │ └── sbt__org_scala_lang_scala_library_2_11_7_jar.xml ├── LICENSE.txt └── coro └── com.oracle.truffle.coro └── src └── com └── oracle └── truffle └── coro └── AsymRunnable.java /oz: -------------------------------------------------------------------------------- 1 | tool/ozlauncher.rb -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | load 'tool/tasks.rake' 2 | -------------------------------------------------------------------------------- /lib/x-oz/system/images: -------------------------------------------------------------------------------- 1 | ../../main/images -------------------------------------------------------------------------------- /opi/emacs/windows/oz.rc: -------------------------------------------------------------------------------- 1 | 101 ICON "oz.ico" 2 | -------------------------------------------------------------------------------- /bootcompiler/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.6 2 | -------------------------------------------------------------------------------- /lib/main/images/stop.xbm: -------------------------------------------------------------------------------- 1 | ../../tools/browser/images/stop.xbm -------------------------------------------------------------------------------- /tool/.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | DisabledByDefault: true 3 | -------------------------------------------------------------------------------- /lib/main/images/mini-down.xbm: -------------------------------------------------------------------------------- 1 | ../../../stdlib/wp/qtk/mini-down.xbm -------------------------------------------------------------------------------- /opi/opi/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | *.a 4 | /.kdev4/ 5 | build/ 6 | -------------------------------------------------------------------------------- /lib/main/images/browserIcon.xbm: -------------------------------------------------------------------------------- 1 | ../../tools/browser/images/browserIcon.xbm -------------------------------------------------------------------------------- /lib/main/images/browserMIcon.xbm: -------------------------------------------------------------------------------- 1 | ../../tools/browser/images/browserMIcon.xbm -------------------------------------------------------------------------------- /examples/panel.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Panel 4 | define 5 | {Panel.open} 6 | end 7 | -------------------------------------------------------------------------------- /lib/main/cp/Schedule.oz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/lib/main/cp/Schedule.oz -------------------------------------------------------------------------------- /opi/emacs/windows/oz.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/opi/emacs/windows/oz.ico -------------------------------------------------------------------------------- /platform-test/dp/url.oz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/platform-test/dp/url.oz -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "stdlib"] 2 | path = stdlib 3 | url = https://github.com/mozart/mozart2-stdlib.git 4 | -------------------------------------------------------------------------------- /bootcompiler/sbt-launch.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/bootcompiler/sbt-launch.jar -------------------------------------------------------------------------------- /examples/hello.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System(showInfo:Show) 4 | define 5 | {Show 'Hello World!'} 6 | end 7 | -------------------------------------------------------------------------------- /platform-test/fd/boundsdistinct.oz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/platform-test/fd/boundsdistinct.oz -------------------------------------------------------------------------------- /lib/tools/inspector/images/depth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/lib/tools/inspector/images/depth.jpg -------------------------------------------------------------------------------- /lib/tools/inspector/images/width.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eregon/mozart-graal/HEAD/lib/tools/inspector/images/width.jpg -------------------------------------------------------------------------------- /bootcompiler/.gitignore: -------------------------------------------------------------------------------- 1 | # sbt specific 2 | target/ 3 | lib_managed/ 4 | src_managed/ 5 | project/boot/ 6 | .cache 7 | /.cache-main 8 | -------------------------------------------------------------------------------- /bootcompiler/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.github.retronym" % "sbt-onejar" % "0.8") 2 | 3 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2") 4 | -------------------------------------------------------------------------------- /examples/exit.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System(showInfo:Show) 4 | Application 5 | define 6 | {Show 'Exiting ...'} 7 | {Application.exit 42} 8 | end 9 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/BootCompilerOptions.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | 3 | case class BootCompilerOptions(selfTailCalls: Boolean, frameFiltering: Boolean) 4 | -------------------------------------------------------------------------------- /lib/compiler/WhileLoop.oz: -------------------------------------------------------------------------------- 1 | functor 2 | export 3 | Compile 4 | define 5 | fun{Compile fWhile(COND BODY COORDS)} 6 | fFOR([forFeature(fAtom('while' unit) COND)] BODY COORDS) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /mx.mozart-graal/oz-native: -------------------------------------------------------------------------------- 1 | DYNAMIC_IMPORTS=/substratevm,/tools 2 | DISABLE_INSTALLABLES=true 3 | DISABLE_LIBPOLYGLOT=true 4 | DISABLE_POLYGLOT=true 5 | EXCLUDE_COMPONENTS=nju,ni,nil,gu,rgx,polynative,svml,vvm 6 | -------------------------------------------------------------------------------- /lib/main/sp/EventSIGCHLD.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import Process(handler:Handler) at 'x-oz://contrib/os/process.so{native}' 3 | export handler : SIGCHLD 4 | define 5 | proc {SIGCHLD E} 6 | {Handler} 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzValue.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.interop.TruffleObject; 4 | 5 | public class OzValue implements TruffleObject { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /bootcompiler/sbt.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SCRIPT_DIR=%~dp0 4 | java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M %JAVA_OPTS% -Dfile.encoding=UTF-8 -jar "%SCRIPT_DIR%sbt-launch.jar" %* 5 | -------------------------------------------------------------------------------- /bootcompiler/sbt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled \ 4 | -XX:MaxPermSize=384M ${JAVA_OPTS} -Dfile.encoding=UTF-8 \ 5 | -jar `dirname $0`/sbt-launch.jar "$@" 6 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/SourceInterface.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | 3 | trait SourceInterface { 4 | def getName(): String 5 | def getPath(): String 6 | def getCode(): String 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vm/jvmci/jdk-8u*-linux-x64.tar.gz 2 | /vm/src/org/mozartoz/truffle/reflection.json 3 | /mxbuild 4 | /graalvm 5 | 6 | *.pyc 7 | *.ozf 8 | 9 | /wish/ozwish 10 | 11 | /*.oz 12 | /Main.image 13 | 14 | /.idea 15 | *.iml 16 | -------------------------------------------------------------------------------- /examples/backtrace.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System(show:Show) 4 | define 5 | A=1 6 | B=A*2 7 | proc {Foo} 8 | A=B 9 | end 10 | fun {Bar} 11 | {Foo} 12 | 42 13 | end 14 | {Show {Bar}} 15 | end 16 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/FrameSlotNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import com.oracle.truffle.api.frame.FrameSlot; 4 | 5 | public interface FrameSlotNode { 6 | 7 | FrameSlot getSlot(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/MutableInt.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public final class MutableInt { 4 | 5 | public int value; 6 | 7 | public MutableInt(int value) { 8 | this.value = value; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/symtab/SystemModules.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | package symtab 3 | 4 | object SystemModules { 5 | /** Consider all functors as "system" modules */ 6 | def isSystemModule(module: String) = true 7 | } 8 | -------------------------------------------------------------------------------- /examples/browser.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Browser(browse:Browse) 4 | define 5 | {Browse 42} 6 | {Browse a(b:c d:[1 2 3])} 7 | 8 | S 9 | P={NewPort S} 10 | {Browse S} 11 | 12 | for I in 1..10 do 13 | {Delay 1000} 14 | {Send P I} 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /opi/README.md: -------------------------------------------------------------------------------- 1 | # Mozart-Oz v2 - OPI 2 | 3 | This is the Open Programming Interface (OPI) component of 4 | [Mozart2](https://github.com/mozart/mozart2), i.e., the IDE. 5 | 6 | Although it is possible to build this component separately, it is designed to be 7 | built as part of Mozart2, which see. 8 | -------------------------------------------------------------------------------- /lib/compiler/Doc/StepPoints: -------------------------------------------------------------------------------- 1 | Granul ::= fine 2 | | coarse 3 | | unknown. 4 | 5 | Kind ::= 'definition' 6 | | 'skip' 7 | | 'fail' 8 | | 'name generation' 9 | | 'call' 10 | | 'exception handler' 11 | | 'conditional' 12 | | 'thread' 13 | | 'lock'. 14 | -------------------------------------------------------------------------------- /lib/compiler/Doc/Functor: -------------------------------------------------------------------------------- 1 | Functor = chunk(apply: procedure/2 2 | 'import': 'import'(Name: Info ...) 3 | 'export': 'export'(Name: Type ...)). 4 | Info = info(type: Type 5 | 'from': value). % optional 6 | Type = [Feature] 7 | | atom. 8 | Feature = int 9 | | literal. 10 | -------------------------------------------------------------------------------- /mx.mozart-graal/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = -H:MaxRuntimeCompileMethods=350 \ 2 | -H:ReflectionConfigurationResources=org/mozartoz/truffle/reflection.json \ 3 | -H:+AllowVMInspection \ 4 | --initialize-at-build-time 5 | 6 | # -H:+RuntimeAssertions 7 | 8 | JavaArgs = -Dpolyglot.engine.PreinitializeContexts=oz 9 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzFuture.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzFuture extends Variable { 4 | 5 | @Override 6 | public String toString() { 7 | if (isBound()) { 8 | return "_<" + getBoundValue(null) + ">"; 9 | } else { 10 | return "_"; 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bench/bench_map.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Application 4 | Harness(bench:Bench) at 'harness.ozf' 5 | define 6 | `$N`=1000000 7 | 8 | fun {BenchMap Xs} 9 | {Map Xs fun {$ X} X * 11 end} 10 | end 11 | 12 | L={List.number 1 `$N` 1} 13 | 14 | {Bench fun {$} {BenchMap L} end} 15 | 16 | {Application.exit 0} 17 | end 18 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/ParserToVM.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | 3 | import org.mozartoz.bootcompiler.BootCompiler.Source 4 | import org.mozartoz.bootcompiler.ast.Node.Pos 5 | 6 | trait ParserToVM { 7 | def createSource(path: String): Source 8 | def sectionFileLine(section: Pos): String 9 | } 10 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/WriteNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import com.oracle.truffle.api.frame.VirtualFrame; 4 | import com.oracle.truffle.api.nodes.NodeInterface; 5 | 6 | public interface WriteNode extends NodeInterface { 7 | 8 | public void write(VirtualFrame topFrame, Object value); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /platform-test/scheduling/enum.oz: -------------------------------------------------------------------------------- 1 | %%% Programming Systems Lab, DFKI Saarbruecken, 2 | %%% Stuhlsatzenhausweg 3, D-66123 Saarbruecken, Phone (+49) 681 302-5312 3 | %%% Author: Joerg Wuertz 4 | %%% Email: wuertz@dfki.uni-sb.de 5 | %%% Last modified: $Date$ by $Author$ 6 | %%% Version: $Revision$ 7 | 8 | proc {NoTE Start Dur ET} 9 | skip 10 | end 11 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/SkipNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.VirtualFrame; 6 | 7 | public class SkipNode extends OzNode { 8 | @Override 9 | public Object execute(VirtualFrame frame) { 10 | return unit; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bench/bench_add.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Application 4 | Harness(bench:Bench) at 'harness.ozf' 5 | define 6 | `$N`=2000000 7 | 8 | fun {BenchAdd A B} 9 | if A==0 then 10 | B 11 | else 12 | {Add A-1 B+1} 13 | end 14 | end 15 | 16 | {Bench fun {$} {BenchAdd `$N` 0} end} 17 | 18 | {Application.exit 0} 19 | end 20 | -------------------------------------------------------------------------------- /platform-test/lib/passed.oz: -------------------------------------------------------------------------------- 1 | 'xxxxxx\n' # 2 | 'x x xx xxxx xxxx xxxxxx xxxxx\n' # 3 | 'x x x x x x x x x\n' # 4 | 'xxxxxx x x xxxx xxxx xxxxx x x\n' # 5 | 'x xxxxxx x x x x x\n' # 6 | 'x x x x x x x x x x\n' # 7 | 'x x x xxxx xxxx xxxxxx xxxxx\n' 8 | -------------------------------------------------------------------------------- /platform-test/bench/port.oz: -------------------------------------------------------------------------------- 1 | functor 2 | export Return 3 | define 4 | Iterations = 1000000 5 | proc {Producer P N} 6 | if N>0 then {Port.send P unit} {Producer P N-1} end 7 | end 8 | proc {PortBench} 9 | {Producer {Port.new _} Iterations} 10 | end 11 | Return = port(PortBench 12 | keys:[port] 13 | bench:1) 14 | end 15 | -------------------------------------------------------------------------------- /platform-test/lib/failed.oz: -------------------------------------------------------------------------------- 1 | 'ooooooo\n' # 2 | 'o oo o o oooooo ooooo\n' # 3 | 'o o o o o o o o\n' # 4 | 'ooooo o o o o ooooo o o\n' # 5 | 'o oooooo o o o o o\n' # 6 | 'o o o o o o o o\n' # 7 | 'o o o o oooooo oooooo ooooo\n' 8 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/call/CallableNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.call; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.VirtualFrame; 6 | 7 | public abstract class CallableNode extends OzNode { 8 | 9 | public abstract Object executeCall(VirtualFrame frame, Object receiver, Object[] arguments); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OnHeapSearchState.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.util.HashSet; 4 | import java.util.LinkedList; 5 | 6 | public class OnHeapSearchState { 7 | 8 | public boolean root = true; 9 | public HashSet encountered = new HashSet<>(); 10 | public LinkedList toExplore = new LinkedList<>(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/main/sp/Guardian.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import WD(new put) at 'x-oz://boot/WeakDictionary' 3 | export 'class' : Guardian 4 | define 5 | class Guardian 6 | attr Table 7 | meth init(Proc) L in 8 | Table <- {WD.new L} 9 | thread {ForAll L Proc} end 10 | end 11 | meth register(V) 12 | {WD.put @Table {NewName} V} 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /platform-test/scheduling/order.oz: -------------------------------------------------------------------------------- 1 | %%% Programming Systems Lab, DFKI Saarbruecken, 2 | %%% Stuhlsatzenhausweg 3, D-66123 Saarbruecken, Phone (+49) 681 302-5312 3 | %%% Author: Joerg Wuertz 4 | %%% Email: wuertz@dfki.uni-sb.de 5 | %%% Last modified: $Date$ by $Author$ 6 | %%% Version: $Revision$ 7 | 8 | proc {CanonicOrder Old New} 9 | Old.start.pe >: New.start.pe 10 | {Trace Old.start.pe} 11 | end 12 | -------------------------------------------------------------------------------- /vm/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.mozartoz.truffle 4 | mozart-truffle 5 | 1 6 | 7 | 8 | com.esotericsoftware 9 | kryo 10 | 3.0.3 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bootcompiler/build.sbt: -------------------------------------------------------------------------------- 1 | name := "bootcompiler" 2 | 3 | version := "2.0-SNAPSHOT" 4 | 5 | scalaVersion := "2.11.7" 6 | 7 | scalacOptions ++= Seq("-deprecation", "-optimize") 8 | 9 | libraryDependencies += "com.lihaoyi" %% "fastparse" % "0.3.7" 10 | 11 | // native-image needs it 12 | libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value 13 | 14 | seq(com.github.retronym.SbtOneJar.oneJarSettings: _*) 15 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzString.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzString extends OzValue { 4 | 5 | private final String chars; 6 | 7 | public OzString(String chars) { 8 | this.chars = chars; 9 | } 10 | 11 | public String getChars() { 12 | return chars; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return ""; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /platform-test/README: -------------------------------------------------------------------------------- 1 | Quick instructions for testing your mozart installation. 2 | 3 | From /share/test: 4 | 5 | make boot-all - Builds all tests with the compiler in 6 | make boot-check - Runs all tests (except dp) with the emulator in 7 | 8 | You can also run oztest and ozbench with the oz from your path/OZ_HOME. Run 9 | 10 | oztest -h 11 | ozbench -h 12 | 13 | for lots of options. 14 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class ArrayUtils { 4 | 5 | public static final Object[] EMPTY = new Object[0]; 6 | 7 | public static Object[] unshift(Object value, Object[] array) { 8 | Object[] result = new Object[1 + array.length]; 9 | result[0] = value; 10 | System.arraycopy(array, 0, result, 1, array.length); 11 | return result; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/BoolLibraries.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.library.ExportLibrary; 4 | import com.oracle.truffle.api.library.ExportMessage; 5 | 6 | @ExportLibrary(value = RecordLibrary.class, receiverType = Boolean.class) 7 | public final class BoolLibraries { 8 | 9 | @ExportMessage 10 | static boolean isLiteral(Boolean bool) { 11 | return true; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/UnboundLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzVar; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | 8 | public class UnboundLiteralNode extends OzNode { 9 | 10 | @Override 11 | public Object execute(VirtualFrame frame) { 12 | return new OzVar(getSourceSection()); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/SelfTailCallException.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.nodes.ControlFlowException; 4 | 5 | public class SelfTailCallException extends ControlFlowException { 6 | 7 | private static final long serialVersionUID = -6432472909387052509L; 8 | public static final SelfTailCallException INSTANCE = new SelfTailCallException(); 9 | 10 | private SelfTailCallException() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/transform/VariableDeduplication.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler.transform 2 | 3 | import org.mozartoz.bootcompiler.ast._ 4 | 5 | object VariableDeduplication extends Transformer with TreeDSL { 6 | override def transformExpr(expression: Expression) = expression match { 7 | case v @ Variable(sym) => 8 | treeCopy.Variable(v, sym) 9 | 10 | case _ => super.transformExpr(expression) 11 | } 12 | } -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/call/GetThreadProcNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.call; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzThread; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | 8 | public class GetThreadProcNode extends OzNode { 9 | 10 | @Override 11 | public Object execute(VirtualFrame frame) { 12 | return OzThread.getCurrent().getAndClearInitialProc(); 13 | } 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /lib/tools/inspector/images/sep.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Mozart, an implementation of Oz 3: 3 | * http://www.mozart-oz.org 4 | * 5 | * See the file "LICENSE" or 6 | * http://www.mozart-oz.org/LICENSE.html 7 | * for information on usage and redistribution 8 | * of this file, and for a DISCLAIMER OF ALL 9 | * WARRANTIES. 10 | * 11 | */ 12 | 13 | #define sep.xbm_width 16 14 | #define sep.xbm_height 1 15 | static unsigned char sep.xbm_bits[] = { 16 | 0x11, 0x11}; 17 | -------------------------------------------------------------------------------- /lib/main/images/mini-dec.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * Programming Systems Lab, DFKI Saarbruecken, 3 | * Stuhlsatzenhausweg 3, D-66123 Saarbruecken, Phone (+49) 681 302-5312 4 | * Author: Christian Schulte 5 | * Email: schulte@dfki.uni-sb.de 6 | * Last modified: $Date$ by $Author$ 7 | * Version: $Revision$ 8 | */ 9 | 10 | #define mini-dec_width 10 11 | #define mini-dec_height 5 12 | static unsigned char mini-dec_bits[] = { 13 | 0x00, 0x00, 0xfc, 0x03, 0xf8, 0x01, 0xf0, 0x00, 0x60, 0x00}; 14 | -------------------------------------------------------------------------------- /lib/main/images/mini-inc.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * Programming Systems Lab, DFKI Saarbruecken, 3 | * Stuhlsatzenhausweg 3, D-66123 Saarbruecken, Phone (+49) 681 302-5312 4 | * Author: Christian Schulte 5 | * Email: schulte@dfki.uni-sb.de 6 | * Last modified: $Date$ by $Author$ 7 | * Version: $Revision$ 8 | */ 9 | 10 | #define mini-inc_width 10 11 | #define mini-inc_height 5 12 | static unsigned char mini-inc_bits[] = { 13 | 0x00, 0x00, 0x60, 0x00, 0xf0, 0x00, 0xf8, 0x01, 0xfc, 0x03}; 14 | -------------------------------------------------------------------------------- /vm/jvmci/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM buildpack-deps:jessie 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | libasound2-dev \ 4 | libcups2-dev \ 5 | libxtst-dev \ 6 | unzip \ 7 | zip \ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | RUN useradd -m mozart 11 | USER mozart 12 | WORKDIR /home/mozart 13 | ENV PATH /home/mozart/mx:$PATH 14 | ADD jdk-8u121-linux-x64.tar.gz . 15 | ENV JAVA_HOME /home/mozart/jdk1.8.0_121 16 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/LiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.VirtualFrame; 6 | 7 | public class LiteralNode extends OzNode { 8 | 9 | private final Object value; 10 | 11 | public LiteralNode(Object value) { 12 | this.value = value; 13 | } 14 | 15 | @Override 16 | public Object execute(VirtualFrame frame) { 17 | return value; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | jdk: 4 | - oraclejdk8 5 | rvm: 6 | - 2.2.2 7 | install: 8 | - rake build 9 | script: 10 | - ./oz 11 | - rake checkstyle 12 | cache: 13 | directories: 14 | - $HOME/.mx/cache 15 | - $HOME/.m2/repository 16 | - $HOME/.ivy2/cache 17 | - $HOME/.sbt/boot 18 | before_cache: 19 | # Tricks to avoid unnecessary cache updates 20 | - find $HOME/.ivy2 -name "ivydata-*.properties" -delete 21 | - find $HOME/.sbt -name "*.lock" -delete 22 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/LongLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.VirtualFrame; 6 | 7 | public class LongLiteralNode extends OzNode { 8 | 9 | private final long value; 10 | 11 | public LongLiteralNode(long value) { 12 | this.value = value; 13 | } 14 | 15 | @Override 16 | public Object execute(VirtualFrame frame) { 17 | return value; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /examples/fib.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System(showInfo:Show) 4 | Boot_Time at 'x-oz://boot/Time' 5 | define 6 | fun {Fib N} 7 | if N =< 1 then 8 | N 9 | else 10 | {Fib N-1} + {Fib N-2} 11 | end 12 | end 13 | 14 | for I in 1..10 do 15 | local 16 | T0={Boot_Time.getMonotonicTime} 17 | {Show {Fib 30}} 18 | T1={Boot_Time.getMonotonicTime} 19 | in 20 | {Show (T1-T0) div 1000000} 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /.idea/libraries/sbt__com_lihaoyi_fastparse_2_11_0_3_7_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/ExecuteValuesNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes; 2 | 3 | import com.oracle.truffle.api.frame.VirtualFrame; 4 | 5 | public class ExecuteValuesNode extends OzNode { 6 | 7 | @Children final OzNode[] valuesNodes; 8 | 9 | public ExecuteValuesNode(OzNode[] valuesNodes) { 10 | this.valuesNodes = valuesNodes; 11 | } 12 | 13 | @Override 14 | public Object[] execute(VirtualFrame frame) { 15 | return NodeHelpers.executeValues(frame, valuesNodes); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /.idea/libraries/sbt__com_lihaoyi_sourcecode_2_11_0_1_1_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/BooleanLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.VirtualFrame; 6 | 7 | public class BooleanLiteralNode extends OzNode { 8 | 9 | private final boolean value; 10 | 11 | public BooleanLiteralNode(boolean value) { 12 | this.value = value; 13 | } 14 | 15 | @Override 16 | public Object execute(VirtualFrame frame) { 17 | return value; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.idea/libraries/sbt__org_scala_lang_scala_reflect_2_11_7_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzChunk.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.object.DynamicObject; 4 | 5 | public class OzChunk extends OzValue { 6 | 7 | private final DynamicObject underlying; 8 | 9 | public OzChunk(DynamicObject underlying) { 10 | this.underlying = underlying; 11 | } 12 | 13 | public DynamicObject getUnderlying() { 14 | return underlying; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return ""; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/AtomLibraries.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.library.ExportLibrary; 4 | import com.oracle.truffle.api.library.ExportMessage; 5 | import org.mozartoz.truffle.nodes.OzGuards; 6 | 7 | @ExportLibrary(value = RecordLibrary.class, receiverType = String.class) 8 | public final class AtomLibraries { 9 | 10 | @ExportMessage 11 | static boolean isLiteral(String atom) { 12 | assert OzGuards.isInterned(atom); 13 | return true; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzReadOnly.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzReadOnly extends Variable { 4 | 5 | public OzReadOnly(Variable variable) { 6 | link(variable); 7 | } 8 | 9 | @Override 10 | public void bind(Object value) { 11 | throw new UnsupportedOperationException(); 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | if (isBound()) { 17 | return "_<" + getBoundValue(null) + ">"; 18 | } else { 19 | return "_"; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /.idea/libraries/sbt__com_lihaoyi_fastparse_utils_2_11_0_3_7_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/Unit.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.library.ExportLibrary; 4 | import com.oracle.truffle.api.library.ExportMessage; 5 | 6 | @ExportLibrary(RecordLibrary.class) 7 | public class Unit extends OzValue { 8 | 9 | public static final Unit INSTANCE = new Unit(); 10 | 11 | private Unit() { 12 | } 13 | 14 | @ExportMessage 15 | boolean isLiteral() { 16 | return true; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "unit"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /lib/main/sp/WeakPointer.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import WD at 'x-oz://boot/WeakDictionary' 3 | export 4 | make : MakeWeakPointer 5 | is : IsWeakPointer 6 | deref : DerefWeakPointer 7 | define 8 | Table = {WD.new _} {WD.close Table} 9 | Tag = {NewName} 10 | fun {MakeWeakPointer V} 11 | N = {NewName} 12 | in 13 | {WD.put Table N V} 14 | {Chunk.new weakPointer(Tag:N)} 15 | end 16 | fun {IsWeakPointer X} 17 | {HasFeature X Tag} 18 | end 19 | fun {DerefWeakPointer X} 20 | {WD.get Table X.Tag} 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/RunMainNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes; 2 | 3 | import com.oracle.truffle.api.frame.VirtualFrame; 4 | import com.oracle.truffle.api.source.Source; 5 | import org.mozartoz.truffle.runtime.OzLanguage; 6 | 7 | public class RunMainNode extends OzNode { 8 | 9 | final Source source; 10 | 11 | public RunMainNode(Source source) { 12 | this.source = source; 13 | } 14 | 15 | @Override 16 | public Object execute(VirtualFrame frame) { 17 | OzLanguage.getContext().run(source); 18 | return unit; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /examples/pingpong.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import System 3 | define 4 | S = pong|_ 5 | 6 | proc {Ping S I} 7 | case S of pong|A then 8 | A = ping|_ 9 | {Ping A.2 I+1} 10 | end 11 | end 12 | 13 | proc {Pong S I} 14 | case S of ping|A then 15 | A = pong|_ 16 | if I mod 1000 == 0 then 17 | {System.showInfo I} 18 | end 19 | {Pong A.2 I+1} 20 | end 21 | end 22 | 23 | thread {Ping S 0} end 24 | thread {Pong S.2 1} end 25 | 26 | {Wait _} 27 | end 28 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/OzTypes.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes; 2 | 3 | import java.math.BigInteger; 4 | 5 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 6 | import com.oracle.truffle.api.dsl.ImplicitCast; 7 | import com.oracle.truffle.api.dsl.TypeSystem; 8 | 9 | @TypeSystem({ long.class, BigInteger.class, Object[].class }) 10 | public abstract class OzTypes { 11 | 12 | @ImplicitCast 13 | @TruffleBoundary 14 | public static BigInteger castBigInteger(long value) { 15 | return BigInteger.valueOf(value); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzPort.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzPort extends OzValue { 4 | 5 | private OzFuture stream; 6 | 7 | public OzPort(OzVar streamVar) { 8 | this.stream = new OzFuture(); 9 | streamVar.link(stream); 10 | } 11 | 12 | public void send(Object value) { 13 | OzFuture newTail = new OzFuture(); 14 | OzCons cons = new OzCons(value, newTail); 15 | stream.bind(cons); 16 | stream = newTail; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return ""; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/util/WrapperUtil.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler.util 2 | 3 | import org.mozartoz.bootcompiler.ast._ 4 | 5 | object WrapperUtil { 6 | def getInnerExpr(expression: Expression): Expression = expression match { 7 | case ClearVarsExpression(expr, _, _) => 8 | expr 9 | 10 | case _ => expression 11 | } 12 | 13 | def getInnerStat(statement: Statement): Statement = statement match { 14 | case ClearVarsStatement(stat, _, _) => 15 | stat 16 | 17 | case _ => statement 18 | } 19 | } -------------------------------------------------------------------------------- /lib/main/dp/DPStatistics.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Glue at 'x-oz://boot/Glue' 4 | export 5 | SiteStatistics 6 | GetTablesInfo 7 | GetNetInfo 8 | PerdioStatistics 9 | CreateLogFile 10 | MessageCounter 11 | define 12 | %% 13 | %% Force linking of base library 14 | %% 15 | {Wait Glue} 16 | 17 | SiteStatistics=Glue.siteStatistics 18 | GetTablesInfo=Glue.getTablesInfo 19 | GetNetInfo=Glue.getNetInfo 20 | PerdioStatistics=Glue.perdioStatistics 21 | 22 | CreateLogFile = Glue.createLogFile 23 | MessageCounter = Glue.getMsgCntr 24 | end 25 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/call/ReadArgumentNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.call; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzArguments; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | 8 | public class ReadArgumentNode extends OzNode { 9 | 10 | private final int index; 11 | 12 | public ReadArgumentNode(int index) { 13 | this.index = index; 14 | } 15 | 16 | @Override 17 | public Object execute(VirtualFrame frame) { 18 | return OzArguments.getArgument(frame, index); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/translator/BuiltinsRegistry.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.translator; 2 | 3 | import org.mozartoz.bootcompiler.symtab.Builtin; 4 | import org.mozartoz.bootcompiler.symtab.Builtins; 5 | 6 | public class BuiltinsRegistry { 7 | 8 | private static final Builtins BUILTINS = new Builtins(); 9 | 10 | public static void register(String moduleName, String builtinName, int arity) { 11 | BUILTINS.register(Builtin.create(moduleName, builtinName, arity)); 12 | } 13 | 14 | public static Builtins getBuiltins() { 15 | return BUILTINS; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tool/cleanup-imports.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # You can call this from .git/hooks/pre-commit with 4 | # exec tool/cleanup-imports.rb 5 | 6 | STDERR.puts "Removing unused imports ..." 7 | 8 | output = `rake checkstyle 2>&1` 9 | status = $? 10 | 11 | output.lines.reverse.grep(/: Unused import -/) do |line| 12 | path, lineno, _ = line.split(':', 3) 13 | lineno = Integer(lineno) 14 | 15 | lines = File.readlines path 16 | lines.delete_at(lineno-1) 17 | File.write path, lines.join 18 | end 19 | 20 | unless status.success? 21 | STDERR.puts output 22 | exit status.exitstatus 23 | end 24 | -------------------------------------------------------------------------------- /lib/tools/inspector/images/depth.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Mozart, an implementation of Oz 3: 3 | * http://www.mozart-oz.org 4 | * 5 | * See the file "LICENSE" or 6 | * http://www.mozart-oz.org/LICENSE.html 7 | * for information on usage and redistribution 8 | * of this file, and for a DISCLAIMER OF ALL 9 | * WARRANTIES. 10 | * 11 | */ 12 | 13 | #define depth.xbm_width 13 14 | #define depth.xbm_height 13 15 | static char depth.xbm_bits[] = { 16 | 0x00,0x00,0xe0,0x01,0xe0,0x01,0xe0,0x01,0xe0,0x01,0xe0,0x01,0xe0,0x01,0xfe, 17 | 0x1f,0xfc,0x0f,0xf0,0x03,0xe0,0x01,0xe0,0x01,0xc0,0x00}; 18 | -------------------------------------------------------------------------------- /lib/tools/inspector/images/width.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Mozart, an implementation of Oz 3: 3 | * http://www.mozart-oz.org 4 | * 5 | * See the file "LICENSE" or 6 | * http://www.mozart-oz.org/LICENSE.html 7 | * for information on usage and redistribution 8 | * of this file, and for a DISCLAIMER OF ALL 9 | * WARRANTIES. 10 | * 11 | */ 12 | 13 | #define width.xbm_width 13 14 | #define width.xbm__height 13 15 | static char width.xbm_bits[] = { 16 | 0x00,0x00,0x80,0x00,0x80,0x01,0x80,0x01,0x80,0x03,0xfe,0x0f,0xfe,0x1f,0xfe, 17 | 0x1f,0xfe,0x0f,0x80,0x03,0x80,0x01,0x80,0x01,0x80,0x00}; 18 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/fastparse/Tokens.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler.fastparse 2 | 3 | object Tokens { 4 | abstract class Token { 5 | var pB: Int = -1 6 | var pE: Int = -1 7 | 8 | def setPos(pB: Int, pE: Int): this.type = { 9 | this.pB = pB 10 | this.pE = pE 11 | this 12 | } 13 | } 14 | 15 | case class PreprocessorSwitch(switch: String, value: Boolean) extends Token 16 | case class PreprocessorDirective(directive: String) extends Token 17 | case class PreprocessorDirectiveWithArg(directive: String, arg: String) extends Token 18 | } 19 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzCell.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzCell extends OzValue { 4 | 5 | Object value; 6 | 7 | public OzCell(Object value) { 8 | this.value = value; 9 | } 10 | 11 | public Object getValue() { 12 | return value; 13 | } 14 | 15 | public void setValue(Object value) { 16 | this.value = value; 17 | } 18 | 19 | public Object exchange(Object newValue) { 20 | Object oldValue = value; 21 | value = newValue; 22 | return oldValue; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return ""; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /lib/tools/browser/images/stop.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * Programming Systems Lab, DFKI Saarbruecken, 3 | * Stuhlsatzenhausweg 3, D-66123 Saarbruecken, Phone (+49) 681 302-5312 4 | * Author: Christian Schulte 5 | * Email: schulte@dfki.uni-sb.de 6 | * Last modified: $Date$ by $Author$ 7 | * Version: $Revision$ 8 | */ 9 | 10 | #define stop.xbm_width 16 11 | #define stop.xbm_height 16 12 | static unsigned char stop.xbm_bits[] = { 13 | 0xf0, 0x0f, 0x18, 0x18, 0xec, 0x37, 0xf6, 0x6f, 0xfb, 0xdf, 0xfd, 0xbf, 14 | 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfb, 0xdf, 15 | 0xf6, 0x6f, 0xec, 0x37, 0x18, 0x18, 0xf0, 0x0f}; 16 | -------------------------------------------------------------------------------- /platform-test/base/gcsusplist.cc: -------------------------------------------------------------------------------- 1 | #include "var_base.hh" 2 | #include "susplist.hh" 3 | #include "tagged.hh" 4 | 5 | OZ_BI_define(BIsusplistLength,1,1) 6 | { 7 | OZ_declareTerm(0,v); 8 | v = OZ_deref(v); 9 | int n = 0; 10 | if (OZ_isVariable(v)) { 11 | for (SuspList * s = tagged2Var(v)->getSuspList(); 12 | s!=NULL; 13 | s=s->getNext()) 14 | { n += 1; } 15 | } 16 | OZ_RETURN_INT(n); 17 | } 18 | OZ_BI_end 19 | 20 | OZ_C_proc_interface * oz_init_module(void) 21 | { 22 | static OZ_C_proc_interface table[] ={ 23 | {"susplistLength",1,1,BIsusplistLength}, 24 | {0,0,0,0} 25 | }; 26 | return table; 27 | } 28 | -------------------------------------------------------------------------------- /platform-test/base/smallbuf.cc: -------------------------------------------------------------------------------- 1 | #include "mozart.h" 2 | #include 3 | #ifdef __MINGW32__ 4 | extern "C" { 5 | #include 6 | } 7 | #else 8 | #include 9 | #endif 10 | 11 | OZ_BI_define(BI_smallbuf,2,0) 12 | { 13 | OZ_declareInt(0,fd); 14 | OZ_declareInt(1,size); 15 | setsockopt(fd,SOL_SOCKET,SO_SNDBUF,(char*)&size,1); 16 | return PROCEED; 17 | } OZ_BI_end 18 | 19 | extern "C" 20 | { 21 | OZ_C_proc_interface * oz_init_module(void) 22 | { 23 | static OZ_C_proc_interface i_table[] = { 24 | {"smallbuf",2,0,BI_smallbuf}, 25 | {0,0,0,0} 26 | }; 27 | return i_table; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/TailCallException.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; 4 | import com.oracle.truffle.api.nodes.ControlFlowException; 5 | 6 | public class TailCallException extends ControlFlowException { 7 | 8 | private static final long serialVersionUID = -6432472909387052509L; 9 | 10 | public final Object receiver; 11 | public @CompilationFinal(dimensions = 1) final Object[] arguments; 12 | 13 | public TailCallException(Object receiver, Object[] arguments) { 14 | this.receiver = receiver; 15 | this.arguments = arguments; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /lib/main/sp/EventSIGUSR2.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import VS(handler:Handler) at 'x-oz://boot/VirtualSite' 3 | export handler : SIGUSR2 4 | define 5 | Synch = {NewCell _} 6 | proc {SIGUSR2 E} 7 | {Exchange Synch unit _} 8 | end 9 | thread 10 | This = {Thread.this} 11 | proc {Loop} 12 | %% look it up now to avoid race condition 13 | %% since it may become bound concurrently 14 | More = {Access Synch} 15 | in 16 | if {Handler} then {Thread.preempt This} 17 | else {Wait More} end 18 | {Loop} 19 | end 20 | in 21 | {Thread.setPriority This 'high'} 22 | {Loop} 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/Metrics.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import org.mozartoz.truffle.Options; 4 | 5 | public class Metrics { 6 | 7 | private static long last = System.currentTimeMillis(); 8 | 9 | public static void reset() { 10 | last = System.currentTimeMillis(); 11 | } 12 | 13 | public static void tick(String desc) { 14 | if (OzLanguage.getOptions().get(Options.MEASURE_STARTUP)) { 15 | long now = System.currentTimeMillis(); 16 | long duration = now - last; 17 | if (duration > 5) { 18 | System.out.println(String.format("%4d", duration) + " " + desc); 19 | } 20 | last = now; 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/RecordFactory.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.object.DynamicObject; 4 | import com.oracle.truffle.api.object.DynamicObjectFactory; 5 | 6 | public class RecordFactory { 7 | 8 | private final Object label; 9 | private final DynamicObjectFactory factory; 10 | 11 | RecordFactory(Object label, DynamicObjectFactory factory) { 12 | this.label = label; 13 | this.factory = factory; 14 | } 15 | 16 | public DynamicObject newRecord(Object... values) { 17 | Object[] initialValues = ArrayUtils.unshift(label, values); 18 | return factory.newInstance(initialValues); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /lib/main/base/Unit.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1997 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | 24 | %% 25 | %% Module 26 | %% 27 | Unit = 'unit'(is: IsUnit 28 | 'unit': unit) 29 | -------------------------------------------------------------------------------- /lib/tools/inspector/images/stop.xbm: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Mozart, an implementation of Oz 3: 3 | * http://www.mozart-oz.org 4 | * 5 | * See the file "LICENSE" or 6 | * http://www.mozart-oz.org/LICENSE.html 7 | * for information on usage and redistribution 8 | * of this file, and for a DISCLAIMER OF ALL 9 | * WARRANTIES. 10 | * 11 | */ 12 | 13 | #define stop.xbm_width 16 14 | #define stop.xbm_height 16 15 | static unsigned char stop.xbm_bits[] = { 16 | 0xf0, 0x0f, 0x18, 0x18, 0xec, 0x37, 0xf6, 0x6f, 0xfb, 0xdf, 0xfd, 0xbf, 17 | 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfd, 0xbf, 0xfb, 0xdf, 18 | 0xf6, 0x6f, 0xec, 0x37, 0x18, 0x18, 0xf0, 0x0f}; 19 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/util/Counter.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | package util 3 | 4 | /** Simple counter for generating unique IDs 5 | * 6 | * @constructor creates a new counter with a given initial value 7 | * @param start first value that will be returned by `next()` 8 | */ 9 | class Counter(start: Int = 1) { 10 | private var _last = start-1 11 | 12 | /** Returns the next generated ID. 13 | * 14 | * The first time it is called it returns `start`. Subsequent calls return 15 | * monotonically increasing values, if wrapping is not an issue. 16 | */ 17 | def next() = { 18 | _last += 1 19 | _last 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/SourceWrapper.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.source.Source; 4 | import org.mozartoz.bootcompiler.SourceInterface; 5 | 6 | public class SourceWrapper implements SourceInterface { 7 | 8 | public final Source source; 9 | 10 | public SourceWrapper(Source source) { 11 | this.source = source; 12 | } 13 | 14 | @Override 15 | public String getName() { 16 | return source.getName(); 17 | } 18 | 19 | @Override 20 | public String getPath() { 21 | return source.getPath(); 22 | } 23 | 24 | @Override 25 | public String getCode() { 26 | return source.getCharacters().toString(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/compiler/ForNotes.txt: -------------------------------------------------------------------------------- 1 | for DECL* do STMT+ end 2 | 3 | DECL ::= ATOM : PATTERN 4 | | PATTERN in EXPR;EXPR;EXPR 5 | 6 | %%% STATEMENT 7 | 8 | CONTINUE = {NewName} 9 | BREAK = {NewName} % need new names for different loops 10 | RETURN = {NewName} 11 | 12 | proc {LoopBody Pat1 ... PatN} 13 | if Test1 andthen ... andthen TestN then 14 | try STMTS catch !CONTINUE then skip end 15 | {LoopBody Next1 ... NextN} 16 | else skip end 17 | end 18 | 19 | try {LoopBody Init1 ... InitN} 20 | catch !BREAK then skip end 21 | 22 | %%% EXPRESSION 23 | 24 | try 25 | try {LoopBody Init1 ... InitN} 26 | catch !BREAK then skip end 27 | VALUE_OF_ACCU 28 | catch !RETURN|V then V end 29 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/EnsureOzLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzGuards; 5 | import org.mozartoz.truffle.nodes.OzNode; 6 | 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | 9 | public class EnsureOzLiteralNode extends OzNode { 10 | 11 | @Child OzNode child; 12 | 13 | public EnsureOzLiteralNode(OzNode child) { 14 | this.child = DerefNode.create(child); 15 | } 16 | 17 | @Override 18 | public Object execute(VirtualFrame frame) { 19 | Object value = child.execute(frame); 20 | assert OzGuards.isLiteral(value); 21 | return value; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/DeoptimizingException.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | /** 4 | * Stacktraceless exception for triggering deoptimization manually. 5 | * SlowPathException cannot be used because it is a checked Exception. 6 | */ 7 | public final class DeoptimizingException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = -304210520191451179L; 10 | 11 | public static final DeoptimizingException INSTANCE = new DeoptimizingException(); 12 | 13 | private DeoptimizingException() { 14 | } 15 | 16 | @SuppressWarnings("sync-override") 17 | @Override 18 | public final Throwable fillInStackTrace() { 19 | return null; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /platform-test/scheduling/resourceConstraints.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Joerg Wuertz (wuertz@dfki.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Joerg Wuertz, 1997, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | proc {ResourceConstraintEF Start Dur ExclusiveTasks} 24 | {Schedule.serialized ExclusiveTasks Start Dur} 25 | end 26 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/GetBacktraceException.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.TruffleException; 4 | import com.oracle.truffle.api.nodes.Node; 5 | 6 | @SuppressWarnings("serial") 7 | public final class GetBacktraceException extends RuntimeException implements TruffleException { 8 | 9 | private final Node currentNode; 10 | 11 | public GetBacktraceException(Node currentNode) { 12 | this.currentNode = currentNode; 13 | } 14 | 15 | @Override 16 | public Node getLocation() { 17 | return currentNode; 18 | } 19 | 20 | @SuppressWarnings("sync-override") 21 | @Override 22 | public final Throwable fillInStackTrace() { 23 | return this; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /lib/main/base/Literal.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Literal = literal(is: IsLiteral) 30 | -------------------------------------------------------------------------------- /opi/opi/README.md: -------------------------------------------------------------------------------- 1 | # Example app based on Mozart2 and its bootcompiler 2 | 3 | This is a trivial example application, whose only purpose is to show how to actually use the [Mozart2 VM](https://github.com/mozart/mozart2) and its [bootstrap compiler](https://github.com/mozart/mozart2-bootcompiler). 4 | 5 | ## Build instructions 6 | 7 | The first time, prepare your build environment with: 8 | 9 | experiment$ mkdir build 10 | experiment$ cd build 11 | build$ cmake -D MOZART_DIR=/path/to/mozart2 \ 12 | -D BOOTCOMPILER_DIR=/path/to/mozart2-bootcompiler .. 13 | 14 | When that has been done one, you can build with: 15 | 16 | build$ make 17 | 18 | ## To run the generated program 19 | 20 | build$ ./testmozart 21 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/symtab/Builtin.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | package symtab 3 | 4 | /** Companion object for Builtin */ 5 | object Builtin { 6 | /** Parameter kind */ 7 | object ParamKind extends Enumeration { 8 | val In, Out = Value 9 | } 10 | 11 | /** Parameter kind */ 12 | type ParamKind = ParamKind.Value 13 | 14 | def create(moduleName: String, name: String, arity: Int) = new Builtin(moduleName, name, arity) 15 | } 16 | 17 | /** Builtin procedure of the host VM */ 18 | class Builtin(val moduleName: String, val name: String, val arity: Int) { 19 | override def toString() = 20 | moduleName + "." + (if (name.charAt(0).isLetter) name else "'" + name + "'") 21 | } 22 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzFailedValue.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.nodes.Node; 4 | 5 | public final class OzFailedValue extends OzValue { 6 | 7 | private final Object data; 8 | 9 | public OzFailedValue(Object data) { 10 | this.data = data; 11 | } 12 | 13 | public OzException getException(Node currentNode) { 14 | OzException exception = OzException.getExceptionFromObject(data); 15 | if (exception != null) { 16 | return exception; 17 | } else { 18 | // No backtrace attached 19 | return new OzException(currentNode, data); 20 | } 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return ""; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /lib/main/base/SiteProperty.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Denys Duchier 4 | %%% 5 | %%% Copyright: 6 | %%% Denys Duchier, 2000 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | SiteProperty = siteProperty( 24 | get : Boot_SiteProperty.get 25 | put : Boot_SiteProperty.put 26 | ) 27 | -------------------------------------------------------------------------------- /lib/main/base/Name.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Name = name(is: IsName 30 | new: NewName) 31 | -------------------------------------------------------------------------------- /lib/main/base/ForeignPointer.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | 24 | %% 25 | %% Module 26 | %% 27 | ForeignPointer = foreignPointer(is: IsForeignPointer 28 | toInt: Boot_ForeignPointer.toInt) 29 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzName.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.library.ExportLibrary; 4 | import com.oracle.truffle.api.library.ExportMessage; 5 | 6 | @ExportLibrary(RecordLibrary.class) 7 | public class OzName extends OzValue implements Comparable { 8 | 9 | private static long currentID = 0; 10 | 11 | private final long id; 12 | 13 | public OzName() { 14 | this.id = ++currentID; 15 | } 16 | 17 | @ExportMessage 18 | boolean isLiteral() { 19 | return true; 20 | } 21 | 22 | @Override 23 | public int compareTo(OzName other) { 24 | return Long.compare(this.id, other.id); 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return ""; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzVar.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.source.SourceSection; 4 | 5 | public class OzVar extends Variable { 6 | 7 | public OzVar() { 8 | } 9 | 10 | public OzVar(SourceSection declaration) { 11 | this.declaration = declaration; 12 | } 13 | 14 | public OzFuture findFuture() { 15 | Variable var = getNext(); 16 | while (var != this) { 17 | if (var instanceof OzFuture) { 18 | return (OzFuture) var; 19 | } 20 | var = var.getNext(); 21 | } 22 | return null; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | if (isBound()) { 28 | return "<" + getBoundValue(null) + ">"; 29 | } else { 30 | return "_"; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /lib/main/base/Chunk.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Chunk = chunk(is: IsChunk 30 | new: NewChunk) 31 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/InitializeVarNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzVar; 5 | 6 | import com.oracle.truffle.api.frame.FrameSlot; 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | 9 | public class InitializeVarNode extends OzNode { 10 | 11 | final FrameSlot slot; 12 | 13 | public InitializeVarNode(FrameSlot slot) { 14 | this.slot = slot; 15 | } 16 | 17 | @Override 18 | public Object execute(VirtualFrame frame) { 19 | frame.setObject(slot, new OzVar(getSourceSection())); 20 | return unit; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return super.toString() + " " + slot.getIdentifier(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/AndNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import org.mozartoz.truffle.nodes.NodeHelpers; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | import com.oracle.truffle.api.nodes.ExplodeLoop; 8 | 9 | public class AndNode extends OzNode { 10 | 11 | @Children final OzNode[] conditions; 12 | 13 | public AndNode(OzNode[] conditions) { 14 | this.conditions = NodeHelpers.deref(conditions); 15 | } 16 | 17 | @Override 18 | @ExplodeLoop 19 | public Object execute(VirtualFrame frame) { 20 | for (OzNode condition : conditions) { 21 | if (!(boolean) condition.execute(frame)) { 22 | return false; 23 | } 24 | } 25 | return true; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bench/bench_flatten.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Application 4 | Harness(bench:Bench) at 'harness.ozf' 5 | define 6 | `$N`=1000 7 | 8 | fun {BenchFlatten Xs} 9 | {Flatten Xs} 10 | end 11 | 12 | fun {GenList Elements Depth} 13 | if Depth==1 then 14 | Elements 15 | else 16 | {Map Elements fun {$ X} {GenList Elements Depth-1} end} 17 | end 18 | end 19 | 20 | % L={Map {List.number 1 `$N` 1} fun {$ X} {GenList [1 2 3] 5} end} 21 | % L={Map {List.number 1 `$N`*100 1} fun {$ X} {GenList [X X X X X] 1} end} 22 | L={Map {List.number 1 62 1} fun {$ I} 23 | {Map {List.number 1 44100 1} fun {$ N} {IntToFloat N}/44100.0 end} 24 | end} 25 | 26 | {Bench fun {$} {BenchFlatten L} end} 27 | 28 | {Application.exit 0} 29 | end 30 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzIO.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.io.InputStream; 4 | import java.io.OutputStream; 5 | 6 | public class OzIO extends OzValue { 7 | 8 | private final InputStream inputStream; 9 | private final OutputStream outputStream; 10 | 11 | public OzIO(InputStream inputStream) { 12 | this.inputStream = inputStream; 13 | this.outputStream = null; 14 | } 15 | 16 | public OzIO(OutputStream outputStream) { 17 | this.inputStream = null; 18 | this.outputStream = outputStream; 19 | } 20 | 21 | public InputStream getInputStream() { 22 | assert inputStream != null; 23 | return inputStream; 24 | } 25 | 26 | public OutputStream getOutputStream() { 27 | assert outputStream != null; 28 | return outputStream; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /platform-test/fd/safe.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | Safe = 14 | proc {$ C} 15 | {FD.tuple code 9 1#9 C} 16 | {FD.distinct C} 17 | {For 1 9 1 proc {$ I} C.I \=: I end} 18 | C.4 - C.6 =: C.7 19 | C.1 * C.2 * C.3 =: C.8 + C.9 20 | C.2 + C.3 + C.6 <: C.8 21 | C.9 <: C.8 22 | {FD.distribute ff C} 23 | end 24 | 25 | SafeSol = 26 | [code(4 3 1 8 9 2 6 7 5)] 27 | 28 | Return= 29 | fd([safe([ 30 | all(equal(fun {$} {Search.base.all Safe} end 31 | SafeSol) 32 | keys: [fd]) 33 | all_entailed(entailed(proc {$} {Search.base.all Safe _} end) 34 | keys: [fd entailed]) 35 | ]) 36 | ]) 37 | 38 | end 39 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzArray.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | public class OzArray extends OzValue { 4 | 5 | private final int low; 6 | private final Object[] store; 7 | 8 | public OzArray(int low, int width, Object initialValue) { 9 | this.low = low; 10 | this.store = new Object[width]; 11 | 12 | for (int i = 0; i < store.length; i++) { 13 | store[i] = initialValue; 14 | } 15 | } 16 | 17 | public int getLow() { 18 | return low; 19 | } 20 | 21 | public int getHigh() { 22 | return low + store.length - 1; 23 | } 24 | 25 | public int getWidth() { 26 | return store.length; 27 | } 28 | 29 | public Object get(int index) { 30 | return store[index - low]; 31 | } 32 | 33 | public void set(int index, Object newValue) { 34 | store[index - low] = newValue; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /lib/main/base/Procedure.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Procedure = procedure(is: IsProcedure 30 | arity: ProcedureArity 31 | apply: Boot_Procedure.apply) 32 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/ProcDeclarationNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.nodes.OzRootNode; 5 | import org.mozartoz.truffle.runtime.OzProc; 6 | 7 | import com.oracle.truffle.api.RootCallTarget; 8 | import com.oracle.truffle.api.frame.VirtualFrame; 9 | 10 | public class ProcDeclarationNode extends OzNode { 11 | 12 | private final RootCallTarget callTarget; 13 | private final int arity; 14 | 15 | public ProcDeclarationNode(RootCallTarget callTarget) { 16 | this.callTarget = callTarget; 17 | this.arity = ((OzRootNode) callTarget.getRootNode()).getArity(); 18 | } 19 | 20 | @Override 21 | public Object execute(VirtualFrame frame) { 22 | return new OzProc(callTarget, frame.materialize(), arity); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/ProgramBuilder.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | 3 | import ast._ 4 | import symtab._ 5 | import oz._ 6 | import transform._ 7 | 8 | /** Provides a method for building a program out of its parts */ 9 | object ProgramBuilder extends TreeDSL with TransformUtils { 10 | val treeCopy = new TreeCopier 11 | 12 | /** Builds a program that defines a regular functor 13 | * 14 | * Given a functor expression , the generated procedure is 15 | * straightforward: 16 | * {{{ 17 | * proc {$ ?} 18 | * = 19 | * end 20 | * }}} 21 | */ 22 | def buildModuleProgram(prog: Program, functor: Expression) { 23 | prog.rawCode = { 24 | Variable(prog.topLevelResultSymbol)(functor) === functor 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/call/TailCallThrowerNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.call; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.ExecuteValuesNode; 5 | import org.mozartoz.truffle.nodes.OzNode; 6 | import org.mozartoz.truffle.runtime.TailCallException; 7 | 8 | import com.oracle.truffle.api.frame.VirtualFrame; 9 | 10 | public class TailCallThrowerNode extends OzNode { 11 | 12 | @Child OzNode receiver; 13 | @Child ExecuteValuesNode arguments; 14 | 15 | public TailCallThrowerNode(OzNode receiver, ExecuteValuesNode arguments) { 16 | this.receiver = DerefNode.create(receiver); 17 | this.arguments = arguments; 18 | } 19 | 20 | public Object execute(VirtualFrame frame) { 21 | throw new TailCallException(receiver.execute(frame), arguments.execute(frame)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /lib/main/base/Cell.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Cell = cell(is: IsCell 30 | new: NewCell 31 | exchange: Exchange 32 | assign: Assign 33 | access: Access) 34 | -------------------------------------------------------------------------------- /platform-test/debug/gc.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% kennytm 4 | %%% 5 | %%% Copyright: 6 | %%% Kenny Chan, 2014 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | 25 | import 26 | System(gcDo) 27 | 28 | export 29 | Return 30 | 31 | define 32 | Return = gcDebug([ 33 | gcDebugTest(proc {$} 34 | {System.gcDo} 35 | {System.gcDo} % <-- should not crash at this point. 36 | end) 37 | ]) 38 | 39 | end 40 | 41 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchIdentityNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.dsl.CreateCast; 7 | import com.oracle.truffle.api.dsl.NodeChild; 8 | import com.oracle.truffle.api.dsl.Specialization; 9 | 10 | @NodeChild("value") 11 | public abstract class PatternMatchIdentityNode extends OzNode { 12 | 13 | private final Object constant; 14 | 15 | @CreateCast("value") 16 | protected OzNode derefValue(OzNode value) { 17 | return DerefNode.create(value); 18 | } 19 | 20 | public PatternMatchIdentityNode(Object constant) { 21 | this.constant = constant; 22 | } 23 | 24 | @Specialization 25 | boolean patternMatch(Object value) { 26 | return constant == value; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/ListLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.NodeHelpers; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.OzCons; 6 | 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | 9 | public class ListLiteralNode extends OzNode { 10 | 11 | @Children final OzNode[] elements; 12 | 13 | public ListLiteralNode(OzNode... elements) { 14 | this.elements = NodeHelpers.derefIfBound(elements); 15 | } 16 | 17 | public Object execute(VirtualFrame frame) { 18 | Object[] elementValues = NodeHelpers.executeValues(frame, elements); 19 | Object list = "nil"; 20 | 21 | for (int i = elementValues.length - 1; i >= 0; i--) { 22 | list = new OzCons(elementValues[i], list); 23 | } 24 | 25 | return list; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchConsNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.OzCons; 6 | 7 | import com.oracle.truffle.api.dsl.CreateCast; 8 | import com.oracle.truffle.api.dsl.NodeChild; 9 | import com.oracle.truffle.api.dsl.Specialization; 10 | 11 | @NodeChild("value") 12 | public abstract class PatternMatchConsNode extends OzNode { 13 | 14 | @CreateCast("value") 15 | protected OzNode derefValue(OzNode value) { 16 | return DerefNode.create(value); 17 | } 18 | 19 | @Specialization 20 | boolean patternMatch(OzCons cons) { 21 | return true; 22 | } 23 | 24 | @Specialization(guards = "!isCons(object)") 25 | boolean patternMatch(Object object) { 26 | return false; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/main/base/Bool.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | Bool = bool(is: IsBool 30 | and: And 31 | 'or': Or 32 | 'not': Not 33 | 'true': true 34 | 'false': false) 35 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/OrElseNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | import com.oracle.truffle.api.profiles.ConditionProfile; 8 | 9 | public class OrElseNode extends OzNode { 10 | 11 | @Child OzNode left; 12 | @Child OzNode right; 13 | 14 | private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile(); 15 | 16 | public OrElseNode(OzNode left, OzNode right) { 17 | this.left = DerefNode.create(left); 18 | this.right = DerefNode.create(right); 19 | } 20 | 21 | @Override 22 | public Object execute(VirtualFrame frame) { 23 | return conditionProfile.profile((boolean) left.execute(frame)) || (boolean) right.execute(frame); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /opi/emacs/windows/getenv.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Leif Kornstaedt 4 | * 5 | * Copyright: 6 | * Leif Kornstaedt, 1999 7 | * 8 | * Last change: 9 | * $Date$ by $Author$ 10 | * $Revision$ 11 | * 12 | * This file is part of Mozart, an implementation of Oz 3: 13 | * http://www.mozart-oz.org 14 | * 15 | * See the file "LICENSE" or 16 | * http://www.mozart-oz.org/LICENSE.html 17 | * for information on usage and redistribution 18 | * of this file, and for a DISCLAIMER OF ALL 19 | * WARRANTIES. 20 | */ 21 | 22 | #include 23 | 24 | #include "startup.hh" 25 | 26 | char *ozGetenv(const char *var) 27 | { 28 | static char buffer[2048]; 29 | int n = GetEnvironmentVariable(var,buffer,sizeof(buffer)); 30 | if (n == 0 || n > sizeof(buffer)) 31 | return NULL; 32 | else 33 | return buffer; 34 | } 35 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/AndThenNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | import com.oracle.truffle.api.profiles.ConditionProfile; 8 | 9 | public class AndThenNode extends OzNode { 10 | 11 | @Child OzNode left; 12 | @Child OzNode right; 13 | 14 | private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile(); 15 | 16 | public AndThenNode(OzNode left, OzNode right) { 17 | this.left = DerefNode.create(left); 18 | this.right = DerefNode.create(right); 19 | } 20 | 21 | @Override 22 | public Object execute(VirtualFrame frame) { 23 | return conditionProfile.profile((boolean) left.execute(frame)) && (boolean) right.execute(frame); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/translator/Loader.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.translator; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import com.oracle.truffle.api.TruffleLanguage.Env; 7 | import com.oracle.truffle.api.source.Source; 8 | import com.oracle.truffle.api.source.SourceSection; 9 | 10 | public class Loader { 11 | 12 | public static final Source MAIN_SOURCE = Source.newBuilder("oz", "", "main").internal(true).build(); 13 | public static final SourceSection MAIN_SOURCE_SECTION = MAIN_SOURCE.createUnavailableSection(); 14 | 15 | // Helpers 16 | 17 | public static Source createSource(Env env, String path) { 18 | File file = new File(path); 19 | try { 20 | return Source.newBuilder("oz", env.getTruffleFile(path)).name(file.getName()).build(); 21 | } catch (IOException e) { 22 | throw new Error(e); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/StacktraceThread.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.util.Map.Entry; 4 | 5 | public class StacktraceThread extends Thread { 6 | @Override 7 | public void run() { 8 | int waitNeeded = 0; 9 | for (Entry entry : OzThread.BACKTRACES.entrySet()) { 10 | final OzThread thread = entry.getKey(); 11 | final OzBacktrace backtrace = entry.getValue(); 12 | 13 | if (isWaitNeeded(backtrace)) { 14 | waitNeeded++; 15 | } else { 16 | System.out.println(thread.getInitialProcLocation()); 17 | backtrace.showUserBacktrace(); 18 | System.out.println(); 19 | } 20 | } 21 | System.out.println(waitNeeded + " threads in WaitNeeded"); 22 | } 23 | 24 | private boolean isWaitNeeded(OzBacktrace backtrace) { 25 | return backtrace.getFirst().equals("from Value.waitNeeded"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/ReadLocalVariableNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.frame.FrameSlot; 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | 8 | public class ReadLocalVariableNode extends OzNode implements FrameSlotNode { 9 | 10 | @Child ReadFrameSlotNode readFrameSlotNode; 11 | 12 | public ReadLocalVariableNode(FrameSlot slot) { 13 | this.readFrameSlotNode = ReadFrameSlotNodeGen.create(slot); 14 | } 15 | 16 | public FrameSlot getSlot() { 17 | return readFrameSlotNode.getSlot(); 18 | } 19 | 20 | @Override 21 | public Object execute(VirtualFrame frame) { 22 | return readFrameSlotNode.executeRead(frame); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return super.toString() + " " + getSlot().getIdentifier(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/ForeignPointerBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; 6 | import com.oracle.truffle.api.dsl.NodeChild; 7 | import com.oracle.truffle.api.dsl.Specialization; 8 | 9 | public abstract class ForeignPointerBuiltins { 10 | 11 | @Builtin(name = "is") 12 | @GenerateNodeFactory 13 | @NodeChild("value") 14 | public static abstract class IsForeignPointerNode extends OzNode { 15 | 16 | @Specialization 17 | Object isForeignPointer(Object value) { 18 | return unimplemented(); 19 | } 20 | 21 | } 22 | 23 | @GenerateNodeFactory 24 | @NodeChild("value") 25 | public static abstract class ToIntNode extends OzNode { 26 | 27 | @Specialization 28 | Object toInt(Object value) { 29 | return unimplemented(); 30 | } 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /mx.mozart-graal/mx_mozart_graal.py: -------------------------------------------------------------------------------- 1 | import mx 2 | import mx_sdk 3 | 4 | _suite = mx.suite("mozart-graal") 5 | 6 | mx_sdk.register_graalvm_component(mx_sdk.GraalVmLanguage( 7 | suite=_suite, 8 | name="Mozart-Graal", 9 | short_name="moz", 10 | dir_name="oz", 11 | license_files=["LICENSE_MOZART_GRAAL.txt"], 12 | third_party_license_files=[], 13 | truffle_jars=[ 14 | "mozart-graal:CORO", 15 | "mozart-graal:MOZART_GRAAL", 16 | ], 17 | support_distributions=[ 18 | "mozart-graal:MOZART_GRAAL_GRAALVM_SUPPORT", 19 | ], 20 | launcher_configs=[ 21 | mx_sdk.LanguageLauncherConfig( 22 | destination="bin/", 23 | jar_distributions=["mozart-graal:MOZART_GRAAL_LAUNCHER"], 24 | main_class="org.mozartoz.truffle.OzLauncher", 25 | build_args=["--language:oz"], 26 | language='oz', 27 | ) 28 | ] 29 | )) 30 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/ExitException.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.TruffleException; 4 | import com.oracle.truffle.api.nodes.Node; 5 | 6 | @SuppressWarnings("serial") 7 | public final class ExitException extends RuntimeException implements TruffleException { 8 | 9 | private final Node location; 10 | private final int exitCode; 11 | 12 | public ExitException(Node location, int exitCode) { 13 | this.location = location; 14 | this.exitCode = exitCode; 15 | } 16 | 17 | @Override 18 | public Node getLocation() { 19 | return location; 20 | } 21 | 22 | @Override 23 | public boolean isExit() { 24 | return true; 25 | } 26 | 27 | @Override 28 | public int getExitStatus() { 29 | return exitCode; 30 | } 31 | 32 | @SuppressWarnings("sync-override") 33 | @Override 34 | public final Throwable fillInStackTrace() { 35 | return this; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /opi/emacs/windows/path.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Leif Kornstaedt 4 | * 5 | * Copyright: 6 | * Leif Kornstaedt, 1999 7 | * 8 | * Last change: 9 | * $Date$ by $Author$ 10 | * $Revision$ 11 | * 12 | * This file is part of Mozart, an implementation of Oz 3: 13 | * http://www.mozart-oz.org 14 | * 15 | * See the file "LICENSE" or 16 | * http://www.mozart-oz.org/LICENSE.html 17 | * for information on usage and redistribution 18 | * of this file, and for a DISCLAIMER OF ALL 19 | * WARRANTIES. 20 | */ 21 | 22 | #include "startup.hh" 23 | 24 | void normalizePath(char *path, bool toUnix) 25 | { 26 | char from, to; 27 | if (toUnix) { 28 | from = '\\'; 29 | to = '/'; 30 | } else { 31 | from = '/'; 32 | to = '\\'; 33 | } 34 | 35 | for (char *aux = path; *aux != '\0'; aux++) { 36 | if (*aux == from) { 37 | *aux = to; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/LiteralBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import static org.mozartoz.truffle.nodes.builtins.Builtin.ALL; 4 | 5 | import com.oracle.truffle.api.library.CachedLibrary; 6 | import org.mozartoz.truffle.nodes.OzNode; 7 | 8 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; 9 | import com.oracle.truffle.api.dsl.NodeChild; 10 | import com.oracle.truffle.api.dsl.Specialization; 11 | import org.mozartoz.truffle.runtime.RecordLibrary; 12 | 13 | public abstract class LiteralBuiltins { 14 | 15 | @Builtin(name = "is", deref = ALL) 16 | @GenerateNodeFactory 17 | @NodeChild("value") 18 | public static abstract class IsLiteralNode extends OzNode { 19 | 20 | @Specialization(limit = "RECORDS_LIMIT") 21 | boolean isLiteral(Object value, 22 | @CachedLibrary("value") RecordLibrary records) { 23 | return records.isLiteral(value); 24 | } 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/AtomBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import static org.mozartoz.truffle.nodes.builtins.Builtin.ALL; 4 | 5 | import org.mozartoz.truffle.nodes.OzGuards; 6 | import org.mozartoz.truffle.nodes.OzNode; 7 | 8 | import com.oracle.truffle.api.dsl.Fallback; 9 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; 10 | import com.oracle.truffle.api.dsl.NodeChild; 11 | import com.oracle.truffle.api.dsl.Specialization; 12 | 13 | public abstract class AtomBuiltins { 14 | 15 | @Builtin(name = "is", deref = ALL) 16 | @GenerateNodeFactory 17 | @NodeChild("value") 18 | public static abstract class IsAtomNode extends OzNode { 19 | 20 | @Specialization 21 | boolean isAtom(String value) { 22 | assert OzGuards.isInterned(value); 23 | return true; 24 | } 25 | 26 | @Fallback 27 | boolean isAtom(Object value) { 28 | return false; 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/InitializeArgNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzArguments; 5 | 6 | import com.oracle.truffle.api.frame.FrameSlot; 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | 9 | public class InitializeArgNode extends OzNode implements FrameSlotNode { 10 | 11 | @Child WriteFrameSlotNode writeFrameSlotNode; 12 | 13 | private final int index; 14 | 15 | public InitializeArgNode(FrameSlot slot, int index) { 16 | this.writeFrameSlotNode = WriteFrameSlotNodeGen.create(slot); 17 | this.index = index; 18 | } 19 | 20 | public FrameSlot getSlot() { 21 | return writeFrameSlotNode.getSlot(); 22 | } 23 | 24 | public Object execute(VirtualFrame frame) { 25 | Object value = OzArguments.getArgument(frame, index); 26 | writeFrameSlotNode.write(frame, value); 27 | return unit; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/transform/TransformUtils.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | package transform 3 | 4 | import ast._ 5 | import ast.Node.Pos 6 | 7 | trait TransformUtils { 8 | def statementsToStatement(statements: Seq[Statement])(pos: Pos) = statements match { 9 | case Seq() => SkipStatement()(pos) 10 | case Seq(stat) => stat 11 | case _ => CompoundStatement(statements)(Node.extend(statements)) 12 | } 13 | 14 | def statsAndStatToStat(statements: Seq[Statement], statement: Statement) = 15 | if (statements.isEmpty) statement 16 | else CompoundStatement(statements :+ statement)(Node.extend(statements(0), statement)) 17 | 18 | def statsAndExprToExpr(statements: Seq[Statement], expression: Expression) = 19 | if (statements.isEmpty) expression 20 | else StatAndExpression(statementsToStatement(statements)(expression), expression)(Node.extend(statements(0), expression)) 21 | } 22 | -------------------------------------------------------------------------------- /platform-test/dp-bench/Makefile.in: -------------------------------------------------------------------------------- 1 | @SET_MAKE@ 2 | VPATH = @srcdir@ 3 | SRCDIR = @srcdir@ 4 | BUILDTOP = @BUILDTOP@ 5 | SRCTOP = @SRCTOP@ 6 | HOMEURL = @HOMEURL@ 7 | PLATFORM = @PLATFORM@ 8 | INSTALL_DIR = @INSTALL_DIR@ 9 | OZC = @OZC@ 10 | OZL = @OZL@ 11 | 12 | TARGETS = copy speed Manager Client 13 | 14 | all: $(TARGETS) 15 | 16 | bootstrap: boot-all 17 | 18 | include $(BUILDTOP)/share/Makefile.boot 19 | 20 | $(TARGETS): % : %.ozf run.ozf 21 | $(OZL) -x $(OZEXECFILE) $< -o $@ 22 | 23 | %.ozf: %.oz 24 | $(OZC) -c $< -o $@ 25 | 26 | install: 27 | 28 | Makefile: Makefile.in ../../config.status 29 | cd ../.. && ./config.status 30 | 31 | ../../config.status: ../../configure 32 | cd ../.. && ./config.status --recheck 33 | 34 | depend: 35 | 36 | clean: 37 | -rm -f *~ *.ozf *.so-* $(TARGETS) 38 | veryclean: clean 39 | distclean: veryclean 40 | -------------------------------------------------------------------------------- /lib/main/base/VirtualByteString.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Kenny Chan 4 | %%% 5 | %%% Copyright: 6 | %%% Kenny Chan, 2012 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | %% 24 | %% Module 25 | %% 26 | 27 | VirtualByteString = virtualByteString( 28 | is: IsVirtualByteString 29 | toCompactByteString: Boot_VirtualByteString.toCompactByteString 30 | toList: fun {$ VBS} 31 | {Boot_VirtualByteString.toByteList VBS nil} 32 | end 33 | toListWithTail: Boot_VirtualByteString.toByteList 34 | length: Boot_VirtualByteString.length 35 | ) 36 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzObject.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.object.DynamicObject; 4 | 5 | public class OzObject extends OzValue { 6 | 7 | private final DynamicObject clazz; 8 | private final DynamicObject features; 9 | private final DynamicObject attributes; 10 | 11 | public OzObject(DynamicObject clazz, DynamicObject features, DynamicObject attributes) { 12 | this.clazz = clazz; 13 | this.features = features; 14 | this.attributes = attributes; 15 | } 16 | 17 | public DynamicObject getClazz() { 18 | return clazz; 19 | } 20 | 21 | public DynamicObject getFeatures() { 22 | assert features != null; 23 | return features; 24 | } 25 | 26 | public DynamicObject getAttributes() { 27 | assert attributes != null; 28 | return attributes; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return ""; // attr=" + attributes + " feat=" + features + ">"; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /platform-test/fd/grocery.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | 14 | 15 | Grocery = 16 | 17 | proc {$ Root} 18 | A#B#C#D = Root 19 | S = 711 20 | in 21 | Root ::: 0#711 22 | A*B*C*D =: S*100*100*100 23 | 24 | A+B+C+D =: S 25 | % eliminate symmetries 26 | D =: 79*{FD.decl} % 79 is prime factor of S=711 27 | B =<: C 28 | C =<: D 29 | A =<: B 30 | {FD.distribute generic(value:splitMax) Root} 31 | 32 | end 33 | 34 | GrocerySol = 35 | [120#125#150#316] 36 | 37 | Return= 38 | 39 | fd([grocery([ 40 | one(equal(fun {$} {Search.base.one Grocery} end 41 | GrocerySol) 42 | keys: [fd]) 43 | one_entailed(entailed(proc {$} {Search.base.one Grocery _} end) 44 | keys: [fd entailed]) 45 | ]) 46 | ]) 47 | 48 | end 49 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/ConsLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.DerefIfBoundNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.OzCons; 6 | 7 | import com.oracle.truffle.api.dsl.CreateCast; 8 | import com.oracle.truffle.api.dsl.NodeChild; 9 | import com.oracle.truffle.api.dsl.NodeChildren; 10 | import com.oracle.truffle.api.dsl.Specialization; 11 | 12 | @NodeChildren({ @NodeChild("head"), @NodeChild("tail") }) 13 | public abstract class ConsLiteralNode extends OzNode { 14 | 15 | @CreateCast("head") 16 | protected OzNode derefHead(OzNode var) { 17 | return DerefIfBoundNode.create(var); 18 | } 19 | 20 | @CreateCast("tail") 21 | protected OzNode derefTail(OzNode var) { 22 | return DerefIfBoundNode.create(var); 23 | } 24 | 25 | @Specialization 26 | public Object execute(Object head, Object tail) { 27 | return new OzCons(head, tail); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/InitializeTmpNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.nodes.DerefIfBoundNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.FrameSlot; 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | 9 | public class InitializeTmpNode extends OzNode implements FrameSlotNode { 10 | 11 | @Child WriteFrameSlotNode writeFrameSlotNode; 12 | @Child OzNode valueNode; 13 | 14 | public InitializeTmpNode(FrameSlot slot, OzNode valueNode) { 15 | this.writeFrameSlotNode = WriteFrameSlotNodeGen.create(slot); 16 | this.valueNode = DerefIfBoundNode.create(valueNode); 17 | } 18 | 19 | public FrameSlot getSlot() { 20 | return writeFrameSlotNode.getSlot(); 21 | } 22 | 23 | @Override 24 | public Object execute(VirtualFrame frame) { 25 | Object value = valueNode.execute(frame); 26 | writeFrameSlotNode.executeWrite(frame, value); 27 | return value; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /lib/main/ap/Custom.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Denys Duchier 4 | %%% 5 | %%% Copyright: 6 | %%% Denys Duchier, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | functor 23 | import 24 | CustomGroup(register) 25 | CustomOption(register get) 26 | CustomEdit(editOption) 27 | export 28 | Register Get EditOption 29 | define 30 | proc {Register What} 31 | case {Label What} 32 | of group then {CustomGroup.register What} 33 | [] option then {CustomOption.register What} 34 | end 35 | end 36 | Get = CustomOption.get 37 | EditOption = CustomEdit.editOption 38 | end 39 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/ParserToVMImpl.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.source.SourceSection; 4 | import org.mozartoz.bootcompiler.ParserToVM; 5 | import org.mozartoz.bootcompiler.SourceInterface; 6 | import org.mozartoz.bootcompiler.ast.Node.Pos; 7 | import org.mozartoz.truffle.translator.Loader; 8 | 9 | public class ParserToVMImpl implements ParserToVM { 10 | 11 | public static final ParserToVM INSTANCE = new ParserToVMImpl(); 12 | 13 | private ParserToVMImpl() { 14 | } 15 | 16 | @Override 17 | public SourceInterface createSource(String path) { 18 | return new SourceWrapper(Loader.createSource(OzLanguage.getContext().getEnv(), path)); 19 | } 20 | 21 | @Override 22 | public String sectionFileLine(Pos pos) { 23 | final SourceSection sourceSection = ((SourceWrapper) pos.source()).source.createSection(pos.charIndex(), pos.length()); 24 | return sourceSection.getSource().getPath() + ":" + sourceSection.getStartLine(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /lib/main/base/Number.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Global 28 | %% 29 | 30 | 31 | %% 32 | %% Module 33 | %% 34 | Number = number(is: IsNumber 35 | '+': Boot_Number.'+' 36 | '-': Boot_Number.'-' 37 | '*': Boot_Number.'*' 38 | '~': Boot_Number.'~' 39 | 'pow': Pow 40 | 'abs': Boot_Number.'abs') 41 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/NoElseNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | import com.oracle.truffle.api.source.SourceSection; 8 | import org.mozartoz.truffle.runtime.Errors; 9 | 10 | public class NoElseNode extends OzNode { 11 | 12 | @Child OzNode valueNode; 13 | 14 | public NoElseNode(OzNode valueNode) { 15 | this.valueNode = valueNode; 16 | } 17 | 18 | @Override 19 | public Object execute(VirtualFrame frame) { 20 | Object value = valueNode.execute(frame); 21 | SourceSection sourceSection = getSourceSection(); 22 | throw Errors.kernelError(this, "noElse", sourceSection.getSource().getName(), (long) getStartLine(sourceSection), value); 23 | } 24 | 25 | @TruffleBoundary 26 | private int getStartLine(SourceSection sourceSection) { 27 | return sourceSection.getStartLine(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/NodeHelpers.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes; 2 | 3 | import com.oracle.truffle.api.frame.VirtualFrame; 4 | import com.oracle.truffle.api.nodes.ExplodeLoop; 5 | 6 | public abstract class NodeHelpers { 7 | 8 | @ExplodeLoop 9 | public static Object[] executeValues(VirtualFrame frame, OzNode[] values) { 10 | Object[] array = new Object[values.length]; 11 | for (int i = 0; i < values.length; i++) { 12 | array[i] = values[i].execute(frame); 13 | } 14 | return array; 15 | } 16 | 17 | public static OzNode[] deref(OzNode[] values) { 18 | OzNode[] deref = new OzNode[values.length]; 19 | for (int i = 0; i < values.length; i++) { 20 | deref[i] = DerefNode.create(values[i]); 21 | } 22 | return deref; 23 | } 24 | 25 | public static OzNode[] derefIfBound(OzNode[] values) { 26 | OzNode[] deref = new OzNode[values.length]; 27 | for (int i = 0; i < values.length; i++) { 28 | deref[i] = DerefIfBoundNode.create(values[i]); 29 | } 30 | return deref; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /lib/tools/panel/panel/errors.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Contributors: 6 | %%% Martin Mueller 7 | %%% 8 | %%% Copyright: 9 | %%% Christian Schulte, 1997 10 | %%% 11 | %%% Last change: 12 | %%% $Date$ by $Author$ 13 | %%% $Revision$ 14 | %%% 15 | %%% This file is part of Mozart, an implementation 16 | %%% of Oz 3 17 | %%% http://www.mozart-oz.org 18 | %%% 19 | %%% See the file "LICENSE" or 20 | %%% http://www.mozart-oz.org/LICENSE.html 21 | %%% for information on usage and redistribution 22 | %%% of this file, and for a DISCLAIMER OF ALL 23 | %%% WARRANTIES. 24 | %%% 25 | 26 | {Error.registerFormatter panel 27 | fun {$ E} 28 | T = 'error in Oz Panel' 29 | in 30 | case E 31 | of panel(option OM) then 32 | error(kind: T 33 | msg: 'Illegal option specification' 34 | items: [hint(l:'Message' 35 | m:oz(OM))]) 36 | else 37 | error(kind: T 38 | items: [line(oz(E))]) 39 | end 40 | end} 41 | -------------------------------------------------------------------------------- /platform-test/base/weakdictionaryGC.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System(gcDo) 4 | export 5 | Return 6 | define 7 | proc{RunGC Stop} 8 | if {Not {IsDet Stop}} then 9 | {System.gcDo} 10 | {Delay 10} 11 | {RunGC Stop} 12 | end 13 | end 14 | 15 | % Checks for bugs 593 & 596 16 | proc{Appear} 17 | S WD={NewWeakDictionary S} 18 | StopGC 19 | in 20 | thread {RunGC StopGC} end 21 | WD.gc:={NewName} 22 | case S of (gc#_)|_ then skip end 23 | StopGC=unit 24 | end 25 | 26 | proc{Key} 27 | S WD={NewWeakDictionary S} 28 | D={NewDictionary} 29 | Key={NewName} 30 | StopGC 31 | in 32 | thread {RunGC StopGC} end 33 | D.Key:=proc{$} skip end 34 | WD.Key:={NewName} 35 | case S of (_#_)|_ then skip end 36 | StopGC=unit 37 | end 38 | 39 | Return = weakdictionary([appear(Appear keys:[dictionary]) 40 | key(Key keys:[dictionary]) 41 | ]) 42 | end 43 | -------------------------------------------------------------------------------- /tool/intellijinit.rb: -------------------------------------------------------------------------------- 1 | def rewrite(file) 2 | lines = File.readlines(file) 3 | lines = yield lines 4 | File.write(file, lines.join) 5 | end 6 | 7 | rewrite "vm/org.mozartoz.truffle.iml" do |lines| 8 | lines.map { |line| 9 | case line 10 | when /name="BOOTCOMPILER"/ 11 | '' + "\n" 12 | else 13 | line 14 | end 15 | } 16 | end 17 | 18 | rewrite ".idea/modules.xml" do |lines| 19 | lines.map { |line| 20 | case line 21 | when // 22 | line + <<-XML 23 | 24 | 25 | XML 26 | else 27 | line 28 | end 29 | } 30 | end 31 | 32 | # Unused 33 | File.delete ".idea/libraries/BOOTCOMPILER.xml" 34 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/ast/UtilNodes.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | package ast 3 | 4 | import symtab._ 5 | 6 | trait RawDeclarationOrVar extends Node 7 | trait RawDeclaration extends RawDeclarationOrVar 8 | 9 | trait InfixSyntax extends Node { 10 | protected val left: Node 11 | protected val right: Node 12 | protected val opSyntax: String 13 | 14 | def syntax(indent: String) = { 15 | val untilOp = left.syntax(indent) + opSyntax 16 | val rightIndent = indent + " "*untilOp.length 17 | untilOp + right.syntax(rightIndent) 18 | } 19 | } 20 | 21 | trait MultiInfixSyntax extends Node { 22 | protected val operands: Seq[Node] 23 | protected val operators: Seq[String] 24 | 25 | def syntax(indent: String) = { 26 | val first = operands.head.syntax(indent) 27 | (operators zip operands.tail).foldLeft(first) { 28 | case (prev, (op, operand)) => 29 | val untilOp = prev + op 30 | untilOp + operand.syntax(indent + " "*untilOp.length) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/WriteCapturedVariableNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.runtime.OzArguments; 4 | 5 | import com.oracle.truffle.api.frame.Frame; 6 | import com.oracle.truffle.api.frame.FrameSlot; 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | import com.oracle.truffle.api.nodes.Node; 9 | 10 | public class WriteCapturedVariableNode extends Node implements WriteNode, FrameSlotNode { 11 | 12 | @Child WriteFrameSlotNode writeFrameSlotNode; 13 | 14 | final int depth; 15 | 16 | public WriteCapturedVariableNode(FrameSlot slot, int depth) { 17 | this.depth = depth; 18 | this.writeFrameSlotNode = WriteFrameSlotNodeGen.create(slot); 19 | } 20 | 21 | public FrameSlot getSlot() { 22 | return writeFrameSlotNode.getSlot(); 23 | } 24 | 25 | @Override 26 | public void write(VirtualFrame topFrame, Object value) { 27 | Frame parentFrame = OzArguments.getParentFrame(topFrame, depth); 28 | writeFrameSlotNode.executeWrite(parentFrame, value); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzDict.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 4 | 5 | import java.util.HashMap; 6 | 7 | public class OzDict extends HashMap { 8 | 9 | private static final long serialVersionUID = -768886564649072349L; 10 | 11 | @Override 12 | public boolean isEmpty() { 13 | return super.isEmpty(); 14 | } 15 | 16 | @TruffleBoundary 17 | @Override 18 | public boolean containsKey(Object key) { 19 | return super.containsKey(key); 20 | } 21 | 22 | @TruffleBoundary 23 | @Override 24 | public Object get(Object key) { 25 | return super.get(key); 26 | } 27 | 28 | @TruffleBoundary 29 | @Override 30 | public Object put(Object key, Object value) { 31 | return super.put(key, value); 32 | } 33 | 34 | @TruffleBoundary 35 | @Override 36 | public Object remove(Object key) { 37 | return super.remove(key); 38 | } 39 | 40 | @TruffleBoundary 41 | @Override 42 | public void clear() { 43 | super.clear(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /lib/compiler/Doc/SlowMeths: -------------------------------------------------------------------------------- 1 | %%% -*- oz -*- 2 | 3 | class C 4 | meth f(a1: X1 ... an: Xn b1: Y1 <= V1 ... bk: Yk <= Vk [...])=M 5 | S 6 | end 7 | end 8 | 9 | => 10 | 11 | %% let MessagePattern and GroundVi be fresh variables 12 | 13 | MessagePattern = messagePattern(a1: unit ... an: unit b1: unit ... bk: unit) 14 | GroundVi = Vi % for all 1 =< i =< k with Vi ground 15 | 16 | proc {'C,f' M} 17 | case M of f(a1: X1 ... an: Xn 18 | ... % if k > 0 or M open 19 | ) 20 | andthen {`Record.aritySublist` M MessagePattern} % if k > 0 and M closed 21 | then Y1 ... Yk M in 22 | if {`Record.testFeature` M b1 $ Y1} then skip 23 | else 24 | Y1 = GroundV1 % if V1 ground 25 | Y1 = V1 % else 26 | end 27 | ... 28 | if {`Record.testFeature` M bk $ Yk} then skip 29 | else 30 | Yk = GroundVk % if Vk ground 31 | Yk = Vk % else 32 | end 33 | S 34 | else 35 | {Exception.raiseError object(arityMismatch file line M self)} 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /platform-test/fd/kalotan.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | Kalotan = 14 | proc {$ Solution} 15 | Vars 16 | [Sex Claim Truth % Kibi 17 | Sex1 Truth1 % Parent 1 18 | Sex2 Truth2a Truth2b] % Parent 2 19 | = Vars 20 | in 21 | Vars:::0#1 22 | (Claim=:Sex)=:Truth 23 | Sex+Truth>:0 24 | (Claim=:0)=:Truth1 25 | Sex1+Truth1>:0 26 | (Sex=:1)=:Truth2a 27 | (Truth=:0)=:Truth2b 28 | Sex2+Truth2a+Truth2b=:2 29 | Sex1\=:Sex2 30 | Solution=Sex#Sex1#Sex2 31 | {FD.distribute ff Vars} 32 | end 33 | 34 | KalotanSol = [1#1#0] 35 | 36 | Return = 37 | fd([kalotan([ 38 | one(equal(fun {$} {Search.base.one Kalotan} end 39 | KalotanSol) 40 | keys: [fd]) 41 | one_entailed(entailed(proc {$} {Search.base.one Kalotan _} end) 42 | keys: [fd entailed]) 43 | ]) 44 | ]) 45 | 46 | end 47 | -------------------------------------------------------------------------------- /platform-test/fs/manuel.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FS 6 | 7 | export 8 | Return 9 | 10 | define 11 | 12 | \insert 'manuel_constr.oz' 13 | 14 | ManuelTest = 15 | fun {$ N T} 16 | L = {StringToAtom {VirtualString.toString N}} 17 | in 18 | L(equal(T 1) keys: [fs]) 19 | end 20 | 21 | ManuelTestFnct = 22 | fun {$ Off} 23 | Vs = {FS.var.list.decl 308} 24 | in 25 | fun {$} 26 | {ManuelConstr Vs Off} 27 | thread 28 | cond {List.forAllInd Vs 29 | proc {$ I V} if I =< 77 30 | then V = {FS.value.make I+Off} 31 | else skip 32 | end 33 | end} 34 | then 1 else 0 end 35 | end 36 | end 37 | end 38 | 39 | Return= 40 | fs([manuel([ 41 | {ManuelTest 1 {ManuelTestFnct 0}} 42 | {ManuelTest 2 {ManuelTestFnct 64}} 43 | {ManuelTest 3 {ManuelTestFnct 1024}} 44 | ]) 45 | ]) 46 | 47 | end 48 | -------------------------------------------------------------------------------- /platform-test/bench/rec.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Denys Duchier (duchier@ps.uni-sb.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Denys Duchier, 2000 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | export 25 | Return 26 | define 27 | proc {Loop N} 28 | if N==0 then skip else 29 | {Loop N-1} 30 | end 31 | end 32 | proc {BigLoop N1 N2} 33 | if N1==0 then skip else 34 | {Loop N2} 35 | {BigLoop N1-1 N2} 36 | end 37 | end 38 | Return = rec([normal(proc {$} 39 | {BigLoop 10 1000000} 40 | end 41 | keys:[bench rec] 42 | bench:1)]) 43 | end 44 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/IfNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | 6 | import com.oracle.truffle.api.frame.VirtualFrame; 7 | import com.oracle.truffle.api.profiles.ConditionProfile; 8 | 9 | public class IfNode extends OzNode { 10 | 11 | @Child OzNode condition; 12 | @Child OzNode thenExpr; 13 | @Child OzNode elseExpr; 14 | 15 | @Child DerefNode derefNode; 16 | 17 | private final ConditionProfile profile = ConditionProfile.createCountingProfile(); 18 | 19 | public IfNode(OzNode condition, OzNode thenExpr, OzNode elseExpr) { 20 | this.condition = condition; 21 | this.thenExpr = thenExpr; 22 | this.elseExpr = elseExpr; 23 | this.derefNode = DerefNode.create(); 24 | } 25 | 26 | @Override 27 | public Object execute(VirtualFrame frame) { 28 | if (profile.profile((boolean) derefNode.executeDeref(condition.execute(frame)))) { 29 | return thenExpr.execute(frame); 30 | } else { 31 | return elseExpr.execute(frame); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/call/SelfTailCallThrowerNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.call; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.runtime.OzArguments; 5 | import org.mozartoz.truffle.runtime.SelfTailCallException; 6 | 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | import com.oracle.truffle.api.nodes.ExplodeLoop; 9 | 10 | public class SelfTailCallThrowerNode extends OzNode { 11 | 12 | @Children final OzNode[] arguments; 13 | 14 | public SelfTailCallThrowerNode(OzNode[] arguments) { 15 | this.arguments = arguments; 16 | } 17 | 18 | public Object execute(VirtualFrame frame) { 19 | replaceArguments(frame); 20 | throw SelfTailCallException.INSTANCE; 21 | } 22 | 23 | @ExplodeLoop 24 | public void replaceArguments(VirtualFrame frame) { 25 | // It's OK to override user arguments here, as when the frame is 26 | // captured they will have been copied to the frame slots. 27 | for (int i = 0; i < arguments.length; i++) { 28 | OzArguments.setArgument(frame, i, arguments[i].execute(frame)); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /lib/main/base/Functor.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Author: 3 | %%% Leif Kornstaedt 4 | %%% 5 | %%% Copyright: 6 | %%% Leif Kornstaedt, 1998-1999 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | local 23 | FunctorID = {NewUniqueName functorID} 24 | 25 | fun {IsFunctor X} 26 | {IsChunk X} andthen {HasFeature X FunctorID} 27 | end 28 | 29 | fun {NewFunctor Import Export Apply} 30 | % TODO assert that the arguments have the expected types 31 | {NewChunk f(FunctorID: unit 32 | 'import': Import 33 | 'export': Export 34 | 'apply': Apply)} 35 | end 36 | in 37 | Functor = 'functor'(is: IsFunctor 38 | new: NewFunctor) 39 | end 40 | -------------------------------------------------------------------------------- /platform-test/fd/pythagoras.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | Pythagoras = 14 | proc {$ Root} 15 | proc {Square X S} 16 | {FD.times X X S} % exploits coreference 17 | end 18 | [A B C] = Root 19 | AA BB CC 20 | in 21 | Root ::: 1#1000 22 | AA = {Square A} 23 | BB = {Square B} 24 | CC = {Square C} 25 | AA + BB =: CC % A*A + B*B =: C*C propagates much worse 26 | A =<: B 27 | B =<: C 28 | 2*BB >=: CC % redundant constraint 29 | {FD.distribute ff Root} 30 | end 31 | 32 | PythagorasSol = [[3 4 5]] 33 | 34 | Return= 35 | fd([pythagoras([ 36 | one(equal(fun {$} {Search.base.one Pythagoras} end 37 | PythagorasSol) 38 | keys: [fd]) 39 | one_entailed(entailed(proc {$} {Search.base.one Pythagoras _} end) 40 | keys: [fd entailed]) 41 | ]) 42 | ]) 43 | 44 | end 45 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/literal/RecordLiteralNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.literal; 2 | 3 | import org.mozartoz.truffle.nodes.NodeHelpers; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.Arity; 6 | import org.mozartoz.truffle.runtime.ArrayUtils; 7 | 8 | import com.oracle.truffle.api.frame.VirtualFrame; 9 | import com.oracle.truffle.api.object.DynamicObjectFactory; 10 | 11 | public class RecordLiteralNode extends OzNode { 12 | 13 | final Arity arity; 14 | final DynamicObjectFactory factory; 15 | @Children final OzNode[] valueNodes; 16 | 17 | public RecordLiteralNode(Arity arity, OzNode[] values) { 18 | assert arity.getWidth() == values.length; 19 | this.arity = arity; 20 | this.factory = arity.getShape().createFactory(); 21 | this.valueNodes = NodeHelpers.derefIfBound(values); 22 | } 23 | 24 | @Override 25 | public Object execute(VirtualFrame frame) { 26 | Object[] values = NodeHelpers.executeValues(frame, valueNodes); 27 | Object[] initialValues = ArrayUtils.unshift(arity.getLabel(), values); 28 | return factory.newInstance(initialValues); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /platform-test/fd/fraction.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | 14 | 15 | Fraction = 16 | proc {$ Root} 17 | sol(a:A b:B c:C d:D e:E f:F g:G h:H i:I) = !Root 18 | BC = {FD.decl} 19 | EF = {FD.decl} 20 | HI = {FD.decl} 21 | in 22 | Root ::: 1#9 23 | {FD.distinct Root} 24 | BC =: 10*B + C 25 | EF =: 10*E + F 26 | HI =: 10*H + I 27 | A*EF*HI + D*BC*HI + G*BC*EF =: BC*EF*HI 28 | % impose order 29 | A*EF >=: D*BC 30 | D*HI >=: G*EF 31 | % redundant constraints 32 | % 3*A >=: BC 33 | % 3*G =<: HI 34 | 35 | {FD.distribute split Root} 36 | end 37 | FractionSol = 38 | [sol(a:9 b:1 c:2 d:5 e:3 f:4 g:7 h:6 i:8)] 39 | Return= 40 | fd([fraction([ 41 | all(equal(fun {$} {Search.base.all Fraction} end 42 | FractionSol) 43 | keys: [fd]) 44 | all_entailed(entailed(proc {$} {Search.base.all Fraction _} end) 45 | keys: [fd scheduling]) 46 | ]) 47 | ]) 48 | 49 | end 50 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/ListBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.OzCons; 6 | 7 | import com.oracle.truffle.api.dsl.CreateCast; 8 | import com.oracle.truffle.api.dsl.NodeChild; 9 | import com.oracle.truffle.api.dsl.Specialization; 10 | 11 | public abstract class ListBuiltins { 12 | 13 | @NodeChild("cons") 14 | public static abstract class HeadNode extends OzNode { 15 | 16 | @CreateCast("cons") 17 | protected OzNode derefCons(OzNode cons) { 18 | return DerefNode.create(cons); 19 | } 20 | 21 | @Specialization 22 | protected Object head(OzCons cons) { 23 | return cons.getHead(); 24 | } 25 | 26 | } 27 | 28 | @NodeChild("cons") 29 | public static abstract class TailNode extends OzNode { 30 | 31 | @CreateCast("cons") 32 | protected OzNode derefCons(OzNode cons) { 33 | return DerefNode.create(cons); 34 | } 35 | 36 | @Specialization 37 | protected Object tail(OzCons cons) { 38 | return cons.getTail(); 39 | } 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/GarbageCollectionNotifier.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.lang.management.GarbageCollectorMXBean; 4 | import java.lang.management.ManagementFactory; 5 | import java.lang.management.MemoryMXBean; 6 | 7 | import javax.management.InstanceNotFoundException; 8 | 9 | public class GarbageCollectionNotifier { 10 | 11 | private static long lastActiveSize = 0L; 12 | 13 | public static long getLastActiveSize() { 14 | return lastActiveSize; 15 | } 16 | 17 | private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean(); 18 | 19 | public static void register() { 20 | for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) { 21 | try { 22 | ManagementFactory.getPlatformMBeanServer().addNotificationListener(gcBean.getObjectName(), (notification, handback) -> { 23 | lastActiveSize = MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed(); 24 | }, null, null); 25 | } catch (InstanceNotFoundException e) { 26 | System.err.println("GC monitoring disabled"); 27 | e.printStackTrace(); 28 | } 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /platform-test/base/proc.oz: -------------------------------------------------------------------------------- 1 | functor 2 | export 3 | Return 4 | define 5 | fun {Closure N} 6 | if N==0 then 7 | nil 8 | else 9 | fun {$} N end|{Closure N-1} 10 | end 11 | end 12 | 13 | Return='proc'([ 14 | closure(proc {$} 15 | Xs={Closure 3} 16 | Applied={Map Xs fun {$ X} {X} end} 17 | in 18 | Applied = [3 2 1] 19 | end 20 | keys: [procedure capture]) 21 | 22 | apply(proc {$} 23 | R 24 | in 25 | {Procedure.apply Number.'+' [1 2 R]} 26 | R = 3 27 | end 28 | keys: [procedure apply]) 29 | 30 | applyObject(proc {$} 31 | class Test 32 | meth init 33 | skip 34 | end 35 | 36 | meth otherwise(Msg) 37 | Msg.2 = Msg.1 38 | end 39 | end 40 | T={New Test init} 41 | in 42 | {T foo(3 $)} = 3 43 | {Procedure.apply T [foo(3 $)]} = 3 44 | end 45 | keys: [procedure apply object]) 46 | ]) 47 | end 48 | -------------------------------------------------------------------------------- /platform-test/dp/template.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | TestMisc 4 | export 5 | Return 6 | define 7 | Sites=1 8 | 9 | proc {Start} 10 | Managers 11 | InP InS={NewPort $ InP} 12 | OutS OutP={NewPort OutS} 13 | in 14 | try Hosts in 15 | {TestMisc.getHostNames Hosts} 16 | {TestMisc.getRemoteManagers Sites Hosts Managers} 17 | {ForAll Managers proc {$ RemMan} 18 | {StartRemSite RemMan OutS InP} 19 | end} 20 | % Local test runner 21 | catch X then 22 | raise X end 23 | end 24 | {TestMisc.gcAll Managers} 25 | {TestMisc.listApply Managers close} 26 | end 27 | 28 | proc {StartRemSite Manager InS OutP} 29 | {Manager apply(url:'' functor 30 | define 31 | proc {Start InS OutP} 32 | % Remote test runner 33 | end 34 | 35 | thread {Start InS OutP} end 36 | end)} 37 | end 38 | 39 | Return = dp([(Start keys:[remote])]) 40 | end 41 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/DerefIfBoundNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes; 2 | 3 | import org.mozartoz.truffle.runtime.Variable; 4 | 5 | import com.oracle.truffle.api.dsl.NodeChild; 6 | import com.oracle.truffle.api.dsl.Specialization; 7 | 8 | @NodeChild("value") 9 | public abstract class DerefIfBoundNode extends OzNode { 10 | 11 | public static DerefIfBoundNode create() { 12 | return DerefIfBoundNodeGen.create(null); 13 | } 14 | 15 | public static DerefIfBoundNode create(OzNode node) { 16 | assert !(node instanceof DerefIfBoundNode); 17 | assert !(node instanceof DerefNode); 18 | return DerefIfBoundNodeGen.create(node); 19 | } 20 | 21 | public abstract OzNode getValue(); 22 | 23 | public abstract Object executeDerefIfBound(Object value); 24 | 25 | @Specialization(guards = "var.isBound()") 26 | Object derefBound(Variable var) { 27 | return var.getBoundValue(this); 28 | } 29 | 30 | @Specialization(guards = "!var.isBound()") 31 | Variable noDerefUnbound(Variable var) { 32 | return var; 33 | } 34 | 35 | @Specialization(guards = "!isVariable(value)") 36 | Object derefIfBound(Object value) { 37 | return value; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/local/ResetSlotsNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.local; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; 6 | import com.oracle.truffle.api.frame.FrameSlot; 7 | import com.oracle.truffle.api.frame.VirtualFrame; 8 | import com.oracle.truffle.api.nodes.ExplodeLoop; 9 | 10 | public class ResetSlotsNode extends OzNode { 11 | 12 | @CompilationFinal(dimensions = 1) FrameSlot[] before; 13 | @Child OzNode node; 14 | @CompilationFinal(dimensions = 1) FrameSlot[] after; 15 | 16 | public ResetSlotsNode(FrameSlot[] before, OzNode node, FrameSlot[] after) { 17 | this.before = before; 18 | this.node = node; 19 | this.after = after; 20 | } 21 | 22 | @ExplodeLoop 23 | private void resetSlots(VirtualFrame frame, FrameSlot[] slots) { 24 | for (int i = 0; i < slots.length; i++) { 25 | frame.setObject(slots[i], null); 26 | } 27 | } 28 | 29 | @Override 30 | public Object execute(VirtualFrame frame) { 31 | resetSlots(frame, before); 32 | Object result = node.execute(frame); 33 | resetSlots(frame, after); 34 | return result; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /platform-test/bench/fd.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Michael Mehl (mehl@dfki.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Michael Mehl, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | 25 | import 26 | Space 27 | export 28 | Return 29 | 30 | define 31 | Return = fd([ 32 | simple(proc {$} 33 | X Y S in 34 | X::1#100000 Y::1#100000 35 | S={Space.new 36 | proc {$ _} 37 | X<:Y Y<:X 38 | end} 39 | {Wait {Space.ask S}} 40 | end 41 | keys:[bench fd propagator] 42 | bench:1) 43 | ]) 44 | end 45 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzUniqueName.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 7 | import com.oracle.truffle.api.library.ExportLibrary; 8 | import com.oracle.truffle.api.library.ExportMessage; 9 | 10 | @ExportLibrary(RecordLibrary.class) 11 | public class OzUniqueName extends OzValue implements Comparable { 12 | 13 | private static final Map TABLE = new HashMap<>(); 14 | 15 | private String name; 16 | 17 | @TruffleBoundary 18 | public static OzUniqueName get(String name) { 19 | return TABLE.computeIfAbsent(name, OzUniqueName::new); 20 | } 21 | 22 | private OzUniqueName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | @ExportMessage 31 | boolean isLiteral() { 32 | return true; 33 | } 34 | 35 | @Override 36 | public int compareTo(OzUniqueName other) { 37 | return name.compareTo(other.name); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return ""; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /lib/main/cp/par/ParServer.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org/ 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | 24 | functor 25 | 26 | export 27 | new: NewServer 28 | newPort: NewServerPort 29 | 30 | define 31 | 32 | fun {NewServer C M} 33 | S P={Port.new S} PS 34 | in 35 | thread 36 | {ForAll S {New {Class.new [C] 'attr' 'feat'(server:PS) nil} M}} 37 | end 38 | proc {PS M} 39 | {Port.send P M} 40 | end 41 | PS 42 | end 43 | 44 | fun {NewServerPort C M} 45 | S P={Port.new S} 46 | in 47 | thread 48 | {ForAll S {New {Class.new [C] 'attr' 'feat'(server:P) nil} M}} 49 | end 50 | P 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/IdentityPair.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | /** 4 | * An identity pair class to be used in general unification and equality 5 | * algorithms. Allows recognizing identical pairs of objects within collections. 6 | */ 7 | public final class IdentityPair implements Comparable { 8 | public final Object a, b; 9 | private final int hashCode; 10 | 11 | public IdentityPair(Object a, Object b) { 12 | int ha = System.identityHashCode(a); 13 | int hb = System.identityHashCode(b); 14 | if (ha < hb) { 15 | this.a = a; 16 | this.b = b; 17 | this.hashCode = 31 * ha + hb; 18 | } else { 19 | this.a = b; 20 | this.b = a; 21 | this.hashCode = 31 * hb + ha; 22 | } 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return hashCode; 28 | } 29 | 30 | @Override 31 | public boolean equals(Object obj) { 32 | if (!(obj instanceof IdentityPair)) { 33 | return false; 34 | } 35 | IdentityPair pair = (IdentityPair) obj; 36 | return this.a == pair.a && this.b == pair.b; 37 | } 38 | 39 | @Override 40 | public int compareTo(IdentityPair o) { 41 | return hashCode - o.hashCode; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /lib/compiler/Doc/FDCompare: -------------------------------------------------------------------------------- 1 | % Generic cases (where Op is one of {'=:', '=<:', '\\=:'}): 2 | 3 | {`GenSum` '#'(X1 ... Xn) Op C} 4 | 5 | X1 + ... + Xn Op C 6 | 7 | {`GenSumC` '#'(C1 ... Cn) '#'(X1 ... Xn) Op C} 8 | 9 | C1*X1 + ... + Cn*Xn Op C 10 | 11 | {`GenSumCN` '#'(C1 ... Cn) '#'(X[1,1]#...#X[1,m1] ... X[n,1]#...#X[n,mn]) Op C} 12 | 13 | C1*X[1,1]*...*X[1,m1] + ... + Cn*X[n,1]*...*X[n,mn] Op C 14 | 15 | {`GenSumR` '#'(X1 ... Xn) Op C V} 16 | 17 | V = (X1 + ... + Xn Op C) 18 | 19 | {`GenSumCR` '#'(C1 ... Cn) '#'(X1 ... Xn) Op C V} 20 | 21 | V = (C1*X1 + ... + Cn*Xn Op C) 22 | 23 | {`GenSumCNR` '#'(C1 ... Cn) '#'(X[1,1]#...#X[1,m1] ... X[n,1]#...#X[n,mn]) Op C V} 24 | 25 | V = (C1*X[1,1]*...*X[1,m1] + ... + Cn*X[n,1]*...*X[n,mn] Op C) 26 | 27 | 28 | 29 | % Special cases not worth the trouble: 30 | 31 | {`PlusRel` X Y Z} 32 | 33 | X + Y =: Z 34 | 35 | {`TimesRel` X Y Z} 36 | 37 | X*Y =: Z 38 | 39 | {`Lepc` X Y C} 40 | 41 | X - Y =<: C 42 | 43 | {`Lec` X C} 44 | 45 | X =<: C 46 | 47 | {`Gec` X C} 48 | 49 | X >=: C 50 | 51 | {`Neq` X Y} 52 | 53 | X \=: Y 54 | 55 | {`Nec` X C} 56 | 57 | X \=: C 58 | 59 | {`Nepc` X Y C} 60 | 61 | X \=: Y + C 62 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/WeakReferenceBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | 5 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; 6 | import com.oracle.truffle.api.dsl.NodeChild; 7 | import com.oracle.truffle.api.dsl.Specialization; 8 | 9 | public abstract class WeakReferenceBuiltins { 10 | 11 | @Builtin(name = "new") 12 | @GenerateNodeFactory 13 | @NodeChild("underlying") 14 | public static abstract class NewWeakReferenceNode extends OzNode { 15 | 16 | @Specialization 17 | Object newWeakReference(Object underlying) { 18 | return unimplemented(); 19 | } 20 | 21 | } 22 | 23 | @Builtin(name = "is") 24 | @GenerateNodeFactory 25 | @NodeChild("value") 26 | public static abstract class IsWeakReferenceNode extends OzNode { 27 | 28 | @Specialization 29 | Object isWeakReference(Object value) { 30 | return unimplemented(); 31 | } 32 | 33 | } 34 | 35 | @GenerateNodeFactory 36 | @NodeChild("weakRef") 37 | public static abstract class GetNode extends OzNode { 38 | 39 | @Specialization 40 | Object get(Object weakRef) { 41 | return unimplemented(); 42 | } 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/translator/ApplyFunctor.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.translator; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.nodes.OzRootNode; 6 | import org.mozartoz.truffle.nodes.builtins.ValueBuiltinsFactory.DotNodeFactory; 7 | import org.mozartoz.truffle.nodes.call.CallNode; 8 | import org.mozartoz.truffle.nodes.control.SequenceNode; 9 | import org.mozartoz.truffle.nodes.literal.LiteralNode; 10 | import org.mozartoz.truffle.runtime.OzLanguage; 11 | import org.mozartoz.truffle.runtime.OzVar; 12 | 13 | import com.oracle.truffle.api.RootCallTarget; 14 | 15 | public abstract class ApplyFunctor { 16 | 17 | public static RootCallTarget apply(OzLanguage language, Object functor, Object imports, String name) { 18 | OzVar result = new OzVar(); 19 | OzNode apply = CallNode.create( 20 | DotNodeFactory.create(new LiteralNode(functor), new LiteralNode("apply")), 21 | new LiteralNode(new Object[] { imports, result })); 22 | 23 | OzNode node = SequenceNode.sequence(apply, DerefNode.create(new LiteralNode(result))); 24 | return OzRootNode.createTopRootNode(language, name, node).toCallTarget(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /lib/main/cp/par/ParGetColor.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org/ 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | 24 | functor 25 | export 26 | get: GetColor 27 | prepare 28 | ColorTab = colors(c(106 90 205) c(46 139 87) c(205 133 63) c(176 48 96) 29 | c(250 235 215) c(154 205 50) c(173 216 230) c(70 130 180) 30 | c(139 69 19) c(143 188 143) c(188 143 143) c(189 183 107) 31 | c(100 149 237) c(233 150 122) c(255 127 80) c(184 134 11) 32 | c(178 34 34) c(0 100 0) c(222 184 135) c(95 158 160) 33 | c(255 228 196)) 34 | 35 | NoColors = {Width ColorTab} 36 | 37 | fun {GetColor N} 38 | ColorTab.((N mod NoColors) + 1) 39 | end 40 | 41 | end 42 | -------------------------------------------------------------------------------- /platform-test/fd/divmod.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | proc {ModDivProb S} 14 | X3 Y3 Z3 X4 Y4 15 | in 16 | S = [X3 Y3 Z3 X4 Y4] 17 | [X3 Y3 Z3]:::1#100 18 | thread {FD.modI X3 Y3 Z3} end 19 | Z3=3 20 | Y3=10 21 | % {Show X3#Y3#Z3} 22 | 23 | [X4 Y4]:::1#100 24 | thread {FD.divI X4 2 Y4} end 25 | % {Show X4#Y4} 26 | Y4\=:36 27 | Y4>:2 28 | 29 | end 30 | 31 | Return= 32 | fd([divmod([ 33 | one(equal(fun {$} 34 | S = {Search.base.one ModDivProb} 35 | T = S.1 36 | in 37 | cond {Map T fun {$ E} {FD.reflect.dom E} end} = 38 | [ 39 | [3#93] 40 | [10] [3] [6#100] 41 | [3#35 37#50] 42 | ] 43 | then 1 else 0 end 44 | end 45 | 1) 46 | keys: [fd]) 47 | ]) 48 | ]) 49 | 50 | end 51 | -------------------------------------------------------------------------------- /platform-test/base/gc2.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | System 4 | Property 5 | export 6 | Return 7 | define 8 | Return = 9 | gc2([changingLimits(proc {$} 10 | % Do not depend on initial threshold 11 | {System.gcDo} 12 | 13 | Min={Property.get 'gc.min'} 14 | Max={Property.get 'gc.max'} 15 | Threshold={Property.get 'gc.threshold'} 16 | NewMax=Threshold 17 | NewMin=Threshold-1 18 | in 19 | {Property.put 'gc.max' 0} % no-op 20 | {Property.get 'gc.max'} = Max 21 | 22 | {Property.put 'gc.max' Min-1} % no-op 23 | {Property.get 'gc.max'} = Max 24 | 25 | {Property.put 'gc.min' 0} % no-op 26 | {Property.get 'gc.min'} = Min 27 | 28 | {Property.put 'gc.min' Max+1} % no-op 29 | {Property.get 'gc.min'} = Min 30 | 31 | {Property.put 'gc.min' NewMin} 32 | {Property.get 'gc.min'} = NewMin 33 | 34 | {Property.put 'gc.max' NewMax} 35 | {Property.get 'gc.max'} = NewMax 36 | {Property.get 'gc.threshold'} < Threshold = true 37 | {System.gcDo} 38 | 39 | % restore 40 | {Property.put 'gc.max' Max} 41 | {Property.put 'gc.min' Min} 42 | {System.gcDo} 43 | end 44 | keys:[gc]) 45 | ]) 46 | end 47 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/Builtin.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target(ElementType.TYPE) 11 | public @interface Builtin { 12 | 13 | public static final Builtin DEFAULT = new Builtin() { 14 | 15 | private final int[] EMPTY_INT_ARRAY = new int[0]; 16 | 17 | @Override 18 | public Class annotationType() { 19 | return Builtin.class; 20 | } 21 | 22 | @Override 23 | public String name() { 24 | return ""; 25 | } 26 | 27 | public boolean proc() { 28 | return false; 29 | } 30 | 31 | @Override 32 | public int[] deref() { 33 | return EMPTY_INT_ARRAY; 34 | } 35 | 36 | @Override 37 | public int[] tryDeref() { 38 | return EMPTY_INT_ARRAY; 39 | }; 40 | }; 41 | 42 | String name() default ""; 43 | 44 | boolean proc() default false; 45 | 46 | int[] deref() default {}; 47 | 48 | int[] tryDeref() default {}; 49 | 50 | public static final int ALL = -1; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchRecordNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.Arity; 6 | 7 | import com.oracle.truffle.api.dsl.CreateCast; 8 | import com.oracle.truffle.api.dsl.NodeChild; 9 | import com.oracle.truffle.api.dsl.Specialization; 10 | import com.oracle.truffle.api.object.DynamicObject; 11 | 12 | @NodeChild("value") 13 | public abstract class PatternMatchRecordNode extends OzNode { 14 | 15 | final Arity arity; 16 | 17 | public PatternMatchRecordNode(Arity arity) { 18 | this.arity = arity; 19 | } 20 | 21 | @CreateCast("value") 22 | protected OzNode derefValue(OzNode value) { 23 | return DerefNode.create(value); 24 | } 25 | 26 | @Specialization(guards = "arity.matches(record)") 27 | boolean patternMatch(DynamicObject record) { 28 | return true; 29 | } 30 | 31 | @Specialization(guards = "!arity.matches(record)") 32 | boolean patternNoMatch(DynamicObject record) { 33 | return false; 34 | } 35 | 36 | @Specialization(guards = "!isRecord(object)") 37 | boolean patternMatch(Object object) { 38 | return false; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchOpenRecordNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.Arity; 6 | 7 | import com.oracle.truffle.api.dsl.CreateCast; 8 | import com.oracle.truffle.api.dsl.NodeChild; 9 | import com.oracle.truffle.api.dsl.Specialization; 10 | import com.oracle.truffle.api.object.DynamicObject; 11 | 12 | @NodeChild("value") 13 | public abstract class PatternMatchOpenRecordNode extends OzNode { 14 | 15 | final Arity arity; 16 | 17 | public PatternMatchOpenRecordNode(Arity arity) { 18 | this.arity = arity; 19 | } 20 | 21 | @CreateCast("value") 22 | protected OzNode derefValue(OzNode value) { 23 | return DerefNode.create(value); 24 | } 25 | 26 | @Specialization(guards = "arity.matchesOpen(record)") 27 | boolean patternMatchOpen(DynamicObject record) { 28 | return true; 29 | } 30 | 31 | @Specialization(guards = "!arity.matchesOpen(record)") 32 | boolean patternNoMatchOpen(DynamicObject record) { 33 | return false; 34 | } 35 | 36 | @Specialization(guards = "!isRecord(object)") 37 | boolean patternMatchOpen(Object object) { 38 | return false; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /vm/jvmci/README.md: -------------------------------------------------------------------------------- 1 | To build JVMCI on Linux, you most likely need an older compiler. 2 | The easiest way to do this is via Docker. 3 | 4 | First, download the `Java SE Development Kit 8u121` from [the archive](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u121-oth-JPR). 5 | 6 | Move the downloaded file `jdk-8u121-linux-x64.tar.gz` to this directory next to the `Dockerfile`. 7 | 8 | Start Docker if it is not already started: 9 | ``` 10 | sudo service docker start 11 | ``` 12 | 13 | Build the image: 14 | ``` 15 | docker build -t mozart-jvmci . 16 | ``` 17 | 18 | Start the image: 19 | ``` 20 | docker run --rm -it mozart-jvmci 21 | ``` 22 | 23 | And then inside run: 24 | ``` 25 | git clone https://github.com/graalvm/mx.git 26 | git clone https://github.com/eregon/jvmci.git 27 | cd jvmci 28 | mx build 29 | ``` 30 | 31 | Then, in *another* terminal, copy the built jdk: 32 | ``` 33 | docker cp `docker ps -q -f ancestor=mozart-jvmci -l`:/home/mozart/jvmci/jdk1.8.0_121/product . 34 | # Make sure it works 35 | ./product/bin/java -version 36 | # Move it to the right location 37 | mkdir -p ../../../jvmci/jdk1.8.0_121 38 | mv product ../../../jvmci/jdk1.8.0_121 39 | ``` 40 | 41 | Exit the docker container: 42 | ``` 43 | exit 44 | ``` 45 | -------------------------------------------------------------------------------- /opi/emacs/windows/startup.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Leif Kornstaedt 4 | * 5 | * Copyright: 6 | * Leif Kornstaedt, 1999 7 | * 8 | * Last change: 9 | * $Date$ by $Author$ 10 | * $Revision$ 11 | * 12 | * This file is part of Mozart, an implementation of Oz 3: 13 | * http://www.mozart-oz.org 14 | * 15 | * See the file "LICENSE" or 16 | * http://www.mozart-oz.org/LICENSE.html 17 | * for information on usage and redistribution 18 | * of this file, and for a DISCLAIMER OF ALL 19 | * WARRANTIES. 20 | */ 21 | 22 | extern bool console; 23 | 24 | // panic.cc 25 | void panic(bool isSystem, const char *format, ...); 26 | 27 | // getenv.cc 28 | char *ozGetenv(const char *var); 29 | 30 | // path.cc 31 | void normalizePath(char *path, bool toUnix); 32 | 33 | // initenv.cc 34 | extern const char *ozplatform; 35 | char *getOzHome(bool toUnix); 36 | void initEnv(void); 37 | 38 | // makecmd.cc 39 | const char *getCmdLine(void); 40 | char *makeCmdLine(bool isWrapper); 41 | 42 | // publishPid.cc 43 | void publishPid(void); 44 | 45 | // process.cc 46 | int createProcess(char *cmdline); 47 | 48 | // registry.cc 49 | char *getRegistry(const char *subKey, const char *valueName); 50 | char *getRegistry(const char *valueName); 51 | -------------------------------------------------------------------------------- /opi/emacs/oz: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # where Oz resides: 4 | 5 | howcalled="$0" 6 | cmd=`basename "$howcalled"` 7 | 8 | if test -z "${OZHOME}" 9 | then 10 | dir=`dirname "$howcalled"` 11 | OZHOME=`(cd "$dir"; cd ..; pwd)` 12 | fi 13 | export OZHOME 14 | 15 | # Determine OZEMACS 16 | 17 | if test -z "${OZEMACS}" 18 | then 19 | IFS="${IFS= }"; saveifs="$IFS"; IFS="$IFS:" 20 | for name in emacs xemacs lemacs; do 21 | for dir in $PATH; do 22 | test -z "$dir" && dir=. 23 | if test -f $dir/$name; then 24 | # Not all systems have dirname. 25 | OZEMACS=$dir/$name 26 | break 2 27 | fi 28 | done 29 | done 30 | IFS="$saveifs" 31 | if test -z "${OZEMACS}" 32 | then 33 | echo "Cannot find emacs" 1>&2 34 | echo "Try setting environment variable OZEMACS" 1>&2 35 | exit 1 36 | fi 37 | fi 38 | 39 | # Call OZEMACS 40 | 41 | if ( "$OZEMACS" --version | grep XEmacs > /dev/null 2>&1 ) 42 | then 43 | exec "$OZEMACS" \ 44 | --eval '(setq load-path (cons "'$OZHOME'/share/mozart/elisp" load-path))' \ 45 | -l oz.elc -f run-oz "$@" 46 | else 47 | exec "$OZEMACS" -L "$OZHOME/share/mozart/elisp" -l oz.elc -f run-oz "$@" 48 | fi 49 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/builtins/ChunkBuiltins.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.builtins; 2 | 3 | import static org.mozartoz.truffle.nodes.builtins.Builtin.ALL; 4 | 5 | import org.mozartoz.truffle.nodes.OzNode; 6 | import org.mozartoz.truffle.runtime.OzChunk; 7 | import org.mozartoz.truffle.runtime.OzProc; 8 | 9 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; 10 | import com.oracle.truffle.api.dsl.NodeChild; 11 | import com.oracle.truffle.api.dsl.Specialization; 12 | import com.oracle.truffle.api.object.DynamicObject; 13 | 14 | public abstract class ChunkBuiltins { 15 | 16 | @Builtin(name = "new", deref = ALL) 17 | @GenerateNodeFactory 18 | @NodeChild("underlying") 19 | public static abstract class NewChunkNode extends OzNode { 20 | 21 | @Specialization 22 | OzChunk newChunk(DynamicObject underlying) { 23 | return new OzChunk(underlying); 24 | } 25 | 26 | } 27 | 28 | @Builtin(name = "is", deref = ALL) 29 | @GenerateNodeFactory 30 | @NodeChild("value") 31 | public static abstract class IsChunkNode extends OzNode { 32 | 33 | @Specialization 34 | boolean isChunk(OzChunk value) { 35 | return true; 36 | } 37 | 38 | @Specialization 39 | boolean isChunk(OzProc value) { 40 | return false; 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /lib/main/base/Exception.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Mueller (mmueller@ps.uni-sb.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Martin Mueller, 1997 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | %% 24 | %% Global 25 | %% 26 | 27 | Exception = exception('raise': Raise 28 | raiseError: Boot_Exception.raiseError 29 | %% 30 | %% wrapper functions 31 | %% 32 | error: fun {$ E} 33 | error(E debug: unit) 34 | end 35 | system: fun {$ E} 36 | system(E debug: unit) 37 | end 38 | failure: fun {$ D} 39 | failure(debug: failure(info: [D])) 40 | end) 41 | -------------------------------------------------------------------------------- /opi/emacs/windows/ppid.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Authors: 3 | * Leif Kornstaedt 4 | * Ralf Scheidhauer 5 | * 6 | * Copyright: 7 | * Leif Kornstaedt, 1999 8 | * Ralf Scheidhauer, 1999 9 | * 10 | * Last change: 11 | * $Date$ by $Author$ 12 | * $Revision$ 13 | * 14 | * This file is part of Mozart, an implementation of Oz 3: 15 | * http://www.mozart-oz.org 16 | * 17 | * See the file "LICENSE" or 18 | * http://www.mozart-oz.org/LICENSE.html 19 | * for information on usage and redistribution 20 | * of this file, and for a DISCLAIMER OF ALL 21 | * WARRANTIES. 22 | */ 23 | 24 | // 25 | // Set the OZPPID environment variable such that an ozengine.exe subprocess 26 | // can check whether its father still lives 27 | // 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "startup.hh" 36 | 37 | /* win32 does not support process groups, 38 | * so we set OZPPID such that a subprocess can check whether 39 | * its father still lives 40 | */ 41 | 42 | void publishPid(void) { 43 | char auxbuf[100]; 44 | int ppid = GetCurrentProcessId(); 45 | sprintf(auxbuf,"%d",ppid); 46 | SetEnvironmentVariable("OZPPID",strdup(auxbuf)); 47 | } 48 | -------------------------------------------------------------------------------- /platform-test/bench/compiler.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Michael Mehl (mehl@dfki.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Michael Mehl, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | 25 | import 26 | Compiler 27 | export 28 | Return 29 | 30 | define 31 | Return = compiler([ 32 | simple(proc {$} 33 | E = {New Compiler.engine init()} 34 | in 35 | {For 1 100 1 36 | proc {$ I} 37 | {E enqueue(feedVirtualString('declare X='#I))} 38 | end} 39 | {Wait {E enqueue(ping($))}} 40 | end 41 | keys:[bench compiler] 42 | bench:1) 43 | ]) 44 | end 45 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/control/TryNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.control; 2 | 3 | import com.oracle.truffle.api.TruffleStackTrace; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.nodes.local.WriteNode; 6 | import org.mozartoz.truffle.runtime.OzException; 7 | 8 | import com.oracle.truffle.api.frame.VirtualFrame; 9 | import com.oracle.truffle.api.profiles.BranchProfile; 10 | 11 | public class TryNode extends OzNode { 12 | 13 | @Child WriteNode writeExceptionVarNode; 14 | @Child OzNode body; 15 | @Child OzNode catchBody; 16 | 17 | private final BranchProfile exceptionProfile = BranchProfile.create(); 18 | 19 | public TryNode(WriteNode writeExceptionVarNode, OzNode body, OzNode catchBody) { 20 | this.body = body; 21 | this.catchBody = catchBody; 22 | this.writeExceptionVarNode = writeExceptionVarNode; 23 | } 24 | 25 | @Override 26 | public Object execute(VirtualFrame frame) { 27 | try { 28 | return body.execute(frame); 29 | } catch (OzException exception) { 30 | exceptionProfile.enter(); 31 | // The exception and its backtrace escapes as a user object 32 | TruffleStackTrace.fillIn(exception); 33 | writeExceptionVarNode.write(frame, exception.getExceptionObject()); 34 | return catchBody.execute(frame); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /lib/main/init/ModuleAbstractions.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Author: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | fun {Link Us} 24 | %% Takes list of urls, returns list of modules 25 | ModMan = {New Module.manager init} 26 | in 27 | %% Compute pairlist of module name and module 28 | {Map Us fun {$ U} 29 | {ModMan link(url:U $)} 30 | end} 31 | end 32 | 33 | fun {Apply UFs} 34 | %% Takes a list of functors or pairs of urls and functors, 35 | %% returns list of modules 36 | ModMan = {New Module.manager init} 37 | in 38 | %% Compute pairlist of module name and module 39 | {Map UFs fun {$ UF} 40 | case UF of U#F then 41 | {ModMan apply(url:U F $)} 42 | else 43 | {ModMan apply(UF $)} 44 | end 45 | end} 46 | end 47 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/runtime/OzRecord.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.runtime; 2 | 3 | import java.util.Map; 4 | 5 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 6 | import com.oracle.truffle.api.object.DynamicObject; 7 | 8 | /** 9 | * An Oz Record is represented as a DynamicObject with RecordObjectType. 10 | */ 11 | public abstract class OzRecord { 12 | 13 | @TruffleBoundary 14 | public static DynamicObject buildRecord(Arity arity, Object... values) { 15 | assert values.length != 0; 16 | assert !arity.isConsArity(); 17 | return arity.createFactory().newRecord(values); 18 | } 19 | 20 | @TruffleBoundary 21 | public static DynamicObject buildRecord(Object label, Map map) { 22 | Object[] features = map.keySet().toArray(); 23 | Arity.sortFeaturesInPlace(features); 24 | Arity arity = Arity.build(label, features); 25 | 26 | Object[] values = new Object[features.length]; 27 | int i = 0; 28 | for (Object feature : features) { 29 | values[i++] = map.get(feature); 30 | } 31 | 32 | return buildRecord(arity, values); 33 | } 34 | 35 | public static Object getLabel(DynamicObject record) { 36 | return Arity.LABEL_LOCATION.get(record); 37 | } 38 | 39 | public static Arity getArity(DynamicObject record) { 40 | return Arity.forRecord(record); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /platform-test/test-opi.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | declare DIR={OS.getEnv 'HOME'}#'/mozart.build/share/test' 24 | {OS.chDir DIR} 25 | 26 | declare 27 | T={{New Module.manager init} 28 | link(url:DIR#'/te.ozf' $)}.run 29 | 30 | {T argv(verbose: true 31 | usage: false 32 | help: false 33 | keys: nil % nil for `all' or a non-empty list of strings: ["fs"] 34 | ignores: nil % nil for `none' or a non-empty list of strings 35 | tests: nil % nil for `all' or a non-empty list of strings: ["fs"] 36 | 'do': true 37 | time: "" % "rgscplt" 38 | memory: "" % "vhacfn" 39 | gc: 0 40 | threads: 1 41 | repeat: 1 42 | delay: 0) _} 43 | 44 | 45 | {Property.put 'messages.idle' true} 46 | -------------------------------------------------------------------------------- /lib/compiler/BackquoteMacro.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import Macro(defmacro listToSequence:Sequify) 3 | export BackquoteExpander 4 | define 5 | fun {BackquoteExpander fMacro(_|L _) _} 6 | {Expand {Sequify L} 1} 7 | end 8 | fun {Expand E N} 9 | case E 10 | of fMacro(fAtom('`' _)|_ _) then {Quote E N+1} 11 | [] fMacro(fAtom(',' _)|L _) then 12 | if N==1 then {Sequify L} else {Quote E N-1} end 13 | else {Quote E N} end 14 | end 15 | fun {Quote E N} 16 | case E 17 | of unit then fAtom(unit unit) 18 | [] true then fAtom(true unit) 19 | [] false then fAtom(false unit) 20 | [] I andthen {IsInt I} then fInt(I unit) 21 | [] F andthen {IsFloat F} then fFloat(F unit) 22 | [] A andthen {IsAtom A} then fAtom(A unit) 23 | [] T andthen {IsTuple T} then 24 | fRecord(fAtom({Label T} unit) 25 | {Map {Record.toList T} fun {$ E} {Expand E N} end}) 26 | [] R andthen {IsRecord R} then 27 | fRecord(fAtom({Label R} unit) 28 | {Map {Record.toListInd R} 29 | fun {$ I E} 30 | fColon( 31 | if {IsInt I} then fInt(I unit) 32 | else fAtom(I unit) end 33 | {Expand E N}) 34 | end}) 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/main/sp/Timer.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | Timer(setTimer mTime) at 'x-oz://boot/Timer' 4 | export 5 | Alarm Delay TimerHandler DelayHandler 6 | define 7 | TimerBox 8 | proc {TimerHandler _} 9 | {Send TimerBox tick} 10 | end 11 | proc {DelayHandler E} 12 | case E of delay(T V) then {Alarm T V} end 13 | end 14 | fun {Alarm T} 15 | Synch 16 | in 17 | {Send TimerBox task({Timer.mTime}+T Synch)} 18 | !!Synch 19 | end 20 | proc {Delay T} 21 | {Wait {Alarm T}} 22 | end 23 | proc {ProcessTask Msgs Tasks} 24 | case Tasks of nil then {ProcessMsg Msgs nil} 25 | [] task(T V)|Tail then 26 | if T=<{Timer.mTime} then V=unit {ProcessTask Msgs Tail} 27 | else {Timer.setTimer T} {ProcessMsg Msgs Tasks} end 28 | end 29 | end 30 | proc {ProcessMsg Msgs Tasks} 31 | case Msgs of M|Msgs then 32 | case M 33 | of tick then {ProcessTask Msgs Tasks} 34 | [] task(T _) then {ProcessTask Msgs {Insert Tasks T M}} 35 | end 36 | end 37 | end 38 | fun {Insert Tasks T Task} 39 | case Tasks of nil then [Task] 40 | [] (Head=task(T2 _))|Tail then 41 | if T (prefix-numeric-value arg) 0))) 11 | (if (and oz-outline-mode 12 | (eq major-mode 'outline-mode)) 13 | (hide-other))) 14 | 15 | (setq minor-mode-alist 16 | (cons '(oz-outline-mode " Click") minor-mode-alist)) 17 | 18 | (defvar oz-outline-map (make-sparse-keymap)) 19 | (define-key oz-outline-map [mouse-2] 'oz-outline-toggle-subtree) 20 | (define-key oz-outline-map [mouse-3] 'oz-outline-reveal-headings) 21 | 22 | (setq minor-mode-map-alist 23 | (cons (cons 'oz-outline-mode oz-outline-map) 24 | minor-mode-map-alist)) 25 | 26 | (defun oz-outline-toggle-subtree (e) 27 | (interactive "e") 28 | (mouse-set-point e) 29 | (save-excursion 30 | (end-of-line) 31 | (if (not (outline-invisible-p)) 32 | (hide-subtree) 33 | (show-subtree)))) 34 | 35 | (defun oz-outline-reveal-headings (e) 36 | (interactive "e") 37 | (mouse-set-point e) 38 | (show-branches)) 39 | 40 | (provide 'oz-extra) 41 | 42 | ;;; Local Variables: *** 43 | ;;; mode: emacs-lisp *** 44 | ;;; byte-compile-dynamic-docstrings: nil *** 45 | ;;; byte-compile-compatibility: t *** 46 | ;;; End: *** 47 | -------------------------------------------------------------------------------- /.idea/libraries/sbt__org_scala_lang_scala_library_2_11_7_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Scala_2_11 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/translator/FrameSlotAndDepth.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.translator; 2 | 3 | import org.mozartoz.truffle.nodes.OzNode; 4 | import org.mozartoz.truffle.nodes.local.ReadCapturedVariableNodeGen; 5 | import org.mozartoz.truffle.nodes.local.ReadLocalVariableNode; 6 | import org.mozartoz.truffle.nodes.local.WriteCapturedVariableNode; 7 | import org.mozartoz.truffle.nodes.local.WriteFrameSlotNodeGen; 8 | import org.mozartoz.truffle.nodes.local.WriteNode; 9 | 10 | import com.oracle.truffle.api.frame.FrameSlot; 11 | 12 | public class FrameSlotAndDepth { 13 | final FrameSlot slot; 14 | final int depth; 15 | 16 | public FrameSlotAndDepth(FrameSlot frameSlot) { 17 | this(frameSlot, 0); 18 | } 19 | 20 | public FrameSlotAndDepth(FrameSlot frameSlot, int depth) { 21 | this.slot = frameSlot; 22 | this.depth = depth; 23 | } 24 | 25 | public FrameSlot getSlot() { 26 | return slot; 27 | } 28 | 29 | public int getDepth() { 30 | return depth; 31 | } 32 | 33 | public OzNode createReadNode() { 34 | if (depth == 0) { 35 | return new ReadLocalVariableNode(slot); 36 | } else { 37 | return ReadCapturedVariableNodeGen.create(slot, depth); 38 | } 39 | } 40 | 41 | public WriteNode createWriteNode() { 42 | if (depth == 0) { 43 | return WriteFrameSlotNodeGen.create(slot); 44 | } else { 45 | return new WriteCapturedVariableNode(slot, depth); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchDynamicArityNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzNode; 5 | import org.mozartoz.truffle.runtime.Arity; 6 | import org.mozartoz.truffle.runtime.OzRecord; 7 | 8 | import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; 9 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; 10 | import com.oracle.truffle.api.dsl.CreateCast; 11 | import com.oracle.truffle.api.dsl.NodeChild; 12 | import com.oracle.truffle.api.dsl.Specialization; 13 | import com.oracle.truffle.api.object.DynamicObject; 14 | 15 | @NodeChild("value") 16 | public abstract class PatternMatchDynamicArityNode extends OzNode { 17 | 18 | @CompilationFinal(dimensions = 1) final Object[] features; 19 | 20 | public PatternMatchDynamicArityNode(Object[] features) { 21 | this.features = features; 22 | } 23 | 24 | @CreateCast("value") 25 | protected OzNode derefValue(OzNode value) { 26 | return DerefNode.create(value); 27 | } 28 | 29 | @TruffleBoundary 30 | @Specialization 31 | boolean patternMatch(DynamicObject record) { 32 | Object label = OzRecord.getLabel(record); 33 | return Arity.build(label, features).matches(record); 34 | } 35 | 36 | @Specialization(guards = "!isRecord(object)") 37 | boolean patternMatch(Object object) { 38 | return false; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /bench/harness.oz: -------------------------------------------------------------------------------- 1 | functor 2 | import 3 | OS 4 | Boot_Time at 'x-oz://boot/Time' 5 | System(showInfo:ShowInfo) 6 | export 7 | measure: Measure 8 | bench: Bench 9 | define 10 | GetTime 11 | Diff 12 | if {HasFeature Boot_Time getMonotonicTime} then % Mozart 2, Mozart-Graal 13 | GetTime = Boot_Time.getMonotonicTime 14 | fun {Diff X Y} 15 | Y - X 16 | end 17 | else 18 | % For Mozart 1, precise to around ~1ms. 19 | % Better than {GetProperty 'time.total'}, which is only precise to 10ms. 20 | fun {GetTime} 21 | Stdout 22 | in 23 | {OS.pipe date ["+%s%N"] _ Stdout#_} 24 | Stdout 25 | end 26 | fun {Diff StdoutX StdoutY} 27 | OutX OutY 28 | in 29 | {OS.wait _ _} 30 | {OS.wait _ _} 31 | {OS.read StdoutX 30 OutX nil _} 32 | {OS.read StdoutY 30 OutY nil _} 33 | {OS.close StdoutX} 34 | {OS.close StdoutY} 35 | {StringToInt OutY} - {StringToInt OutX} 36 | end 37 | end 38 | 39 | fun {Measure F} 40 | T0 = {GetTime} 41 | R={F} 42 | T1 = {GetTime} 43 | in 44 | {ShowInfo ({Diff T0 T1} div 1000000)} 45 | R 46 | end 47 | 48 | Iterations=50 49 | proc {Bench F} 50 | R={NewCell nil} 51 | in 52 | for I in 1..Iterations do 53 | R := nil % Let last result GC 54 | R := {Measure F} 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /vm/src/org/mozartoz/truffle/nodes/pattern/PatternMatchEqualNode.java: -------------------------------------------------------------------------------- 1 | package org.mozartoz.truffle.nodes.pattern; 2 | 3 | import org.mozartoz.truffle.nodes.DerefNode; 4 | import org.mozartoz.truffle.nodes.OzGuards; 5 | import org.mozartoz.truffle.nodes.OzNode; 6 | import org.mozartoz.truffle.nodes.local.DFSEqualNode; 7 | 8 | import com.oracle.truffle.api.dsl.CreateCast; 9 | import com.oracle.truffle.api.dsl.NodeChild; 10 | import com.oracle.truffle.api.dsl.Specialization; 11 | 12 | @NodeChild("value") 13 | public abstract class PatternMatchEqualNode extends OzNode { 14 | 15 | private final Object constant; 16 | 17 | // Cyclic patterns are only possible using variables which 18 | // are handled through equality, so it should not cause problems. 19 | @Child DFSEqualNode equalNode = DFSEqualNode.create(); 20 | 21 | @CreateCast("value") 22 | protected OzNode derefValue(OzNode value) { 23 | return DerefNode.create(value); 24 | } 25 | 26 | public static OzNode create(Object constant, OzNode value) { 27 | if (OzGuards.hasReferenceEquality(constant)) { 28 | return PatternMatchIdentityNodeGen.create(constant, value); 29 | } else { 30 | return PatternMatchEqualNodeGen.create(constant, value); 31 | } 32 | } 33 | 34 | public PatternMatchEqualNode(Object constant) { 35 | this.constant = constant; 36 | } 37 | 38 | @Specialization 39 | boolean patternMatch(Object value) { 40 | return equalNode.executeEqual(constant, value, null); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /platform-test/lib/help-bench.oz: -------------------------------------------------------------------------------- 1 | % -*- Mode: text -*- 2 | ' 3 | Usage: ./ozbench [options] 4 | 5 | ozbench runs benchmarks and prints the average times of 6 | (default 5) runs in the form 7 | 8 | : 9 | times in ms: t: ... 10 | 11 | where is the total time in milliseconds. The other times shown are: 12 | 13 | r:run, g:garbage collection, c:copying, p:propagators, s:system. 14 | 15 | Every benchmark runs at least (default 1500) milliseconds. 16 | A star (*) after the timings indicates that the variation is more than 17 | ten percent. 18 | 19 | The following options are supported: 20 | --[no]verbose, -v [default=no] 21 | Print verbose output 22 | --[no]detailed, [default=no] 23 | Print detailed timings 24 | --usage, --help, -h, -? 25 | Print this text 26 | --gc= [default=0] 27 | If non zero, run garbage collection each milliseconds 28 | --mintime= [default=1500] 29 | Minimal time a benchmark should run 30 | --[no]variance [default=no] 31 | Print the standard variance 32 | --repeat= [default=5] 33 | Number of runs 34 | --tests=,..., [default=all] 35 | Run only those tests in which names at least one occurs 36 | --keys=,..., [default=all] 37 | Run only those tests that feature at least one as key 38 | --ignores=,..., [default=none] 39 | Ignore tests specified by 40 | ' 41 | -------------------------------------------------------------------------------- /bootcompiler/src/main/scala/org/mozartoz/bootcompiler/ast/package.scala: -------------------------------------------------------------------------------- 1 | package org.mozartoz.bootcompiler 2 | 3 | import oz._ 4 | import ast.Node.Pos 5 | 6 | /** Classes representing the AST of Oz code 7 | * 8 | * Provides general utilities for working with ASTs. 9 | */ 10 | package object ast { 11 | // Utils 12 | 13 | def escapePseudoChars(name: String, delim: Char) = { 14 | val result = new StringBuffer 15 | name foreach { c => 16 | if (c == '\\' || c == delim) 17 | result append '\\' 18 | result append c 19 | } 20 | result.toString 21 | } 22 | 23 | /** Builds an Oz List expression from a list of expressions */ 24 | def exprListToListExpr(elems: Seq[Expression])(pos: Pos): Expression = { 25 | elems.foldRight(Constant(OzAtom("nil"))(pos): Expression)((e, tail) => cons(e, tail)) 26 | } 27 | 28 | /** Builds an Oz Cons pair */ 29 | def cons(head: Expression, tail: Expression) = 30 | Record(Constant(OzAtom("|"))(head), 31 | Seq(withAutoFeature(head), withAutoFeature(tail)))(head) 32 | 33 | /** Builds an Oz #-tuple */ 34 | def sharp(fields: Seq[Expression])(pos: Pos) = { 35 | if (fields.isEmpty) Constant(OzAtom("#"))(pos) 36 | else { 37 | Record(Constant(OzAtom("#"))(fields(0)), fields map withAutoFeature)(fields.head) 38 | } 39 | } 40 | 41 | /** Equips an expression with an AutoFeature */ 42 | def withAutoFeature(expr: Expression): RecordField = 43 | RecordField(AutoFeature()(expr), expr)(expr) 44 | } 45 | -------------------------------------------------------------------------------- /platform-test/base/instruction.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Leif Kornstaedt 4 | %%% 5 | %%% Copyright: 6 | %%% Leif Kornstaedt, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | functor 23 | export Return 24 | define 25 | Return = 26 | instruction([testList(stuck(proc {$} 27 | {proc {$ X} 28 | case X of '|'(_ _) then skip 29 | [] f then skip 30 | else skip 31 | end 32 | end '|'(_ _ ...)} 33 | end) 34 | keys: [instruction ofs]) 35 | match(equal(fun {$} 36 | {fun {$ X} 37 | case X of '|'(_ _) then a 38 | else b 39 | end 40 | end '#'(...)} 41 | end b) 42 | keys: [instruction ofs])]) 43 | end 44 | -------------------------------------------------------------------------------- /lib/tools/panel/Panel.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1997 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | 25 | import 26 | Property(get 27 | put) 28 | 29 | System(gcDo) 30 | 31 | Application(exit) 32 | 33 | Error(registerFormatter) 34 | 35 | Open(file) 36 | 37 | Tk 38 | 39 | TkTools(error 40 | dialog 41 | note 42 | notebook 43 | scale 44 | textframe 45 | numberentry 46 | menubar) 47 | 48 | export 49 | 'class': PanelClass 50 | 'object': Panel 51 | 52 | 'open': OpenPanel 53 | 'close': ClosePanel 54 | 55 | require 56 | DefaultURL(homeUrl) 57 | URL(make resolve toAtom) 58 | 59 | prepare 60 | BitmapUrl = {URL.toAtom {URL.resolve DefaultURL.homeUrl 61 | {URL.make 'images/'}}} 62 | 63 | define 64 | \insert 'panel/errors.oz' 65 | \insert 'panel/main.oz' 66 | 67 | Panel = {New PanelClass init} 68 | 69 | proc {OpenPanel} 70 | {Panel open} 71 | end 72 | 73 | proc {ClosePanel} 74 | {Panel close} 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /lib/main/ap/CustomGroup.oz: -------------------------------------------------------------------------------- 1 | functor 2 | export 3 | Register Get RegisterMember 4 | define 5 | %% All known groups 6 | 7 | Registry = {Dictionary.new} 8 | 9 | %% for each group, all its members 10 | 11 | Members = {Dictionary.new} 12 | Top = {NewName} 13 | {Dictionary.put Members Top nil} 14 | 15 | %% 16 | 17 | proc {Register Group} 18 | Name = Group.1 19 | in 20 | if {Dictionary.member Registry Name} then 21 | {Exception.raiseError custom(alreadyExists Group)} 22 | else 23 | {Dictionary.put Registry Name Group} 24 | {RegisterMember Group} 25 | end 26 | end 27 | 28 | %% 29 | 30 | fun {GetParents G} 31 | L = {CondSelect G 'group' Top} 32 | in 33 | if {IsLiteral L} then [L] else L end 34 | end 35 | 36 | %% 37 | 38 | proc {RegisterMember Member} 39 | Type = {Label Member} 40 | Name = Member.1 41 | Spec = Type(Name) 42 | in 43 | {ForAll {GetParents Member} 44 | proc {$ Group} 45 | L = {Dictionary.condGet Members Group nil} 46 | in 47 | if {List.member Spec L} then skip else 48 | {Dictionary.put Members Group Spec|L} 49 | end 50 | end} 51 | end 52 | 53 | %% 54 | 55 | NotFound = {NewName} 56 | 57 | fun {Get Name} 58 | G = {Dictionary.condGet Registry Name NotFound} 59 | in 60 | if G==NotFound then 61 | {Exception.raiseError custom(unknownGroup Name)} unit 62 | else G end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/main/base/Atom.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | 30 | fun {AtomToCompactString A} 31 | if {IsAtom A} then 32 | case A 33 | of nil then {VirtualString.toCompactString "nil"} 34 | [] '#' then {VirtualString.toCompactString "#"} 35 | else {VirtualString.toCompactString A} 36 | end 37 | else 38 | {Exception.raiseError kernel(type 'Atom.toCompactString' [A] 'Atom' 1)} 39 | unit 40 | end 41 | end 42 | 43 | fun {AtomToString A} 44 | if {IsAtom A} then 45 | case A 46 | of nil then "nil" 47 | [] '#' then "#" 48 | else {VirtualString.toString A} 49 | end 50 | else 51 | {Exception.raiseError kernel(type 'Atom.toString' [A] 'Atom' 1)} 52 | unit 53 | end 54 | end 55 | 56 | Atom = atom(is: IsAtom 57 | toCompactString: AtomToCompactString 58 | toString: AtomToString) 59 | -------------------------------------------------------------------------------- /tool/gen_builtins.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | file = ARGV[0] || 'builtins/ModThread-builtin.json' 4 | mod = JSON.parse(File.read(file), symbolize_names: true) 5 | 6 | mod_name = mod[:name] 7 | 8 | mod[:builtins].each { |builtin| 9 | builtin_name = builtin[:name] 10 | fun_name = builtin_name 11 | fun_name += mod_name if %w[is new create this].include?(builtin_name) 12 | class_name = fun_name[0].upcase + fun_name[1..-1] 13 | params = builtin[:params] 14 | is_proc = params.empty? || params.last[:kind] != "Out" 15 | inputs = is_proc ? params : params[0...-1] 16 | children = if inputs.empty? 17 | "" 18 | elsif inputs.size == 1 19 | "\t@NodeChild(\"#{inputs[0][:name]}\")" 20 | else 21 | "\t@NodeChildren({ " + inputs.map { |par| 22 | "@NodeChild(\"#{par[:name]}\")" 23 | } * ", " + " })" 24 | end 25 | fun_args = inputs.map { |par| 26 | "#{par[:kind] == 'Out' ? 'OzVar' : 'Object'} #{par[:name]}" 27 | } * ', ' 28 | 29 | changed_name = fun_name != builtin_name 30 | if is_proc && changed_name 31 | puts "\t@Builtin(name = \"#{builtin_name}\", proc = true)" 32 | elsif is_proc 33 | puts "\t@Builtin(proc = true)" 34 | elsif changed_name 35 | puts "\t@Builtin(name = \"#{builtin_name}\")" 36 | end 37 | puts < { 29 | public OutT run(AsymCoroutine coroutine, InT value); 30 | } 31 | -------------------------------------------------------------------------------- /lib/main/cp/par/ParFindLimit.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Christian Schulte 4 | %%% 5 | %%% Copyright: 6 | %%% Christian Schulte, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org/ 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | 24 | functor 25 | 26 | export 27 | find: FindLimit 28 | 29 | prepare 30 | 31 | fun {NextPower N M} 32 | if N=<{Pow 10.0 M} then {Pow 10.0 M} else {NextPower N M+1.0} end 33 | end 34 | 35 | fun {NextIntegral N P I} 36 | if N= 4 | * Ralf Scheidhauer 5 | * 6 | * Copyright: 7 | * Leif Kornstaedt, 1999 8 | * Ralf Scheidhauer, 1999 9 | * 10 | * Last change: 11 | * $Date$ by $Author$ 12 | * $Revision$ 13 | * 14 | * This file is part of Mozart, an implementation of Oz 3: 15 | * http://www.mozart-oz.org 16 | * 17 | * See the file "LICENSE" or 18 | * http://www.mozart-oz.org/LICENSE.html 19 | * for information on usage and redistribution 20 | * of this file, and for a DISCLAIMER OF ALL 21 | * WARRANTIES. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include "startup.hh" 28 | 29 | char *getRegistry(const char *subKey, const char *valueName) 30 | { 31 | char *ret = NULL; 32 | 33 | HKEY hk; 34 | if (RegOpenKey(HKEY_LOCAL_MACHINE,subKey,&hk) != ERROR_SUCCESS) 35 | return NULL; 36 | 37 | DWORD type; 38 | DWORD buf_size = MAX_PATH; 39 | char buf[MAX_PATH]; 40 | if (RegQueryValueEx(hk,valueName,0,&type,(LPBYTE) buf,&buf_size) 41 | == ERROR_SUCCESS) { 42 | switch (type) { 43 | case REG_SZ: 44 | ret = strdup(buf); 45 | break; 46 | case REG_EXPAND_SZ: 47 | { 48 | char buf2[MAX_PATH]; 49 | DWORD n = ExpandEnvironmentStrings(buf, buf2, MAX_PATH); 50 | if (n != 0 && n != MAX_PATH) { 51 | ret = strdup(buf2); 52 | } 53 | } 54 | break; 55 | default: 56 | break; 57 | } 58 | } 59 | 60 | RegCloseKey(hk); 61 | 62 | return ret; 63 | } 64 | -------------------------------------------------------------------------------- /lib/compiler/Abstractions.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Author: 3 | %%% Leif Kornstaedt 4 | %%% 5 | %%% Copyright: 6 | %%% Leif Kornstaedt, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | proc {EvalExpression VS Env ?Kill ?Result} E I S in 23 | E = {New Engine init()} 24 | I = {New Interface init(E)} 25 | {E enqueue(mergeEnv(Env))} 26 | {E enqueue(setSwitch(expression true))} 27 | {E enqueue(setSwitch(threadedqueries false))} 28 | {E enqueue(feedVirtualString(VS return(result: ?Result)))} 29 | thread T in 30 | T = {Thread.this} 31 | proc {Kill} 32 | {E clearQueue()} 33 | {E interrupt()} 34 | try 35 | {Thread.terminate T} 36 | S = killed 37 | catch _ then skip % already dead 38 | end 39 | end 40 | {I sync()} 41 | if {I hasErrors($)} then Ms in 42 | {I getMessages(?Ms)} 43 | S = error(compiler(evalExpression VS Ms)) 44 | else 45 | S = success 46 | end 47 | end 48 | case S of error(M) then 49 | {Exception.raiseError M} 50 | [] success then skip 51 | [] killed then skip 52 | end 53 | end 54 | 55 | fun {VirtualStringToValue VS} 56 | {EvalExpression VS env() _} 57 | end 58 | -------------------------------------------------------------------------------- /lib/main/base/Tuple.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Module 28 | %% 29 | local 30 | proc {Copy N O T1 T2} 31 | if N>0 then T2.(N+O)=T1.N {Copy N-1 O T1 T2} end 32 | end 33 | proc {Append T1 T2 ?T3} 34 | W1={Width T1} W2={Width T2} 35 | in 36 | if W1==0 then T3=T2 37 | elseif W2==0 then T3={Adjoin T1 T2} 38 | else 39 | T3={MakeTuple {Label T2} W1+W2} 40 | {Copy W1 0 T1 T3} {Copy W2 W1 T2 T3} 41 | end 42 | end 43 | proc {TupleToArray I T A} 44 | if I>0 then {Array.put A I T.I} {TupleToArray I-1 T A} end 45 | end 46 | in 47 | Tuple = tuple(make: MakeTuple 48 | append: Append 49 | is: IsTuple 50 | toArray: fun {$ T} 51 | W={Width T} 52 | A={Array.new 1 W unit} 53 | in 54 | {TupleToArray W T A} 55 | A 56 | end) 57 | end 58 | -------------------------------------------------------------------------------- /platform-test/fd/buildhouse.oz: -------------------------------------------------------------------------------- 1 | 2 | % See Hentenryck page 165 3 | % we have tasks A, B, C etc. with start dates SA, SB etc., durations and precedence relations. 4 | % Eg. task A with duration has to be scheduled before task B, thus SB >=' SA+'7 5 | 6 | functor 7 | 8 | import 9 | 10 | FD 11 | 12 | Search 13 | 14 | export 15 | Return 16 | define 17 | 18 | 19 | proc {BuildHouse Sol} 20 | Sol = [_ _ _ _ _ _ _ _ _ _ _ _] 21 | Sol = {FD.dom 0#30} 22 | {Precedence Sol} 23 | {FD.distribute ff Sol} 24 | end 25 | 26 | proc {GeqOff X Y Off} 27 | X >=: Y + Off 28 | end 29 | 30 | proc {Precedence [SA SB SC SD SE SF SG SH _ SJ SK Send]} 31 | {GeqOff SB SA 7} 32 | {GeqOff SD SA 7} 33 | {GeqOff SC SB 3} 34 | {GeqOff SE SC 1} 35 | {GeqOff SE SD 8} 36 | {GeqOff SG SC 1} 37 | {GeqOff SG SD 8} 38 | {GeqOff SF SD 8} 39 | {GeqOff SF SC 1} 40 | {GeqOff SH SF 1} 41 | {GeqOff SJ SH 3} 42 | {GeqOff SK SG 1} 43 | {GeqOff SK SE 2} 44 | {GeqOff SK SJ 2} 45 | {GeqOff Send SK 1} 46 | choice Send = {FD.reflect.min Send} end 47 | end 48 | 49 | BuildHouseSol = 50 | [[0 7 10 7 15 15 15 16 0 19 21 22]] 51 | Return= 52 | fd([buildhouse([ 53 | one(equal(fun {$} {Search.base.one BuildHouse} end 54 | BuildHouseSol) 55 | keys: [fd]) 56 | one_entailed(entailed(proc {$} {Search.base.one BuildHouse _} end) 57 | keys: [fd entailed]) 58 | ]) 59 | ]) 60 | 61 | 62 | end 63 | -------------------------------------------------------------------------------- /lib/main/base/Port.oz: -------------------------------------------------------------------------------- 1 | %%% Copyright © 2012, Université catholique de Louvain 2 | %%% All rights reserved. 3 | %%% 4 | %%% Redistribution and use in source and binary forms, with or without 5 | %%% modification, are permitted provided that the following conditions are met: 6 | %%% 7 | %%% * Redistributions of source code must retain the above copyright notice, 8 | %%% this list of conditions and the following disclaimer. 9 | %%% * Redistributions in binary form must reproduce the above copyright notice, 10 | %%% this list of conditions and the following disclaimer in the documentation 11 | %%% and/or other materials provided with the distribution. 12 | %%% 13 | %%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | %%% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | %%% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | %%% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | %%% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | %%% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | %%% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | %%% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | %%% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | %%% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | %%% POSSIBILITY OF SUCH DAMAGE. 24 | 25 | Port = port(is: IsPort 26 | new: NewPort 27 | send: Send 28 | sendRecv: SendRecv) 29 | -------------------------------------------------------------------------------- /platform-test/fd/hubert.oz: -------------------------------------------------------------------------------- 1 | % crypto arithmetic 2 | % A/BC + D/EF + G/HI = 1 3 | % A/BC >= D/EF >= G/HI 4 | % all letters are digits between 1 and 9 5 | 6 | % redundant constraints (logic consequences) 7 | % 3(A/BC) >= 1, 3(G/HI) =< 1 8 | 9 | % Solution: 9/12 + 5/34 + 7/68 = 1 10 | % i.e. sol( a: 9 b: 1 c: 2 d: 5 e: 3 f: 4 g: 7 h: 6 i: 8 ) 11 | 12 | functor 13 | 14 | import 15 | 16 | FD 17 | 18 | Search 19 | 20 | export 21 | Return 22 | define 23 | 24 | 25 | 26 | Hubert = 27 | proc {$ X} 28 | A B C D E F G H I 29 | BC = {FD.int 12#98} 30 | EF = {FD.int 12#98} 31 | HI = {FD.int 12#98} 32 | in 33 | X = sol(a:A b:B c:C d:D e:E f:F g:G h:H i:I) 34 | = {FD.dom 1#9} 35 | = {FD.distinct} 36 | BC =: 10*B + C 37 | EF =: 10*E + F 38 | HI =: 10*H + I 39 | A*EF*HI + D*BC*HI + G*BC*EF =: BC*EF*HI 40 | A*EF >=: D*BC 41 | D*HI >=: G*EF 42 | 43 | 3*A >=: BC 44 | 3*G =<: HI 45 | 46 | {FD.distribute ff X} 47 | end 48 | 49 | HubertSol = [sol(a:9 b:1 c:2 d:5 e:3 f:4 g:7 h:6 i:8)] 50 | 51 | Return= 52 | 53 | fd([hubert([ 54 | one(equal(fun {$} {Search.base.one Hubert} end 55 | HubertSol) 56 | keys: [fd]) 57 | all(equal(fun {$} {Search.base.all Hubert} end 58 | HubertSol) 59 | keys: [fd]) 60 | one_entailed(entailed(proc {$} {Search.base.one Hubert _} end) 61 | keys: [fd entailed]) 62 | all_entailed(entailed(proc {$} {Search.base.all Hubert _} end) 63 | keys: [fd entailed]) 64 | ]) 65 | ]) 66 | 67 | end 68 | -------------------------------------------------------------------------------- /platform-test/fd/family.oz: -------------------------------------------------------------------------------- 1 | functor 2 | 3 | import 4 | 5 | FD 6 | 7 | Search 8 | 9 | export 10 | Return 11 | define 12 | 13 | 14 | 15 | Family = 16 | proc {$ Root} 17 | proc {FamilyC Name F} 18 | Coeffs = [1 1 1 ~1 ~1 ~1] 19 | Ages 20 | in 21 | F = Name(boys:{AgeList} girls:{AgeList}) 22 | Ages = {Append F.boys F.girls} 23 | {FD.distinct Ages} 24 | {FD.sumC Coeffs Ages '=:' 0} 25 | {FD.sumCN Coeffs {Map Ages fun {$ A} [A A] end} '=:' 0} 26 | end 27 | proc {AgeList L} 28 | {FD.list 3 0#9 L} 29 | {Nth L 1} >: {Nth L 2} 30 | {Nth L 2} >: {Nth L 3} 31 | end 32 | Maria = {FamilyC maria} 33 | Clara = {FamilyC clara} 34 | AgeOfMariasYoungestGirl = {Nth Maria.girls 3} 35 | AgeOfClarasYoungestGirl = {Nth Clara.girls 3} 36 | Ages = {FoldR [Clara.girls Clara.boys Maria.girls Maria.boys] Append nil} 37 | in 38 | Root = Maria#Clara 39 | {ForAll Maria.boys proc {$ A} A >: AgeOfMariasYoungestGirl end} 40 | AgeOfClarasYoungestGirl = 0 41 | {FD.sum Ages '=:' 60} 42 | {FD.distribute split Ages} 43 | end 44 | 45 | FamilySol = 46 | [maria(boys:[9 5 4] girls:[8 7 3])# 47 | clara(boys:[8 3 1] girls:[7 5 0])] 48 | 49 | Return= 50 | fd([family([ 51 | all(equal(fun {$} {Search.base.all Family} end 52 | FamilySol) 53 | keys: [fd]) 54 | all_entailed(entailed(proc {$} {Search.base.all Family _} end) 55 | keys: [fd entailed]) 56 | ]) 57 | ]) 58 | 59 | end 60 | -------------------------------------------------------------------------------- /lib/main/support/Listener.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Author: 3 | %%% Leif Kornstaedt 4 | %%% 5 | %%% Copyright: 6 | %%% Leif Kornstaedt, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | functor 23 | export 24 | 'class': Listener 25 | define 26 | class Listener 27 | prop locking 28 | attr Port: unit Narrator: unit ServerThread: unit 29 | meth init(NarratorObject Serve) 30 | lock Ms in 31 | Port <- {NewPort Ms} 32 | {NarratorObject register(@Port)} 33 | Narrator <- NarratorObject 34 | thread 35 | ServerThread <- {Thread.this} 36 | {self Serve(Ms)} 37 | end 38 | end 39 | end 40 | meth close() 41 | lock 42 | case @Narrator of unit then skip 43 | else 44 | {Thread.terminate @ServerThread} 45 | {Send @Port close()} 46 | {@Narrator unregister(@Port)} 47 | Narrator <- unit 48 | Port <- unit 49 | ServerThread <- unit 50 | end 51 | end 52 | end 53 | meth getNarrator($) 54 | @Narrator 55 | end 56 | meth getPort($) 57 | @Port 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /opi/emacs/windows/panic.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: 3 | * Leif Kornstaedt 4 | * 5 | * Copyright: 6 | * Leif Kornstaedt, 1999 7 | * 8 | * Last change: 9 | * $Date$ by $Author$ 10 | * $Revision$ 11 | * 12 | * This file is part of Mozart, an implementation of Oz 3: 13 | * http://www.mozart-oz.org 14 | * 15 | * See the file "LICENSE" or 16 | * http://www.mozart-oz.org/LICENSE.html 17 | * for information on usage and redistribution 18 | * of this file, and for a DISCLAIMER OF ALL 19 | * WARRANTIES. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "startup.hh" 27 | 28 | void panic(bool isSystem, const char *format, ...) 29 | { 30 | va_list argList; 31 | char buf[1024]; 32 | 33 | va_start(argList, format); 34 | vsprintf(buf, format, argList); 35 | 36 | if (isSystem) { 37 | LPVOID lpMsgBuf; 38 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 39 | FORMAT_MESSAGE_FROM_SYSTEM | 40 | FORMAT_MESSAGE_IGNORE_INSERTS, 41 | NULL, 42 | GetLastError(), 43 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 44 | (LPTSTR) &lpMsgBuf, 45 | 0, 46 | NULL); 47 | strcat(buf, (LPTSTR) lpMsgBuf); 48 | LocalFree(lpMsgBuf); 49 | } 50 | 51 | if (console) { 52 | fprintf(stderr,"Fatal Error: %s\n",buf); 53 | } else { 54 | MessageBeep(MB_ICONEXCLAMATION); 55 | MessageBox(NULL, buf, "Mozart Fatal Error", 56 | MB_ICONSTOP | MB_SETFOREGROUND); 57 | } 58 | 59 | ExitProcess(1); 60 | } 61 | -------------------------------------------------------------------------------- /lib/compiler/Compiler.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Author: 3 | %%% Leif Kornstaedt 4 | %%% 5 | %%% Copyright: 6 | %%% Leif Kornstaedt, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation of Oz 3: 13 | %%% http://www.mozart-oz.org 14 | %%% 15 | %%% See the file "LICENSE" or 16 | %%% http://www.mozart-oz.org/LICENSE.html 17 | %%% for information on usage and redistribution 18 | %%% of this file, and for a DISCLAIMER OF ALL 19 | %%% WARRANTIES. 20 | %%% 21 | 22 | functor 23 | import 24 | Debug at 'x-oz://boot/Debug' 25 | Parser 26 | CompilerSupport(nameVariable) 27 | Property(get condGet) 28 | Error(extendedVSToVS exceptionToMessage registerFormatter printException) 29 | Type(ask) 30 | Narrator('class') 31 | ErrorListener('class') 32 | PrintName(is) 33 | Unnester(makeExpressionQuery unnestQuery) 34 | Core(userVariable output) 35 | CodeStore('class') 36 | Assembler(internalAssemble assemble) 37 | \ifndef NO_GUMP 38 | Gump(makeProductionTemplates) 39 | ProductionTemplates(default) 40 | \endif 41 | export 42 | Engine 43 | Interface 44 | ParseOzFile 45 | ParseOzVirtualString 46 | Assemble 47 | CodeStoreClass 48 | EvalExpression 49 | VirtualStringToValue 50 | define 51 | local 52 | \insert FormatStrings 53 | \insert CheckTupleSyntax 54 | in 55 | \insert CompilerClass 56 | \insert ParseOz 57 | \insert Interface 58 | \insert Abstractions 59 | \insert Errors 60 | end 61 | CodeStoreClass = CodeStore.'class' 62 | Assemble = Assembler.assemble 63 | end 64 | -------------------------------------------------------------------------------- /lib/main/base/Int.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Martin Henz (henz@iscs.nus.edu.sg) 4 | %%% Christian Schulte 5 | %%% 6 | %%% Copyright: 7 | %%% Martin Henz, 1997 8 | %%% Christian Schulte, 1997 9 | %%% 10 | %%% Last change: 11 | %%% $Date$ by $Author$ 12 | %%% $Revision$ 13 | %%% 14 | %%% This file is part of Mozart, an implementation 15 | %%% of Oz 3 16 | %%% http://www.mozart-oz.org 17 | %%% 18 | %%% See the file "LICENSE" or 19 | %%% http://www.mozart-oz.org/LICENSE.html 20 | %%% for information on usage and redistribution 21 | %%% of this file, and for a DISCLAIMER OF ALL 22 | %%% WARRANTIES. 23 | %%% 24 | 25 | 26 | %% 27 | %% Global 28 | %% 29 | 30 | fun {IsNat X} 0 =< X end 31 | fun {IsOdd X} X mod 2 \= 0 end 32 | fun {IsEven X} X mod 2 == 0 end 33 | 34 | %% 35 | %% Module 36 | %% 37 | fun {IntToCompactString I} 38 | if {IsInt I} then 39 | {VirtualString.toCompactString I} 40 | else 41 | {Exception.raiseError kernel(type 'Int.toCompactString' [I] 'Integer' 1)} 42 | unit 43 | end 44 | end 45 | 46 | fun {IntToString I} 47 | if {IsInt I} then 48 | {VirtualString.toString {Value.toVirtualString I 0 0}} 49 | else 50 | {Exception.raiseError kernel(type 'Int.toString' [I] 'Integer' 1)} 51 | unit 52 | end 53 | end 54 | 55 | Int = int(is: IsInt 56 | isNat: IsNat 57 | isOdd: IsOdd 58 | isEven: IsEven 59 | 'div': Boot_Int.'div' 60 | 'mod': Boot_Int.'mod' 61 | toFloat: IntToFloat 62 | toCompactString: IntToCompactString 63 | toString: IntToString) 64 | -------------------------------------------------------------------------------- /platform-test/bench/tak.oz: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Authors: 3 | %%% Michael Mehl (mehl@dfki.de) 4 | %%% 5 | %%% Copyright: 6 | %%% Michael Mehl, 1998 7 | %%% 8 | %%% Last change: 9 | %%% $Date$ by $Author$ 10 | %%% $Revision$ 11 | %%% 12 | %%% This file is part of Mozart, an implementation 13 | %%% of Oz 3 14 | %%% http://www.mozart-oz.org 15 | %%% 16 | %%% See the file "LICENSE" or 17 | %%% http://www.mozart-oz.org/LICENSE.html 18 | %%% for information on usage and redistribution 19 | %%% of this file, and for a DISCLAIMER OF ALL 20 | %%% WARRANTIES. 21 | %%% 22 | 23 | functor 24 | 25 | export 26 | Return 27 | 28 | define 29 | 30 | fun {Tak X Y Z} 31 | if X= [default=0] 11 | If non zero, run garbage collection each milliseconds 12 | --threads= [default=1] 13 | Run threads concurrently (for each test) 14 | --repeat= [default=1] 15 | Each thread repeats the test times 16 | --delay= [default=0] 17 | Wait ms before a next run (kludge for (linux) inetd) 18 | --tests=,..., [default=all] 19 | Run only those tests in which names at least one occurs 20 | --keys=,..., [default=all] 21 | Run only those tests that feature at least one as key 22 | --ignores=,..., [default=none] 23 | Ignore tests specified by 24 | --time= [default=""] 25 | Print run times in verbose mode. If one of the following keys 26 | is in the corresponding information is printed: 27 | r:run g:gc s:system c:copy p:propagate l:load t:total 28 | Example: "time=rgs" prints the run, gc and system time. 29 | --memory= [default=""] 30 | Print memory consumption. If one of the following keys 31 | is in the corresponding information is printed: 32 | v:virtual memory 33 | h:heap (active size) 34 | a:byte for atoms 35 | c:atoms for code 36 | f:bytes in free lists 37 | n:bytes for names 38 | ' 39 | --------------------------------------------------------------------------------