Search in sources :

Example 1 with DiagnosticCode

use of org.ballerinalang.util.diagnostic.DiagnosticCode in project ballerina by ballerina-lang.

the class SemanticAnalyzer method analyzeNode.

BType analyzeNode(BLangNode node, SymbolEnv env, BType expType, DiagnosticCode diagCode) {
    SymbolEnv prevEnv = this.env;
    BType preExpType = this.expType;
    DiagnosticCode preDiagCode = this.diagCode;
    // TODO Check the possibility of using a try/finally here
    this.env = env;
    this.expType = expType;
    this.diagCode = diagCode;
    node.accept(this);
    this.env = prevEnv;
    this.expType = preExpType;
    this.diagCode = preDiagCode;
    return resType;
}
Also used : BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) DiagnosticCode(org.ballerinalang.util.diagnostic.DiagnosticCode)

Example 2 with DiagnosticCode

use of org.ballerinalang.util.diagnostic.DiagnosticCode in project ballerina by ballerina-lang.

the class TypeChecker method checkExpr.

public List<BType> checkExpr(BLangExpression expr, SymbolEnv env, List<BType> expTypes, DiagnosticCode diagCode) {
    // TODO Check the possibility of using a try/finally here
    SymbolEnv prevEnv = this.env;
    List<BType> preExpTypes = this.expTypes;
    DiagnosticCode preDiagCode = this.diagCode;
    this.env = env;
    this.diagCode = diagCode;
    this.expTypes = expTypes;
    expr.accept(this);
    setExprType(expr, expTypes);
    this.env = prevEnv;
    this.expTypes = preExpTypes;
    this.diagCode = preDiagCode;
    return resultTypes;
}
Also used : BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) DiagnosticCode(org.ballerinalang.util.diagnostic.DiagnosticCode)

Example 3 with DiagnosticCode

use of org.ballerinalang.util.diagnostic.DiagnosticCode in project ballerina by ballerina-lang.

the class SymbolResolver method resolveTypeNode.

public BType resolveTypeNode(BLangType typeNode, SymbolEnv env, DiagnosticCode diagCode) {
    SymbolEnv prevEnv = this.env;
    DiagnosticCode preDiagCode = this.diagCode;
    this.env = env;
    this.diagCode = diagCode;
    typeNode.accept(this);
    this.env = prevEnv;
    this.diagCode = preDiagCode;
    // if it is not already a union type, JSON type, or any type
    if (typeNode.nullable && this.resultType.tag == TypeTags.UNION) {
        BUnionType unionType = (BUnionType) this.resultType;
        unionType.memberTypes.add(symTable.nullType);
        unionType.setNullable(true);
    } else if (typeNode.nullable && resultType.tag != TypeTags.JSON && resultType.tag != TypeTags.ANY) {
        Set<BType> memberTypes = new HashSet<BType>(2) {

            {
                add(resultType);
                add(symTable.nullType);
            }
        };
        this.resultType = new BUnionType(null, memberTypes, true);
    }
    typeNode.type = resultType;
    return resultType;
}
Also used : BUnionType(org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType) EnumSet(java.util.EnumSet) Set(java.util.Set) HashSet(java.util.HashSet) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) DiagnosticCode(org.ballerinalang.util.diagnostic.DiagnosticCode)

Aggregations

DiagnosticCode (org.ballerinalang.util.diagnostic.DiagnosticCode)3 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)3 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)3 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 BUnionType (org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType)1