use of org.wso2.transport.http.netty.config.Parameter 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.transport.http.netty.config.Parameter in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangVariable varNode) {
int ownerSymTag = env.scope.owner.tag;
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE) {
// If the variable is parameter then the variable symbol is already defined
if (varNode.symbol == null) {
symbolEnter.defineNode(varNode, env);
}
}
BType lhsType = varNode.symbol.type;
varNode.type = lhsType;
// Here we validate annotation attachments for package level variables.
varNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.CONST);
a.accept(this);
});
// Here we validate document attachments for package level variables.
varNode.docAttachments.forEach(doc -> {
doc.accept(this);
});
// Analyze the init expression
BLangExpression rhsExpr = varNode.expr;
if (rhsExpr == null) {
return;
}
// Here we create a new symbol environment to catch self references by keep the current
// variable symbol in the symbol environment
// e.g. int a = x + a;
SymbolEnv varInitEnv = SymbolEnv.createVarInitEnv(varNode, env, varNode.symbol);
// It will we done during the init-function of the respective construct is visited.
if ((ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE || (ownerSymTag & SymTag.SERVICE) == SymTag.SERVICE || (ownerSymTag & SymTag.CONNECTOR) == SymTag.CONNECTOR) {
return;
}
// Return if this not a safe assignment
if (!varNode.safeAssignment) {
typeChecker.checkExpr(rhsExpr, varInitEnv, Lists.of(lhsType));
return;
}
handleSafeAssignment(varNode.pos, lhsType, rhsExpr, varInitEnv);
}
use of org.wso2.transport.http.netty.config.Parameter in project ballerina by ballerina-lang.
the class CodeGenerator method createTransformerInfoEntry.
private void createTransformerInfoEntry(BLangInvokableNode invokable) {
BInvokableSymbol transformerSymbol = invokable.symbol;
BInvokableType transformerType = (BInvokableType) transformerSymbol.type;
// Add transformer name as an UTFCPEntry to the constant pool
int transformerNameCPIndex = this.addUTF8CPEntry(currentPkgInfo, transformerSymbol.name.value);
TransformerInfo transformerInfo = new TransformerInfo(currentPackageRefCPIndex, transformerNameCPIndex);
transformerInfo.paramTypes = transformerType.paramTypes.toArray(new BType[0]);
transformerInfo.retParamTypes = transformerType.retTypes.toArray(new BType[0]);
transformerInfo.flags = transformerSymbol.flags;
this.addWorkerInfoEntries(transformerInfo, invokable.getWorkers());
// Add parameter default value info
addParameterDefaultValues(invokable, transformerInfo);
transformerInfo.signatureCPIndex = addUTF8CPEntry(this.currentPkgInfo, generateFunctionSig(transformerInfo.paramTypes, transformerInfo.retParamTypes));
this.currentPkgInfo.transformerInfoMap.put(transformerSymbol.name.value, transformerInfo);
}
use of org.wso2.transport.http.netty.config.Parameter in project ballerina by ballerina-lang.
the class CodeGenerator method generateNamedArgs.
private int generateNamedArgs(BLangInvocation iExpr, Operand[] operands, int currentIndex) {
if (iExpr.namedArgs.isEmpty()) {
return currentIndex;
}
PackageInfo pkgInfo = programFile.packageInfoMap.get(iExpr.symbol.pkgID.bvmAlias());
CallableUnitInfo callableUnitInfo;
if (iExpr.symbol.kind == SymbolKind.FUNCTION) {
callableUnitInfo = pkgInfo.functionInfoMap.get(iExpr.symbol.name.value);
} else if (iExpr.symbol.kind == SymbolKind.ACTION) {
ConnectorInfo connectorInfo = pkgInfo.connectorInfoMap.get(iExpr.symbol.owner.name.value);
callableUnitInfo = connectorInfo.actionInfoMap.get(iExpr.symbol.name.value);
} else {
throw new IllegalStateException("Unsupported callable unit");
}
ParamDefaultValueAttributeInfo defaultValAttrInfo = (ParamDefaultValueAttributeInfo) callableUnitInfo.getAttributeInfo(AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE);
for (int i = 0; i < iExpr.namedArgs.size(); i++) {
BLangExpression argExpr = iExpr.namedArgs.get(i);
// at this point. If so, get the default value for that parameter from the function info.
if (argExpr == null) {
DefaultValue defaultVal = defaultValAttrInfo.getDefaultValueInfo()[i];
argExpr = getDefaultValExpr(defaultVal);
}
operands[currentIndex++] = genNode(argExpr, this.env).regIndex;
}
return currentIndex;
}
use of org.wso2.transport.http.netty.config.Parameter in project ballerina by ballerina-lang.
the class Desugar method visit.
@Override
public void visit(BLangAction actionNode) {
addReturnIfNotPresent(actionNode);
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionNode.symbol.scope, env);
// To preserve endpoint code gen order at action.
Collections.reverse(actionNode.endpoints);
actionNode.endpoints = rewrite(actionNode.endpoints, actionEnv);
actionNode.body = rewrite(actionNode.body, actionEnv);
actionNode.workers = rewrite(actionNode.workers, actionEnv);
// we rewrite it's parameter list to have the receiver variable as the first parameter
BInvokableSymbol actionSymbol = actionNode.symbol;
List<BVarSymbol> params = actionSymbol.params;
BVarSymbol receiverSymbol = actionNode.symbol.receiverSymbol;
params.add(0, receiverSymbol);
BInvokableType actionType = (BInvokableType) actionSymbol.type;
if (receiverSymbol != null) {
actionType.paramTypes.add(0, receiverSymbol.type);
}
result = actionNode;
}
Aggregations