1 //===-- iCall.cpp - Implement the Call & Invoke instructions -----*- C++ -*--=//
3 // This file implements the call and invoke instructions.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/iOther.h"
8 #include "llvm/DerivedTypes.h"
9 #include "llvm/Method.h"
11 CallInst::CallInst(Method *m, vector<Value*> ¶ms,
13 : Instruction(m->getReturnType(), Instruction::Call, Name), M(m, this) {
15 const MethodType* MT = M->getMethodType();
16 const MethodType::ParamTypes &PL = MT->getParamTypes();
17 assert(params.size() == PL.size() && "Calling a function with bad signature");
19 MethodType::ParamTypes::const_iterator It = PL.begin();
21 for (unsigned i = 0; i < params.size(); i++) {
22 assert(*It++ == params[i]->getType());
23 Params.push_back(Use(params[i], this));
27 CallInst::CallInst(const CallInst &CI)
28 : Instruction(CI.getType(), Instruction::Call), M(CI.M, this) {
29 for (unsigned i = 0; i < CI.Params.size(); i++)
30 Params.push_back(Use(CI.Params[i], this));
33 void CallInst::dropAllReferences() {
38 bool CallInst::setOperand(unsigned i, Value *Val) {
39 if (i > Params.size()) return false;
41 M = Val->castMethodAsserting();
43 // TODO: assert = method arg type