aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-27 18:26:24 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:12 +0100
commit62df23e4b75b1f57a4c110d7aac0e50a3a971074 (patch)
treef66f36ea10441237be847dfe4063528db95f53a5 /src/dotty/tools/dotc/core/pickling/PickleFormat.scala
parent60e520c73d20526f2cf21c90088480f0a971fbc3 (diff)
downloaddotty-62df23e4b75b1f57a4c110d7aac0e50a3a971074.tar.gz
dotty-62df23e4b75b1f57a4c110d7aac0e50a3a971074.tar.bz2
dotty-62df23e4b75b1f57a4c110d7aac0e50a3a971074.zip
Align PickleFormat with doc spec
New version number: 0.04 Also removed dead code in pickler.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/PickleFormat.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/PickleFormat.scala277
1 files changed, 142 insertions, 135 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
index a03da3a79..483cc35b3 100644
--- a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
+++ b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala
@@ -13,29 +13,30 @@ can be dropped without changing the grammar.
Micro-syntax:
- LongNat = Digit* StopDigit // big endian, value fits in a Long without overflow
- LongInt = LongNat // big endian 2's complement, value fits in a Long without overflow
- Nat = LongNat // value fits in an Int without overflow
- Int = LongInt // value fits in an Int without overflow
+ LongInt = Digit* StopDigit // big endian 2's complement, value fits in a Long w/o overflow
+ Int = LongInt // big endian 2's complement, fits in an Int w/o overflow
+ Nat = LongInt // non-negative value, fits in an Int without overflow
Digit = 0 | ... | 127
StopDigit = 128 | ... | 255 // value = digit - 128
Macro-format:
- File = Header majorVersion_Nat minorVersion_Nat UUID nameTable_Length Name* Section*
+ File = Header majorVersion_Nat minorVersion_Nat UUID
+ nameTable_Length Name* Section*
Header = "5CA1AB1F"
- UUID = Byte*16
+ UUID = Byte*16 // random UUID
Section = NameRef Length Bytes
Length = Nat // length of rest of entry in bytes
- Name = UTF8 Length UTF8-CodePoint*
- QUALIFIED Length qualified_NameRef selector_NameRef
- SIGNED Length original_NameRef resultSig_NameRef paramSig_NameRef*
- EXPANDED Length original_NameRef
- MODULECLASS Length module_NameRef
- SUPERACCESSOR Length accessed_NameRef
- DEFAULTGETTER Length method_NameRef paramNumber_Nat
+ Name = UTF8 Length UTF8-CodePoint*
+ QUALIFIED Length qualified_NameRef selector_NameRef
+ SIGNED Length original_NameRef resultSig_NameRef paramSig_NameRef*
+ EXPANDED Length original_NameRef
+ MODULECLASS Length module_NameRef
+ SUPERACCESSOR Length accessed_NameRef
+ DEFAULTGETTER Length method_NameRef paramNumber_Nat
+ MANGLED Length mangle_NameRef name_NameRef
...
NameRef = Nat // ordinal number of name in name table, starting from 1.
@@ -45,100 +46,104 @@ a type-name or a term-name. The same string can represent both.
Standard-Section: "ASTs" TopLevelStat*
- TopLevelStat = PACKAGE Length Path TopLevelStat*
+ TopLevelStat = PACKAGE Length Path TopLevelStat*
Stat
Stat = Term
- VALDEF Length NameRef Type rhs_Tree Modifier*
- DEFDEF Length NameRef TypeParam* Params* return_Type rhs_Tree
- Modifier*
- TYPEDEF Length NameRef (Type | Template) Modifier*
- IMPORT Length qual_Term Selector*
-
- TypeParam = TYPEPARAM Length NameRef Type Modifier*
- Params = PARAMS Length Param*
- Param = PARAM Length NameRef Type Modifier*
- Template = TEMPLATE Length TypeParam* Param* Parent* Self? Stat* // Stat* always starts with the primary constructor.
+ VALDEF Length NameRef Type rhs_Tree Modifier*
+ DEFDEF Length NameRef TypeParam* Params* return_Type rhs_Tree
+ Modifier*
+ TYPEDEF Length NameRef (Type | Template) Modifier*
+ IMPORT Length qual_Term Selector*
+ Selector = IMPORTED Length name_NameRef
+ RENAMED Length from_NameRef to_NameRef
+ // Imports are for scala.meta, they are not used in the backend
+
+ TypeParam = TYPEPARAM Length NameRef Type Modifier*
+ Params = PARAMS Length Param*
+ IMPLICITPARAMS Length Param* // not yet used
+ Param = PARAM Length NameRef Type Modifier*
+ Template = TEMPLATE Length TypeParam* Param* Parent* Self? Stat* // Stat* always starts with the primary constructor.
Parent = Application
Type
- Self = SELFDEF Length NameRef Type
- Selector = IMPORTED Length name_NameRef
- RENAMED Length from_NameRef to_NameRef
+ Self = SELFDEF Length selfName_NameRef selfType_Type
Term = Path
Application
- IDENT NameRef Type
- SELECT possiblySigned_NameRef qual_Term
- SUPER Length this_Term mixinTrait_Type?
- NEW Length cls_Type
- PAIR Length left_Term right_Term
- TYPED Length expr_Term ascription_Type
- NAMEDARG Length paramName_NameRef arg_Term
- ASSIGN Length lhs_Term rhs_Term
- BLOCK Length expr_Term Stat*
- IF Length cond_Term then_Term else_Term
- CLOSURE Length meth_Term target_Type env_Term*
- MATCH Length sel_Term CaseDef*
- RETURN Length meth_ASTRef expr_Term?
- TRY Length expr_Term CaseDef* finalizer_Term?
- THROW Length expr_Term
- REPEATED Length elem_Term*
- BIND Length boundName_NameRef patType_Type pat_Term
- ALTERNATIVE Length alt_Term*
- UNAPPLY Length fun_Term ImplicitArg* pat_Type pat_Term*
+ IDENT NameRef Type // used when ident’s type is not a TermRef
+ SELECT possiblySigned_NameRef qual_Term
+ SUPER Length this_Term mixinTrait_Type?
+ NEW Length cls_Type
+ PAIR Length left_Term right_Term
+ TYPED Length expr_Term ascription_Type
+ NAMEDARG Length paramName_NameRef arg_Term
+ ASSIGN Length lhs_Term rhs_Term
+ BLOCK Length expr_Term Stat*
+ IF Length cond_Term then_Term else_Term
+ CLOSURE Length meth_Term target_Type env_Term*
+ MATCH Length sel_Term CaseDef*
+ RETURN Length meth_ASTRef expr_Term?
+ TRY Length expr_Term CaseDef* finalizer_Term?
+ THROW Length expr_Term
+ REPEATED Length elem_Term*
+ BIND Length boundName_NameRef patType_Type pat_Term
+ ALTERNATIVE Length alt_Term*
+ UNAPPLY Length fun_Term ImplicitArg* pat_Type pat_Term*
EMPTYTREE
- Application = APPLY Length fn_Term arg_Term*
- TYPEAPPLY Length fn_Term arg_Type*
- CaseDef = CASEDEF Length pat_Tree rhs_Tree guard_Tree?
- ImplicitArg = IMPLICITARG Length arg_Tree
- Annotation = ANNOTATION Length tycon_Symbol fullAnnotation_Term
+ SHARED term_ASTRef
+ Application = APPLY Length fn_Term arg_Term*
+
+ TYPEAPPLY Length fn_Term arg_Type*
+ CaseDef = CASEDEF Length pat_Tree rhs_Tree guard_Tree?
+ ImplicitArg = IMPLICITARG Length arg_Tree
ASTRef = Nat // byte position in AST payload
Path = Constant
- TERMREFdirect sym_ASTRef
- TERMREFsymbol sym_ASTRef qual_Type
- TERMREFpkg fullyQualified_NameRef
- TERMREF possiblySigned_NameRef qual_Type
- THIS Length clsRef_Type
- SKOLEMtype refinedType_ASTref
- SHARED path_ASTRef
+ TERMREFdirect sym_ASTRef
+ TERMREFsymbol sym_ASTRef qual_Type
+ TERMREFpkg fullyQualified_NameRef
+ TERMREF possiblySigned_NameRef qual_Type
+ THIS Length clsRef_Type
+ SKOLEMtype refinedType_ASTRef
+ SHARED path_ASTRef
Constant = UNITconst
FALSEconst
TRUEconst
- BYTEconst Int
- SHORTconst Int
- CHARconst Nat
- INTconst Int
- LONGconst LongInt
- FLOATconst Int
- DOUBLEconst LongInt
- STRINGconst NameRef
+ BYTEconst Int
+ SHORTconst Int
+ CHARconst Nat
+ INTconst Int
+ LONGconst LongInt
+ FLOATconst Int
+ DOUBLEconst LongInt
+ STRINGconst NameRef
NULLconst
- CLASSconst Length Type
- ENUMconst Length Path
-
+ CLASSconst Length Type
+ ENUMconst Length Path
+
Type = Path
- TYPEREFdirect sym_ASTRef
- TYPEREFsymbol sym_ASTRef qual_Type
- TYPEREFpkg fullyQualified_NameRef
- TYPEREF possiblySigned_NameRef qual_Type
- SUPERtype Length this_Type underlying_Type
- REFINEDtype Length underlying_Type refinement_NameRef info_Type
- APPLIEDtype Length tycon_Type arg_Type*
- TYPEBOUNDS Length low_Type high_Type
- TYPEALIAS Length alias_Type
- ANNOTATED Length fullAnnotation_Term underlying_Type
- ANDtype Length left_Type right_Type
- ORtype Length left_Type right_Type
- BIND Length boundName_NameRef underlying_Type selfRef_Type
- BYNAMEtype Length underlying_Type
- POLYtype Length result_Type NamesTypes // needed for refinements
- METHODtype Length result_Type NamesTypes // needed for refinements
- PARAMtype Length binder_ASTref paramNum_Nat // needed for refinements
+ TYPEREFdirect sym_ASTRef
+ TYPEREFsymbol sym_ASTRef qual_Type
+ TYPEREFpkg fullyQualified_NameRef
+ TYPEREF possiblySigned_NameRef qual_Type
+ SUPERtype Length this_Type underlying_Type
+ REFINEDtype Length underlying_Type refinement_NameRef info_Type
+ APPLIEDtype Length tycon_Type arg_Type*
+ TYPEBOUNDS Length low_Type high_Type
+ TYPEALIAS Length alias_Type
+ ANNOTATED Length fullAnnotation_Term underlying_Type
+ ANDtype Length left_Type right_Type
+ ORtype Length left_Type right_Type
+ BIND Length boundName_NameRef bounds_Type selfRef_Type
+ // for type-variables defined in a type pattern
+ // bounds = type bounds, selfRef = reference to type itself. BYNAMEtype Length underlying_Type
+ POLYtype Length result_Type NamesTypes // needed for refinements
+ METHODtype Length result_Type NamesTypes // needed for refinements
+ PARAMtype Length binder_ASTref paramNum_Nat // needed for refinements
NOTYPE
- SHARED type_ASTRef
+ SHARED type_ASTRef
NamesTypes = ParamType*
NameType = paramName_NameRef typeOrBounds_ASTRef
@@ -154,11 +159,11 @@ Standard-Section: "ASTs" TopLevelStat*
IMPLICIT
LAZY
OVERRIDE
- INLINE
+ INLINE // macro
ABSOVERRIDE // abstract override
STATIC // mapped to static Java member
MODULE // an object or its class
- TRAIT
+ TRAIT // a trait
LOCAL // private[this] or protected[this]
SYNTHETIC // generated by Scala compiler
ARTIFACT // to be tagged Java Synthetic
@@ -172,8 +177,9 @@ Standard-Section: "ASTs" TopLevelStat*
SCALA2X // Imported from Scala2.x
DEFAULTparameterized // Method with default params
DEFAULTinit // variable with “_” initializer
- INSUPERCALL // defined the argument of a constructor supercall
+ INSUPERCALL // defined in the argument of a constructor supercall
Annotation
+ Annotation = ANNOTATION Length tycon_Symbol fullAnnotation_Term
Note: Tree tags are grouped into 4 categories that determine what follows, and thus allow to compute the size of the tagged tree in a generic way.
@@ -283,51 +289,52 @@ object PickleFormat {
final val IMPORT = 132
final val TYPEPARAM = 133
final val PARAMS = 134
- final val PARAM = 135
- final val IMPORTED = 136
- final val RENAMED = 137
- final val APPLY = 138
- final val TYPEAPPLY = 139
- final val NEW = 140
- final val PAIR = 141
- final val TYPED = 142
- final val NAMEDARG = 143
- final val ASSIGN = 144
- final val BLOCK = 145
- final val IF = 146
- final val CLOSURE = 147
- final val MATCH = 148
- final val RETURN = 149
- final val TRY = 150
- final val THROW = 151
- final val REPEATED = 152
- final val BIND = 153
- final val ALTERNATIVE = 154
- final val UNAPPLY = 155
- final val ANNOTATED = 156
- final val CASEDEF = 157
- final val IMPLICITarg = 158
- final val TEMPLATE = 159
- final val SELFDEF = 160
- final val THIS = 161
- final val SUPER = 162
- final val CLASSconst = 163
- final val ENUMconst = 164
- final val SUPERtype = 165
- final val REFINEDtype = 166
- final val APPLIEDtype = 167
- final val TYPEBOUNDS = 168
- final val TYPEALIAS = 169
- final val ANDtype = 170
- final val ORtype = 171
- final val BYNAMEtype = 172
- final val METHODtype = 173
- final val POLYtype = 174
- final val PARAMtype = 175
- final val IMPLICITARG = 176
- final val ANNOTATION = 177
- final val PRIVATEqualified = 178
- final val PROTECTEDqualified = 179
+ final val IMPLICITPARAMS = 135
+ final val PARAM = 136
+ final val IMPORTED = 137
+ final val RENAMED = 138
+ final val APPLY = 139
+ final val TYPEAPPLY = 140
+ final val NEW = 141
+ final val PAIR = 142
+ final val TYPED = 143
+ final val NAMEDARG = 144
+ final val ASSIGN = 145
+ final val BLOCK = 146
+ final val IF = 147
+ final val CLOSURE = 148
+ final val MATCH = 149
+ final val RETURN = 150
+ final val TRY = 151
+ final val THROW = 152
+ final val REPEATED = 153
+ final val BIND = 154
+ final val ALTERNATIVE = 155
+ final val UNAPPLY = 156
+ final val ANNOTATED = 157
+ final val CASEDEF = 158
+ final val IMPLICITarg = 159
+ final val TEMPLATE = 160
+ final val SELFDEF = 161
+ final val THIS = 162
+ final val SUPER = 163
+ final val CLASSconst = 164
+ final val ENUMconst = 165
+ final val SUPERtype = 166
+ final val REFINEDtype = 167
+ final val APPLIEDtype = 168
+ final val TYPEBOUNDS = 169
+ final val TYPEALIAS = 170
+ final val ANDtype = 171
+ final val ORtype = 172
+ final val BYNAMEtype = 173
+ final val METHODtype = 174
+ final val POLYtype = 175
+ final val PARAMtype = 176
+ final val IMPLICITARG = 177
+ final val ANNOTATION = 178
+ final val PRIVATEqualified = 179
+ final val PROTECTEDqualified = 180
final val firstSimpleTreeTag = EMPTYTREE
final val firstNatTreeTag = SHARED