use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolEnter method defineEndpointVarSymbol.
public BEndpointVarSymbol defineEndpointVarSymbol(DiagnosticPos pos, Set<Flag> flagSet, BType varType, Name varName, SymbolEnv env) {
// Create variable symbol
Scope enclScope = env.scope;
BEndpointVarSymbol varSymbol = new BEndpointVarSymbol(Flags.asMask(flagSet), varName, env.enclPkg.symbol.pkgID, varType, enclScope.owner);
// Find duplicates
if (!symResolver.checkForUniqueSymbol(pos, env, varSymbol, SymTag.VARIABLE_NAME)) {
varSymbol.type = symTable.errType;
}
enclScope.define(varSymbol.name, varSymbol);
return varSymbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolEnter method defineConnectorSymbolParams.
private void defineConnectorSymbolParams(BLangConnector connectorNode, BConnectorSymbol symbol, SymbolEnv connectorEnv) {
List<BVarSymbol> paramSymbols = connectorNode.params.stream().peek(varNode -> defineNode(varNode, connectorEnv)).map(varNode -> varNode.symbol).collect(Collectors.toList());
symbol.params = paramSymbols;
// Create connector type
List<BType> paramTypes = paramSymbols.stream().map(paramSym -> paramSym.type).collect(Collectors.toList());
symbol.type = new BConnectorType(paramTypes, symbol);
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangEndpoint endpoint) {
BType varType = symResolver.resolveTypeNode(endpoint.endpointTypeNode, env);
Name varName = names.fromIdNode(endpoint.name);
endpoint.type = varType;
endpoint.symbol = defineEndpointVarSymbol(endpoint.pos, endpoint.flagSet, varType, varName, env);
endpointSPIAnalyzer.resolveEndpointSymbol(endpoint);
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
public void visit(BLangConstrainedType constrainedTypeNode) {
BType type = resolveTypeNode(constrainedTypeNode.type, env);
BType constraintType = resolveTypeNode(constrainedTypeNode.constraint, env);
if (type.tag == TypeTags.TABLE) {
resultType = new BTableType(TypeTags.TABLE, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.STREAM) {
resultType = new BStreamType(TypeTags.STREAM, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.FUTURE) {
resultType = new BFutureType(TypeTags.FUTURE, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.MAP) {
resultType = new BMapType(TypeTags.MAP, constraintType, type.tsymbol);
} else {
if (!types.checkStructToJSONCompatibility(constraintType) && constraintType != symTable.errType) {
dlog.error(constrainedTypeNode.pos, DiagnosticCode.INCOMPATIBLE_TYPE_CONSTRAINT, type, constraintType);
resultType = symTable.errType;
return;
}
resultType = new BJSONType(TypeTags.JSON, constraintType, type.tsymbol);
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
@Override
public void visit(BLangFunctionTypeNode functionTypeNode) {
List<BType> paramTypes = new ArrayList<>();
List<BType> retParamTypes = new ArrayList<>();
functionTypeNode.getParamTypeNode().forEach(t -> paramTypes.add(resolveTypeNode((BLangType) t, env)));
functionTypeNode.getReturnParamTypeNode().forEach(t -> retParamTypes.add(resolveTypeNode((BLangType) t, env)));
resultType = new BInvokableType(paramTypes, retParamTypes, null);
}
Aggregations