Start working on type code
This commit is contained in:
25
03/type.cpp
Normal file
25
03/type.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "type.hpp"
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
std::string type_mgr::new_type_name() {
|
||||
std::ostringstream oss;
|
||||
int temp = last_id++;
|
||||
|
||||
do {
|
||||
oss << (char) ('a' + (temp % 26));
|
||||
temp /= 26;
|
||||
} while(temp);
|
||||
std::string str = oss.str();
|
||||
|
||||
std::reverse(str.begin(), str.end());
|
||||
return str;
|
||||
};
|
||||
|
||||
type_ptr type_mgr::new_type() {
|
||||
return type_ptr(new type_var(new_type_name()));
|
||||
}
|
||||
|
||||
type_ptr type_mgr::new_arrow_type() {
|
||||
return type_ptr(new type_arr(new_type(), new_type()));
|
||||
}
|
||||
Reference in New Issue
Block a user