Browse Source

Massive cleanup

Yentl Van Tendeloo 6 years ago
parent
commit
592282cbcf

+ 13 - 36
README.md

@@ -10,52 +10,32 @@ Starting up the Modelverse
 ==========================
 
 Starting up the Modelverse is easy: simply execute the `scripts/run_local_modelverse.py` script, with as parameter the port you want to use.
-This will compile the Modelverse statechart and execute it afterwards.
-You can now directly communicate with the Modelverse task initialisation layer.
-It is not recommended that you do this manually, so we will now introduce the action language.
-
-Compiling Action Language
-=========================
-
-For a more user-friendly experience, an Action Language compiler was introduced that can automatically generate Modelverse instructions.
-During compilation, a live Modelverse is required, as the bytecodes are immediately uploaded after compilation.
-The Modelverse uses a traditional compilation phase and linking phase, though this is all hidden to the user through the `scripts/make_all.py` script.
-The script takes as parameter the address of the Modelverse, the taskname with which to communicate, and a list of source files.
-For realistic applications, we recommend to always link to the bootstrap code, by including the file `bootstrap/\*.alc`.
-Even on systems that don't support globbing (e.g., Windows), this will automatically be expanded by the compiler.
-
-For example, to compile the simple textual interface, you must compile the interface's action language, together with all bootstrapping code (the libraries):
-
-```sh
-python scripts/make_all.py http://127.0.0.1:8001 test_task bootstrap/*.alc integration/code/pn_interface.alc
-```
-
-Compilation is (relatively) smart, as it will not compile code again that is already present in the Modelverse.
-As such, except for the first task, the bootstrap code no longer needs to be compiled, only linked.
-In the future, this is expected to become more user friendly for users, such that they no longer need to have the bootstrapping code available locally.
-
-After this part, your action language in `integration/code/pn_interface.alc` is compiled and running on the Modelverse.
-The Modelverse will, during loading, execute the main function it finds in any of these files.
+By default, port 8001 is used.
 
 Communicating with the Modelverse
 =================================
 
-Now that your code is running on the Modelverse, you will want to communicate with it!
+Now that the Modelverse is running, you will want to communicate with it!
 To do this, you can use whatever tool you want, as long as it can send and receive XML/HTTPRequests.
 For example, a mere internet browser can already communicate with the Modelverse, though not in the most user-friendly way.
 
 A nicer way is through the Python prompt script `scripts/prompt.py`.
 After that, it will print out all the output of the Modelverse, and send in all your queries directly to the Modelverse.
 
+Python wrapper
+==============
+
+To automatically communicate with the Modelverse in a programmatic way, a Python wrapper is provided.
+This wrapper is found in `wrappers/modelverse.py`, and provides Python functions that make the necessary Modelverse requests.
+At the moment, not all functions are implemented in the wrapper yet.
+
 Performance
 ===========
 
-Performance of the Modelverse is currently rather low, especially in the make\_all script, as this uses an explicitly modelled bytecode upload system.
-To drastically increase performance, this can be switched to a native implementation and a different compiler.
-Additionally, all compilations of source files can happen in parallel, using as many cores as are available.
-Even further, you can skip symbol resolution in the linking phase if you know that all symbols are defined.
-To do all of this, use the `scripts/make_parallel.py` script.
-It is identical to the `scripts/make_all.py` script, but uses multiple cores and uses native code.
+Performance of the Modelverse is currently rather low.
+This is primarily caused by the reliance on the action language, which is an explicitly modelled (and interpreted) language.
+Additionally, the Modelverse runs remotely, meaning that all requests have to pass over the network.
+Even when this is executed on the same machine, this causes quite some overhead.
 
 Additional documentation
 ========================
@@ -70,9 +50,6 @@ Running the tests is easy: simply execute `scripts/run_tests.py` in the main mod
 This will invoke the necessary build commands (to create bootstrapping code etc.) and call the tests for each individual aspect of the Modelverse.
 Note that testing is done using py.test, which is the only dependency of the Modelverse (and only for tests, of course).
 
-Regarding performance of tests, the tests will try to execute the compilation in parallel, though they test both the explicitly modelled upload system and the native code.
-As such, test performance for the "co\_\*" tests is known to be slow.
-
 Using PyPy
 ----------
 

+ 0 - 25
integration/code/binary_to_decimal.alc

@@ -1,25 +0,0 @@
-include "primitives.alh"
-
-Integer function b2d(param : String):
-	Integer value
-	value = 0
-	Integer length
-	length = string_len(param)
-	Integer counter
-	counter = integer_subtraction(length, 1)
-	Integer accumul
-	accumul = 1
-
-	while (counter >= 0):
-		if (string_get(param, counter) == "1"):
-			value = integer_addition(value, accumul)
-		accumul = integer_multiplication(accumul, 2)
-		counter = integer_subtraction(counter, 1)
-
-	return value!
-
-Void function main():
-	while(True):
-		output(b2d(input()))
-
-	return!

+ 0 - 13
integration/code/factorial.alc

@@ -1,13 +0,0 @@
-include "primitives.alh"
-
-Integer function factorial(n : Integer):
-	if(n <= 1):
-		return 1!
-	else:
-		return n * factorial(n - 1)!
-
-Void function main():
-	while(True):
-		output(factorial(input()))
-
-	return!

+ 0 - 13
integration/code/fibonacci.alc

@@ -1,13 +0,0 @@
-include "primitives.alh"
-
-Integer function fib(param : Integer):
-	if (param <= 2):
-		return 1!
-	else:
-		return fib(param - 1) + fib(param - 2)!
-
-Void function main():
-	while(True):
-		output(fib(input()))
-
-	return!

+ 0 - 19
integration/code/fibonacci_smart.alc

@@ -1,19 +0,0 @@
-include "primitives.alh"
-
-Element numbers = ?
-
-Integer function fib(param : Integer):
-	Integer new
-	while (param > list_len(numbers)):
-		new = list_len(numbers)
-		list_append(numbers, integer_addition(dict_read(numbers, new - 2), dict_read(numbers, new - 1)))
-	return dict_read(numbers, param - 1)!
-
-Void function main():
-	numbers = create_node()
-	list_append(numbers, 1)
-	list_append(numbers, 1)
-	while(True):
-		output(fib(input()))
-
-	return!

+ 0 - 14
integration/code/if_elif.alc

@@ -1,14 +0,0 @@
-include "primitives.alh"
-
-Integer function compare_with_zero(n : Integer):
-	if(n < 0):
-		return -1!
-	elif(n == 0):
-		return 0!
-	return 1!
-
-Void function main():
-	while(True):
-		output(compare_with_zero(input()))
-
-	return!

+ 0 - 15
integration/code/if_elif_else.alc

@@ -1,15 +0,0 @@
-include "primitives.alh"
-
-Integer function compare_with_zero(n : Integer):
-	if(n < 0):
-		return -1!
-	elif(n == 0):
-		return 0!
-	else:
-		return 1!
-
-Void function main():
-	while(True):
-		output(compare_with_zero(input()))
-
-	return!

+ 0 - 18
integration/code/leap_year.alc

@@ -1,18 +0,0 @@
-include "lib_remainder.alc"
-
-Boolean function leap_year(year : Integer):
-	// Is a leap year if it is divisible by 4
-	if (remainder(year, 4) == 0):
-		// Unless it is also divisible by 1000
-		if (remainder(year, 1000) == 0):
-			return False!
-		else:
-			return True!
-	else:
-		return False!
-
-Void function main():
-	while (True):
-		output(leap_year(input()))
-
-	return!

+ 0 - 4
integration/code/lib_remainder.alc

@@ -1,4 +0,0 @@
-include "primitives.alh"
-
-Integer function remainder(a : Integer, b: Integer):
-	return a - ((a / b) * b)!

