Skip to content

Commit

Permalink
Merge pull request #3785 from onflow/bastian/sync-compiler-2
Browse files Browse the repository at this point in the history
Sync compiler feature branch
  • Loading branch information
turbolent authored Feb 20, 2025
2 parents f694f6e + 4c4eb7f commit 0266434
Show file tree
Hide file tree
Showing 108 changed files with 4,576 additions and 2,325 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility-check-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
# Upload checking results for later use

- name: Archive checking results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.chain }}-checking-results
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# Upload

- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.chain }}-contracts
path: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ If you would like to contribute to Cadence, have a look at the [contributing gui

Development documentation can be found in the [`/docs` directory](https://github.com/onflow/cadence/tree/master/docs).
For example, it contains the source for the language reference.

You can also look out for the next [Cadence Working Group](https://github.com/onflow/Flow-Working-Groups/tree/main/cadence_language_and_execution_working_group) meeting and join our discussions!
13 changes: 13 additions & 0 deletions activations/activations.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ func (a *Activation[T]) Set(name string, value T) {
a.entries[name] = value
}

func (a *Activation[T]) Clone() *Activation[T] {
clone := NewActivation[T](a.MemoryGauge, a.Parent)

if a.entries != nil {
clone.entries = make(map[string]T, len(a.entries))
for name, value := range a.entries { //nolint:maprange
clone.entries[name] = value
}
}

return clone
}

// Activations is a stack of activation records.
// Each entry represents a new activation record.
//
Expand Down
6 changes: 3 additions & 3 deletions ast/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Element interface {

type StatementDeclarationVisitor[T any] interface {
VisitVariableDeclaration(*VariableDeclaration) T
VisitFunctionDeclaration(*FunctionDeclaration) T
VisitFunctionDeclaration(declaration *FunctionDeclaration, isStatement bool) T
VisitSpecialFunctionDeclaration(*SpecialFunctionDeclaration) T
VisitCompositeDeclaration(*CompositeDeclaration) T
VisitAttachmentDeclaration(*AttachmentDeclaration) T
Expand Down Expand Up @@ -68,7 +68,7 @@ func AcceptDeclaration[T any](declaration Declaration, visitor DeclarationVisito
return visitor.VisitVariableDeclaration(declaration.(*VariableDeclaration))

case ElementTypeFunctionDeclaration:
return visitor.VisitFunctionDeclaration(declaration.(*FunctionDeclaration))
return visitor.VisitFunctionDeclaration(declaration.(*FunctionDeclaration), false)

case ElementTypeSpecialFunctionDeclaration:
return visitor.VisitSpecialFunctionDeclaration(declaration.(*SpecialFunctionDeclaration))
Expand Down Expand Up @@ -151,7 +151,7 @@ func AcceptStatement[T any](statement Statement, visitor StatementVisitor[T]) (_
return visitor.VisitVariableDeclaration(statement.(*VariableDeclaration))

case ElementTypeFunctionDeclaration:
return visitor.VisitFunctionDeclaration(statement.(*FunctionDeclaration))
return visitor.VisitFunctionDeclaration(statement.(*FunctionDeclaration), true)

case ElementTypeSpecialFunctionDeclaration:
return visitor.VisitSpecialFunctionDeclaration(statement.(*SpecialFunctionDeclaration))
Expand Down
2 changes: 1 addition & 1 deletion bbq/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ func (c *Compiler[_]) compileInitializer(declaration *ast.SpecialFunctionDeclara
c.codeGen.Emit(opcode.InstructionReturnValue{})
}

func (c *Compiler[_]) VisitFunctionDeclaration(declaration *ast.FunctionDeclaration) (_ struct{}) {
func (c *Compiler[_]) VisitFunctionDeclaration(declaration *ast.FunctionDeclaration, _ bool) (_ struct{}) {
declareReceiver := !c.compositeTypeStack.isEmpty()
function := c.declareFunction(declaration, declareReceiver)

Expand Down
2 changes: 1 addition & 1 deletion bbq/compiler/desugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (d *Desugar) VisitVariableDeclaration(declaration *ast.VariableDeclaration)
return declaration
}

func (d *Desugar) VisitFunctionDeclaration(declaration *ast.FunctionDeclaration) ast.Declaration {
func (d *Desugar) VisitFunctionDeclaration(declaration *ast.FunctionDeclaration, _ bool) ast.Declaration {
funcBlock := declaration.FunctionBlock
funcName := declaration.Identifier.Identifier

Expand Down
2 changes: 1 addition & 1 deletion cmd/decode-state-values/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func loadStorageKey(

if composite, ok := v.(*interpreter.CompositeValue); ok &&
composite.Kind == common.CompositeKindResource &&
composite.ResourceUUID(inter, interpreter.EmptyLocationRange) == nil {
composite.ResourceUUID(inter) == nil {

log.Printf(
"Failed to get UUID for resource @ 0x%x %s",
Expand Down
4 changes: 2 additions & 2 deletions compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ In the future we can integrate this as part of CI, maybe as a periodic job.
pip3 install -r requirements.txt
```

- Run the suite. For example, to clone the repositories, benchmark, and compare to branch `master`:
- Run the suite:

```sh
python3 main.py --format=pretty --bench --compare-ref master
python3 main.py
```
9 changes: 2 additions & 7 deletions compat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def cadence_replacement(cadence_version: Optional[str]) -> str:
if cadence_version:
return f'github.com/onflow/cadence@{cadence_version}'
# default: point to local cadence repo
return shlex.quote(Path.cwd().parent.absolute().resolve().as_posix())
return shlex.quote(Path(__file__).parent.parent.absolute().resolve().as_posix())

def flowgo_replacement(flowgo_version: Optional[str]) -> str:
if flowgo_version:
Expand Down Expand Up @@ -102,11 +102,6 @@ def run(
result = subprocess.run(self.command, shell=True, env=env)
return result.returncode == 0

def load_index(path: Path) -> List[str]:
logger.info(f"Loading suite index from {path} ...")
with path.open(mode="r") as f:
return yaml.safe_load(f)

@dataclass
class Description:
description: str
Expand Down Expand Up @@ -308,7 +303,7 @@ def run(
all_succeeded = True

if not names:
names = load_index(SUITE_PATH / "index.yaml")
names = [f.stem for f in SUITE_PATH.glob("*.yaml")]

for name in names:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
description: NBA Top Shot
description: Dapper Labs NBA Top Shot
maintainers:
- [email protected]
- [email protected]
url: https://github.com/dapperlabs/nba-smart-contracts.git
branch: master
go_tests:
Expand Down
7 changes: 7 additions & 0 deletions compat/suite/dapper-labs-nfl-smart-contracts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: Dapper Labs NFL Smart Contracts
maintainers:
url: https://github.com/dapperlabs/nfl-smart-contracts.git
branch: main
go_tests:
- path: lib/go/test
command: make test
2 changes: 0 additions & 2 deletions compat/suite/flow-core-contracts.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
description: Flow Core Contracts
maintainers:
- [email protected]
- [email protected]
url: https://github.com/onflow/flow-core-contracts.git
branch: master
go_tests:
Expand Down
2 changes: 0 additions & 2 deletions compat/suite/flow-ft.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
description: Flow Fungible Token
maintainers:
- [email protected]
- [email protected]
url: https://github.com/onflow/flow-ft.git
branch: master
go_tests:
Expand Down
2 changes: 0 additions & 2 deletions compat/suite/flow-nft.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
description: Flow Non-Fungible Token
maintainers:
- [email protected]
- [email protected]
url: https://github.com/onflow/flow-nft.git
branch: master
go_tests:
Expand Down
1 change: 0 additions & 1 deletion compat/suite/green-goo-dao-flow-utils.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
description: Green Goo Dao flow-utils
maintainers:
- [email protected]
url: https://github.com/green-goo-dao/flow-utils.git
branch: main
cadence_tests:
Expand Down
4 changes: 0 additions & 4 deletions compat/suite/index.yaml

This file was deleted.

Loading

0 comments on commit 0266434

Please sign in to comment.