Skip to content

Commit df3ec0d

Browse files
authored
Merge branch 'main' into dev/peefy/feat_query_tool
2 parents 0fb03bd + 1b71e25 commit df3ec0d

File tree

69 files changed

+952
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+952
-196
lines changed

.github/ISSUE_TEMPLATE.md

-31
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

-6
This file was deleted.

.github/workflows/cla.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "CLA Assistant"
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_target:
6+
types: [opened,closed,synchronize]
7+
8+
jobs:
9+
CLAssistant:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: "CLA Assistant"
13+
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
14+
# Beta Release
15+
uses: cla-assistant/[email protected]
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
# the below token should have repo scope and must be manually added by you in the repository's secret
19+
PERSONAL_ACCESS_TOKEN : ${{ secrets.KUSIONSTACK_BOT_TOKEN }}
20+
with:
21+
path-to-document: 'https://github.com/KusionStack/.github/blob/main/CLA.md' # e.g. a CLA or a DCO document
22+
23+
# branch should not be protected
24+
lock-pullrequest-aftermerge: True
25+
path-to-signatures: 'signatures/version1/cla.json'
26+
remote-organization-name: KusionStack
27+
remote-repository-name: cla.db
28+
branch: 'main'
29+
allowlist: 'test'
30+
31+
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
32+
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
33+
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
34+
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
35+
#signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
36+
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
37+
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
38+
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
39+
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
40+
#use-dco-flag: true - If you are using DCO instead of CLA
41+

.github/workflows/github-actions.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: KCLVM-actions
2-
on: [push]
2+
on: ["push", "pull_request"]
33
jobs:
44
test-unit:
55
name: Test
@@ -35,5 +35,10 @@ jobs:
3535
components: clippy, rustfmt
3636
- name: Rust unit test
3737
working-directory: ./kclvm
38-
run: make test
38+
run: make codecov-lcov
3939
shell: bash
40+
- name: Coveralls upload
41+
uses: coverallsapp/github-action@master
42+
with:
43+
github-token: ${{ secrets.GITHUB_TOKEN }}
44+
path-to-lcov: ./kclvm/.kclvm/lcov.info

.gitignore

+9-8
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ lark_parser.pickle
7474
/scripts/docker/kclvm-builder-centos7/crates.io-index
7575
/scripts/docker/kclvm-builder-ubuntu/crates.io-index
7676
*.tar.gz
77+
78+
# KCLVM cache and temp output
79+
.kclvm
80+
*.dylib
81+
*.so
82+
*.dll
83+
*.lock
84+
*.ll
85+
*.ll.lock
7786
_a.out.*
7887
_a.out_*.*
79-
# KCLVM cache
80-
.kclvm
81-
__main__.dylib
82-
__main__.so
83-
__main__.dll
84-
__main__.lock
85-
__main__.ll
86-
__main__.ll.lock