+ 0 - 6
integration/code/main.alc

@@ -1,6 +0,0 @@
-include "io.alh"
-
-Void function main():
-	while(True):
-		output("Hello, world!")
-	return!

+ 0 - 13
integration/code/power.alc

@@ -1,13 +0,0 @@
-include "primitives.alh"
-
-Integer function power(base : Integer, exponent : Integer):
-	if (exponent == 0):
-		return 1!
-	else:
-		return base * power(base, exponent - 1)!
-
-Void function main():
-	while (True):
-		output(power(input(), input()))
-
-	return!

+ 0 - 7
integration/code/remainder.alc

@@ -1,7 +0,0 @@
-include "lib_remainder.alc"
-
-Void function main():
-	while(True):
-		output(remainder(input(), input()))
-
-	return!

+ 0 - 23
integration/code/revert.alc

@@ -1,23 +0,0 @@
-include "primitives.alh"
-
-String function revert_string(a : String):
-	Integer length
-	length = string_len(a)
-
-	Integer counter
-	counter = 0
-
-	String result
-	result = ""
-
-	while (counter < length):
-		result = string_join(string_get(a, counter), result)
-		counter = counter + 1
-
-	return result!
-
-Void function main():
-	while (True):
-		output(revert_string(input()))
-
-	return!

+ 0 - 9
integration/test_binary2decimal.py

@@ -1,9 +0,0 @@
-import unittest
-
-from utils import run_file
-
-class TestBinary2Decimal(unittest.TestCase):
-    def test_binary2decimal(self):
-        self.assertTrue(run_file(["binary_to_decimal.alc", "primitives.alc"],
-            ["1", "10", "11", "100", "001", "1100111101"],
-            [1, 2, 3, 4, 1, 829]))

+ 0 - 190
integration/test_constructors_al.py

@@ -1,190 +0,0 @@
-import unittest
-import sys
-import os
-
-from utils import execute, kill, run_file, run_barebone
-
-class TestConstructorsActionLanguage(unittest.TestCase):
-    def test_constructors_simple(self):
-        commands = ["output",                    # Output
-                        "const", True,
-                        True,                     # (has next)
-                        "return",                # Return
-                            True,                 # (has value)
-                            "const", True,
-                ]
-        self.assertTrue(run_barebone(commands, [True], 1))
-
-    def test_constructors_if_else_true(self):
-        commands = ["if",                    # If
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has else
-                        "output",            # False-part
-                            "const", False,
-                            False,            # Has next
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [True], 1))
-
-    def test_constructors_if_else_false(self):
-        commands = ["if",                    # If
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has else
-                        "output",            # False-part
-                            "const", False,
-                            False,            # Has next
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [False], 1))
-
-    def test_constructors_if_true(self):
-        commands = ["if",                    # If
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        False,                # Has else
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [True], 1))
-
-    def test_constructors_if_false(self):
-        commands = ["if",                    # If
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        False,                # Has else
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [None], 1, timeout=True))
-
-    def test_constructors_addition(self):
-        commands = ["output",
-                        "call",
-                            "deref", "primitives/integer_addition",
-                            2,
-                            "const", 1,
-                            "const", 5,
-                            False,
-                        True,
-                        "return", True, "const", True,
-                ]
-        self.assertTrue(run_barebone(commands, [6], 1))
-
-    def test_constructors_while_false(self):
-        commands = ["while",                 # While
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has next
-                        "output",            # Output false
-                            "const", False,
-                            True,             # Has next
-                            "return",        # Return
-                                True,         # Has value
-                                "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [False], 1))
-
-    def test_constructors_while_true(self):
-        commands = ["while",                 # While
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has next
-                        "output",            # False-part
-                            "const", False,
-                            True,            # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [True, True, True, True], 1))
-
-    def test_constructors_declare_and_assign(self):
-        commands = ["declare",
-                        "1",
-                        True,
-                    "assign",
-                        "resolve", "1",
-                        "const", 5,
-                        True,
-                    "output",
-                        "access", "resolve", "1",
-                        True,
-                    "return",
-                        True,
-                        "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands, [5], 1))
-
-    def test_constructors_output_input(self):
-        commands = ["output",
-                        "input",
-                        True,
-                    "return",
-                        True,
-                        "const", "true",
-                ]
-        self.assertTrue(run_barebone(commands + [123456], [123456], 1))
-
-    def test_constructors_continue(self):
-        commands = ["while",
-                        "const", True,
-                        "output", "const", 1,
-                            True,
-                            "if",
-                                "const", True,
-                                "continue",
-                                False,
-                                True,
-                            "output", "const", 2,
-                                False,
-                        True,
-                    "output", "const", 3,
-                        True,
-                    "return", True,
-                        "const", True,
-                ]
-        self.assertTrue(run_barebone(commands, [1, 1, 1, 1, 1], 1))
-
-    def test_constructors_break(self):
-        commands = ["while",
-                        "const", True,
-                        "output", "const", 1,
-                            True,
-                            "if",
-                                "const", True,
-                                "break",
-                                False,
-                                True,
-                            "output", "const", 2,
-                                False,
-                        True,
-                    "output", "const", 3,
-                        True,
-                    "return", True,
-                        "const", True,
-                ]
-        self.assertTrue(run_barebone(commands, [1, 3], 1))

+ 0 - 227
integration/test_constructors_al_linkable.py

@@ -1,227 +0,0 @@
-import unittest
-import sys
-import os
-
-from utils import execute, kill, run_file, run_barebone
-
-def extend_commands(commands):
-    # Initially we communicate with the compilation_manager to add the bytecodes
-    pre =   [
-                3,
-                "upload",
-                "test.o",
-                "MD5_HASH",
-                True,     # use NEW interface for constructors
-                "funcdef", "main", 0, # Main function
-            ]
-    # We only have to define "main" for now
-    post =  [
-                True,
-                "main",
-                True,
-                False,
-            ]
-    return pre + commands + post
-
-class TestConstructorsActionLanguageLinkable(unittest.TestCase):
-    def test_constructors_simple(self):
-        commands = [
-                        "output",
-                            "const", True,
-                            True,
-                        "return",
-                            True,
-                            "const", True,
-                        False,
-                    ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [True], None, link=["test.o"]))
-
-    def test_constructors_if_else_true(self):
-        commands = [
-                        "if",                    # If
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has else
-                        "output",            # False-part
-                            "const", False,
-                            False,            # Has next
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                        False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [True], None, link=["test.o"]))
-
-    def test_constructors_if_else_false(self):
-        commands = [
-                        "if",                    # If
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has else
-                        "output",            # False-part
-                            "const", False,
-                            False,            # Has next
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                        False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [False], None, link=["test.o"]))
-
-    def test_constructors_if_true(self):
-        commands = [
-                        "if",                    # If
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        False,                # Has else
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                    False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [True], None, link=["test.o"]))
-
-    def test_constructors_if_false(self):
-        commands = [
-                        "if",                    # If
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        False,                # Has else
-                        True,                 # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                        False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [None], None, timeout=True, link=["test.o"]))
-
-    def test_constructors_while_false(self):
-        commands = [
-                        "while",                 # While
-                        "const", False,   # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has next
-                        "output",            # Output false
-                            "const", False,
-                            True,             # Has next
-                            "return",        # Return
-                                True,         # Has value
-                                "const", "true",
-                        False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [False], None, link=["test.o"]))
-
-    def test_constructors_while_true(self):
-        commands = [
-                        "while",                 # While
-                        "const", True,    # Condition
-                        "output",            # True-part
-                            "const", True,
-                            False,            # Has next
-                        True,                 # Has next
-                        "output",            # False-part
-                            "const", False,
-                            True,            # Has next
-                        "return",            # Return
-                            True,             # Has value
-                            "const", "true",
-                        False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [True, True, True, True], None, link=["test.o"]))
-
-    def test_constructors_declare_and_assign(self):
-        commands = [
-                    "declare",
-                        "1",
-                        True,
-                    "assign",
-                        "resolve", "1",
-                        "const", 5,
-                        True,
-                    "output",
-                        "access", "resolve", "1",
-                        True,
-                    "return",
-                        True,
-                        "const", "true",
-                    False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [5], None, link=["test.o"]))
-
-    def test_constructors_output_input(self):
-        commands = [
-                     "output",
-                        "input",
-                        True,
-                    "return",
-                        True,
-                        "const", "true",
-                    False,
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [123456], None, link=["test.o"], inputs=["123456"]))
-
-    def test_constructors_continue(self):
-        commands = ["while",
-                        "const", True,
-                        "output", "const", 1,
-                            True,
-                            "if",
-                                "const", True,
-                                "continue",
-                                False,
-                                True,
-                            "output", "const", 2,
-                                False,
-                        True,
-                    "output", "const", 3,
-                        True,
-                    "return", True,
-                        "const", True,
-                    False
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [1, 1, 1, 1, 1], None, link=["test.o"]))
-
-    def test_constructors_break(self):
-        commands = ["while",
-                        "const", True,
-                        "output", "const", 1,
-                            True,
-                            "if",
-                                "const", True,
-                                "break",
-                                False,
-                                True,
-                            "output", "const", 2,
-                                False,
-                        True,
-                    "output", "const", 3,
-                        True,
-                    "return", True,
-                        "const", True,
-                    False
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, [1, 3], None, link=["test.o"]))

