use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.
the class SymbolEnter method defineConnectorMembers.
private void defineConnectorMembers(List<BLangConnector> connectors, SymbolEnv pkgEnv) {
connectors.forEach(connector -> {
SymbolEnv conEnv = SymbolEnv.createConnectorEnv(connector, connector.symbol.scope, pkgEnv);
connector.varDefs.forEach(varDef -> defineNode(varDef.var, conEnv));
defineConnectorInitFunction(connector, conEnv);
connector.actions.stream().peek(action -> action.flagSet.add(Flag.PUBLIC)).forEach(action -> defineNode(action, conEnv));
});
}
use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.
the class TaintAnalyzer method attachTaintTableBasedOnAnnotations.
private void attachTaintTableBasedOnAnnotations(BLangConnector connectorNode) {
if (connectorNode.symbol.taintTable == null) {
List<Boolean> retParamsTaintedStatus = new ArrayList<>();
Map<Integer, TaintRecord> taintTable = new HashMap<>();
taintTable.put(ALL_UNTAINTED_TABLE_ENTRY_INDEX, new TaintRecord(retParamsTaintedStatus, null));
if (connectorNode.params.size() > 0) {
// Append taint table with tainted status when each parameter is tainted.
for (int paramIndex = 0; paramIndex < connectorNode.params.size(); paramIndex++) {
BLangVariable param = connectorNode.params.get(paramIndex);
// If parameter is sensitive, test for this parameter being tainted is invalid.
if (hasAnnotation(param, ANNOTATION_SENSITIVE)) {
continue;
}
taintTable.put(paramIndex, new TaintRecord(retParamsTaintedStatus, null));
}
}
connectorNode.symbol.taintTable = taintTable;
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangConnector connectorNode) {
BSymbol connectorSymbol = connectorNode.symbol;
SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorSymbol.scope, env);
connectorNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.CONNECTOR);
this.analyzeDef(a, connectorEnv);
});
connectorNode.docAttachments.forEach(doc -> analyzeDef(doc, connectorEnv));
connectorNode.params.forEach(param -> this.analyzeDef(param, connectorEnv));
connectorNode.varDefs.forEach(varDef -> this.analyzeDef(varDef, connectorEnv));
connectorNode.endpoints.forEach(e -> analyzeDef(e, connectorEnv));
this.analyzeDef(connectorNode.initFunction, connectorEnv);
connectorNode.actions.forEach(action -> this.analyzeDef(action, connectorEnv));
this.analyzeDef(connectorNode.initAction, connectorEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangConnector connectorNode) {
BLangFunction initFunction = (BLangFunction) connectorNode.getInitFunction();
visit(initFunction);
currentConnectorInfo = currentPkgInfo.getConnectorInfo(connectorNode.getName().getValue());
SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorNode.symbol.scope, this.env);
connectorNode.actions.forEach(action -> genNode(action, connectorEnv));
genNode(connectorNode.initAction, connectorEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangConnector in project ballerina by ballerina-lang.
the class CodeGenerator method createConnectorInfoEntry.
private void createConnectorInfoEntry(BLangConnector connectorNode) {
BConnectorType connectorType = (BConnectorType) connectorNode.symbol.type;
// Add connector name as an UTFCPEntry to the constant pool
int connectorNameCPIndex = addUTF8CPEntry(currentPkgInfo, connectorNode.name.value);
// Create connector info
ConnectorInfo connectorInfo = new ConnectorInfo(currentPackageRefCPIndex, connectorNameCPIndex, connectorNode.symbol.flags);
connectorInfo.paramTypes = connectorType.paramTypes.toArray(new BType[0]);
connectorInfo.signatureCPIndex = addUTF8CPEntry(this.currentPkgInfo, generateConnectorSig(connectorInfo));
// Add connector level variables
int localVarAttNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE.value());
LocalVariableAttributeInfo localVarAttributeInfo = new LocalVariableAttributeInfo(localVarAttNameIndex);
connectorNode.params.forEach(var -> visitVarSymbol(var.symbol, fieldIndexes, localVarAttributeInfo));
connectorNode.varDefs.forEach(var -> visitVarSymbol(var.var.symbol, fieldIndexes, localVarAttributeInfo));
connectorInfo.addAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE, localVarAttributeInfo);
// Create variable count attribute info
prepareIndexes(fieldIndexes);
int[] fieldCount = new int[] { fieldIndexes.tInt, fieldIndexes.tFloat, fieldIndexes.tString, fieldIndexes.tBoolean, fieldIndexes.tBlob, fieldIndexes.tRef };
addVariableCountAttributeInfo(currentPkgInfo, connectorInfo, fieldCount);
// Create the init function info
BLangFunction connectorInitFunction = (BLangFunction) connectorNode.getInitFunction();
createFunctionInfoEntry(connectorInitFunction);
this.currentPkgInfo.connectorInfoMap.put(connectorNode.name.value, connectorInfo);
// Create action info entries for all actions
connectorNode.actions.forEach(res -> createActionInfoEntry(res, connectorInfo));
createActionInfoEntry(connectorNode.initAction, connectorInfo);
fieldIndexes = new VariableIndex(FIELD);
}
Aggregations