Search in sources :

Example 1 with BServiceSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.

the class SemanticAnalyzer method handleServiceEndpointBinds.

private void handleServiceEndpointBinds(BLangService serviceNode, BServiceSymbol serviceSymbol) {
    for (BLangSimpleVarRef ep : serviceNode.boundEndpoints) {
        typeChecker.checkExpr(ep, env);
        if (ep.symbol == null || (ep.symbol.tag & SymTag.ENDPOINT) != SymTag.ENDPOINT) {
            dlog.error(ep.pos, DiagnosticCode.ENDPOINT_INVALID_TYPE, ep.variableName);
            continue;
        }
        final BEndpointVarSymbol epSym = (BEndpointVarSymbol) ep.symbol;
        if ((epSym.tag & SymTag.ENDPOINT) == SymTag.ENDPOINT) {
            if (epSym.registrable) {
                serviceSymbol.boundEndpoints.add(epSym);
                if (serviceNode.endpointType == null) {
                    serviceNode.endpointType = (BStructType) epSym.type;
                    serviceNode.endpointClientType = endpointSPIAnalyzer.getClientType((BStructSymbol) serviceNode.endpointType.tsymbol);
                }
            // TODO : Validate serviceType endpoint type with bind endpoint types.
            } else {
                dlog.error(ep.pos, DiagnosticCode.ENDPOINT_NOT_SUPPORT_REGISTRATION, epSym);
            }
        } else {
            dlog.error(ep.pos, DiagnosticCode.ENDPOINT_INVALID_TYPE, epSym);
        }
    }
    if (serviceNode.endpointType == null) {
        dlog.error(serviceNode.pos, DiagnosticCode.SERVICE_INVALID_ENDPOINT_TYPE, serviceNode.name);
    }
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) BEndpointVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BEndpointVarSymbol) BStructSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol)

Example 2 with BServiceSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.

the class EndpointDesugar method rewriteService.

private void rewriteService(BLangService service, SymbolEnv pkgEnv) {
    final BServiceSymbol serviceSymbol = (BServiceSymbol) service.symbol;
    if (serviceSymbol.boundEndpoints.isEmpty()) {
        return;
    }
    final BSymbol enclosingSymbol = pkgEnv.enclPkg.symbol;
    final BSymbol varSymbol = pkgEnv.enclPkg.startFunction.symbol;
    final BLangBlockStmt startBlock = pkgEnv.enclPkg.startFunction.body;
    serviceSymbol.boundEndpoints.forEach(endpointVarSymbol -> {
        final BLangBlockStmt generateCode = generateServiceRegistered(endpointVarSymbol, service, pkgEnv, enclosingSymbol, varSymbol);
        ASTBuilderUtil.prependStatements(generateCode, startBlock);
    });
}
Also used : BServiceSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol) BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)

Example 3 with BServiceSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.

the class SymbolEnter method visit.

@Override
public void visit(BLangService serviceNode) {
    BServiceSymbol serviceSymbol = Symbols.createServiceSymbol(Flags.asMask(serviceNode.flagSet), names.fromIdNode(serviceNode.name), env.enclPkg.symbol.pkgID, serviceNode.type, env.scope.owner);
    serviceNode.symbol = serviceSymbol;
    serviceNode.symbol.type = new BServiceType(serviceSymbol);
    defineSymbol(serviceNode.pos, serviceSymbol);
}
Also used : BServiceSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol) BServiceType(org.wso2.ballerinalang.compiler.semantics.model.types.BServiceType)

Example 4 with BServiceSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

public void visit(BLangService serviceNode) {
    BServiceSymbol serviceSymbol = (BServiceSymbol) serviceNode.symbol;
    SymbolEnv serviceEnv = SymbolEnv.createServiceEnv(serviceNode, serviceSymbol.scope, env);
    handleServiceTypeStruct(serviceNode);
    handleServiceEndpointBinds(serviceNode, serviceSymbol);
    serviceNode.annAttachments.forEach(a -> {
        a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.SERVICE);
        this.analyzeDef(a, serviceEnv);
    });
    serviceNode.docAttachments.forEach(doc -> analyzeDef(doc, serviceEnv));
    serviceNode.vars.forEach(v -> this.analyzeDef(v, serviceEnv));
    serviceNode.endpoints.forEach(e -> {
        symbolEnter.defineNode(e, serviceEnv);
        analyzeDef(e, serviceEnv);
    });
    this.analyzeDef(serviceNode.initFunction, serviceEnv);
    serviceNode.resources.forEach(r -> this.analyzeDef(r, serviceEnv));
}
Also used : BServiceSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BLangAnnotationAttachmentPoint(org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint)

Aggregations

BServiceSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol)3 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)1 BEndpointVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BEndpointVarSymbol)1 BStructSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol)1 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)1 BServiceType (org.wso2.ballerinalang.compiler.semantics.model.types.BServiceType)1 BLangAnnotationAttachmentPoint (org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint)1 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)1 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)1