+ 0 - 468
integration/test_constructors_models.py

@@ -1,468 +0,0 @@
-import unittest
-import sys
-import os
-
-from utils import execute, kill, run_file, run_barebone, get_constructor
-
-bottom = [
-        "model",
-        "instantiate_bottom", "1",
-        "add_node", "1", "Element",
-        "add_node", "1", "Class",
-        "add_node", "1", "Attribute",
-        "add_node", "1", "SimpleAttribute",
-        "add_node", "1", "String",
-        "add_value", "1", "name_value", "name",
-        "add_edge", "1", "Association", "Class", "Class",
-        "add_edge", "1", "Inheritance", "Element", "Element",
-        "add_edge", "1", "AttributeLink", "Element", "Attribute",
-        "add_edge", "1", "attr_name", "AttributeLink", "String",
-        "add_edge", "1", "attr_name_name", "attr_name", "name_value",
-        "add_edge", "1", "class_inh_element", "Class", "Element",
-        "add_edge", "1", "attribute_inh_element", "Attribute", "Element",
-        "add_edge", "1", "simple_inh_attribute", "SimpleAttribute", "Attribute",
-        "add_edge", "1", "association_inh_element", "Association", "Element",
-        "add_edge", "1", "attributelink_inh_element", "AttributeLink", "Element",
-
-        "retype_model", "1", "1",
-        "retype", "1", "Element", "Class",
-        "retype", "1", "Class", "Class",
-        "retype", "1", "Attribute", "Class",
-        "retype", "1", "SimpleAttribute", "Class",
-        "retype", "1", "String", "SimpleAttribute",
-        "retype", "1", "name_value", "String",
-        "retype", "1", "Association", "Association",
-        "retype", "1", "Inheritance", "Association",
-        "retype", "1", "AttributeLink", "Association",
-        "retype", "1", "attr_name", "AttributeLink",
-        "retype", "1", "attr_name_name", "attr_name",
-        "retype", "1", "class_inh_element", "Inheritance",
-        "retype", "1", "attribute_inh_element", "Inheritance",
-        "retype", "1", "simple_inh_attribute", "Inheritance",
-        "retype", "1", "association_inh_element", "Inheritance",
-        "retype", "1", "attributelink_inh_element", "Inheritance",
-
-        "instantiate_node", "1", "SimpleAttribute", "Location",
-        "instantiate_node", "1", "SimpleAttribute", "Natural",
-        "instantiate_node", "1", "SimpleAttribute", "Boolean",
-        "instantiate_link", "1", "AttributeLink", "attr_optional", "AttributeLink", "Boolean",
-        "instantiate_attribute", "1", "attr_optional", "name", "optional",
-        "instantiate_attribute", "1", "attr_optional", "optional", False,
-        "instantiate_attribute", "1", "attr_name", "optional", False,
-
-        "instantiate_node", "1", "Class", "ComplexAttribute",
-        "instantiate_link", "1", "Inheritance", "", "ComplexAttribute", "Attribute",
-
-        "model_define_attribute", "1", "Class", "lower_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Class", "upper_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Association", "source_lower_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Association", "source_upper_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Association", "target_lower_cardinality", True, "Natural",
-        "model_define_attribute", "1", "Association", "target_upper_cardinality", True, "Natural",
-        "model_define_attribute", "1", "ComplexAttribute", "type", False, "Location",
-
-        "export_node", "1", "models/SimpleClassDiagrams_new",
-        "exit",
-    ]
-
-bottom_link_al = [
-        "model",
-        "instantiate_node", "1", "ComplexAttribute", "ActionLanguage",
-        "instantiate_attribute", "1", "ActionLanguage", "type", "models/ActionLanguage",
-
-        "model_define_attribute", "1", "Element", "constraint", True, "ActionLanguage",
-        "exit",
-    ]
-
-action_language = [
-        "model",
-        "instantiate_model", "1", "2",
-        "instantiate_node", "2", "Class", "Element",
-        "instantiate_node", "2", "Class", "Action",
-        "instantiate_node", "2", "Class", "Statement",
-        "instantiate_node", "2", "Class", "Expression",
-        "instantiate_node", "2", "Class", "funcdef",
-        "instantiate_node", "2", "Class", "param",
-        "instantiate_node", "2", "Class", "if",
-        "instantiate_node", "2", "Class", "break",
-        "instantiate_node", "2", "Class", "while",
-        "instantiate_node", "2", "Class", "continue",
-        "instantiate_node", "2", "Class", "assign",
-        "instantiate_node", "2", "Class", "return",
-        "instantiate_node", "2", "Class", "output",
-        "instantiate_node", "2", "Class", "declare",
-        "instantiate_node", "2", "Class", "global",
-        "instantiate_node", "2", "Class", "access",
-        "instantiate_node", "2", "Class", "constant",
-        "instantiate_node", "2", "Class", "input",
-        "instantiate_node", "2", "Class", "resolve",
-        "instantiate_node", "2", "Class", "call",
-        "instantiate_node", "2", "Class", "String",
-        "instantiate_node", "2", "SimpleAttribute", "StringAttr",
-
-        "instantiate_node", "2", "Class", "Initial",
-        "instantiate_attribute", "2", "Initial", "lower_cardinality", 1,
-        "instantiate_attribute", "2", "Initial", "upper_cardinality", 1,
-        "instantiate_link", "2", "Association", "initial_funcdef", "Initial", "Action",
-        "instantiate_attribute", "2", "initial_funcdef", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "initial_funcdef", "target_upper_cardinality", 1,
-
-        "instantiate_link", "2", "Inheritance", "", "Action", "Element",
-        "instantiate_link", "2", "Inheritance", "", "funcdef", "Action",
-        "instantiate_link", "2", "Inheritance", "", "param", "Action",
-        "instantiate_link", "2", "Inheritance", "", "Statement", "Action",
-        "instantiate_link", "2", "Inheritance", "", "Expression", "Action",
-        "instantiate_link", "2", "Inheritance", "", "resolve", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "if", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "break", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "continue", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "global", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "while", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "assign", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "return", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "call", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "declare", "Statement",
-        "instantiate_link", "2", "Inheritance", "", "call", "Expression",
-        "instantiate_link", "2", "Inheritance", "", "access", "Expression",
-        "instantiate_link", "2", "Inheritance", "", "constant", "Expression",
-        "instantiate_link", "2", "Inheritance", "", "input", "Expression",
-        "instantiate_link", "2", "Inheritance", "", "String", "Element",
-
-        "instantiate_link", "2", "Association", "dict_link", "Action", "Element",
-        "model_define_attribute", "2", "dict_link", "name", False, "StringAttr",
-
-        "instantiate_link", "2", "Association", "Statement_next", "Statement", "Statement",
-        "instantiate_link", "2", "Association", "if_cond", "if", "Expression",
-        "instantiate_link", "2", "Association", "if_then", "if", "Statement",
-        "instantiate_link", "2", "Association", "if_else", "if", "Statement",
-        "instantiate_link", "2", "Association", "while_cond", "while", "Expression",
-        "instantiate_link", "2", "Association", "while_body", "while", "Statement",
-        "instantiate_link", "2", "Association", "assign_var", "assign", "resolve",
-        "instantiate_link", "2", "Association", "assign_value", "assign", "Expression",
-        "instantiate_link", "2", "Association", "break_while", "break", "while",
-        "instantiate_link", "2", "Association", "continue_while", "continue", "while",
-        "instantiate_link", "2", "Association", "return_value", "return", "Expression",
-        "instantiate_link", "2", "Association", "resolve_var", "resolve", "Element",
-        "instantiate_link", "2", "Association", "access_var", "access", "resolve",
-        "instantiate_link", "2", "Association", "constant_node", "constant", "Element",
-        "instantiate_link", "2", "Association", "output_node", "output", "Expression",
-        "instantiate_link", "2", "Association", "global_var", "global", "String",
-        "instantiate_link", "2", "Association", "param_name", "param", "String",
-        "instantiate_link", "2", "Association", "param_value", "param", "Expression",
-        "instantiate_link", "2", "Association", "param_next_param", "param", "param",
-        "instantiate_link", "2", "Association", "funcdef_body", "funcdef", "Statement",
-        "instantiate_link", "2", "Association", "call_func", "call", "Expression",
-        "instantiate_link", "2", "Association", "call_params", "call", "param",
-        "instantiate_link", "2", "Association", "call_last_param", "call", "param",
-
-        "instantiate_link", "2", "Inheritance", "", "Statement_next", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "if_cond", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "if_then", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "if_else", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "while_cond", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "while_body", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "assign_var", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "assign_value", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "break_while", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "continue_while", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "return_value", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "resolve_var", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "access_var", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "constant_node", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "output_node", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "global_var", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "param_name", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "param_value", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "param_next_param", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "funcdef_body", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "call_func", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "call_params", "dict_link",
-        "instantiate_link", "2", "Inheritance", "", "call_last_param", "dict_link",
-
-        "instantiate_attribute", "2", "if_cond", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "if_then", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "while_cond", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "while_body", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "assign_var", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "assign_value", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "break_while", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "continue_while", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "resolve_var", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "access_var", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "constant_node", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "output_node", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "global_var", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "param_name", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "param_value", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "funcdef_body", "target_lower_cardinality", 1,
-        "instantiate_attribute", "2", "call_func", "target_lower_cardinality", 1,
-
-        "instantiate_attribute", "2", "Statement_next", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "if_cond", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "if_then", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "if_else", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "while_cond", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "while_body", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "assign_var", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "assign_value", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "break_while", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "continue_while", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "return_value", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "resolve_var", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "access_var", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "constant_node", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "output_node", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "global_var", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "param_name", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "param_value", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "param_next_param", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "funcdef_body", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "call_func", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "call_params", "target_upper_cardinality", 1,
-        "instantiate_attribute", "2", "call_last_param", "target_upper_cardinality", 1,
-
-        "export_node", "2", "models/ActionLanguage_new",
-        "exit",
-    ]
-
-def add_constraint(model, element, code):
-    return ["model",
-            "instantiate_attribute_code", model, element, "constraint"] + \
-                get_constructor(code) + \
-            ["exit",]
-
-instantiate_scd = [
-        "model",
-        "instantiate_model", "1", "3",
-        "instantiate_node", "3", "Class", "Place",
-        "instantiate_node", "3", "Class", "Transition",
-        "instantiate_node", "3", "SimpleAttribute", "Natural",
-        "instantiate_link", "3", "Association", "P2T", "Place", "Transition",
-        "instantiate_link", "3", "Association", "T2P", "Transition", "Place",
-        "model_define_attribute", "3", "Place", "tokens", False, "Natural",
-        "model_define_attribute", "3", "P2T", "weight", False, "Natural",
-        "model_define_attribute", "3", "T2P", "weight", False, "Natural",
-        "export_node", "3", "models/PetriNets_new",
-        "exit",
-    ]
-
-instantiate_pn = [
-        "model",
-        "instantiate_model", "3", "4",
-        "instantiate_node", "4", "Place", "p1",
-        "instantiate_node", "4", "Place", "p2",
-        "instantiate_node", "4", "Transition", "t1",
-        "instantiate_node", "4", "Transition", "t2",
-        "instantiate_link", "4", "P2T", "p1_t1", "p1", "t1",
-        "instantiate_link", "4", "T2P", "t1_p2", "t1", "p2",
-        "instantiate_link", "4", "P2T", "p2_t2", "p2", "t2",
-        "instantiate_link", "4", "T2P", "t2_p1", "t2", "p1",
-        "instantiate_attribute", "4", "p1_t1", "weight", 1,
-        "instantiate_attribute", "4", "t1_p2", "weight", 2,
-        "instantiate_attribute", "4", "p2_t2", "weight", 3,
-        "instantiate_attribute", "4", "t2_p1", "weight", 4,
-        "instantiate_attribute", "4", "p1", "tokens", 5,
-        "instantiate_attribute", "4", "p2", "tokens", 6,
-        "export_node", "4", "models/PN_instance",
-        "exit",
-    ]
-
-instantiate_example = [
-        "model",
-        "instantiate_model", "1", "2",
-        "instantiate_node", "2", "Class", "A",
-        "instantiate_node", "2", "Class", "B",
-        "instantiate_node", "2", "SimpleAttribute", "C",
-        "instantiate_link", "2", "Inheritance", "b_inherits_a", "B", "A",
-        "instantiate_link", "2", "Association", "A_to_B", "A", "B",
-        "model_define_attribute", "2", "A", "tokens", False, "C",
-        "export_node", "2", "models/example_MM",
-        "exit",
-        "model",
-        "instantiate_model", "2", "3",
-        "instantiate_node", "3", "A", "a",
-        "instantiate_node", "3", "B", "b",
-        "instantiate_link", "3", "A_to_B", "a_to_b", "a", "b",
-        "instantiate_attribute", "3", "a", "tokens", 123,
-        "instantiate_attribute", "3", "b", "tokens", 234,
-        "export_node", "3", "models/example_M",
-        "exit",
-    ]
-
-def conformance_call(operation, model, metamodel):
-    return [
-            "output",
-                "call",
-                    "access", "resolve", str(operation),
-                    3,
-                    "call", "access", "resolve", "import_node", 1, "const", "models/example_M", False,
-                    "const", str(model),
-                    "const", str(metamodel),
-                False,
-            True,
-            ]
-
-is_direct_instance = \
-    conformance_call("is_direct_instance", "a", "A") + \
-    conformance_call("is_direct_instance", "b", "A") + \
-    conformance_call("is_direct_instance", "a", "B") + \
-    conformance_call("is_direct_instance", "b", "B") + \
-    conformance_call("is_direct_instance", "a", "C") + \
-    conformance_call("is_direct_instance", "b", "C")
-
-is_nominal_instance = \
-    conformance_call("is_nominal_instance", "a", "A") + \
-    conformance_call("is_nominal_instance", "b", "A") + \
-    conformance_call("is_nominal_instance", "a", "B") + \
-    conformance_call("is_nominal_instance", "b", "B") + \
-    conformance_call("is_nominal_instance", "a", "C") + \
-    conformance_call("is_nominal_instance", "b", "C")
-
-def conformance_check(node):
-    return [
-            "output",
-                "call",
-                    "access", "resolve", "conformance_scd",
-                    1,
-                    "call", "access", "resolve", "import_node", 1, "const", str(node), False,
-                    False,
-                True,
-            ]
-
-code_natural = \
-    """
-        include "primitives.alh"
-        String function constraint(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            if (is_physical_int(self)):
-                if (integer_gte(self, 0)):
-                    return "OK"!
-                else:
-                    return "Natural number not larger than or equal to zero"!
-            else:
-                return "Natural number not larger than or equal to zero"!
-    """
-
-code_string = \
-    """
-        include "primitives.alh"
-        String function constraint(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            log("In constraint")
-            if (is_physical_string(self)):
-                return "OK"!
-            else:
-                return "String has non-string instance"!
-    """
-
-code_boolean = \
-    """
-        include "primitives.alh"
-        String function constraint(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            if (is_physical_boolean(self)):
-                return "OK"!
-            else:
-                return "Boolean has non-boolean instance"!
-    """
-
-code_location = \
-    """
-        include "primitives.alh"
-        include "library.alh"
-        String function constraint(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            if (is_physical_string(self)):
-                if (element_neq(import_node(self), read_root())):
-                    return "OK"!
-                else:
-                    return "Location references non-existing element!"!
-            else:
-                return "Location has non-string instance"!
-    """
-
-code_complex_attribute = \
-    """
-        include "primitives.alh"
-        include "library.alh"
-        String function constraint(model : Element, name : String):
-            Element self
-            self = model["model"][name]
-            if (is_physical_string(self)):
-                if (element_neq(import_node(self), read_root())):
-                    return "OK"!
-                else:
-                    return "Complex Attribute references non-existing element!"!
-            else:
-                return ("Complex Attribute has non-string value: " + cast_e2s(self))!
-    """
-
-class TestConstructorsModels(unittest.TestCase):
-    def test_constructors_instantiate_bottom(self):
-        commands = bottom + conformance_check("models/SimpleClassDiagrams_new") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_action_language(self):
-        commands = bottom + action_language + bottom_link_al + \
-                    add_constraint("2", "String", code_string) + \
-                    add_constraint("2", "StringAttr", code_string) + \
-                    conformance_check("models/ActionLanguage_new") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_constraints_scd(self):
-        commands = bottom + action_language + bottom_link_al + \
-                    add_constraint("2", "String", code_string) + \
-                    add_constraint("2", "StringAttr", code_string) + \
-                    add_constraint("1", "Natural", code_natural) + \
-                    add_constraint("1", "String", code_string) + \
-                    add_constraint("1", "Location", code_location) + \
-                    add_constraint("1", "Boolean", code_boolean) + \
-                    add_constraint("1", "ActionLanguage", code_complex_attribute) + \
-                    conformance_check("models/SimpleClassDiagrams_new") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_constraints_pn(self):
-        commands = bottom + action_language + bottom_link_al + \
-                    add_constraint("2", "String", code_string) + \
-                    add_constraint("2", "StringAttr", code_string) + \
-                    add_constraint("1", "Natural", code_natural) + \
-                    add_constraint("1", "String", code_string) + \
-                    add_constraint("1", "Location", code_location) + \
-                    add_constraint("1", "Boolean", code_boolean) + \
-                    add_constraint("1", "ActionLanguage", code_complex_attribute) + \
-                    instantiate_scd + \
-                    add_constraint("3", "Natural", code_natural) + \
-                    conformance_check("models/PetriNets_new") + \
-                    instantiate_pn + \
-                    conformance_check("models/PN_instance") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_instantiate_scd(self):
-        commands = bottom + instantiate_scd + conformance_check("models/PetriNets_new") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_instantiate_pn(self):
-        commands = bottom + instantiate_scd + instantiate_pn + conformance_check("models/PN_instance") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 1))
-
-    def test_constructors_instantiate_example(self):
-        commands = bottom + instantiate_example + conformance_check("models/example_MM") + conformance_check("models/example_M") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK", "OK"], 1))
-
-    def test_constructors_is_direct_instance(self):
-        commands = bottom + instantiate_example + is_direct_instance + ["return", False]
-        expected = [True, False,
-                    False, True,
-                    False, False]
-        self.assertTrue(run_barebone(commands, expected, 1))
-
-    def test_constructors_is_nominal_instance(self):
-        commands = bottom + instantiate_example + is_nominal_instance + ["return", False]
-        expected = [True, True, 
-                    False, True,
-                    False, False]
-        self.assertTrue(run_barebone(commands, expected, 1))

+ 0 - 88
integration/test_constructors_models_compiled.py

@@ -1,88 +0,0 @@
-import unittest
-import sys
-import os
-
-from utils import execute, kill, run_file, run_barebone
-sys.path.append("interface/HUTN")
-from hutn_compiler.compiler import main as do_compile
-
-def model_compile(filename):
-    return do_compile(filename, "interface/HUTN/grammars/modelling.g", "M")
-
-def conformance_call(operation, model, metamodel):
-    return [
-            "output",
-                "call",
-                    "access", "resolve", str(operation),
-                    3,
-                    "call", "access", "resolve", "import_node", 1, "const", "models/example_M", False,
-                    "const", str(model),
-                    "const", str(metamodel),
-                False,
-            True,
-            ]
-
-def conformance_check(node):
-    return [
-            "output",
-                "call",
-                    "access", "resolve", "conformance_scd",
-                    1,
-                    "call", "access", "resolve", "import_node", 1, "const", str(node), False,
-                    False,
-                True,
-            ]
-
-class TestConstructorsModelsCompiled(unittest.TestCase):
-    def test_constructors_petrinets(self):
-        commands = model_compile("integration/code/petrinets.mvc") + \
-                   ["exit", 1] + conformance_check("models/PetriNets") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinet_instance(self):
-        commands = model_compile("integration/code/petrinets.mvc") + \
-                   model_compile("integration/code/my_petrinet.mvc") + \
-                   ["exit", 1] + conformance_check("models/my_petrinet") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinet_full(self):
-        commands = model_compile("integration/code/my_petrinet_with_MM.mvc") + \
-                   ["exit", 1] + conformance_check("models/my_petrinet") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinets_constraints(self):
-        commands = model_compile("integration/code/petrinets_constraints.mvc") + \
-                   ["exit", 1] + conformance_check("models/PetriNets") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinet_instance_constraints(self):
-        commands = model_compile("integration/code/petrinets_constraints.mvc") + \
-                   model_compile("integration/code/my_petrinet.mvc") + \
-                   ["exit", 1] + conformance_check("models/my_petrinet") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinet_full_constraints(self):
-        commands = model_compile("integration/code/my_petrinet_with_MM_and_constraints.mvc") + \
-                   ["exit", 1] + conformance_check("models/my_petrinet") + ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK"], 4))
-
-    def test_constructors_petrinet_invalids(self):
-        commands = model_compile("integration/code/several_petrinets.mvc") + \
-                   ["exit", 1] + \
-                   conformance_check("models/valid_petrinet") + \
-                   conformance_check("models/invalid_petrinet_1") + \
-                   conformance_check("models/invalid_petrinet_2") + \
-                   conformance_check("models/invalid_petrinet_3") + \
-                   conformance_check("models/invalid_petrinet_4") + \
-                   conformance_check("models/invalid_petrinet_5") + \
-                   conformance_check("models/invalid_petrinet_6") + \
-                   conformance_check("models/invalid_petrinet_7") + \
-                   ["return", False]
-        self.assertTrue(run_barebone(commands, ["OK", 
-                    "Natural does not have a positive or zero value at p1.tokens",
-                    "Natural does not have a positive or zero value at p2t.weight",
-                    "Destination of model edge not typed by destination of type: wrong_p2t",
-                    "Source of model edge not typed by source of type: wrong_t2p",
-                    "Lower cardinality violation for outgoing edge of type Place_tokens at p1",
-                    "Lower cardinality violation for outgoing edge of type P2T_weight at p2t",
-                    "Natural has no integer value at p1.tokens"], 4))

