use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.
the class Types method checkArrayEquality.
public boolean checkArrayEquality(BType source, BType target) {
if (target.tag == TypeTags.ARRAY && source.tag == TypeTags.ARRAY) {
// Both types are array types
BArrayType lhrArrayType = (BArrayType) target;
BArrayType rhsArrayType = (BArrayType) source;
return checkArrayEquality(lhrArrayType.eType, rhsArrayType.eType);
}
// Now one or both types are not array types and they have to be equal
return isSameType(source, target);
}
use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.
the class Types method isArrayTypesAssignable.
public boolean isArrayTypesAssignable(BType source, BType target) {
if (target.tag == TypeTags.ARRAY && source.tag == TypeTags.ARRAY) {
// Both types are array types
BArrayType lhsArrayType = (BArrayType) target;
BArrayType rhsArrayType = (BArrayType) source;
return isArrayTypesAssignable(rhsArrayType.eType, lhsArrayType.eType);
} else if (source.tag == TypeTags.ARRAY) {
// to JSON.
if (target.tag == TypeTags.JSON) {
return getElementType(source).tag == TypeTags.JSON;
}
// Then lhs type should 'any' type
return target.tag == TypeTags.ANY;
} else if (target.tag == TypeTags.ARRAY) {
// Only the left-hand side is an array type
return false;
}
// Now both types are not array types and they have to be equal
if (target == source) {
// TODO Figure out this.
return true;
}
// In this case, lhs type should be of type 'any' and the rhs type cannot be a value type
return target.tag == TypeTags.ANY && !isValueType(source);
}
use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endTransformerDef.
public void endTransformerDef(DiagnosticPos pos, Set<Whitespace> ws, boolean publicFunc, String name, boolean paramsAvailable) {
BLangTransformer transformer = (BLangTransformer) this.invokableNodeStack.pop();
transformer.pos = pos;
transformer.addWS(ws);
transformer.setName(this.createIdentifier(name));
if (paramsAvailable) {
this.varListStack.pop().forEach(variableNode -> {
((BLangVariable) variableNode).docTag = DocTag.PARAM;
transformer.addParameter(variableNode);
});
}
// get the source and the target params
List<VariableNode> mappingParams = this.varListStack.pop();
// set the first mapping-param as the source for transformer
VariableNode source = mappingParams.remove(0);
((BLangVariable) source).docTag = DocTag.RECEIVER;
transformer.setSource(source);
mappingParams.forEach(variableNode -> {
((BLangVariable) variableNode).docTag = DocTag.RECEIVER;
transformer.addReturnParameter(variableNode);
});
if (publicFunc) {
transformer.flagSet.add(Flag.PUBLIC);
}
this.compUnit.addTopLevelNode(transformer);
}
use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.
the class PackageLoader method updateVersionFromToml.
private void updateVersionFromToml(PackageID pkgId) {
String orgName = pkgId.orgName.value;
String pkgName = pkgId.name.value;
String pkgAlias = orgName + "/" + pkgName;
// TODO: make getDependencies return a map
Optional<Dependency> dependency = manifest.getDependencies().stream().filter(d -> d.getPackageName().equals(pkgAlias)).findFirst();
if (dependency.isPresent()) {
if (pkgId.version.value.isEmpty()) {
pkgId.version = new Name(dependency.get().getVersion());
} else {
throw new BLangCompilerException("dependency version in Ballerina.toml mismatches" + " with the version in the source for package " + pkgAlias);
}
}
}
use of org.wso2.siddhi.core.stream.input.source.Source in project ballerina by ballerina-lang.
the class LauncherUtils method compile.
/**
* Compile and get the executable program file.
*
* @param sourceRootPath Path to the source root
* @param sourcePath Path to the source from the source root
* @param offline Should the build call remote repos
* @return Executable program
*/
public static ProgramFile compile(Path sourceRootPath, Path sourcePath, boolean offline) {
CompilerContext context = new CompilerContext();
CompilerOptions options = CompilerOptions.getInstance(context);
options.put(PROJECT_DIR, sourceRootPath.toString());
options.put(COMPILER_PHASE, CompilerPhase.CODE_GEN.toString());
options.put(PRESERVE_WHITESPACE, "false");
options.put(OFFLINE, Boolean.toString(offline));
// compile
Compiler compiler = Compiler.getInstance(context);
BLangPackage entryPkgNode = compiler.compile(sourcePath.toString());
CompiledBinaryFile.ProgramFile programFile = compiler.getExecutableProgram(entryPkgNode);
if (programFile == null) {
throw createLauncherException("compilation contains errors");
}
ProgramFile progFile = getExecutableProgram(programFile);
progFile.setProgramFilePath(sourcePath);
return progFile;
}
Aggregations