aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/error.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-15 14:00:32 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-15 15:00:55 +0100
commitde7394372c77b695d4779606ea7587dfe61a35de (patch)
treedb10983d46c0b4b3b5a7b67eeb457e58abb07fff /src/error.h
parentf08187e454f56954b41d95615ca2e370ba19667e (diff)
downloadsciteco-de7394372c77b695d4779606ea7587dfe61a35de.tar.gz
revised looping implementation, aggregating loops, sane $$ semantics, some optimizationa and additional checks
* undo tokens emitted by the expression stack no longer waste memory by pointing to the stack implementation. This uses some ugly C++ constant template arguments but saves 4 or 8 byte per undo token depending on the architecture. * Round braces are counted now and the return command $$ will use this information to discard all non-relevant brace levels. * It is an error to close a brace when none have been opened. * The bracing rules are still very liberal, allowing you to close braces in macros belonging to a higher call frame or leave them open at the end of a macro. While this is technically possible, it is perhaps a good idea to stricten these rules in some future release. * Loops no longer (ab)use the expression stack to store program counters and loop counters. This removes flow control from the responsibility of the expression stack which is much safer now since we can control where we jump to. This also eased implemented proper semantics for $$. * It is an error to leave loops open at the end of a macro or trying to close a loop opened in the caller of the macro. Similarily it is only possible to close a loop from the current invocation frame. This means it is now impossible to accidentally jump to invalid PCs. * Even though loop context stacks could be attached directly to the macro invocation frame, this would be inefficient. Instead there's a loop frame pointer now that is part of the invocation frame. All frames will reuse the same stack structure. * Loops are automatically discarded when returning using $$. * Special aggregating forms of the loop start (":<") and loop end (":>") commands are possible now and have been implemented. This improves SciTECO's capability as a stack-oriented language. It is no longer necessary to write recursive macros to generate stack values of arbitrary length dynamically or to process them. * All expression and loop stacks are still fixed-size. It may be a good idea to implement dynamic resizing (TODO). * Added some G_UNLIKELYs to Execute::macro(). Should improve the branch prediction of modern CPUs. * Local Q-Register tables are allocated on the stack now instead of on the heap (the bulk of a table is stored on the heap anyway). Should improve performance of macro invocations. * Document that "F<" will jump to the beginning of the macro if there is no loop. This is not in standard TECO, but I consider it a useful feature.
Diffstat (limited to 'src/error.h')
-rw-r--r--src/error.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/error.h b/src/error.h
index a4f4660..f4dbfbf 100644
--- a/src/error.h
+++ b/src/error.h
@@ -39,7 +39,12 @@ class Quit {};
* Thrown as exception to cause a macro to
* return or a command-line termination.
*/
-class Return {};
+class Return {
+public:
+ guint args;
+
+ Return(guint _args = 0) : args(_args) {}
+};
class Error {
gchar *description;