parent
ae31969ad2
commit
f42cce7a8e
|
@ -17,21 +17,11 @@
|
|||
using namespace llvm;
|
||||
using namespace clang;
|
||||
|
||||
void Expr::dump() const {
|
||||
if (this == 0) {
|
||||
std::cerr << "<null expr>";
|
||||
return;
|
||||
}
|
||||
std::cerr << "(";
|
||||
dump_impl();
|
||||
std::cerr << ")";
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Primary Expressions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void DeclExpr::dump_impl() const {
|
||||
void DeclRefExpr::dump_impl() const {
|
||||
std::cerr << "x";
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
|
|||
case tok::identifier: {
|
||||
// Could be enum-constant or decl.
|
||||
//Tok.getIdentifierInfo()
|
||||
return new DeclExpr(*(Decl*)0);
|
||||
return new DeclRefExpr(*(Decl*)0);
|
||||
}
|
||||
|
||||
case tok::char_constant: // constant: character-constant
|
||||
|
@ -184,7 +184,7 @@ Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
|
|||
case tok::kw___FUNCTION__: // primary-expression: __FUNCTION__ [GNU]
|
||||
case tok::kw___PRETTY_FUNCTION__: // primary-expression: __P..Y_F..N__ [GNU]
|
||||
//assert(0 && "FIXME: Unimp so far!");
|
||||
return new DeclExpr(*(Decl*)0);
|
||||
return new DeclRefExpr(*(Decl*)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
//===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Chris Lattner and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the Stmt class and statement subclasses.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/Stmt.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include <iostream>
|
||||
using namespace llvm;
|
||||
using namespace clang;
|
||||
|
||||
void Stmt::dump() const {
|
||||
if (this == 0) {
|
||||
std::cerr << "<null>";
|
||||
return;
|
||||
}
|
||||
bool isExpr = dynamic_cast<const Expr*>(this) != 0;
|
||||
if (isExpr) std::cerr << "(";
|
||||
dump_impl();
|
||||
if (isExpr) std::cerr << ")";
|
||||
}
|
|
@ -176,7 +176,7 @@ Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
|
|||
case tok::identifier: {
|
||||
// Could be enum-constant or decl.
|
||||
//Tok.getIdentifierInfo()
|
||||
return new DeclExpr(*(Decl*)0);
|
||||
return new DeclRefExpr(*(Decl*)0);
|
||||
}
|
||||
|
||||
case tok::char_constant: // constant: character-constant
|
||||
|
@ -184,7 +184,7 @@ Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
|
|||
case tok::kw___FUNCTION__: // primary-expression: __FUNCTION__ [GNU]
|
||||
case tok::kw___PRETTY_FUNCTION__: // primary-expression: __P..Y_F..N__ [GNU]
|
||||
//assert(0 && "FIXME: Unimp so far!");
|
||||
return new DeclExpr(*(Decl*)0);
|
||||
return new DeclRefExpr(*(Decl*)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */; };
|
||||
DE3450D70AEB543100DBC861 /* DirectoryLookup.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3450D60AEB543100DBC861 /* DirectoryLookup.h */; };
|
||||
DE3451580AEC176100DBC861 /* MacroExpander.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3451570AEC176100DBC861 /* MacroExpander.cpp */; };
|
||||
DE3452410AEF1A2D00DBC861 /* Stmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3452400AEF1A2D00DBC861 /* Stmt.cpp */; };
|
||||
DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE46BF270AE0A82D00CC047C /* TargetInfo.h */; };
|
||||
DE5932D10AD60FF400BC794C /* clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932CD0AD60FF400BC794C /* clang.cpp */; };
|
||||
DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE5932CE0AD60FF400BC794C /* clang.h */; };
|
||||
|
@ -116,7 +117,7 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
|
||||
DE06BECA0A854E4B0050E87E /* Scope.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Scope.h; path = clang/Parse/Scope.h; sourceTree = "<group>"; };
|
||||
DE06CC170A899E110050E87E /* Statement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Statement.cpp; path = Parse/Statement.cpp; sourceTree = "<group>"; };
|
||||
|
@ -135,6 +136,7 @@
|
|||
DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HeaderSearch.cpp; sourceTree = "<group>"; };
|
||||
DE3450D60AEB543100DBC861 /* DirectoryLookup.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DirectoryLookup.h; sourceTree = "<group>"; };
|
||||
DE3451570AEC176100DBC861 /* MacroExpander.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MacroExpander.cpp; sourceTree = "<group>"; };
|
||||
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Stmt.cpp; path = AST/Stmt.cpp; sourceTree = "<group>"; };
|
||||
DE46BF270AE0A82D00CC047C /* TargetInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetInfo.h; sourceTree = "<group>"; };
|
||||
DE5932CD0AD60FF400BC794C /* clang.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = clang.cpp; path = Driver/clang.cpp; sourceTree = "<group>"; };
|
||||
DE5932CE0AD60FF400BC794C /* clang.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = clang.h; path = Driver/clang.h; sourceTree = "<group>"; };
|
||||
|
@ -287,6 +289,7 @@
|
|||
DEC8DAAC0A94400300353FCA /* ASTStreamer.cpp */,
|
||||
DEC8D9B50A9434FA00353FCA /* Builder.cpp */,
|
||||
DE0FCB330A9C21F100248FD5 /* Expr.cpp */,
|
||||
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */,
|
||||
);
|
||||
name = AST;
|
||||
sourceTree = "<group>";
|
||||
|
@ -439,6 +442,7 @@
|
|||
DED62ABB0AE2EDF1001E80A4 /* Decl.cpp in Sources */,
|
||||
DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */,
|
||||
DE3451580AEC176100DBC861 /* MacroExpander.cpp in Sources */,
|
||||
DE3452410AEF1A2D00DBC861 /* Stmt.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
#ifndef LLVM_CLANG_AST_EXPR_H
|
||||
#define LLVM_CLANG_AST_EXPR_H
|
||||
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "clang/AST/Stmt.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace clang {
|
||||
|
@ -23,32 +22,29 @@ namespace clang {
|
|||
class Decl;
|
||||
class Type;
|
||||
|
||||
/// Expr - This represents one expression etc.
|
||||
/// Expr - This represents one expression. Note that Expr's are subclasses of
|
||||
/// Stmt. This allows an expression to be transparently used any place a Stmt
|
||||
/// is required.
|
||||
///
|
||||
class Expr {
|
||||
/// Type.
|
||||
class Expr : public Stmt {
|
||||
/// TODO: Type.
|
||||
public:
|
||||
Expr() {}
|
||||
virtual ~Expr() {}
|
||||
~Expr() {}
|
||||
|
||||
// FIXME: Change to non-virtual method that uses visitor pattern to do this.
|
||||
void dump() const;
|
||||
|
||||
private:
|
||||
virtual void dump_impl() const = 0;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Primary Expressions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// DeclExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
|
||||
/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
|
||||
/// enum, etc.
|
||||
class DeclExpr : public Expr {
|
||||
class DeclRefExpr : public Expr {
|
||||
// TODO: Union with the decl when resolved.
|
||||
Decl &D;
|
||||
public:
|
||||
DeclExpr(Decl &d) : D(d) {}
|
||||
DeclRefExpr(Decl &d) : D(d) {}
|
||||
virtual void dump_impl() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
//===--- Stmt.h - Classes for representing statements -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Chris Lattner and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the Stmt interface and subclasses.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_AST_STMT_H
|
||||
#define LLVM_CLANG_AST_STMT_H
|
||||
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace clang {
|
||||
|
||||
/// Stmt - This represents one statement. Note that statements are modelled as
|
||||
/// subclasses of exprs so that
|
||||
///
|
||||
class Stmt {
|
||||
/// Type.
|
||||
public:
|
||||
Stmt() {}
|
||||
virtual ~Stmt() {}
|
||||
|
||||
// FIXME: Change to non-virtual method that uses visitor pattern to do this.
|
||||
void dump() const;
|
||||
|
||||
private:
|
||||
virtual void dump_impl() const = 0;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Primary Expressions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if 0
|
||||
/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
|
||||
/// enum, etc.
|
||||
class DeclRefExpr : public Stmt {
|
||||
// TODO: Union with the decl when resolved.
|
||||
Decl &D;
|
||||
public:
|
||||
DeclRef(Decl &d) : D(d) {}
|
||||
virtual void dump_impl() const;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // end namespace clang
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue