Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,199 additions
and
251 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
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,128 +1,14 @@ | ||
// Mash lang classes unit | ||
// Code version: 10 | ||
// Code version: 1.0 | ||
|
||
uses <bf> | ||
|
||
class class: // for free class-methods declaration | ||
end // like: proc class::MyProc() -- for that --> MyClass->MyMethod = class::MyProc | ||
uses <classes\types> | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// Point | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
class point: | ||
public: | ||
var x, y | ||
proc Create, Free, Set, Compare | ||
end | ||
|
||
proc point::Create(x, y): | ||
$x ?= new(x) | ||
$y ?= new(y) | ||
end | ||
|
||
proc point::Free(): | ||
Free($x, $y, $) | ||
end | ||
|
||
proc point::Set(x, y): | ||
$x = x | ||
$y = y | ||
end | ||
|
||
func point::Compare(p): | ||
return ($x == p->x) & ($y == p->y) | ||
end | ||
|
||
class point3(point): | ||
public: | ||
var z | ||
proc Create, Free | ||
func Compare | ||
end | ||
|
||
proc point3::Create(x, y, z): | ||
point::Create$(x, y) | ||
$z ?= new(z) | ||
end | ||
|
||
proc point3::Free(): | ||
Free($z) | ||
point::Free$() | ||
end | ||
|
||
func point3::Compare(p): | ||
return ($z == p->z) & point::Compare$(p) | ||
end | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// Vector | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
class vector: | ||
public: | ||
var Items | ||
proc Create, Free, Push_Back, Rem_Back, Rem_First | ||
func Pop_Back, Pop_First, Peek_Back, Peek_First, At, Size | ||
end | ||
|
||
proc vector::Create(): | ||
$Items ?= new[1] | ||
$Items[0] ?= new(0) | ||
end | ||
|
||
proc vector::Push_Back(Object): | ||
SetLen($Items, $Items[0] + 2) | ||
$Items[0]++ | ||
$Items[$Items[0]] ?= Object | ||
end | ||
|
||
func vector::Pop_Back(): | ||
var r = $Items[$Items[0]] | ||
SetLen($Items, $Items[0]) | ||
$Items[0]-- | ||
return r | ||
end | ||
|
||
func vector::Pop_First(): | ||
var r = $Items[1] | ||
for(var i = copy(1); i < $Items[0]; i++): | ||
$Items[i] ?= $Items[i + 1] | ||
end | ||
SetLen($Items, $Items[0]) | ||
$Items[0]-- | ||
return r | ||
end | ||
|
||
func vector::Peek_Back(): | ||
return $Items[$Items[0]] | ||
end | ||
|
||
func vector::Peek_First(): | ||
return $Items[1] | ||
end | ||
|
||
proc vector::Rem_First(): | ||
for(var i = copy(1); i < $Items[0]; i++): | ||
$Items[i] ?= $Items[i + 1] | ||
end | ||
SetLen($Items, $Items[0]) | ||
$Items[0]-- | ||
end | ||
|
||
proc vector::Rem_Back(): | ||
SetLen($Items, $Items[0]) | ||
$Items[0]-- | ||
end | ||
|
||
func vector::At(Index): | ||
return $Items[Index - 1] | ||
end | ||
|
||
func vector::Size(): | ||
return $Items[0] | ||
end | ||
|
||
proc vector::Free(): | ||
Free($Items[0], $Items, $) | ||
end | ||
uses <classes\points> | ||
uses <classes\vector> | ||
uses <classes\list> | ||
uses <classes\streams> | ||
uses <classes\stringlist> | ||
uses <classes\map> | ||
uses <classes\tree> |
Oops, something went wrong.