1 #include "ast/default_value.h"
5 using namespace tanlang;
10 if (type->is_pointer()) {
11 ret = Literal::CreateNullPointerLiteral(src, pcast<PointerType>(type)->get_pointee());
13 }
else if (type->is_array()) {
15 Type *element_type = at->get_element_type();
16 size_t size = (size_t)at->array_size();
18 vector<Literal *> elements(size);
19 for (uint32_t i = 0; i < size; ++i) {
20 elements[i] = DefaultValue::CreateTypeDefaultValueLiteral(src, element_type);
23 ret = Literal::CreateArrayLiteral(src, element_type, elements);
25 }
else if (type->is_string()) {
26 ret = Literal::CreateStringLiteral(src,
"");
28 }
else if (type->is_struct()) {
31 }
else if (type->is_function()) {
34 }
else if (type->is_float()) {
35 ret = Literal::CreateFloatLiteral(src, 0, (
size_t)type->get_size_bits());
37 }
else if (type->is_int()) {
38 ret = Literal::CreateIntegerLiteral(src, 0, (
size_t)type->get_size_bits(), type->is_unsigned());
40 }
else if (type->is_bool()) {
41 ret = Literal::CreateBoolLiteral(src,
false);
43 }
else if (type->is_char()) {
44 ret = Literal::CreateCharLiteral(src,
'\0');
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.
Type is immutable once created. The exception is StructType. Its information is updated in multiple s...