Rename 'data' to 'oneof', resolving a fixme in the spec. Yay for CLU!

Swift SVN r212
This commit is contained in:
Chris Lattner
2010-11-11 01:20:36 +00:00
parent 3892ef2e1d
commit 906ba908fd
15 changed files with 196 additions and 195 deletions

View File

@@ -28,13 +28,13 @@ namespace llvm {
namespace swift {
class Type;
class DataType;
class OneOfType;
class TupleType;
class FunctionType;
class ArrayType;
class Identifier;
class TupleTypeElt;
class DataDecl;
class OneOfDecl;
/// ASTContext - This object creates and owns the AST objects.
class ASTContext {
@@ -44,7 +44,7 @@ class ASTContext {
void *IdentifierTable; // llvm::StringMap<char>
void *AliasTypes; // llvm::DenseMap<Identifier, AliasType*>
void *DataTypes; // llvm::DenseMap<Identifier, DataType*>
void *OneOfTypes; // llvm::DenseMap<Identifier, OneOfType*>
void *TupleTypes; // llvm::FoldingSet<TupleType>
void *FunctionTypes; // DenseMap<std::pair<Type*, Type*>, FunctionType*>
void *ArrayTypes; // DenseMap<std::pair<Type*, uint64_t>, ArrayType*>
@@ -88,9 +88,9 @@ public:
/// same name.
void InstallAliasType(Identifier Name, Type *Underlying);
/// InstallDataType - Return the type corresponding to the specified data
/// InstallOneOfType - Return the type corresponding to the specified oneof
/// declaration.
void InstallDataType(DataDecl *TheDecl);
void InstallOneOfType(OneOfDecl *TheDecl);
/// getTupleType - Return the uniqued tuple type with the specified elements.
TupleType *getTupleType(const TupleTypeElt *Fields,

View File

@@ -30,13 +30,13 @@ namespace swift {
class ASTContext;
class Type;
class Expr;
class DataElementDecl;
class OneOfElementDecl;
enum DeclKind {
DataDeclKind,
OneOfDeclKind,
VarDeclKind,
FuncDeclKind,
DataElementDeclKind,
OneOfElementDeclKind,
ArgDeclKind,
AnonDeclKind,
ElementRefDeclKind
@@ -88,7 +88,7 @@ public:
unsigned Alignment = 8) throw();
};
/// NamedDecl - The common base class between DataDecl and ValueDecl.
/// NamedDecl - The common base class between OneOfDecl and ValueDecl.
class NamedDecl : public Decl {
public:
Identifier Name;
@@ -99,9 +99,9 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return (D->getKind() == VarDeclKind || D->getKind() == FuncDeclKind ||
D->getKind() == DataElementDeclKind || D->getKind() == ArgDeclKind||
D->getKind() == OneOfElementDeclKind || D->getKind() == ArgDeclKind||
D->getKind() == AnonDeclKind || D->getKind() == ElementRefDeclKind||
D->getKind() == DataDeclKind);
D->getKind() == OneOfDeclKind);
}
static bool classof(const NamedDecl *D) { return true; }
@@ -115,36 +115,36 @@ protected:
};
/// DataDecl - 'data' declaration. This represents the data element itself,
/// not the elements of the data.
class DataDecl : public NamedDecl {
/// OneOfDecl - 'oneof' declaration. This represents the oneof declaration
/// itself, not its elements.
class OneOfDecl : public NamedDecl {
public:
llvm::SMLoc DataLoc;
llvm::SMLoc OneOfLoc;
DataElementDecl **Elements;
OneOfElementDecl **Elements;
unsigned NumElements;
DataDecl(llvm::SMLoc dataloc, Identifier name,
const DeclAttributes &attrs = DeclAttributes())
: NamedDecl(DataDeclKind, name, attrs),
DataLoc(dataloc), Elements(0), NumElements(0) {
OneOfDecl(llvm::SMLoc oneofloc, Identifier name,
const DeclAttributes &attrs = DeclAttributes())
: NamedDecl(OneOfDeclKind, name, attrs),
OneOfLoc(oneofloc), Elements(0), NumElements(0) {
}
llvm::SMLoc getLocStart() const { return DataLoc; }
DataElementDecl *getElement(unsigned i) const {
llvm::SMLoc getLocStart() const { return OneOfLoc; }
OneOfElementDecl *getElement(unsigned i) const {
assert(i < NumElements && "Invalid index");
return Elements[i];
}
DataElementDecl *getElement(Identifier Name) const;
OneOfElementDecl *getElement(Identifier Name) const;
void print(llvm::raw_ostream &OS, unsigned Indent = 0) const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == DataDeclKind;
return D->getKind() == OneOfDeclKind;
}
static bool classof(const DataDecl *D) { return true; }
static bool classof(const OneOfDecl *D) { return true; }
};
/// ValueDecl - All named decls that are values in the language. These can
@@ -157,7 +157,7 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return (D->getKind() == VarDeclKind || D->getKind() == FuncDeclKind ||
D->getKind() == DataElementDeclKind || D->getKind() == ArgDeclKind||
D->getKind() == OneOfElementDeclKind || D->getKind() == ArgDeclKind||
D->getKind() == AnonDeclKind || D->getKind() == ElementRefDeclKind);
}
static bool classof(const ValueDecl *D) { return true; }
@@ -213,24 +213,24 @@ public:
};
/// DataElementDecl - This represents an element of a 'data' declaration, e.g.
/// OneOfElementDecl - This represents an element of a 'oneof' declaration, e.g.
/// X and Y in:
/// data d { X, Y int }
/// The type of a DataElementDecl is always the DataType for the containing
/// data.
class DataElementDecl : public ValueDecl {
/// oneof d { X : int, Y : int, Z }
/// The type of a OneOfElementDecl is always the OneOfType for the containing
/// oneof.
class OneOfElementDecl : public ValueDecl {
public:
llvm::SMLoc IdentifierLoc;
/// ArgumentType - This is the type specified with the data element. For
/// ArgumentType - This is the type specified with the oneof element. For
/// example 'int' in the Y example above. This is null if there is no type
/// associated with this data element.
/// associated with this element (such as in the Z example).
Type *ArgumentType;
DataElementDecl(llvm::SMLoc identloc, Identifier name, Type *ty,
Type *argtype)
: ValueDecl(DataElementDeclKind, name, ty, 0),
OneOfElementDecl(llvm::SMLoc identloc, Identifier name, Type *ty,
Type *argtype)
: ValueDecl(OneOfElementDeclKind, name, ty, 0),
IdentifierLoc(identloc), ArgumentType(argtype) {}
@@ -240,9 +240,9 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == DataElementDeclKind;
return D->getKind() == OneOfElementDeclKind;
}
static bool classof(const DataElementDecl *D) { return true; }
static bool classof(const OneOfElementDecl *D) { return true; }
};

View File

@@ -28,13 +28,13 @@ namespace swift {
class ASTContext;
class Expr;
class Identifier;
class DataDecl;
class OneOfDecl;
enum TypeKind {
BuiltinInt32Kind,
DependentTypeKind,
AliasTypeKind,
DataTypeKind,
OneOfTypeKind,
TupleTypeKind,
FunctionTypeKind,
ArrayTypeKind,
@@ -145,20 +145,20 @@ public:
}
};
/// DataType - A type declared with a 'data' declaration.
class DataType : public Type {
/// OneOfType - A type declared with a 'oneof' declaration.
class OneOfType : public Type {
friend class ASTContext;
DataType(DataDecl *DD)
: Type(DataTypeKind, this), TheDecl(DD) {}
OneOfType(OneOfDecl *DD)
: Type(OneOfTypeKind, this), TheDecl(DD) {}
public:
DataDecl *const TheDecl;
OneOfDecl *const TheDecl;
void print(llvm::raw_ostream &OS) const;
// Implement isa/cast/dyncast/etc.
static bool classof(const DataType *) { return true; }
static bool classof(const OneOfType *) { return true; }
static bool classof(const Type *T) {
return T->Kind == DataTypeKind;
return T->Kind == OneOfTypeKind;
}
};

View File

@@ -35,7 +35,7 @@ namespace swift {
class Type;
class Decl;
class DeclAttributes;
class DataDecl;
class OneOfDecl;
class FuncDecl;
class VarDecl;
class ASTContext;
@@ -106,8 +106,8 @@ private:
bool ParseAttribute(DeclAttributes &Attributes);
bool ParseVarName(NameRecord &Record);
DataDecl *ParseDeclData();
DataDecl *ParseDeclStruct();
OneOfDecl *ParseDeclOneOf();
OneOfDecl *ParseDeclStruct();
VarDecl *ParseDeclVar();
FuncDecl *ParseDeclFunc();

View File

@@ -42,7 +42,7 @@ namespace tok {
// KEYWORD(__builtin_float_type)
// KEYWORD(__builtin_double_type)
KEYWORD(data)
KEYWORD(oneof)
KEYWORD(struct)
KEYWORD(func)
KEYWORD(var)

View File

@@ -33,7 +33,7 @@ namespace llvm {
namespace swift {
class Expr;
class Type;
class DataDecl;
class OneOfDecl;
class VarDecl;
class FuncDecl;
class AnonDecl;
@@ -98,16 +98,16 @@ public:
void CreateArgumentDeclsForFunc(FuncDecl *FD);
FuncDecl *ActOnFuncBody(FuncDecl *FD, Expr *Body);
DataDecl *ActOnDataDecl(llvm::SMLoc DataLoc, Identifier Name,
OneOfDecl *ActOnOneOfDecl(llvm::SMLoc OneOfLoc, Identifier Name,
DeclAttributes &Attrs);
struct DataElementInfo {
struct OneOfElementInfo {
llvm::SMLoc NameLoc;
llvm::StringRef Name;
Type *EltType;
};
void ActOnCompleteDataDecl(DataDecl *DD, const DataElementInfo *Elements,
void ActOnCompleteOneOfDecl(OneOfDecl *DD, const OneOfElementInfo *Elements,
unsigned NumElements);
// Name processing.