docs/dev_guide/1.about_this_guide.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# About this Guide
2+
3+
This guide is intended to help document how `KCLVM` (the KCL compiler) works, and to help new contributors get involved in KCLVM development.
4+
5+
This guide consists of **4** parts:
6+
7+
1. **Building and Testing `KCLVM`**: Contains information that should be useful no matter how you are contributing, about building, testing, debugging, profiling, etc.
8+
2. **Contributing to `KCLVM`**: Contains information that should be useful no matter how you are contributing, about procedures for contribution, using git and Github, etc.
9+
3. **`KCLVM` Architecture**: Contains an introduction to the architecture of the compiler and a detailed introduction to each compilation process.
10+
4. **Appendices**: There are a few of these with different information, including a glossary.
11+
12+
The Guide itself is of course open-source as well, and the sources can be found at the [GitHub repository](https://github.com/KusionStack/KCLVM/tree/main/docs/dev_guide). If you find any mistakes in the guide, please file an issue about it. Even better, open a Github Pull Request (PR) with a correction!
13+
14+
If you do contribute to the guide, please see the corresponding subsection on writing documentation in this guide.
15+
16+
## Other Documentations
17+
18+
* [KCL Documents](https://kusionstack.io/docs/reference/lang/lang/tour)
19+
* [KCL Examples](https://github.com/KusionStack/examples)

docs/dev_guide/2.quick_start.md

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Quick Start
2+
3+
This documentation is *NOT* intended to be comprehensive; it is meant to be a quick guide for the most useful things. For more information, see the develop guide in its entirety.
4+
5+
## Asking Questions
6+
7+
Before asking a question, make sure you have:
8+
9+
- Searched open and closed:
10+
- [KCLVM GitHub Issues](https://github.com/KusionStack/KCLVM/issues?utf8=%E2%9C%93&q=is%3Aissue)
11+
12+
- Read the documentations:
13+
- [KCLVM Documents](https://kusionstack.io/docs/reference/lang/lang/tour)
14+
- [KCLVM Readme](https://github.com/KusionStack/KCLVM)
15+
16+
If you have any questions about `KCLVM`, you are welcome to ask your questions in [KCLVM Github Issues](https://github.com/KusionStack/KCLVM/issues). When you ask a question, please describe the details as clearly as possible so that others in the KCLVM community can understand, and you *MUST* be polite and avoid personal attack and avoid not objective comparison with other projects.
17+
18+
## Cloning and Building `KCLVM`
19+
20+
### System Requirements
21+
22+
The following hardware is recommended.
23+
24+
- 10GB+ of free disk space.
25+
- 4GB+ RAM
26+
- 2+ cores
27+
28+
### Dependencies
29+
30+
#### Docker
31+
32+
- `docker`
33+
34+
In the top level of the `KusionStack/KCLVM` repo and run:
35+
36+
```sh
37+
make sh-in-docker
38+
```
39+
40+
Using a docker image is our recommended way, of course, you can also configure your local development environment according to the following content.
41+
42+
#### macOS and OS X
43+
44+
- `git`
45+
- `Python 3.7+`
46+
- `Rust 1.60+`
47+
- `LLVM 12`
48+
49+
You'll need LLVM installed and `llvm-config` in your `PATH`. Just download from [LLVM 12](https://releases.llvm.org/download.html) or install `llvm@12` using `brew`.
50+
51+
```sh
52+
brew install llvm@12
53+
```
54+
55+
Add the LLVM installation location to `LLVM_SYS_120_PREFIX` and the `$PATH`.
56+
57+
```
58+
export LLVM_SYS_120_PREFIX=<your LLVM 12 install location>
59+
export PATH=<your LLVM 12 install location>/bin:$PATH
60+
```
61+
62+
#### Linux
63+
64+
- `git`
65+
- `Rust 1.60+`
66+
- `Python3 Building Dependencies`
67+
- `LLVM 12`
68+
69+
For UNIX based systems, you can run:
70+
71+
```
72+
yum groupinstall -y "Development Tools"
73+
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel
74+
yum install -y libpcap-devel xz-devel readline-devel tk-devel gdbm-devel db4-deve
75+
yum -y install yum-utils
76+
yum-builddep -y python3
77+
yum install -y zlib*
78+
yum install -y openssl-devel
79+
yum install -y glibc-static
80+
81+
# clang-12 & llvm-12
82+
RUN yum -y install clang
83+
RUN clang --version
84+
RUN yum -y install llvm-devel
85+
RUN yum -y install libffi-devel
86+
RUN ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so
87+
```
88+
89+
On Debian, Ubuntu, and other apt based systems, you can run:
90+
91+
```
92+
apt-get update
93+
94+
apt-get install -y git wget curl
95+
apt-get install -y make gcc patch
96+
apt-get install -y python-dev libffi-dev
97+
apt-get install -y zlib1g-dev ncurses-dev build-essential libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev
98+
99+
# clang-12 & llvm-12
100+
RUN apt-get install -y clang-12 lld-12
101+
RUN ln -sf /usr/bin/clang-12 /usr/bin/clang
102+
RUN ln -sf /usr/bin/wasm-ld-12 /usr/bin/wasm-ld
103+
```
104+
105+
#### Windows
106+
107+
- `git`
108+
- `Rust 1.60+`
109+
- `Python 3.7+`
110+
- `LLVM 12`
111+
112+
Please add the LLVM installation location to `LLVM_SYS_120_PREFIX` and the `$PATH`.
113+
114+
### Cloning
115+
116+
You can just do a normal git clone:
117+
118+
```sh
119+
git clone https://github.com/KusionStack/KCLVM.git
120+
cd KCLVM
121+
```
122+
123+
### Building
124+
125+
In the top level of the `KusionStack/KCLVM` repo and run:
126+
127+
```sh
128+
./run.sh -a build
129+
```
130+
131+
### Testing
132+
133+
In the top level of the `KusionStack/KCLVM` repo and run:
134+
135+
```
136+
./run.sh -a test
137+
```
138+
139+
See the chapters on building and testing for more details.
140+
141+
## Contributor Procedures
142+
143+
### Create an Issue
144+
145+
Every change should be accompanied by a dedicated tracking issue for that change. The main text of this issue should describe the change being made, with a focus on what users must do to fix their code. The issue should be approachable and practical; it may make sense to direct users to some other issue for the full details. The issue also serves as a place where users can comment with questions or other concerns.
146+
147+
When you open an issue on the `KusionStack/KCLVM` repo, you need to to choose an issue template on this [page](https://github.com/KusionStack/KCLVM/issues/new/choose), you can choose a template according to different situations and fill in the corresponding content, and you also need to select appropriate labels for your issue to help classify and identify.
148+
149+
### Create a PR
150+
151+
When you open a PR on the `KusionStack/KCLVM` repo, you need to assign reviewers in the [KCL Dev Team](https://github.com/orgs/KusionStack/teams/kcl-dev) list, and reviewers are the persons that will approve the PR to be tested and merged.
152+
153+
Please note that all code changes in the KCLVM project require corresponding comments and tests. For more code and test writing details, please see the chapters on code of conduct and testing.
154+
155+
Besides, all PRs need to have corresponding issues tracking, and need to add appropriate labels and milestone information.
156+
157+
#### Bug Fixes or "Normal" Code Changes
158+
159+
For most PRs, no special procedures are needed. You can just open an issue and a PR, and it will be reviewed, approved, and merged. This includes most bug fixes, refactorings, and other user-invisible changes.
160+
161+
Also, note that it is perfectly acceptable to open WIP PRs or GitHub Draft PRs. Some people prefer to do this so they can get feedback along the way or share their code with a collaborator. Others do this so they can utilize the CI to build and test their PR (e.g. if you are developing on a laptop).
162+
163+
#### New Features
164+
165+
In order to implement a new feature, usually you will need to go through [the KEP process](https://github.com/KusionStack/KEP) to propose a design, have discussions, etc.
166+
167+
After a feature is approved to be added, a tracking issue is created on the `KusionStack/KCLVM` repo, which tracks the progress towards the implementation of the feature, any bugs reported, and eventually stabilization. The feature then can be implemented.

internal/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft kclvm

internal/__init__.py

Whitespace-only changes.

internal/kclvm_py/api/__init__.py

Whitespace-only changes.

internal/kclvm_py/compiler/build/utils/__init__.py

Whitespace-only changes.

internal/kclvm_py/compiler/check/__init__.py

Whitespace-only changes.

internal/kclvm_py/compiler/extension/__init__.py

Whitespace-only changes.

internal/kclvm_py/compiler/extension/builtin/system_module/__init__.py

Whitespace-only changes.

internal/kclvm_py/kcl/grammar/__init__.py

Whitespace-only changes.

internal/kclvm_py/kcl/types/checker.py

+3
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,9 @@ def walk_AugAssignStmt(self, t: ast.AugAssignStmt):
24932493
def walk_ListIfItemExpr(self, t: ast.ListIfItemExpr):
24942494
self.expr_or_any_type(t.if_cond)
24952495
or_else_type = self.expr_or_any_type(t.orelse)
2496+
# `orelse` node maybe a list unpack node, use its item type instead.
2497+
if isinstance(or_else_type, objpkg.KCLListTypeObject):
2498+
or_else_type = or_else_type.item_type
24962499
exprs_type = sup(self.exprs(t.exprs))
24972500
return sup([or_else_type, exprs_type])
24982501

internal/kclvm_py/program/__init__.py

Whitespace-only changes.

internal/kclvm_py/program/repl/__init__.py

Whitespace-only changes.

internal/kclvm_py/scripts/__init__.py

Whitespace-only changes.

internal/kclvm_py/scripts/cli/__init__.py

Whitespace-only changes.

internal/kclvm_py/scripts/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
wheel==0.34.2
1+
wheel==0.34.2
22
twine==3.2.0
33
pyyaml==5.4
44
pytest-xdist==2.2.1

internal/kclvm_py/spec/__init__.py

Whitespace-only changes.

internal/kclvm_py/spec/gpyrpc/__init__.py

Whitespace-only changes.

internal/kclvm_py/spec/gpyrpc/protoc-gen-protorpc-py/__init__.py

Whitespace-only changes.

internal/kclvm_py/spec/modfile/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/docs/templates/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/lint/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/lint/message/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/lint/reporters/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/list_attribute/__init__.py

Whitespace-only changes.

internal/kclvm_py/tools/printer/printer.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ def walk_IfStmt(self, t: ast.IfStmt):
286286
self.print(Indentation.Dedent)
287287
if t.elif_cond:
288288
for cond, body in zip(t.elif_cond, t.elif_body):
289+
# Nested if statements need to be considered,
290+
# so `elif` needs to be preceded by the current indentation.
289291
self.print(
292+
Indentation.Fill,
290293
ast.TokenValue.ELIF,
291294
WHITESPACE,
292295
cond,
@@ -297,15 +300,17 @@ def walk_IfStmt(self, t: ast.IfStmt):
297300
self.stmts(body)
298301
self.print(Indentation.Dedent)
299302
if t.else_body:
303+
# Nested if statements need to be considered,
304+
# so `else` needs to be preceded by the current indentation.
300305
self.print(
306+
Indentation.Fill,
301307
ast.TokenValue.ELSE,
302308
ast.TokenValue.COLON,
303309
NEWLINE,
304310
Indentation.Indent,
305311
)
306312
self.stmts(t.else_body)
307313
self.print(Indentation.Dedent)
308-
self.print(NEWLINE)
309314

310315
def walk_ImportStmt(self, t: ast.ImportStmt):
311316
"""ast.AST: ImportStmt
@@ -645,6 +650,7 @@ def walk_UnaryExpr(self, t: ast.UnaryExpr):
645650
assert isinstance(t, ast.UnaryExpr)
646651
self.print(
647652
ast.OPERATOR_VALUE_MAP[t.op],
653+
WHITESPACE if t.op == ast.UnaryOp.Not else "",
648654
t.operand,
649655
)
650656

@@ -1119,7 +1125,9 @@ def walk_JoinedString(self, t: ast.JoinedString):
11191125
ast.TokenValue.RIGHT_BRACE,
11201126
)
11211127
elif isinstance(value, ast.StringLit):
1122-
self.write(value.raw_value or '{}'.format(value.value.replace('"', '\\"')))
1128+
self.write(
1129+
value.raw_value or "{}".format(value.value.replace('"', '\\"'))
1130+
)
11231131
elif isinstance(value, ast.Expr):
11241132
self.expr(value)
11251133
else:

0 commit comments

Comments
 (0)