mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Consistent naming for Expression and Value. (#621)
- `Kind` enumerator names always match the corresponding factory function, accessor, and type names (if any). - All abbreviations in those names are expanded. - Those names always have a suffix to disambiguate expressions from values. `VarTV` is excluded from these changes because there's a pending PR to remove it.
This commit is contained in:
@@ -8,145 +8,158 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
auto Expression::GetVariable() const -> const Variable& {
|
||||
return std::get<Variable>(value);
|
||||
auto Expression::GetIdentifierExpression() const
|
||||
-> const IdentifierExpression& {
|
||||
return std::get<IdentifierExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetFieldAccess() const -> const FieldAccess& {
|
||||
return std::get<FieldAccess>(value);
|
||||
auto Expression::GetFieldAccessExpression() const
|
||||
-> const FieldAccessExpression& {
|
||||
return std::get<FieldAccessExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetIndex() const -> const Index& {
|
||||
return std::get<Index>(value);
|
||||
auto Expression::GetIndexExpression() const -> const IndexExpression& {
|
||||
return std::get<IndexExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetPatternVariable() const -> const PatternVariable& {
|
||||
return std::get<PatternVariable>(value);
|
||||
auto Expression::GetPatternVariableExpression() const
|
||||
-> const PatternVariableExpression& {
|
||||
return std::get<PatternVariableExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetInteger() const -> int {
|
||||
auto Expression::GetIntLiteral() const -> int {
|
||||
return std::get<IntLiteral>(value).value;
|
||||
}
|
||||
|
||||
auto Expression::GetBoolean() const -> bool {
|
||||
auto Expression::GetBoolLiteral() const -> bool {
|
||||
return std::get<BoolLiteral>(value).value;
|
||||
}
|
||||
|
||||
auto Expression::GetTuple() const -> const Tuple& {
|
||||
return std::get<Tuple>(value);
|
||||
auto Expression::GetTupleLiteral() const -> const TupleLiteral& {
|
||||
return std::get<TupleLiteral>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetPrimitiveOperator() const -> const PrimitiveOperator& {
|
||||
return std::get<PrimitiveOperator>(value);
|
||||
auto Expression::GetPrimitiveOperatorExpression() const
|
||||
-> const PrimitiveOperatorExpression& {
|
||||
return std::get<PrimitiveOperatorExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetCall() const -> const Call& {
|
||||
return std::get<Call>(value);
|
||||
auto Expression::GetCallExpression() const -> const CallExpression& {
|
||||
return std::get<CallExpression>(value);
|
||||
}
|
||||
|
||||
auto Expression::GetFunctionType() const -> const FunctionType& {
|
||||
return std::get<FunctionType>(value);
|
||||
auto Expression::GetFunctionTypeLiteral() const -> const FunctionTypeLiteral& {
|
||||
return std::get<FunctionTypeLiteral>(value);
|
||||
}
|
||||
|
||||
auto Expression::MakeTypeType(int line_num) -> const Expression* {
|
||||
auto Expression::MakeTypeTypeLiteral(int line_num) -> const Expression* {
|
||||
auto* t = new Expression();
|
||||
t->line_num = line_num;
|
||||
t->value = TypeT();
|
||||
t->value = TypeTypeLiteral();
|
||||
return t;
|
||||
}
|
||||
|
||||
auto Expression::MakeIntType(int line_num) -> const Expression* {
|
||||
auto Expression::MakeIntTypeLiteral(int line_num) -> const Expression* {
|
||||
auto* t = new Expression();
|
||||
t->line_num = line_num;
|
||||
t->value = IntT();
|
||||
t->value = IntTypeLiteral();
|
||||
return t;
|
||||
}
|
||||
|
||||
auto Expression::MakeBoolType(int line_num) -> const Expression* {
|
||||
auto Expression::MakeBoolTypeLiteral(int line_num) -> const Expression* {
|
||||
auto* t = new Expression();
|
||||
t->line_num = line_num;
|
||||
t->value = BoolT();
|
||||
t->value = BoolTypeLiteral();
|
||||
return t;
|
||||
}
|
||||
|
||||
auto Expression::MakeAutoType(int line_num) -> const Expression* {
|
||||
auto Expression::MakeAutoTypeLiteral(int line_num) -> const Expression* {
|
||||
auto* t = new Expression();
|
||||
t->line_num = line_num;
|
||||
t->value = AutoT();
|
||||
t->value = AutoTypeLiteral();
|
||||
return t;
|
||||
}
|
||||
|
||||
// Returns a Continuation type AST node at the given source location.
|
||||
auto Expression::MakeContinuationType(int line_num) -> const Expression* {
|
||||
auto Expression::MakeContinuationTypeLiteral(int line_num)
|
||||
-> const Expression* {
|
||||
auto* type = new Expression();
|
||||
type->line_num = line_num;
|
||||
type->value = ContinuationT();
|
||||
type->value = ContinuationTypeLiteral();
|
||||
return type;
|
||||
}
|
||||
|
||||
auto Expression::MakeFunType(int line_num, const Expression* param,
|
||||
const Expression* ret) -> const Expression* {
|
||||
auto Expression::MakeFunctionTypeLiteral(int line_num, const Expression* param,
|
||||
const Expression* ret)
|
||||
-> const Expression* {
|
||||
auto* t = new Expression();
|
||||
t->line_num = line_num;
|
||||
t->value = FunctionType({.parameter = param, .return_type = ret});
|
||||
t->value = FunctionTypeLiteral({.parameter = param, .return_type = ret});
|
||||
return t;
|
||||
}
|
||||
|
||||
auto Expression::MakeVar(int line_num, std::string var) -> const Expression* {
|
||||
auto Expression::MakeIdentifierExpression(int line_num, std::string var)
|
||||
-> const Expression* {
|
||||
auto* v = new Expression();
|
||||
v->line_num = line_num;
|
||||
v->value = Variable({.name = std::move(var)});
|
||||
v->value = IdentifierExpression({.name = std::move(var)});
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Expression::MakeVarPat(int line_num, std::string var,
|
||||
const Expression* type) -> const Expression* {
|
||||
auto Expression::MakePatternVariableExpression(int line_num, std::string var,
|
||||
const Expression* type)
|
||||
-> const Expression* {
|
||||
auto* v = new Expression();
|
||||
v->line_num = line_num;
|
||||
v->value = PatternVariable({.name = std::move(var), .type = type});
|
||||
v->value = PatternVariableExpression({.name = std::move(var), .type = type});
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Expression::MakeInt(int line_num, int i) -> const Expression* {
|
||||
auto Expression::MakeIntLiteral(int line_num, int i) -> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = IntLiteral({.value = i});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeBool(int line_num, bool b) -> const Expression* {
|
||||
auto Expression::MakeBoolLiteral(int line_num, bool b) -> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = BoolLiteral({.value = b});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeOp(int line_num, enum Operator op,
|
||||
std::vector<const Expression*> args)
|
||||
auto Expression::MakePrimitiveOperatorExpression(
|
||||
int line_num, enum Operator op, std::vector<const Expression*> args)
|
||||
-> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = PrimitiveOperator({.op = op, .arguments = std::move(args)});
|
||||
e->value =
|
||||
PrimitiveOperatorExpression({.op = op, .arguments = std::move(args)});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeCall(int line_num, const Expression* fun,
|
||||
const Expression* arg) -> const Expression* {
|
||||
auto Expression::MakeCallExpression(int line_num, const Expression* fun,
|
||||
const Expression* arg)
|
||||
-> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = Call({.function = fun, .argument = arg});
|
||||
e->value = CallExpression({.function = fun, .argument = arg});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeGetField(int line_num, const Expression* exp,
|
||||
std::string field) -> const Expression* {
|
||||
auto Expression::MakeFieldAccessExpression(int line_num, const Expression* exp,
|
||||
std::string field)
|
||||
-> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = FieldAccess({.aggregate = exp, .field = std::move(field)});
|
||||
e->value =
|
||||
FieldAccessExpression({.aggregate = exp, .field = std::move(field)});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeTuple(int line_num, std::vector<FieldInitializer> args)
|
||||
auto Expression::MakeTupleLiteral(int line_num,
|
||||
std::vector<FieldInitializer> args)
|
||||
-> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
@@ -166,15 +179,15 @@ auto Expression::MakeTuple(int line_num, std::vector<FieldInitializer> args)
|
||||
seen_named_member = true;
|
||||
}
|
||||
}
|
||||
e->value = Tuple({.fields = args});
|
||||
e->value = TupleLiteral({.fields = args});
|
||||
return e;
|
||||
}
|
||||
|
||||
auto Expression::MakeIndex(int line_num, const Expression* exp,
|
||||
const Expression* i) -> const Expression* {
|
||||
auto Expression::MakeIndexExpression(int line_num, const Expression* exp,
|
||||
const Expression* i) -> const Expression* {
|
||||
auto* e = new Expression();
|
||||
e->line_num = line_num;
|
||||
e->value = Index({.aggregate = exp, .offset = i});
|
||||
e->value = IndexExpression({.aggregate = exp, .offset = i});
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -220,32 +233,32 @@ static void PrintFields(const std::vector<FieldInitializer>& fields) {
|
||||
|
||||
void PrintExp(const Expression* e) {
|
||||
switch (e->tag()) {
|
||||
case ExpressionKind::Index:
|
||||
PrintExp(e->GetIndex().aggregate);
|
||||
case ExpressionKind::IndexExpression:
|
||||
PrintExp(e->GetIndexExpression().aggregate);
|
||||
std::cout << "[";
|
||||
PrintExp(e->GetIndex().offset);
|
||||
PrintExp(e->GetIndexExpression().offset);
|
||||
std::cout << "]";
|
||||
break;
|
||||
case ExpressionKind::GetField:
|
||||
PrintExp(e->GetFieldAccess().aggregate);
|
||||
case ExpressionKind::FieldAccessExpression:
|
||||
PrintExp(e->GetFieldAccessExpression().aggregate);
|
||||
std::cout << ".";
|
||||
std::cout << e->GetFieldAccess().field;
|
||||
std::cout << e->GetFieldAccessExpression().field;
|
||||
break;
|
||||
case ExpressionKind::Tuple:
|
||||
case ExpressionKind::TupleLiteral:
|
||||
std::cout << "(";
|
||||
PrintFields(e->GetTuple().fields);
|
||||
PrintFields(e->GetTupleLiteral().fields);
|
||||
std::cout << ")";
|
||||
break;
|
||||
case ExpressionKind::Integer:
|
||||
std::cout << e->GetInteger();
|
||||
case ExpressionKind::IntLiteral:
|
||||
std::cout << e->GetIntLiteral();
|
||||
break;
|
||||
case ExpressionKind::Boolean:
|
||||
case ExpressionKind::BoolLiteral:
|
||||
std::cout << std::boolalpha;
|
||||
std::cout << e->GetBoolean();
|
||||
std::cout << e->GetBoolLiteral();
|
||||
break;
|
||||
case ExpressionKind::PrimitiveOp: {
|
||||
case ExpressionKind::PrimitiveOperatorExpression: {
|
||||
std::cout << "(";
|
||||
PrimitiveOperator op = e->GetPrimitiveOperator();
|
||||
PrimitiveOperatorExpression op = e->GetPrimitiveOperatorExpression();
|
||||
if (op.arguments.size() == 0) {
|
||||
PrintOp(op.op);
|
||||
} else if (op.arguments.size() == 1) {
|
||||
@@ -265,44 +278,45 @@ void PrintExp(const Expression* e) {
|
||||
std::cout << ")";
|
||||
break;
|
||||
}
|
||||
case ExpressionKind::Variable:
|
||||
std::cout << e->GetVariable().name;
|
||||
case ExpressionKind::IdentifierExpression:
|
||||
std::cout << e->GetIdentifierExpression().name;
|
||||
break;
|
||||
case ExpressionKind::PatternVariable:
|
||||
PrintExp(e->GetPatternVariable().type);
|
||||
case ExpressionKind::PatternVariableExpression:
|
||||
PrintExp(e->GetPatternVariableExpression().type);
|
||||
std::cout << ": ";
|
||||
std::cout << e->GetPatternVariable().name;
|
||||
std::cout << e->GetPatternVariableExpression().name;
|
||||
break;
|
||||
case ExpressionKind::Call:
|
||||
PrintExp(e->GetCall().function);
|
||||
if (e->GetCall().argument->tag() == ExpressionKind::Tuple) {
|
||||
PrintExp(e->GetCall().argument);
|
||||
case ExpressionKind::CallExpression:
|
||||
PrintExp(e->GetCallExpression().function);
|
||||
if (e->GetCallExpression().argument->tag() ==
|
||||
ExpressionKind::TupleLiteral) {
|
||||
PrintExp(e->GetCallExpression().argument);
|
||||
} else {
|
||||
std::cout << "(";
|
||||
PrintExp(e->GetCall().argument);
|
||||
PrintExp(e->GetCallExpression().argument);
|
||||
std::cout << ")";
|
||||
}
|
||||
break;
|
||||
case ExpressionKind::BoolT:
|
||||
case ExpressionKind::BoolTypeLiteral:
|
||||
std::cout << "Bool";
|
||||
break;
|
||||
case ExpressionKind::IntT:
|
||||
case ExpressionKind::IntTypeLiteral:
|
||||
std::cout << "Int";
|
||||
break;
|
||||
case ExpressionKind::TypeT:
|
||||
case ExpressionKind::TypeTypeLiteral:
|
||||
std::cout << "Type";
|
||||
break;
|
||||
case ExpressionKind::AutoT:
|
||||
case ExpressionKind::AutoTypeLiteral:
|
||||
std::cout << "auto";
|
||||
break;
|
||||
case ExpressionKind::ContinuationT:
|
||||
case ExpressionKind::ContinuationTypeLiteral:
|
||||
std::cout << "Continuation";
|
||||
break;
|
||||
case ExpressionKind::FunctionT:
|
||||
case ExpressionKind::FunctionTypeLiteral:
|
||||
std::cout << "fn ";
|
||||
PrintExp(e->GetFunctionType().parameter);
|
||||
PrintExp(e->GetFunctionTypeLiteral().parameter);
|
||||
std::cout << " -> ";
|
||||
PrintExp(e->GetFunctionType().return_type);
|
||||
PrintExp(e->GetFunctionTypeLiteral().return_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,21 +23,21 @@ struct FieldInitializer {
|
||||
};
|
||||
|
||||
enum class ExpressionKind {
|
||||
AutoT,
|
||||
BoolT,
|
||||
Boolean,
|
||||
Call,
|
||||
FunctionT,
|
||||
GetField,
|
||||
Index,
|
||||
IntT,
|
||||
ContinuationT, // The type of a continuation value.
|
||||
Integer,
|
||||
PatternVariable,
|
||||
PrimitiveOp,
|
||||
Tuple,
|
||||
TypeT,
|
||||
Variable,
|
||||
AutoTypeLiteral,
|
||||
BoolTypeLiteral,
|
||||
BoolLiteral,
|
||||
CallExpression,
|
||||
FunctionTypeLiteral,
|
||||
FieldAccessExpression,
|
||||
IndexExpression,
|
||||
IntTypeLiteral,
|
||||
ContinuationTypeLiteral, // The type of a continuation value.
|
||||
IntLiteral,
|
||||
PatternVariableExpression,
|
||||
PrimitiveOperatorExpression,
|
||||
TupleLiteral,
|
||||
TypeTypeLiteral,
|
||||
IdentifierExpression,
|
||||
};
|
||||
|
||||
enum class Operator {
|
||||
@@ -55,124 +55,134 @@ enum class Operator {
|
||||
|
||||
struct Expression;
|
||||
|
||||
struct Variable {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Variable;
|
||||
struct IdentifierExpression {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::IdentifierExpression;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct FieldAccess {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::GetField;
|
||||
struct FieldAccessExpression {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::FieldAccessExpression;
|
||||
const Expression* aggregate;
|
||||
std::string field;
|
||||
};
|
||||
|
||||
struct Index {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Index;
|
||||
struct IndexExpression {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::IndexExpression;
|
||||
const Expression* aggregate;
|
||||
const Expression* offset;
|
||||
};
|
||||
|
||||
struct PatternVariable {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::PatternVariable;
|
||||
struct PatternVariableExpression {
|
||||
static constexpr ExpressionKind Kind =
|
||||
ExpressionKind::PatternVariableExpression;
|
||||
std::string name;
|
||||
const Expression* type;
|
||||
};
|
||||
|
||||
struct IntLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Integer;
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::IntLiteral;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct BoolLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Boolean;
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::BoolLiteral;
|
||||
bool value;
|
||||
};
|
||||
|
||||
struct Tuple {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Tuple;
|
||||
struct TupleLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::TupleLiteral;
|
||||
std::vector<FieldInitializer> fields;
|
||||
};
|
||||
|
||||
struct PrimitiveOperator {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::PrimitiveOp;
|
||||
struct PrimitiveOperatorExpression {
|
||||
static constexpr ExpressionKind Kind =
|
||||
ExpressionKind::PrimitiveOperatorExpression;
|
||||
Operator op;
|
||||
std::vector<const Expression*> arguments;
|
||||
};
|
||||
|
||||
struct Call {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::Call;
|
||||
struct CallExpression {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::CallExpression;
|
||||
const Expression* function;
|
||||
const Expression* argument;
|
||||
};
|
||||
|
||||
struct FunctionType {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::FunctionT;
|
||||
struct FunctionTypeLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::FunctionTypeLiteral;
|
||||
const Expression* parameter;
|
||||
const Expression* return_type;
|
||||
};
|
||||
|
||||
struct AutoT {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::AutoT;
|
||||
struct AutoTypeLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::AutoTypeLiteral;
|
||||
};
|
||||
|
||||
struct BoolT {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::BoolT;
|
||||
struct BoolTypeLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::BoolTypeLiteral;
|
||||
};
|
||||
|
||||
struct IntT {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::IntT;
|
||||
struct IntTypeLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::IntTypeLiteral;
|
||||
};
|
||||
|
||||
struct ContinuationT {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::ContinuationT;
|
||||
struct ContinuationTypeLiteral {
|
||||
static constexpr ExpressionKind Kind =
|
||||
ExpressionKind::ContinuationTypeLiteral;
|
||||
};
|
||||
|
||||
struct TypeT {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::TypeT;
|
||||
struct TypeTypeLiteral {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::TypeTypeLiteral;
|
||||
};
|
||||
|
||||
struct Expression {
|
||||
int line_num;
|
||||
inline auto tag() const -> ExpressionKind;
|
||||
|
||||
static auto MakeVar(int line_num, std::string var) -> const Expression*;
|
||||
static auto MakeVarPat(int line_num, std::string var, const Expression* type)
|
||||
static auto MakeIdentifierExpression(int line_num, std::string var)
|
||||
-> const Expression*;
|
||||
static auto MakeInt(int line_num, int i) -> const Expression*;
|
||||
static auto MakeBool(int line_num, bool b) -> const Expression*;
|
||||
static auto MakeOp(int line_num, Operator op,
|
||||
std::vector<const Expression*> args) -> const Expression*;
|
||||
static auto MakeCall(int line_num, const Expression* fun,
|
||||
const Expression* arg) -> const Expression*;
|
||||
static auto MakeGetField(int line_num, const Expression* exp,
|
||||
std::string field) -> const Expression*;
|
||||
static auto MakeTuple(int line_num, std::vector<FieldInitializer> args)
|
||||
static auto MakePatternVariableExpression(int line_num, std::string var,
|
||||
const Expression* type)
|
||||
-> const Expression*;
|
||||
static auto MakeIndex(int line_num, const Expression* exp,
|
||||
const Expression* i) -> const Expression*;
|
||||
static auto MakeTypeType(int line_num) -> const Expression*;
|
||||
static auto MakeIntType(int line_num) -> const Expression*;
|
||||
static auto MakeBoolType(int line_num) -> const Expression*;
|
||||
static auto MakeFunType(int line_num, const Expression* param,
|
||||
const Expression* ret) -> const Expression*;
|
||||
static auto MakeAutoType(int line_num) -> const Expression*;
|
||||
static auto MakeContinuationType(int line_num) -> const Expression*;
|
||||
static auto MakeIntLiteral(int line_num, int i) -> const Expression*;
|
||||
static auto MakeBoolLiteral(int line_num, bool b) -> const Expression*;
|
||||
static auto MakePrimitiveOperatorExpression(
|
||||
int line_num, Operator op, std::vector<const Expression*> args)
|
||||
-> const Expression*;
|
||||
static auto MakeCallExpression(int line_num, const Expression* fun,
|
||||
const Expression* arg) -> const Expression*;
|
||||
static auto MakeFieldAccessExpression(int line_num, const Expression* exp,
|
||||
std::string field) -> const Expression*;
|
||||
static auto MakeTupleLiteral(int line_num, std::vector<FieldInitializer> args)
|
||||
-> const Expression*;
|
||||
static auto MakeIndexExpression(int line_num, const Expression* exp,
|
||||
const Expression* i) -> const Expression*;
|
||||
static auto MakeTypeTypeLiteral(int line_num) -> const Expression*;
|
||||
static auto MakeIntTypeLiteral(int line_num) -> const Expression*;
|
||||
static auto MakeBoolTypeLiteral(int line_num) -> const Expression*;
|
||||
static auto MakeFunctionTypeLiteral(int line_num, const Expression* param,
|
||||
const Expression* ret)
|
||||
-> const Expression*;
|
||||
static auto MakeAutoTypeLiteral(int line_num) -> const Expression*;
|
||||
static auto MakeContinuationTypeLiteral(int line_num) -> const Expression*;
|
||||
|
||||
auto GetVariable() const -> const Variable&;
|
||||
auto GetFieldAccess() const -> const FieldAccess&;
|
||||
auto GetIndex() const -> const Index&;
|
||||
auto GetPatternVariable() const -> const PatternVariable&;
|
||||
auto GetInteger() const -> int;
|
||||
auto GetBoolean() const -> bool;
|
||||
auto GetTuple() const -> const Tuple&;
|
||||
auto GetPrimitiveOperator() const -> const PrimitiveOperator&;
|
||||
auto GetCall() const -> const Call&;
|
||||
auto GetFunctionType() const -> const FunctionType&;
|
||||
auto GetIdentifierExpression() const -> const IdentifierExpression&;
|
||||
auto GetFieldAccessExpression() const -> const FieldAccessExpression&;
|
||||
auto GetIndexExpression() const -> const IndexExpression&;
|
||||
auto GetPatternVariableExpression() const -> const PatternVariableExpression&;
|
||||
auto GetIntLiteral() const -> int;
|
||||
auto GetBoolLiteral() const -> bool;
|
||||
auto GetTupleLiteral() const -> const TupleLiteral&;
|
||||
auto GetPrimitiveOperatorExpression() const
|
||||
-> const PrimitiveOperatorExpression&;
|
||||
auto GetCallExpression() const -> const CallExpression&;
|
||||
auto GetFunctionTypeLiteral() const -> const FunctionTypeLiteral&;
|
||||
|
||||
private:
|
||||
std::variant<Variable, FieldAccess, Index, PatternVariable, IntLiteral,
|
||||
BoolLiteral, Tuple, PrimitiveOperator, Call, FunctionType, AutoT,
|
||||
BoolT, IntT, ContinuationT, TypeT>
|
||||
std::variant<IdentifierExpression, FieldAccessExpression, IndexExpression,
|
||||
PatternVariableExpression, IntLiteral, BoolLiteral, TupleLiteral,
|
||||
PrimitiveOperatorExpression, CallExpression, FunctionTypeLiteral,
|
||||
AutoTypeLiteral, BoolTypeLiteral, IntTypeLiteral,
|
||||
ContinuationTypeLiteral, TypeTypeLiteral>
|
||||
value;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user