Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nested pragma declarations #2169

Merged
merged 3 commits into from
Dec 6, 2022

Conversation

turbolent
Copy link
Member

Description

There is an increasing interest in using pragma declarations:

Currently, pragma declarations are not documented in the grammar and the parser only supports them as top-level declarations.

Document pragma declarations in the grammar and add support for nested pragma declarations to the parser.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov
Copy link

codecov bot commented Nov 25, 2022

Codecov Report

Merging #2169 (2dc4091) into master (e2f0bc5) will decrease coverage by 0.08%.
The diff coverage is 78.65%.

@@            Coverage Diff             @@
##           master    #2169      +/-   ##
==========================================
- Coverage   77.68%   77.60%   -0.09%     
==========================================
  Files         308      309       +1     
  Lines       64246    64803     +557     
==========================================
+ Hits        49910    50288     +378     
- Misses      12600    12769     +169     
- Partials     1736     1746      +10     
Flag Coverage Δ
unittests 77.60% <78.65%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/parser/declaration.go 82.90% <78.40%> (-0.62%) ⬇️
runtime/common/declarationkind.go 80.90% <100.00%> (ø)
runtime/format/capability.go 68.75% <0.00%> (-31.25%) ⬇️
runtime/runtime.go 85.84% <0.00%> (-1.63%) ⬇️
runtime/interpreter/visitor.go 9.30% <0.00%> (-0.46%) ⬇️
runtime/interpreter/value.go 68.84% <0.00%> (-0.12%) ⬇️
runtime/common/metering.go 92.23% <0.00%> (ø)
runtime/sema/simple_type.go 96.15% <0.00%> (ø)
runtime/sema/authaccount_type.go 100.00% <0.00%> (ø)
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

github-actions bot commented Nov 26, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit de28ef3
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Collapsed results for better readability

old.txtnew.txt
time/opdelta
CheckContractInterfaceFungibleTokenConformance-2112µs ± 1%114µs ± 1%+1.91%(p=0.001 n=7+6)
ContractInterfaceFungibleToken-239.8µs ± 3%39.9µs ± 0%~(p=0.065 n=6+6)
InterpretRecursionFib-22.46ms ± 1%2.57ms ± 8%+4.31%(p=0.026 n=7+7)
NewInterpreter/new_interpreter-21.09µs ± 1%1.10µs ± 0%+0.83%(p=0.003 n=7+6)
NewInterpreter/new_sub-interpreter-2590ns ± 8%592ns ± 6%~(p=0.165 n=7+7)
ParseArray-27.66ms ± 1%7.62ms ± 3%~(p=0.180 n=6+6)
ParseDeploy/byte_array-211.5ms ± 2%11.7ms ± 6%~(p=0.710 n=7+7)
ParseDeploy/decode_hex-21.20ms ± 1%1.22ms ± 1%+1.41%(p=0.001 n=6+7)
ParseFungibleToken/With_memory_metering-2184µs ± 3%183µs ± 2%~(p=0.097 n=7+7)
ParseFungibleToken/Without_memory_metering-2143µs ± 0%142µs ± 0%−0.32%(p=0.014 n=7+6)
ParseInfix-27.10µs ± 1%7.04µs ± 1%−0.77%(p=0.009 n=6+7)
QualifiedIdentifierCreation/One_level-22.43ns ± 1%2.42ns ± 1%~(p=0.866 n=7+6)
QualifiedIdentifierCreation/Three_levels-2117ns ± 0%117ns ± 1%~(p=0.124 n=7+7)
RuntimeFungibleTokenTransfer-2667µs ± 7%530µs ±22%−20.52%(p=0.005 n=6+7)
RuntimeResourceDictionaryValues-25.25ms ± 0%5.17ms ± 1%−1.52%(p=0.001 n=7+6)
RuntimeScriptNoop-223.0µs ±34%22.4µs ±31%~(p=0.456 n=7+7)
SuperTypeInference/arrays-2294ns ± 0%283ns ± 1%−3.92%(p=0.002 n=6+6)
SuperTypeInference/composites-2129ns ± 0%131ns ± 0%+2.05%(p=0.001 n=6+7)
SuperTypeInference/integers-292.2ns ± 0%93.4ns ± 0%+1.30%(p=0.001 n=7+7)
ValueIsSubtypeOfSemaType-287.1ns ± 1%89.3ns ± 2%+2.56%(p=0.004 n=6+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-249.7kB ± 0%49.8kB ± 0%+0.32%(p=0.001 n=7+7)
ContractInterfaceFungibleToken-224.0kB ± 0%24.1kB ± 0%+0.40%(p=0.001 n=7+7)
InterpretRecursionFib-21.00MB ± 0%1.00MB ± 0%~(p=0.486 n=7+7)
NewInterpreter/new_interpreter-2752B ± 0%768B ± 0%+2.13%(p=0.001 n=7+7)
NewInterpreter/new_sub-interpreter-2200B ± 0%200B ± 0%~(all equal)
ParseArray-22.79MB ± 5%2.72MB ± 0%−2.54%(p=0.048 n=7+5)
ParseDeploy/byte_array-24.16MB ± 2%4.21MB ± 3%~(p=0.301 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.154 n=7+7)
ParseFungibleToken/With_memory_metering-229.2kB ± 0%29.2kB ± 0%~(p=0.592 n=7+7)
ParseFungibleToken/Without_memory_metering-229.2kB ± 0%29.2kB ± 0%~(p=0.351 n=5+6)
ParseInfix-21.92kB ± 0%1.92kB ± 0%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2103kB ± 0%102kB ± 1%−0.52%(p=0.026 n=7+7)
RuntimeResourceDictionaryValues-22.28MB ± 0%2.28MB ± 0%+0.29%(p=0.007 n=7+7)
RuntimeScriptNoop-28.46kB ± 0%8.45kB ± 1%~(p=0.876 n=7+7)
SuperTypeInference/arrays-296.0B ± 0%96.0B ± 0%~(all equal)
SuperTypeInference/composites-20.00B 0.00B ~(all equal)
SuperTypeInference/integers-20.00B 0.00B ~(all equal)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-2815 ± 0%815 ± 0%~(all equal)
ContractInterfaceFungibleToken-2388 ± 0%388 ± 0%~(all equal)
InterpretRecursionFib-218.9k ± 0%18.9k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-24.00 ± 0%4.00 ± 0%~(all equal)
ParseArray-259.6k ± 0%59.6k ± 0%~(p=1.000 n=7+7)
ParseDeploy/byte_array-289.4k ± 0%89.4k ± 0%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-264.0 ± 0%64.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-2779 ± 0%779 ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-2779 ± 0%779 ± 0%~(all equal)
ParseInfix-248.0 ± 0%48.0 ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
RuntimeFungibleTokenTransfer-21.99k ± 0%1.99k ± 0%+0.11%(p=0.001 n=6+7)
RuntimeResourceDictionaryValues-236.9k ± 0%36.9k ± 0%+0.01%(p=0.001 n=7+7)
RuntimeScriptNoop-2132 ± 0%132 ± 0%~(all equal)
SuperTypeInference/arrays-23.00 ± 0%3.00 ± 0%~(all equal)
SuperTypeInference/composites-20.00 0.00 ~(all equal)
SuperTypeInference/integers-20.00 0.00 ~(all equal)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent turbolent requested review from SupunS and a team December 6, 2022 00:27
@turbolent turbolent merged commit 65fd955 into master Dec 6, 2022
@turbolent turbolent deleted the bastian/improve-pragma-parsing branch December 6, 2022 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants