Files
swift-mirror/lib/SIL/SIL.cpp
Joe Groff a593076d09 SIL: Introduce a SILConstant type.
We need something more general than ValueDecl to be able to talk about anonymous functions, curried entry points, etc. as SIL constants. SILConstant is a (ValueDecl | CapturingExpr) union with an additional index for discriminating multiple instances or entry points derived from the same AST entity. Update ConstantInst and SILModule's function table to be keyed by SILConstant rather than ValueDecl.

Swift SVN r3372
2012-12-05 22:40:38 +00:00

41 lines
1.2 KiB
C++

//===--- SILFunction.cpp - Defines the SILFunction data structure ---------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/SIL/Function.h"
#include "swift/SIL/SILModule.h"
#include "swift/SIL/SILConstant.h"
#include "swift/AST/Decl.h"
#include "swift/AST/Expr.h"
using namespace swift;
Function::~Function() {
}
SILModule::SILModule(ASTContext &Context, bool hasTopLevel) :
Context(Context), toplevel(nullptr) {
if (hasTopLevel)
toplevel = new (*this) Function(*this);
}
SILModule::~SILModule() {
}
Type SILConstant::getType() const {
// FIXME: This won't work for intermediate curry decls
if (ValueDecl *vd = loc.dyn_cast<ValueDecl*>()) {
return vd->getTypeOfReference();
} else if (CapturingExpr *e = loc.dyn_cast<CapturingExpr*>()) {
return e->getType();
}
llvm_unreachable("unexpected constant loc");
}