+ 0 - 9
integration/test_factorial.py

@@ -1,9 +0,0 @@
-import unittest
-
-from utils import run_file
-
-class TestFactorial(unittest.TestCase):
-    def test_factorial(self):
-        self.assertTrue(run_file(["factorial.alc", "primitives.alc"],
-            [1, 2, 3, 4, 20],
-            [1, 2, 6, 24, 2432902008176640000]))

+ 0 - 10
integration/test_fibonacci.py

@@ -1,10 +0,0 @@
-import unittest
-
-from utils import run_file
-
-
-class TestFibonacci(unittest.TestCase):
-    def test_fibonacci(self):
-        self.assertTrue(run_file(["fibonacci.alc", "primitives.alc"],
-            [1, 2, 3, 4],
-            [1, 1, 2, 3]))

+ 0 - 9
integration/test_fibonacci_smart.py

@@ -1,9 +0,0 @@
-import unittest
-
-from utils import run_file
-
-class TestFibonacciSmart(unittest.TestCase):
-    def test_fibonacci_smart(self):
-        self.assertTrue(run_file(["fibonacci_smart.alc", "primitives.alc"],
-            [1, 2, 3, 4, 5, 6, 7, 8],
-            [1, 1, 2, 3, 5, 8, 13, 21]))

+ 0 - 15
integration/test_if_elif.py

