Browse Source

Remove AstTypeType

gingerBill 6 years ago
parent
commit
ef2931d4a5
5 changed files with 3 additions and 59 deletions
  1. 0 9
      src/check_expr.cpp
  2. 1 31
      src/check_type.cpp
  3. 1 2
      src/checker.cpp
  4. 1 13
      src/parser.cpp
  5. 0 4
      src/parser.hpp

+ 0 - 9
src/check_expr.cpp

@@ -6130,7 +6130,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
 	case_end;
 	case_end;
 
 
 	case Ast_TypeidType:
 	case Ast_TypeidType:
-	case Ast_TypeType:
 	case Ast_PolyType:
 	case Ast_PolyType:
 	case Ast_ProcType:
 	case Ast_ProcType:
 	case Ast_PointerType:
 	case Ast_PointerType:
@@ -6573,14 +6572,6 @@ gbString write_expr_to_string(gbString str, Ast *node) {
 		str = gb_string_appendc(str, ")");
 		str = gb_string_appendc(str, ")");
 	case_end;
 	case_end;
 
 
-	case_ast_node(tt, TypeType, node);
-		str = gb_string_appendc(str, "type");
-		if (tt->specialization) {
-			str = gb_string_appendc(str, "/");
-			str = write_expr_to_string(str, tt->specialization);
-		}
-	case_end;
-
 	case_ast_node(tt, TypeidType, node);
 	case_ast_node(tt, TypeidType, node);
 		str = gb_string_appendc(str, "typeid");
 		str = gb_string_appendc(str, "typeid");
 		if (tt->specialization) {
 		if (tt->specialization) {

+ 1 - 31
src/check_type.cpp

@@ -382,14 +382,6 @@ void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array<
 						specialization = check_type(ctx, s);
 						specialization = check_type(ctx, s);
 					}
 					}
 					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
 					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
-				} else if (type_expr->kind == Ast_TypeType) {
-					is_type_param = true;
-					Type *specialization = nullptr;
-					if (type_expr->TypeType.specialization != nullptr) {
-						Ast *s = type_expr->TypeType.specialization;
-						specialization = check_type(ctx, s);
-					}
-					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
 				} else {
 				} else {
 					type = check_type(ctx, type_expr);
 					type = check_type(ctx, type_expr);
 					if (is_type_polymorphic(type)) {
 					if (is_type_polymorphic(type)) {
@@ -574,14 +566,6 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array<Op
 						specialization = check_type(ctx, s);
 						specialization = check_type(ctx, s);
 					}
 					}
 					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
 					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
-				} else if (type_expr->kind == Ast_TypeType) {
-					is_type_param = true;
-					Type *specialization = nullptr;
-					if (type_expr->TypeType.specialization != nullptr) {
-						Ast *s = type_expr->TypeType.specialization;
-						specialization = check_type(ctx, s);
-					}
-					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
 				} else {
 				} else {
 					type = check_type(ctx, type_expr);
 					type = check_type(ctx, type_expr);
 					if (is_type_polymorphic(type)) {
 					if (is_type_polymorphic(type)) {
@@ -1383,20 +1367,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
 				} else {
 				} else {
 					type = t_typeid;
 					type = t_typeid;
 				}
 				}
-			} else if (type_expr->kind == Ast_TypeType) {
-				ast_node(tt, TypeType, type_expr);
-				is_type_param = true;
-				specialization = check_type(ctx, tt->specialization);
-				if (specialization == t_invalid){
-					specialization = nullptr;
-				}
-
-				if (operands != nullptr) {
-					detemine_type_from_operand = true;
-					type = t_invalid;
-				} else {
-					type = alloc_type_generic(ctx->scope, 0, str_lit(""), specialization);
-				}
 			} else {
 			} else {
 				bool prev = ctx->allow_polymorphic_types;
 				bool prev = ctx->allow_polymorphic_types;
 				if (operands != nullptr) {
 				if (operands != nullptr) {
@@ -1412,7 +1382,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
 			}
 			}
 
 
 			if (default_value != nullptr) {
 			if (default_value != nullptr) {
-				if (type_expr != nullptr && (type_expr->kind == Ast_TypeType || type_expr->kind == Ast_TypeidType)) {
+				if (type_expr != nullptr && type_expr->kind == Ast_TypeidType) {
 					error(type_expr, "A type parameter may not have a default value");
 					error(type_expr, "A type parameter may not have a default value");
 				} else {
 				} else {
 					param_value = handle_parameter_value(ctx, type, nullptr, default_value, true);
 					param_value = handle_parameter_value(ctx, type, nullptr, default_value, true);

+ 1 - 2
src/checker.cpp

@@ -2150,8 +2150,7 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) {
 
 
 			d->attributes = vd->attributes;
 			d->attributes = vd->attributes;
 
 
-			if (is_ast_type(init) ||
-				(vd->type != nullptr && vd->type->kind == Ast_TypeType)) {
+			if (is_ast_type(init)) {
 				e = alloc_entity_type_name(d->scope, token, nullptr);
 				e = alloc_entity_type_name(d->scope, token, nullptr);
 				if (vd->type != nullptr) {
 				if (vd->type != nullptr) {
 					error(name, "A type declaration cannot have an type parameter");
 					error(name, "A type declaration cannot have an type parameter");

+ 1 - 13
src/parser.cpp

@@ -77,7 +77,6 @@ Token ast_token(Ast *node) {
 	case Ast_UnionField:
 	case Ast_UnionField:
 		return ast_token(node->UnionField.name);
 		return ast_token(node->UnionField.name);
 
 
-	case Ast_TypeType:         return node->TypeType.token;
 	case Ast_TypeidType:       return node->TypeidType.token;
 	case Ast_TypeidType:       return node->TypeidType.token;
 	case Ast_HelperType:       return node->HelperType.token;
 	case Ast_HelperType:       return node->HelperType.token;
 	case Ast_DistinctType:     return node->DistinctType.token;
 	case Ast_DistinctType:     return node->DistinctType.token;
@@ -314,9 +313,6 @@ Ast *clone_ast(Ast *node) {
 	case Ast_TypeidType:
 	case Ast_TypeidType:
 		n->TypeidType.specialization = clone_ast(n->TypeidType.specialization);
 		n->TypeidType.specialization = clone_ast(n->TypeidType.specialization);
 		break;
 		break;
-	case Ast_TypeType:
-		n->TypeType.specialization = clone_ast(n->TypeType.specialization);
-		break;
 	case Ast_HelperType:
 	case Ast_HelperType:
 		n->HelperType.type = clone_ast(n->HelperType.type);
 		n->HelperType.type = clone_ast(n->HelperType.type);
 		break;
 		break;
@@ -839,13 +835,6 @@ Ast *ast_typeid_type(AstFile *f, Token token, Ast *specialization) {
 	return result;
 	return result;
 }
 }
 
 
-Ast *ast_type_type(AstFile *f, Token token, Ast *specialization) {
-	Ast *result = alloc_ast_node(f, Ast_TypeType);
-	result->TypeType.token = token;
-	result->TypeType.specialization = specialization;
-	return result;
-}
-
 Ast *ast_helper_type(AstFile *f, Token token, Ast *type) {
 Ast *ast_helper_type(AstFile *f, Token token, Ast *type) {
 	Ast *result = alloc_ast_node(f, Ast_HelperType);
 	Ast *result = alloc_ast_node(f, Ast_HelperType);
 	result->HelperType.token = token;
 	result->HelperType.token = token;
@@ -2740,8 +2729,7 @@ Ast *parse_proc_type(AstFile *f, Token proc_token) {
 		Ast *param = params->FieldList.list[i];
 		Ast *param = params->FieldList.list[i];
 		ast_node(field, Field, param);
 		ast_node(field, Field, param);
 		if (field->type != nullptr) {
 		if (field->type != nullptr) {
-		    if (field->type->kind == Ast_TypeType ||
-		        field->type->kind == Ast_PolyType) {
+		    if (field->type->kind == Ast_PolyType) {
 				is_generic = true;
 				is_generic = true;
 				goto end;
 				goto end;
 			}
 			}

+ 0 - 4
src/parser.hpp

@@ -423,10 +423,6 @@ AST_KIND(_TypeBegin, "", bool) \
 		Token token; \
 		Token token; \
 		Ast *specialization; \
 		Ast *specialization; \
 	}) \
 	}) \
-	AST_KIND(TypeType, "type", struct { \
-		Token token; \
-		Ast *specialization; \
-	}) \
 	AST_KIND(HelperType, "helper type", struct { \
 	AST_KIND(HelperType, "helper type", struct { \
 		Token token; \
 		Token token; \
 		Ast *type; \
 		Ast *type; \