Exemplo n.º 1
0
  void walk_function(const FunctionScopePtr& fscope) {
    if (fscope->isClosure()) return;
    auto ms = dynamic_pointer_cast<MethodStatement>(fscope->getStmt());

    ConstructPtr node(ms->getStmts());
    with_scope(
      fscope->getVariables(),
      [&] {
        walk_ast(node);
      }
    );
  }
Exemplo n.º 2
0
void FunctionScope::setContainsThis(bool f /* = true */) {
    m_containsThis = f;

    BlockScopePtr bs(this->getOuterScope());
    while (bs && bs->is(BlockScope::FunctionScope)) {
        FunctionScopePtr fs = static_pointer_cast<FunctionScope>(bs);
        if (!fs->isClosure()) {
            break;
        }
        fs->setContainsThis(f);
        bs = bs->getOuterScope();
    }

    for (auto it = m_clonedTraitOuterScope.begin(); it != m_clonedTraitOuterScope.end(); it++) {
        (*it)->setContainsThis(f);
    }
}
Exemplo n.º 3
0
void FunctionScope::setContainsBareThis(bool f, bool ref /* = false */) {
    if (f) {
        m_containsBareThis |= ref ? 2 : 1;
    } else {
        m_containsBareThis = 0;
    }

    BlockScopePtr bs(this->getOuterScope());
    while (bs && bs->is(BlockScope::FunctionScope)) {
        FunctionScopePtr fs = static_pointer_cast<FunctionScope>(bs);
        if (!fs->isClosure()) {
            break;
        }
        fs->setContainsBareThis(f, ref);
        bs = bs->getOuterScope();
    }

    for (auto it = m_clonedTraitOuterScope.begin(); it != m_clonedTraitOuterScope.end(); it++) {
        (*it)->setContainsBareThis(f, ref);
    }
}