@@ -1,15 +0,0 @@
-import unittest
-
-from utils import run_file
-
-
-class TestIfElif(unittest.TestCase):
-    def test_if_elif_else(self):
-        self.assertTrue(run_file(["if_elif_else.alc", "primitives.alc"],
-            [-1, 10, 11, 0, 1, 0, -100],
-            [-1, 1, 1, 0, 1, 0, -1]))
-
-    def test_if_elif(self):
-        self.assertTrue(run_file(["if_elif.alc", "primitives.alc"],
-                                 [-1, 10, 11, 0, 1, 0, -100],
-                                 [-1, 1, 1, 0, 1, 0, -1]))

+ 0 - 10
integration/test_leap_year.py

@@ -1,10 +0,0 @@
-import unittest
-
-from utils import run_file
-
-
-class TestLeapYear(unittest.TestCase):
-    def test_leap_year(self):
-        self.assertTrue(run_file(["leap_year.alc", "primitives.alc"],
-            [2016, 2015, 2014, 2013, 2012, 2001, 2000, 1999],
-            [True, False, False, False, True, False, False, False]))

+ 0 - 10
integration/test_main.py

@@ -1,10 +0,0 @@
-import unittest
-
-from utils import run_file
-
-
-class TestMain(unittest.TestCase):
-    def test_main(self):
-        self.assertTrue(run_file(["main.alc", "primitives.alc"],
-            [],
-            ["Hello, world!", "Hello, world!", "Hello, world!"]))

+ 0 - 10
integration/test_power.py

@@ -1,10 +0,0 @@
-import unittest
-
-from utils import run_file
-
-
-class TestPower(unittest.TestCase):
-    def test_power(self):
-        self.assertTrue(run_file(["power.alc", "primitives.alc"],
-            [1, 0, 2, 1, 5, 0, 2, 2, 3, 2, 10, 2, 10, 10],
-            [1, 2, 1, 4, 9, 100, 10000000000]))

+ 0 - 9
integration/test_remainder.py

@@ -1,9 +0,0 @@
-import unittest
-
-from utils import run_file
-
-class TestRemainder(unittest.TestCase):
-    def test_remainder(self):
-        self.assertTrue(run_file(["remainder.alc", "primitives.alc"],
-            [1, 2, 20, 2, 99, 100, 17, 3],
-            [1, 0, 99, 2]))

+ 0 - 9
integration/test_revert.py

@@ -1,9 +0,0 @@
-import unittest
-
-from utils import run_file
-
-class TestRevert(unittest.TestCase):
-    def test_revert(self):
-        self.assertTrue(run_file(["revert.alc", "primitives.alc"],
-            ["abc", "defghi", "This is a very simple test case!", "abccba"],
-            ["cba", "ihgfed", "!esac tset elpmis yrev a si sihT", "abccba"]))

+ 0 - 232
integration/utils.py

@@ -68,243 +68,11 @@ def flush_data(address, data):
         urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "taskname": taskname})), timeout=INIT_TIMEOUT).read()
     return []
 
-def compile_file(address, mod_filename, filename, mode, proc):
-    # Load in the file required
-    try:
-        timeout_val = 240
-        import random
-        taskname = str(random.random())
-        while 1:
-            proc2 = execute("compile", [address, mod_filename, taskname, filename, mode], wait=False)
-
-            if proc.returncode is not None:
-                # Modelverse has already terminated, which isn't a good sign!
-                raise Exception("Modelverse died!")
-
-            while proc2.returncode is None:
-                time.sleep(0.01)
-                proc2.poll()
-                timeout_val -= 0.01
-                if timeout_val < 0:
-                    kill(proc2)
-                    print("Compilation timeout expired!")
-                    return False
-
-            if proc2.returncode != 2:
-                break
-
-        # Make sure everything stopped correctly
-        assert proc2.returncode == 0
-        if proc2.returncode != 0:
-            return False
-    except:
-        raise
-    finally:
-        try:
-            kill(proc2)
-        except UnboundLocalError:
-            pass
-
 def start_mvc():
     port = getFreePort()
     address = "http://127.0.0.1:%s" % port
     proc = execute("run_local_modelverse", [str(port)], wait=False)
     return proc, address
