ast_type.cc

来自「编译原理课程设计之pp2语法分析程序」· CC 代码 · 共 52 行

CC
52
字号
/* File: ast_type.cc * ----------------- * Implementation of type node classes. */#include "ast_type.h"#include "ast_decl.h" /* Class constants * --------------- * These are public constants for the built-in base types (int, double, etc.) * They can be accessed with the syntax Type::intType. This allows you to * directly access them and share the built-in types where needed rather that * creates lots of copies. */Type *Type::intType    = new Type("int");Type *Type::doubleType = new Type("double");Type *Type::voidType   = new Type("void");Type *Type::boolType   = new Type("bool");Type *Type::nullType   = new Type("null");Type *Type::stringType = new Type("string");Type *Type::errorType  = new Type("error"); Type::Type(const char *n) {    Assert(n);    typeName = strdup(n);}void Type::PrintChildren(int indentLevel) {    printf("%s", typeName);}	NamedType::NamedType(Identifier *i) : Type(*i->GetLocation()) {    Assert(i != NULL);    (id=i)->SetParent(this);} void NamedType::PrintChildren(int indentLevel) {    id->Print(indentLevel+1);}ArrayType::ArrayType(yyltype loc, Type *et) : Type(loc) {    Assert(et != NULL);    (elemType=et)->SetParent(this);}void ArrayType::PrintChildren(int indentLevel) {    elemType->Print(indentLevel+1);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?