diff options
Diffstat (limited to 'compatibility/compatibility.nom')
| -rw-r--r-- | compatibility/compatibility.nom | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom index 61818d6..982cec6 100644 --- a/compatibility/compatibility.nom +++ b/compatibility/compatibility.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V2.5.5.4 +#!/usr/bin/env nomsu -V2.5.5.5 # This file contains code for defining ways to upgrade code between different versions of Nomsu. @@ -18,39 +18,46 @@ action [upgrade action %stub to %version via %upgrade_fn]: parse [upgrade %tree to %version as %body] as (..) upgrade to %version via ([%] -> (% with %tree -> %body)) -compile [upgrade action %action to %version as %body] to: - %replacements = {} - for %i in 1 to (length of %action): - if (%action.%i.type is "Var"): - %replacements.(%action.%i.1) = "\(\%tree as lua id)[\%i]" - - local action [make tree %t]: - when: - (%t is "Var" syntax tree): - if %replacements.(%t.1): - return %replacements.(%t.1) - ..else: - return ".." - \(%t.type)(\(quote "\(%t.source)"), \(..) - quote "\(%t.1) \000\(=lua "string.format('%X', __MANGLE_INDEX)")" - ..) - - (%t is syntax tree): - %args = ((make tree %) for % in %t) - add "\(\%tree as lua id).source" to %args at index 1 - return "\(%t.type)(\(%args joined with ", "))" - - else: - return (quote "\%t") +compile [upgrade action %actions to %version as %body] to: + if (%actions is "Action" syntax tree): + %actions = [%actions] + %lua = (Lua "") + for %action in %actions: + %replacements = {} + for %i in 1 to (length of %action): + if (%action.%i.type is "Var"): + %replacements.(%action.%i.1) = "\(\%tree as lua id)[\%i]" + + local action [make tree %t]: + when: + (%t is "Var" syntax tree): + if %replacements.(%t.1): + return %replacements.(%t.1) + ..else: + return ".." + \(%t.type)(\(quote "\(%t.source)"), \(..) + quote "\(%t.1) \000\(=lua "string.format('%X', __MANGLE_INDEX)")" + ..) + + (%t is syntax tree): + %args = ((make tree %) for % in %t) + add "\(\%tree as lua id).source" to %args at index 1 + return "\(%t.type)(\(%args joined with ", "))" + + else: + return (quote "\%t") + + unless ("\%lua" == ""): to %lua write "\n" + to %lua write (..) + Lua ".." + A_upgrade_action_1_to_2_via_3(\(quote %action.stub), \(%version as lua expr), function(\(..) + \%tree as lua id + ..) + __MANGLE_INDEX = (__MANGLE_INDEX or 0) + 1 + return \(make tree %body) + end) - return (..) - Lua ".." - A_upgrade_action_1_to_2_via_3(\(quote %action.stub), \(%version as lua expr), function(\(..) - \%tree as lua id - ..) - __MANGLE_INDEX = (__MANGLE_INDEX or 0) + 1 - return \(make tree %body) - end) + return %lua action [..] %tree upgraded from %start_version to %end_version |