-    # TODO Return only when everything is fine! (i.e., parse the output of proc and wait until it contains "MvC is ready"
-    while 1:
-        l = proc.stdout.readline()
-        if "MvC is ready" in l:
-            return proc, address
-
-def run_file(files, parameters, expected, wait=False):
-    # Resolve file
-    import os.path
-
-    if wait is True:
-        expected = None
-
-    time.sleep(0.01)
-    port = getFreePort()
-    address = "http://127.0.0.1:%i" % port
-    try:
-        # Run Modelverse server
-        proc = execute("run_local_modelverse", [str(port)], wait=False)
-
-        threads = []
-        mod_files = []
-        for filename in files:
-            if os.path.isfile(filename):
-                mod_filename = filename
-            elif os.path.isfile("integration/code/%s" % filename):
-                mod_filename = "integration/code/%s" % filename
-            elif os.path.isfile("bootstrap/%s" % filename):
-                mod_filename = "bootstrap/%s" % filename
-            else:
-                raise Exception("File not found: %s" % filename)
-            mod_files.append(mod_filename)
-
-        to_compile = to_recompile(address, mod_files)
-
-        for mod_filename in to_compile:
-            if mod_filename.endswith(".mvc"):
-                model_mode = "MO"
-                mod_files.remove(mod_filename)
-            else:
-                model_mode = "PO"
-            if parallel_push:
-                import threading
-                threads.append(threading.Thread(target=compile_file, args=[address, mod_filename, mod_filename, model_mode, proc]))
-                threads[-1].start()
-            else:
-                compile_file(address, mod_filename, mod_filename, model_mode, proc)
-
-        if parallel_push:
-            for t in threads:
-                t.join()
-
-        # Fire up the linker
-        val = execute("link_and_load", [address, taskname] + mod_files, wait=True)
-        if val != 0:
-            raise Exception("Linking error")
-
-        # Send the request ...
-        flush_data(address, parameters)
-        
-        # ... and wait for replies
-        if expected is None:
-            while 1:
-                val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname})), timeout=TIMEOUT).read()
-                val = json.loads(val)
-                print(val)
-        for e in expected:
-            c = len(e) if isinstance(e, set) else 1
-            if isinstance(e, set):
-                # Copy set before we start popping from it, as it might be reused elsewhere
-                e = set(e)
-            for _ in range(c):
-                val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname})), timeout=TIMEOUT).read()
-                val = json.loads(val)
-
-                if proc.returncode is not None:
-                    # Modelverse has already terminated, which isn't a good sign!
-                    raise Exception("Modelverse died!")
-
-                print("Got %s, expect %s" % (val, e))
-                if isinstance(e, set):
-                    assert val in e
-                    if val not in e:
-                        return False
-                    e.remove(val)
-                elif e is None:
-                    # Skip output value
-                    pass
-                else:
-                    assert val == e
-                    if val != e:
-                        return False
-
-        # All passed!
-        return True
-    except:
-        raise
-    finally:
-        try:
-            kill(proc)
-        except UnboundLocalError:
-            pass
-
-def run_barebone(parameters, expected, interface="0", timeout=False, wait=False, link=None, inputs=[]):
-    port = getFreePort()
-    address = "http://127.0.0.1:%i" % port
-    try:
-        # Run Modelverse server
-        proc = execute("run_local_modelverse", [str(port)], wait=False)
-
-        # Create task and set interface
-        timeout_val = INIT_TIMEOUT
-        start = time.time()
-        while 1:
-            proc.poll()
-            if proc.returncode is not None:
-                # Modelverse has already terminated, which isn't a good sign!
-                return False
-
-            try:
-                urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"})), timeout=INIT_TIMEOUT).read()
-                if interface is not None:
-                    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": interface, "taskname": taskname})), timeout=INIT_TIMEOUT).read()
-                break
-            except:
-                time.sleep(0.01)
-
-                if time.time() - start > timeout_val:
-                    raise
-
-        # Send the request
-        print("Sending data: " + str(parameters))
-        flush_data(address, parameters)
-
-        # Now do linking and loading
-        if link is not None:
-            # Execute linker
-            timeout_val = INIT_TIMEOUT
-            proc2 = execute("link_and_load", [address, taskname] + link, wait=False)
-
-            while proc2.returncode is None:
-                time.sleep(0.01)
-                proc2.poll()
-                timeout_val -= 0.01
-                if timeout_val < 0:
-                    kill(proc2)
-                    print("Linking timeout expired!")
-                    return False
-                if proc.returncode is not None:
-                    # Modelverse has already terminated, which isn't a good sign!
-                    return False
-
-        for inp in inputs:
-            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": inp, "taskname": taskname})), timeout=INIT_TIMEOUT).read()
-            proc.poll()
-            if proc.returncode is not None:
-                # Modelverse has already terminated, which isn't a good sign!
-                return False
-
-        counter = 0
-        for e in expected:
-            c = len(e) if isinstance(e, set) else 1
-            for _ in range(c):
-                try:
-                    proc.poll()
-                    if proc.returncode is not None:
-                        # Modelverse has already terminated, which isn't a good sign!
-                        return False
-
-                    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname})), timeout=TIMEOUT if not timeout else INIT_TIMEOUT).read()
-                    val = json.loads(val)
-                except:
-                    if timeout:
-                        return True
-                    else:
-                        raise
-
-                #print("Got %s, expect %s" % (val, e))
-                if isinstance(e, set):
-                    assert val in e
-                    if val not in e:
-                        return False
-                    e.remove(val)
-                elif e is None:
-                    # Skip this input
-                    pass
-                else:
-                    assert val == e
-                    if val != e:
-                        return False
-
-        # All passed!
-        return not timeout
-    finally:
-        kill(proc)
 
 def get_constructor(code):
     code_fragments = code.split("\n")

+ 0 - 47
scripts/check_objects.py

@@ -1,47 +0,0 @@
-import urllib
-import urllib2
-import json
-import random
-import hashlib
-import time
-
-def to_recompile(address, files):
-    taskname = str(random.random())
-    files = sorted(files)
-    rebuild = []
-
-    def flush_data(data):
-        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "taskname": taskname}))).read()
-
-    while 1:
-        try:
-            # Create new task
-            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"}))).read()
-            break
-        except:
-            time.sleep(0.01)
-
-    data = []
-    for f in files:
-        data.extend([3, "is_defined", f])
-    flush_data(data)
-
-    md5_values = {}
-    for f in files:
-        md5 = hashlib.md5()
-        md5.update(open(f, 'r').read())
-        md5_values[f] = md5.hexdigest()
-
-    for f in files:
-        v = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname}))).read()
-        mv_md5 = json.loads(v)
-        if md5_values[f] == mv_md5:
-            # Identical, so don't rebuild
-            pass
-            print("[CACHE] %s" % f)
-        else:
-            # Different, so rebuild
-            rebuild.append(f)
-
-    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '-1', "taskname": taskname}))).read()
-    return rebuild

+ 0 - 44
scripts/compile.py

@@ -1,44 +0,0 @@
-import sys
-import os
-import urllib2
-import urllib
-import subprocess
-import time
-
-TIMEOUT = 10
-
-def do_compile(address, filename, taskname, modulename, mode, optionals=['--debug'], grammar=""):
-    filename = os.path.realpath(filename)
-    if grammar == "":
-        if mode[0] == "M":
-            # Load model grammar
-            grammar = "grammars/modelling.g"
-        else:
-            # Load AL grammar
-            grammar = "grammars/actionlanguage.g"
-
-    # Create new task
-    start = time.time()
-    while time.time() - start < TIMEOUT:
-        try:
-            urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"}))).read()
-            break
-        except:
-            # Try again
-            continue
-    subprocess.check_call([sys.executable, "hutn_compiler/compiler.py", filename, grammar, mode, taskname, modulename, filename, address] + optionals, cwd="interface/HUTN")
-    return 0
-
-if __name__ == "__main__":
-    if len(sys.argv) != 6:
-        sys.stderr.write("Expected different parameters!\n")
-        sys.stderr.write("    %s address filename taskname modulename mode\n" % sys.argv[0])
-        sys.exit(1)
-    else:
-        address = sys.argv[1]
-        filename = sys.argv[2]
-        taskname = sys.argv[3]
-        modulename = sys.argv[4]
-        mode = sys.argv[5]
-        
-        sys.exit(do_compile(address, filename, taskname, modulename, mode))

+ 0 - 34
scripts/execute_model.py

