当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::next方法代码示例

本文整理汇总了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";
}
开发者ID:mfichman,项目名称:jogo,代码行数:32,代码来源:CCodeGenerator.cpp

示例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";
}
开发者ID:mfichman,项目名称:jogo,代码行数:33,代码来源:CCodeGenerator.cpp

示例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";
    }
}
开发者ID:mfichman,项目名称:jogo,代码行数:29,代码来源:CCodeGenerator.cpp

示例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_--;
}
开发者ID:mfichman,项目名称:jogo,代码行数:12,代码来源:TreePrinter.cpp


注:本文中的expression::Ptr::next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。