Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabilang committed Oct 13, 2023
2 parents 47aaa8f + b9686df commit 5b94cf5
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 34 deletions.
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

# The Ballerina programming language

[Ballerina](https://ballerina.io/) is a statically typed, open-source cloud-native programming language developed
and supported by [WSO2](https://wso2.com/).
[Ballerina](https://ballerina.io/) is an open-source cloud-native programming language optimized for integration. It is developed and supported by [WSO2](https://wso2.com/).

With Ballerina, you could easily develop microservices, API endpoints and integrations,
and any other application for the cloud. Additionally, Ballerina has all the general-purpose
Expand All @@ -34,18 +33,6 @@ Extensible metadata enables easy integration of Ballerina programs with cloud pl
You could directly generate Docker and Kubernetes artifacts straight away from
the source code.

## Get started

You can use one of the following options to try out Ballerina.

* [Set up Ballerina](https://ballerina.io/learn/get-started/)
* [Ballerina Playground](https://play.ballerina.io/)

You can use the following resources to learn Ballerina.

* [Ballerina by Example](https://ballerina.io/learn/by-example/)
* [Ballerina learn pages and guides](https://ballerina.io/learn/)

## Download and install

For instructions on downloading and installing, see [Ballerina Downloads](https://ballerina.io/downloads/).
Expand All @@ -58,13 +45,20 @@ For more installation options, see [Installation options](https://ballerina.io/d

Try out Ballerina's development capabilities using the [Ballerina extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=WSO2.ballerina).

## Get started

You can use the following resources to learn Ballerina.

* [Ballerina by Example](https://ballerina.io/learn/by-example/)
* [Ballerina learn pages and guides](https://ballerina.io/learn/)

## Report issues and security flaws

>**Tip:** If you are unsure whether you have found a bug, search the existing issues in the GitHub repo and raise it in the [Ballerina Discord](https://discord.com/invite/wAJYFbMrG2) or [Stack Overflow](https://stackoverflow.com/questions/tagged/ballerina).
- Language, Tooling, Ballerina library, Website: <a href="https://github.com/ballerina-platform/ballerina-lang/issues">ballerina-lang</a> repo
- Extended library: <a href="https://github.com/ballerina-platform/ballerina-extended-library/issues">ballerina-extended-library</a> repo
- Security flaw: send an email to security@ballerina.io. For details, see the <a href="https://ballerina.io/security/">security policy</a>.
- Language, Tooling, Website: <a href="https://github.com/ballerina-platform/ballerina-lang/issues">ballerina-lang</a> repo
- Ballerina library: <a href="https://github.com/ballerina-platform/ballerina-standard-library/issues">ballerina-lang</a> repo
- Security flaw: send an email to security@ballerina.io. For details, see the <a href="https://ballerina.io/security-policy/">security policy</a>.


## Contribute to Ballerina
Expand All @@ -79,7 +73,6 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball

## Useful links

* Join [Ballerina-Dev](https://groups.google.com/g/ballerina-dev) group for technical discussions related to the Ballerina project.
* Chat live with us on our [Discord community](https://discord.com/invite/wAJYFbMrG2).
* Post technical questions on the Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
* For more details on how to engage with the community, see [Community](https://ballerina.io/community/).
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,15 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target,
if (nativeImageCommand == null) {
throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " +
"environment variable\nHINT: To install GraalVM, follow the link: " +
"https://ballerina.io/learn/build-a-native-executable/#configure-graalvm");
"https://ballerina.io/learn/build-the-executable-locally/#configure-graalvm");
}
nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator
+ (OS.contains("win") ? "native-image.cmd" : "native-image");

File commandExecutable = Paths.get(nativeImageCommand).toFile();
if (!commandExecutable.exists()) {
throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " +
"Install it using: gu install native-image");
throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME/bin "

Check warning on line 481 in cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java

View check run for this annotation

Codecov / codecov/patch

cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java#L481

Added line #L481 was not covered by tests
+ "directory. Install it using: gu install native-image");
}
} catch (ProjectException e) {
throw createLauncherException(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DocumentContext {
private NodeCloner nodeCloner;
private final DocumentId documentId;
private final String name;
private final String content;
private String content;
private boolean disableSyntaxTree = false;

private DocumentContext(DocumentId documentId, String name, String content, boolean disableSyntaxTree) {
Expand Down Expand Up @@ -187,4 +187,11 @@ private void reportSyntaxDiagnostics(PackageID pkgID, SyntaxTree tree, BLangDiag
DocumentContext duplicate() {
return new DocumentContext(this.documentId, this.name, syntaxTree().toSourceCode(), false);
}

void shrink() {
if (this.compilationUnit != null) {
this.compilationUnit.topLevelNodes.clear();
}
this.content = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ private void performCodeGen() {
moduleDiagnostics.add(
new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project()));
}

//TODO: remove this once ballerina-lang#41407 is fixed
ModuleContext.shrinkDocuments(moduleContext);
}
// add compilation diagnostics
diagnostics.addAll(moduleDiagnostics);
Expand Down Expand Up @@ -553,15 +556,15 @@ private Path emitGraalExecutable(Path executableFilePath) {
if (nativeImageCommand == null) {
throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " +
"environment variable\nHINT: To install GraalVM, follow the link: " +
"https://ballerina.io/learn/build-a-native-executable/#configure-graalvm");
"https://ballerina.io/learn/build-the-executable-locally/#configure-graalvm");
}
nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator
+ (OS.contains("win") ? "native-image.cmd" : "native-image");

File commandExecutable = Paths.get(nativeImageCommand).toFile();
if (!commandExecutable.exists()) {
throw new ProjectException("cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " +
"Install it using: gu install native-image");
throw new ProjectException("cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME/bin " +

Check warning on line 566 in compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java

View check run for this annotation

Codecov / codecov/patch

compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java#L566

Added line #L566 was not covered by tests
"directory. Install it using: gu install native-image");
}

String graalVMBuildOptions = project.buildOptions().graalVMBuildOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ static void loadPlatformSpecificCodeInternal(ModuleContext moduleContext, Compil
// TODO implement
}

//TODO: should be removed once we properly fix ballerina-lang#41407
static void shrinkDocuments(ModuleContext moduleContext) {
moduleContext.srcDocContextMap.values().forEach(DocumentContext::shrink);
}

Optional<MdDocumentContext> moduleMdContext() {
return Optional.ofNullable(this.moduleMdContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ private CompiledJarFile generate(BPackageSymbol packageSymbol) {
HashMap<String, String> originalIdentifierMap = JvmDesugarPhase.encodeModuleIdentifiers(packageSymbol.bir);

// TODO Get-rid of the following assignment
packageSymbol.compiledJarFile = jvmPackageGen.generate(packageSymbol.bir, true);
CompiledJarFile compiledJarFile = jvmPackageGen.generate(packageSymbol.bir, true);

//Revert encoding identifier names
JvmDesugarPhase.replaceEncodedModuleIdentifiers(packageSymbol.bir, originalIdentifierMap);
return packageSymbol.compiledJarFile;
return compiledJarFile;
}

private void populateExternalMap(JvmPackageGen jvmPackageGen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ private BLangLambdaFunction addReturnAndDefineLambda(BLangFunction function, BLa

BInvokableSymbol lambdaFunctionSymbol = createInvokableSymbol(function, pkgID, owner);
BLangLambdaFunction lambdaFunction = desugar.createLambdaFunction(function, lambdaFunctionSymbol, env);
lambdaFunction.capturedClosureEnv = env.createClone();
lambdaFunction.capturedClosureEnv = env;

pkgNode.functions.add(function);
pkgNode.topLevelNodes.add(function);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ public void visit(BLangLambdaFunction bLangLambdaFunction) {
boolean isWorker = bLangLambdaFunction.function.flagSet.contains(Flag.WORKER);
bLangLambdaFunction.enclMapSymbols = collectClosureMapSymbols(symbolEnv, enclInvokable, isWorker);
}
bLangLambdaFunction.capturedClosureEnv = null;
result = bLangLambdaFunction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ private BLangExpression createClosureForDefaultValue(String closureName, String
BLangReturn returnStmt = ASTBuilderUtil.createReturnStmt(function.pos, (BLangBlockFunctionBody) function.body);
returnStmt.expr = varNode.expr;
BLangLambdaFunction lambdaFunction = createLambdaFunction(function);
lambdaFunction.capturedClosureEnv = env.createClone();
lambdaFunction.capturedClosureEnv = env;
BInvokableSymbol varSymbol = createSimpleVariable(function, lambdaFunction, false);
env.enclPkg.symbol.scope.define(function.symbol.name, function.symbol);
env.enclPkg.functions.add(function);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6222,7 +6222,7 @@ private BLangNode rewriteObjectMemberAccessAsField(BLangFieldBasedAccess fieldAc

BLangLambdaFunction lambdaFunction = (BLangLambdaFunction) TreeBuilder.createLambdaFunctionNode();
lambdaFunction.function = func;
lambdaFunction.capturedClosureEnv = env.createClone();
lambdaFunction.capturedClosureEnv = env;
env.enclPkg.functions.add(func);
env.enclPkg.topLevelNodes.add(func);
//env.enclPkg.lambdaFunctions.add(lambdaFunction);
Expand Down Expand Up @@ -7809,6 +7809,7 @@ public void visit(BLangLambdaFunction bLangLambdaFunction) {
funcSymbol.addAnnotation(this.strandAnnotAttachement.annotationAttachmentSymbol);
funcSymbol.schedulerPolicy = SchedulerPolicy.ANY;
}
bLangLambdaFunction.capturedClosureEnv = null;
result = bLangLambdaFunction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.ballerinalang.model.symbols.SymbolKind;
import org.ballerinalang.model.symbols.SymbolOrigin;
import org.ballerinalang.repository.CompiledPackage;
import org.wso2.ballerinalang.compiler.CompiledJarFile;
import org.wso2.ballerinalang.compiler.bir.model.BIRNode;
import org.wso2.ballerinalang.compiler.semantics.model.types.BPackageType;
import org.wso2.ballerinalang.compiler.util.Name;
Expand Down Expand Up @@ -56,9 +55,6 @@ public class BPackageSymbol extends BTypeSymbol {
public BIRNode.BIRPackage bir; // TODO try to remove this
public BIRPackageFile birPackageFile;

// kep code generated jar binary content in memory
public CompiledJarFile compiledJarFile;

// TODO Refactor following two flags
public boolean entryPointExists = false;

Expand Down

0 comments on commit 5b94cf5

Please sign in to comment.