@@ -1,34 +0,0 @@
-import random
-import sys
-import glob
-import time
-
-from compile import do_compile
-from link_and_load import link_and_load
-from make_parallel import main
-
-models = []
-code = []
-
-address = sys.argv[1]
-taskname = sys.argv[2]
-files = [a.replace("\\", "/") for a in sum([glob.glob(f) for f in sys.argv[3:]], [])]
-
-for f in files:
-    if f.endswith(".mvc"):
-        models.append(f)
-    elif f.endswith(".alc"):
-        code.append(f)
-    else:
-        print("Unknown file format for file " + f)
-        print("Requires either .mvc or .alc")
-
-def do_compile_wrapper(filename, mode, grammar):
-    do_compile(address, filename, str(random.random()), filename, mode, ["--debug"], grammar=grammar)
-
-# Parse all models and upload them
-for m in models:
-    print("[MODEL] %s" % m)
-    do_compile_wrapper(m, "MO", "grammars/modelling.g")
-
-main(address, taskname, code)

+ 0 - 20
scripts/link_and_load.py

@@ -1,20 +0,0 @@
-import sys
-import urllib2
-
-def link_and_load(address, taskname, objs):
-    urllib2.urlopen(urllib2.Request(address, 'op=set_input&taskname=task_manager&value="%s"' % taskname)).read()
-
-    sys.path.append("interface/HUTN")
-    from hutn_compiler.linker import link
-    link(address, taskname, objs)
-
-if __name__ == "__main__":
-    if len(sys.argv) < 4:
-        sys.stderr.write("Expected different parameters!\n")
-        sys.stderr.write("    %s address taskname [files]*\n")
-    else:
-        address = sys.argv[1]
-        taskname = sys.argv[2]
-        objs = sys.argv[3:]
-
-        link_and_load(address, taskname, objs)

+ 0 - 22
scripts/make_all.py

@@ -1,22 +0,0 @@
-import sys
-
-from check_objects import to_recompile
-from compile import do_compile
-from link_and_load import link_and_load
-import random
-import glob
-
-if __name__ == "__main__":
-    if len(sys.argv) < 4:
-        sys.stderr.write("Expected different parameters!\n")
-        sys.stderr.write("    %s address taskname [file]*\n")
-    else:
-        address = sys.argv[1]
-        taskname = sys.argv[2]
-        files = [a.replace("\\", "/") for a in sum([glob.glob(f) for f in sys.argv[3:]], [])]
-
-        new_files = to_recompile(address, files)
-        for f in new_files:
-            do_compile(address, f, str(random.random()), f, "PO", ["--debug"])
-
-        link_and_load(address, taskname, files)

+ 0 - 36
scripts/make_parallel.py

@@ -1,36 +0,0 @@
-import sys
-
-from check_objects import to_recompile
-from compile import do_compile
-from link_and_load import link_and_load
-import random
-import multiprocessing
-import glob
-import os
-
-def do_compile_wrapper(args):
-    address, taskname, filename = args
-    do_compile(address, filename, str(random.random()), filename, "PO", ["--debug"])
-
-def main(address, taskname, files):
-    new_files = to_recompile(address, files)
-    if os.name == "posix":
-        # At least linux decently implements forking, so use as many cores as possible
-        p = multiprocessing.Pool(multiprocessing.cpu_count() * 2)
-        p.map(do_compile_wrapper, [[address, taskname, f] for f in new_files])
-    else:
-        # Other systems are less intelligent, so just do this sequentially
-        map(do_compile_wrapper, [[address, taskname, f] for f in new_files])
-    link_and_load(address, taskname, files)
-
-if __name__ == "__main__":
-    if len(sys.argv) < 4:
-        sys.stderr.write("Expected different parameters!\n")
-        sys.stderr.write("    %s address taskname [file]*\n" % sys.argv[0])
-        sys.exit(1)
-
-    address = sys.argv[1]
-    taskname = sys.argv[2]
-    files = [a.replace("\\", "/") for a in sum([glob.glob(f) for f in sys.argv[3:]], [])]
-
-    main(address, taskname, files)

+ 0 - 27
scripts/process.py

@@ -1,27 +0,0 @@
-def flush_data(address, taskname, data):
-    if data:
-        urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "data": json.dumps(data), "taskname": taskname})), timeout=10).read()
-    return []
-
-def fetch_output(address, taskname):
-    val = urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": taskname})), timeout=10).read()
-    l, r = output.split("&", 1)
-    if "value" in l:
-        output = r
-    else:
-        output = l
-    _, output = output.split("=", 1)
-    return output
-
-def send_to_mv(address, taskname, lst):
-    data = []
-    variables = {}
-
-    for c in lst:
-        if isinstance(c, int):
-            data = flush_data(address, taskname, data)
-            variables[c] = fetch_output(address, taskname)
-        else:
-            data.append(c)
-
-    return variables

+ 0 - 49
scripts/run_MvC_server.py

@@ -1,49 +0,0 @@
-import subprocess
-import sys
-import threading
-import time
-import random
-import urllib
-import urllib2
-
-import sys
-
-if len(sys.argv) > 1:
-    address = sys.argv[1]
-    MVK_ADDRESS, MVK_PORT = address.rsplit(":", 1)
-else:
-    MVK_PORT = 8001
-    MVK_ADDRESS = "http://127.0.0.1"
-    address = "%s:%s" % (MVK_ADDRESS, MVK_PORT)
-
-ADMIN_USER = "admin"
-ADMIN_PASSWORD = "admin"
-SETUP_USER = "setup_task"
-
-# Compile the Statechart first
-subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
-
-# Start up the MvK as a subprocess
-try:
-    obj = subprocess.Popen([sys.executable, "-u", "run_mvk_server.py", str(MVK_PORT)], cwd="hybrid_server", stdout=subprocess.PIPE)
-    #obj = subprocess.Popen([sys.executable, "run_mvk_server.py", str(MVK_PORT), "--kernel=legacy-interpreter"], cwd="hybrid_server")
-
-    # Compile all MvC code
-    subprocess.call([sys.executable, "scripts/execute_model.py", address, SETUP_USER, "bootstrap/*.alc", "core/*.alc", "core/*.mvc"])
-
-    # Set the admin taskname and password
-    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % ADMIN_USER, "taskname": SETUP_USER}))).read()
-    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % ADMIN_PASSWORD, "taskname": SETUP_USER}))).read()
-    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"%s"' % ADMIN_PASSWORD, "taskname": SETUP_USER}))).read()
-    urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "set_input", "value": '"exit"', "taskname": SETUP_USER}))).read()
-
-    while 1:
-        print(obj.stdout.readline().strip())
-finally:
-    try:
-        obj.terminate()
-        time.sleep(1)
-        if not obj.poll():
-            obj.kill()
-    except:
-        pass

+ 7 - 9
scripts/run_local_modelverse.py

@@ -3,13 +3,11 @@ import sys
 
 # sys.executable to use the same Python interpreter used to invoke this command
 if len(sys.argv) < 2:
-    sys.stderr.write("Expected different parameters!\n")
-    sys.stderr.write("    %s port\n" % sys.argv[0])
-else:
-    subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
-    # There's no need to specify `--kernel=baseline-jit` here, because that's the default kernel.
-    # Also, specifying a kernel here breaks the performance tests.
+    port = "8001"
 
-    subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:], cwd="hybrid_server")
-    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
-    #subprocess.call([sys.executable, "-m", "cProfile", "-s", "tottime", "run_mvk_server.py"] + sys.argv[1:], cwd="hybrid_server", stdout=open("/tmp/stdout", 'w'), stderr=open("/tmp/stderr", "w"))
+subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
+subprocess.call([sys.executable, "run_mvk_server.py", port], cwd="hybrid_server")
+
+# Additional ways of calling...
+#subprocess.call([sys.executable, "run_mvk_server.py", port] + ["--kernel=baseline-jit"], cwd="hybrid_server")
+#subprocess.call([sys.executable, "-m", "cProfile", "-s", "tottime", "run_mvk_server.py", port], cwd="hybrid_server", stdout=open("/tmp/stdout", 'w'), stderr=open("/tmp/stderr", "w"))