Search in sources :

Example 1 with ControlBlock

use of com.redhat.ceylon.model.typechecker.model.ControlBlock in project ceylon-compiler by ceylon.

the class DefiniteAssignmentVisitor method visit.

public void visit(Tree.SpecifierStatement stmt) {
    Tree.Term bme = stmt.getBaseMemberExpression();
    if (bme instanceof Tree.MemberOrTypeExpression) {
        Declaration decl = ((Tree.MemberOrTypeExpression) bme).getDeclaration();
        if (// non-variable and deferred
        tracked.containsKey(decl) && // specification is in a for/else
        forBlock != null && !forBlock.equals(tracked.get(decl))) {
            // not declared in *this* for/else
            if (elseBlock == null) {
                ((Value) decl).setSpecifiedInForElse(true);
            }
            ControlBlock assigningBlock = elseBlock != null ? elseBlock : forBlock;
            Set<Value> assigned = assigningBlock.getSpecifiedValues();
            if (assigned == null) {
                assigned = new HashSet<Value>(1);
                assigningBlock.setSpecifiedValues(assigned);
            }
            assigned.add((Value) decl);
        }
    }
    super.visit(stmt);
}
Also used : ControlBlock(com.redhat.ceylon.model.typechecker.model.ControlBlock) Value(com.redhat.ceylon.model.typechecker.model.Value) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration)

Example 2 with ControlBlock

use of com.redhat.ceylon.model.typechecker.model.ControlBlock in project ceylon-compiler by ceylon.

the class DefiniteAssignmentVisitor method visit.

public void visit(Tree.AnyClass that) {
    ControlBlock prevControlBlock = forBlock;
    forBlock = null;
    super.visit(that);
    forBlock = prevControlBlock;
}
Also used : ControlBlock(com.redhat.ceylon.model.typechecker.model.ControlBlock)

Example 3 with ControlBlock

use of com.redhat.ceylon.model.typechecker.model.ControlBlock in project ceylon-compiler by ceylon.

the class DefiniteAssignmentVisitor method visit.

public void visit(Tree.AnyMethod that) {
    ControlBlock prevControlBlock = forBlock;
    forBlock = null;
    super.visit(that);
    forBlock = prevControlBlock;
}
Also used : ControlBlock(com.redhat.ceylon.model.typechecker.model.ControlBlock)

Example 4 with ControlBlock

use of com.redhat.ceylon.model.typechecker.model.ControlBlock in project ceylon-compiler by ceylon.

the class StatementTransformer method closeInnerSubstituionsForSpecifiedValues.

/**
     * Removes the "inner substitutions" for any deferred values specified 
     * in the given control block
     */
private void closeInnerSubstituionsForSpecifiedValues(Tree.ControlClause contolClause) {
    if (contolClause != null) {
        ControlBlock controlBlock = contolClause.getControlBlock();
        java.util.Set<Value> assigned = controlBlock.getSpecifiedValues();
        if (assigned != null) {
            for (Value value : assigned) {
                DeferredSpecification ds = statementGen().getDeferredSpecification(value);
                if (ds != null) {
                    ds.closeInnerSubstitution();
                }
            }
        }
    }
}
Also used : ControlBlock(com.redhat.ceylon.model.typechecker.model.ControlBlock) Value(com.redhat.ceylon.model.typechecker.model.Value)

Example 5 with ControlBlock

use of com.redhat.ceylon.model.typechecker.model.ControlBlock in project ceylon-compiler by ceylon.

the class DefiniteAssignmentVisitor method visit.

public void visit(Tree.ForStatement that) {
    ControlBlock prevControlBlock = forBlock;
    forBlock = that.getForClause().getControlBlock();
    that.getForClause().visit(this);
    if (that.getElseClause() != null) {
        elseBlock = that.getElseClause().getControlBlock();
        that.getElseClause().visit(this);
        elseBlock = null;
    }
    forBlock = prevControlBlock;
}
Also used : ControlBlock(com.redhat.ceylon.model.typechecker.model.ControlBlock)

Aggregations

ControlBlock (com.redhat.ceylon.model.typechecker.model.ControlBlock)6 Value (com.redhat.ceylon.model.typechecker.model.Value)2 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)1 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)1