-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Переписаны почти все нативные вставки в back-end’е Рефала-5 (#2)
Теперь большинство функций платформенно-зависимых модулей написано на Модульном Рефале и вызывает функции из Platform::Refal5. Нативные вставки остались там, где они необходимы или без них будет хуже.
- Loading branch information
Showing
6 changed files
with
158 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
$MODULE CoreBE::MOrder; | ||
|
||
$NATIVE Refal5 FUNCTION | ||
$ENTRY SymbCompare @@' | ||
c { | ||
c s.Left s.Right | ||
c , <$Local::CoreBE::MOrder::GetType$ s.Left > | ||
c <$Local::CoreBE::MOrder::GetType$ s.Right >: | ||
c { | ||
c s.Type s.LeftVal s.Type s.RightVal | ||
c , <Compare s.LeftVal s.RightVal >: | ||
c { | ||
c '-' = '<'; | ||
c '0' = '='; | ||
c '+' = '>'; | ||
c }; | ||
|
||
c Number s.LeftVal s.Type s.RightVal = '>'; | ||
c s.Type s.LeftVal Number s.RightVal = '<'; | ||
c Char s.LeftVal s.Type s.RightVal = '>'; | ||
c s.Type s.LeftVal Char s.RightVal = '<'; | ||
c s.L-Type s.L-Val s.R-Type s.R-Val = '='; | ||
c } | ||
c } | ||
'@@; | ||
|
||
$NATIVE Refal5 FUNCTION | ||
GetType @@' | ||
c { | ||
c s.Atom, <Type s.Atom >: | ||
c { | ||
c 'N' e.1 = Number s.Atom; | ||
c 'L' e.1 = Char <Ord s.Atom >; | ||
c 'O' e.1 = Char <Ord s.Atom >; | ||
c 'P' e.1 = Char <Ord s.Atom >; | ||
c 'D' e.1 = Char <Ord s.Atom >; | ||
c e.1 = Other 0; | ||
c } | ||
c } | ||
'@@; | ||
$IMPORT Platform::Refal5; | ||
|
||
|
||
$ENTRY SymbCompare { | ||
s.Left s.Right = <SymbCompare-SwTypes <GetType s.Left> <GetType s.Right>>; | ||
} | ||
|
||
SymbCompare-SwTypes { | ||
s.Type s.LeftVal s.Type s.RightVal = | ||
<SymbCompare-SwTypes-Sign <Platform.Refal5.Compare s.LeftVal s.RightVal>>; | ||
|
||
Number s.LeftVal s.Type s.RightVal = '>'; | ||
s.Type s.LeftVal Number s.RightVal = '<'; | ||
Char s.LeftVal s.Type s.RightVal = '>'; | ||
s.Type s.LeftVal Char s.RightVal = '<'; | ||
s.L-Type s.L-Val s.R-Type s.R-Val = '='; | ||
} | ||
|
||
SymbCompare-SwTypes-Sign { | ||
'-' = '<'; | ||
'0' = '='; | ||
'+' = '>'; | ||
} | ||
|
||
GetType { | ||
s.Atom = <GetType-SwType <Platform.Refal5.Type s.Atom>>; | ||
} | ||
|
||
GetType-SwType { | ||
'N' s.SybType s.Atom = Number s.Atom; | ||
'L' s.SybType s.Atom = Char <Platform.Refal5.Ord s.Atom>; | ||
'O' s.SybType s.Atom = Char <Platform.Refal5.Ord s.Atom>; | ||
'P' s.SybType s.Atom = Char <Platform.Refal5.Ord s.Atom>; | ||
'D' s.SybType s.Atom = Char <Platform.Refal5.Ord s.Atom>; | ||
s.Type s.SybType s.Atom = Other 0; | ||
} | ||
|
||
$END CoreBE::MOrder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
$MODULE CoreBE::Math; | ||
|
||
$NATIVE Refal5 FUNCTION | ||
$ENTRY Binary @@' | ||
c { | ||
c '+' s.Left s.Right , <Add s.Left s.Right > : e.Car s.Last = s.Last; | ||
c '-' s.Left s.Right , <Sub s.Left s.Right > : e.Car s.Last = s.Last; | ||
c '*' s.Left s.Right , <Mul s.Left s.Right > : e.Car s.Last = s.Last; | ||
c '/' s.Left s.Right = <Div s.Left s.Right >; | ||
c '%' s.Left s.Right = <Mod s.Left s.Right >; | ||
c } | ||
'@@; | ||
|
||
$NATIVE Refal5 FUNCTION | ||
$ENTRY NumberCompare @@' | ||
c { | ||
c s.Left s.Right, <Compare s.Left s.Right >: | ||
c { | ||
c '-' = '<'; | ||
c '0' = '='; | ||
c '+' = '>'; | ||
c } | ||
c } | ||
'@@; | ||
$IMPORT Platform::Refal5; | ||
|
||
|
||
$ENTRY Binary { | ||
'+' s.Left s.Right = <Last <Platform.Refal5.Add s.Left s.Right>>; | ||
'-' s.Left s.Right = <Last <Platform.Refal5.Sub s.Left s.Right>>; | ||
'*' s.Left s.Right = <Last <Platform.Refal5.Mul s.Left s.Right>>; | ||
'/' s.Left s.Right = <Platform.Refal5.Div s.Left s.Right>; | ||
'%' s.Left s.Right = <Platform.Refal5.Mod s.Left s.Right>; | ||
} | ||
|
||
Last { e.Car s.Last = s.Last; } | ||
|
||
|
||
$ENTRY NumberCompare { | ||
s.Left s.Right = | ||
<NumberCompare-SwSign <Platform.Refal5.Compare s.Left s.Right>>; | ||
} | ||
|
||
NumberCompare-SwSign { | ||
'-' = '<'; | ||
'0' = '='; | ||
'+' = '>'; | ||
} | ||
|
||
$END CoreBE::Math. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.