Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "use interface add hash function" #2

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading