-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcalloutArgument.cpp
37 lines (32 loc) · 1017 Bytes
/
calloutArgument.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Implementation of the \ref calloutArgument class
*/
#include "calloutArgument.h"
#include "stringLiteral.h"
#include "utilities.h"
/**
* Constructor for the class when expression argument is given to callout
* @param arg expression which is given as an argument
*/
calloutArgument::calloutArgument(class Expression *arg) {
this->expr = arg;
}
/**
* Constructor for the class when it should deal string arguments
* @param literal string that is given as an argument
*/
calloutArgument::calloutArgument(std::string literal) {
class stringLiteral *tmp = new stringLiteral(std::move(literal));
this->expr = tmp;
}
Value *calloutArgument::generateCode(Constructs *compilerConstructs) {
if (expr == nullptr) {
compilerConstructs->errors++;
return reportError("Invalid Callout Arg");
}
Value *v = expr->generateCode(compilerConstructs);
if (expr->getEtype() == exprType::location) {
v = compilerConstructs->Builder->CreateLoad(v);
}
return v;
}