本文整理汇总了C++中expression::Ptr::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::next方法的具体用法?C++ Ptr::next怎么用?C++ Ptr::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类expression::Ptr
的用法示例。
在下文中一共展示了Ptr::next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call
void CCodeGenerator::call(Function* function, Expression* args) {
std::vector<Operand> val;
for (Expression::Ptr a = args; a; a = a->next()) {
val.push_back(emit(a));
}
if (!function->type()->is_void()) {
return_ = alloc_temp(function->type());
} else {
line();
}
out_ << function->label() << "(";
Expression::Ptr arg = args;
Formal::Ptr formal = function->formals();
for (int i = 0; i < val.size(); i++) {
if(!formal->is_self() && !formal->type()->equals(arg->type())) {
// Cast to the appropriate C-type, since C doesn't know anything
// about subtypes, etc..
out_ << "(";
operator()(formal->type());
out_ << ")";
}
out_ << val[i];
if (i < val.size() - 1) {
out_ << ", ";
}
formal = formal->next();
arg = arg->next();
}
out_ << ");\n";
}
示例2: operator
void CCodeGenerator::operator()(Construct* expr) {
// Look up the function by name in the current context.
String::Ptr id = env_->name("@init");
Class::Ptr clazz = expr->type()->clazz();
Function::Ptr func = clazz->function(id);
std::vector<Operand> args;
for (Expression::Ptr a = expr->arguments(); a; a = a->next()) {
args.push_back(emit(a));
}
return_ = alloc_temp(clazz->type());
out_ << func->label() << "(";
Formal::Ptr formal = func->formals();
Expression::Ptr arg = expr->arguments();
for (int i = 0; i < args.size(); i++) {
if(!formal->is_self() && !formal->type()->equals(arg->type())) {
// Cast to the appropriate C-type, since C doesn't know anything
// about subtypes, etc..
out_ << "(";
operator()(formal->type());
out_ << ")";
}
out_ << args[i];
if (i < args.size() - 1) {
out_ << ", ";
}
formal = formal->next();
arg = arg->next();
}
out_ << ");\n";
}
示例3: native_operator
void CCodeGenerator::native_operator(Call* expr) {
std::string id = expr->function()->name()->string();
std::vector<Operand> args;
for (Expression::Ptr a = expr->arguments(); a; a = a->next()) {
args.push_back(emit(a));
}
return_ = alloc_temp(expr->type());
if (id == "@add") {
out_ << args[0] << "+" << args[1] << ";\n";
} else if (id == "@sub") {
out_ << args[0] << "-" << args[1] << ";\n";
} else if (id == "@mul") {
out_ << args[0] << "*" << args[1] << ";\n";
} else if (id == "@div") {
out_ << args[0] << "/" << args[1] << ";\n";
} else if (id == "@neg") {
out_ << "-" << args[0] << ";\n";
} else if (id == "@mod") {
out_ << args[0] << "%" << args[1] << ";\n";
} else if (id == "@compl") {
out_ << "~" << args[0] << ";\n";
} else if (id == "@equal") {
out_ << args[0] << "==" << args[1] << ";\n";
} else if (id == "@less") {
out_ << args[0] << "<" << args[1] << ";\n";
}
}
示例4: operator
void TreePrinter::operator()(HashLiteral* expression) {
indent_level_++;
out_ << "HashLiteral\n";
int i = 0;
for (Expression::Ptr e = expression->arguments(); e; e = e->next()) {
print_tabs(); out_ << "argument" << i << ": ";
e(this);
i++;
}
indent_level_--;
}