Skip to content

Commit

Permalink
Merge pull request #2 from ConvolutedDog/revert-62-new-branch
Browse files Browse the repository at this point in the history
Revert "use interface add hash function"
  • Loading branch information
ConvolutedDog authored Sep 3, 2024
2 parents cb54ddc + 656fc21 commit 7fd3211
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 68 deletions.
1 change: 0 additions & 1 deletion builtin_packages/.prajna
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use string::String;

use serializable::Serializable;
use serialize;
use hash::Hashable;

func ExitWithMessage(msg: String) {
msg.PrintLine();
Expand Down
1 change: 0 additions & 1 deletion builtin_packages/float.prajna
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,3 @@ implement FloatScientificPrinter<FloatType> {
return str_re;
}
}

54 changes: 0 additions & 54 deletions builtin_packages/hash.prajna

This file was deleted.

5 changes: 2 additions & 3 deletions builtin_packages/int.prajna
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


template <Bits>
implement Uint<Bits> {
@static
Expand Down Expand Up @@ -25,6 +27,3 @@ implement Int<Bits> {
return !Int<Bits>::Max();
}
}



2 changes: 2 additions & 0 deletions builtin_packages/primitive_type.prajna
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,5 @@ use NegativeAndPositiveTemplate2<char>;
// use ComparableTemplate2<bool>;
use LogicalableTemplate2<bool>;



30 changes: 21 additions & 9 deletions tests/prajna_sources/special_statement_test.prajna
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
@test
func Test1() {
3i64.Hash().ToString().PrintLine();
2i32.Hash().ToString().PrintLine();
template <T>
struct Hash{}

template <T>
implement Hash<T> {
func __call__(v: T)->i64 {
return 1;
}
}

implement Hash<i64> {
func __call__(v: i64)->i64 {
return v;
}
}

4.0f64.Hash().ToString().PrintLine();
3.1f32.Hash().ToString().PrintLine();

'b'.Hash().ToString().PrintLine();
"hello".Hash().ToString().PrintLine();
true.Hash().ToString().PrintLine();
@test
func Test1() {
var tmp: Hash<i64>;
tmp(3).PrintLine();
var tmp2: Hash<f32>;
tmp2(3.0f32).PrintLine();
}


Expand Down

0 comments on commit 7fd3211

Please sign in to comment.