예제 #1
0
파일: codegen.cpp 프로젝트: abelsson/prism
void Assignment::codeGen(CodeGenContext& context)
{
    if (debug)
        std::cout << "Creating assignment for " << lhs->m_name << endl;
    if (context.locals().find(lhs->m_name) == context.locals().end()) {
        std::cerr << "undeclared variable " << lhs->m_name << endl;
        return;
    }

    rhs->codeGen(context);
    context.vpop(context.locals()[lhs->m_name]->addr);
}
예제 #2
0
파일: codegen.cpp 프로젝트: abelsson/prism
void VariableDeclaration::codeGen(CodeGenContext& context)
{
    if (debug)
        std::cout << "Creating variable declaration " << m_type->m_name << " " << m_name->m_name << endl;

    context.locals()[m_name->m_name] = value();
    if (m_assignment_expr != NULL) {
        Assignment assn(m_name, m_assignment_expr);
        assn.codeGen(context);
    }
}
예제 #3
0
파일: codegen.cpp 프로젝트: abelsson/prism
void ForeachStatement::codeGen(CodeGenContext &context)
{
    m_var_decl->codeGen(context);
    m_expr->codeGen(context);
    context.vmake_iter();
    int pos = context.getCurrent();
    context.viter_value();
    context.vpop(context.locals()[m_var_decl->m_name->m_name]->addr);
    m_block->codeGen(context, false);
    context.vloop_iter(pos);
    context.vpop(444);
    context.vpop(444);
}