# How to run

Running the Modelverse is all done through the use of scripts to coordinate the three different projects.

The following scripts are included by default.

## check_objects.py

Checks whether all compiled objects can be found, and if their symbol table does not contain undefined references. This script cannot be executed directly and is only a helper.

## compile.py

Compiles the provided code with the selected mode. This should also not be called by end-users, though it is possible.

Invocation:

    python scripts/compile.py address file username object mode

Parameter name | Description | Example
--- | --- | ---
address | Address of the Modelverse | http://localhost:8001
file | File to be compiled | file.alc
username | Username to use when compiling | test_user
object | Object name to export to | object.o
mode | Either CO (constructors) or PO (graph) | PO

## execute_model.py

Compile a model and action language files together, executing the action language. First, all models are added, and then the action language is executed, starting at function “main”. Models being created are temporary, so they need to be exported before they can be accessed in the action language.

Invocation:

    python scripts/execute_model.py address username file1 file2 ...

Parameter name | Description | Example
--- | --- | ---
address | Address of the Modelverse | http://localhost:8001
username | Username to use when compiling | test
file | File to compile (either .mvc or .alc) | test.alc

## fix_files.py

Fix some files that must be kept identical. This is sometimes necessary because if a file gets updated, the changes must propagate. Usually, this is done with symbolic links or similar, but there does not seem to be a nice cross-platform way of doing this in Git.

Invocation:

    python scripts/fix_files.py

## flush_compiler_caches.py

Clear all cached files from the compiler. The compiler will automatically reparse files when they have been changed, but changes to the compiler code itself will not be detected. When changing the compiler, this file should be executed to flush these file caches.

Invocation:

    python scripts/flush_compiler_caches.py

## generate_bootstrap.py

Creates the bootstrap file for the Modelverse State. This creates the necessary initial graph which contains links to all primitive code that is executed by the Modelverse before users can communicate with it. Generally, this needs to be executed when any file in the bootstrap/ folder is modified. Compilation is fairly smart, only recompiling parts that have changed.

Invocation:

    python scripts/generate_bootstrap.py

## link_and_load.py

This takes a set of objects in the Modelverse, links them together in a single “executable” and executes it immediately. Generally not needed by end-users.

Invocation:

    python scripts/link_and_load.py address username object1 object2 ...

Parameter name | Description | Example
--- | --- | ---
address | Address of the Modelverse | http://localhost:8001
username | Username to use when compiling | test
object | File to compile (either .mvc or .alc) | test.alc

## make_all.py

Compile a set of files and executes them immediately. This uses constructors by default, which is the most elegant, but also the slowest.

Invocation:

    python scripts/make_all.py address username file1 file2 ...

Parameter name | Description | Example
--- | --- | ---
address | Address of the Modelverse | http://localhost:8001
username | Username to use when compiling | test
file | File to compile (either .mvc or .alc) | test.alc

## make_parallel.py

A parallel version of make_all.py. This uses the direct graph compilation, and compiles these graphs in parallel. This is much faster than make_all, though much less elegant.

Invocation:

    python scripts/make_parallel.py address username file1 file2 ...

Parameter name | Description | Example
--- | --- | ---
address | Address of the Modelverse | http://localhost:8001
username | Username to use when compiling | test
file | File to compile (either .mvc or .alc) | test.alc

## prompt.py

A generic prompt interface to the Modelverse. You can log in as a specific user and start sending input messages to the Modelverse as that user. All output sent by the Modelverse will be printed in the console. There is no logic in the prompt itself, making it completely generic.

Invocation:

    python scripts/prompt.py

## run_local_modelverse.py

Locally runs an instance of the Modelverse at the requested port. This combines MvK and MvS at the same system, and actually makes a direct link between them, omitting the slow use of sockets. While this is kind of a hack at the moment, it is really necessary with the current low performance. To split them up, there just needs to be a statechart in between both of them (which is already written and working).

Invocation:

    python scripts/run_local_modelverse.py port

Parameter name | Description | Example
--- | --- | ---
port | Port to host the Modelverse on | 8001

## run_tests.py

Run the tests for all parts of the Modelverse.

Invocation:

    python scripts/run_tests.py