Explorar o código

Remove an unused field, update documentation

Joeri Exelmans %!s(int64=5) %!d(string=hai) anos
pai
achega
1912ac2988

+ 0 - 2
src/sccd/action_lang/static/expression.py

@@ -96,8 +96,6 @@ class FunctionCall(Expression):
     function: Expression
     params: List[Expression]
 
-    type: Optional[type] = None
-
     def init_expr(self, scope: Scope) -> SCCDType:
         function_type = self.function.init_expr(scope)
         if not isinstance(function_type, SCCDFunction):

+ 2 - 1
src/sccd/action_lang/static/scope.py

@@ -117,7 +117,8 @@ class Scope:
     scope, scope_offset, var = found
     return (scope_offset + var.offset, var.type)
 
-  # Attempt to declare given name in this scope. Only succeeds if name does not exist yet in any scope.
+  # Attempt to declare given name in this scope.
+  # Similar to put_lvalue, but only succeeds if the name does not exist yet in any scope.
   # Returns offset relative to this scope (always a positive number since this function only creates new variables in this scope)
   def declare(self, name: str, type: SCCDType, const: bool = False) -> int:
     found = self._internal_lookup(name)

+ 1 - 4
src/sccd/action_lang/static/statement.py

@@ -115,14 +115,11 @@ class Assignment(Statement):
 @dataclass
 class Block(Statement):
     stmts: List[Statement]
-    scope: Optional[Scope] = None
 
     def init_stmt(self, scope: Scope) -> ReturnBehavior:
-        self.scope = scope
-
         so_far = NeverReturns
         for i, stmt in enumerate(self.stmts):
-            now_what = stmt.init_stmt(self.scope)
+            now_what = stmt.init_stmt(scope)
             so_far = ReturnBehavior.sequence(so_far, now_what)            
         return so_far
 

+ 9 - 0
src/sccd/statechart/dynamic/builtin_scope.py

@@ -1,8 +1,13 @@
 from sccd.action_lang.static.expression import *
 from sccd.util.debug import *
 
+# Builtin "global" functions in statechart language
+
 BuiltIn = Scope("builtin", None)
 
+# The way we add our builtin functions is a bit hackish because they are implemented
+# "natively" in Python, rather than in action language code.
+
 BuiltIn.declare("INSTATE", SCCDFunction([SCCDArray(SCCDString)], SCCDBool), const=True)
 BuiltIn.declare("log10", SCCDFunction([SCCDInt], SCCDFloat), const=True)
 BuiltIn.declare("float_to_int", SCCDFunction([SCCDFloat], SCCDInt), const=True)
@@ -15,6 +20,8 @@ def load_builtins(memory: MemoryInterface, state):
   
   memory.push_frame(BuiltIn)
 
+  # Wrapper functions of the signature expected by the action language:
+
   def in_state(memory: MemoryInterface, state_list: List[str]) -> bool:
     return state.in_state(state_list)
 
@@ -30,6 +37,8 @@ def load_builtins(memory: MemoryInterface, state):
   def int_to_str(memory: MemoryInterface, i: int) -> str:
     return str(i)
 
+  # Manually write wrapper functions to memory:
+
   frame = memory.current_frame()
 
   frame.storage[0] = in_state

+ 0 - 3
src/sccd/statechart/static/globals.py

@@ -1,6 +1,3 @@
-# TODO: move this module to 'statechart.static' !
-# even though the 'globals' applies to the 'class diagram' (module 'cd'), the statechart is aware of it, and moving this module would make for a cleaner 'import' hierarchy
-
 from typing import *
 from sccd.util.namespace import *
 from sccd.util.duration import *

+ 2 - 0
src/sccd/statechart/static/statechart.py

@@ -56,6 +56,8 @@ SemanticChoice = Union[_T, List[_T]]
 class SemanticConfiguration:
   # All semantic aspects and their default values.
   # Every field can be set to a list of multiple options, or just a value.
+
+  # The following is the default configuration:
   big_step_maximality: SemanticChoice[BigStepMaximality] = BigStepMaximality.TAKE_MANY
   combo_step_maximality: SemanticChoice[ComboStepMaximality] = ComboStepMaximality.COMBO_TAKE_ONE
   internal_event_lifeline: SemanticChoice[InternalEventLifeline] = InternalEventLifeline.NEXT_COMBO_STEP