Skip to content

Commit

Permalink
Add support for 0.8.28
Browse files Browse the repository at this point in the history
  • Loading branch information
cd1m0 committed Dec 3, 2024
1 parent 6dcf747 commit 3e2ca30
Show file tree
Hide file tree
Showing 10 changed files with 15,976 additions and 15,833 deletions.
1 change: 1 addition & 0 deletions src/ast/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum DataLocation {
Storage = "storage",
Memory = "memory",
CallData = "calldata",
Transient = "transient",
Default = "default"
}

Expand Down
4 changes: 4 additions & 0 deletions src/ast/writing/ast_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ class VariableDeclarationWriter extends ASTNodeWriter {
elements.push(" ", node.vOverrideSpecifier);
}

if (node.storageLocation === DataLocation.Transient) {
elements.push(" ", node.storageLocation);
}

elements.push(" ", node.name);

if (node.vValue) {
Expand Down
4 changes: 3 additions & 1 deletion src/compile/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export const CompilerVersions08 = [
"0.8.23",
"0.8.24",
"0.8.25",
"0.8.26"
"0.8.26",
"0.8.27",
"0.8.28"
];

export const CompilerSeries = [
Expand Down
6 changes: 5 additions & 1 deletion src/types/infer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,11 @@ export class InferType {
*/
inferVariableDeclLocation(decl: VariableDeclaration): DataLocation {
if (decl.stateVariable) {
return decl.constant ? DataLocation.Memory : DataLocation.Storage;
return decl.constant
? DataLocation.Memory
: decl.storageLocation === DataLocation.Default
? DataLocation.Storage
: decl.storageLocation;
}

if (decl.storageLocation !== DataLocation.Default) {
Expand Down
6 changes: 3 additions & 3 deletions src/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export function specializeType(type: TypeNode, loc: DataLocation): TypeNode {
// Always treat map keys as in-memory copies
const concreteKeyT = specializeType(type.keyType, DataLocation.Memory);
// The result of map indexing is always a pointer to a value that lives in storage
const concreteValueT = specializeType(type.valueType, DataLocation.Storage);
const concreteValueT = specializeType(type.valueType, DataLocation.Storage); // @todo update when maps supported in transient
// Maps always live in storage
return new PointerType(new MappingType(concreteKeyT, concreteValueT), DataLocation.Storage);
return new PointerType(new MappingType(concreteKeyT, concreteValueT), DataLocation.Storage); // @todo update when maps supported in transient
}

// TODO: What to do about string literals?
Expand Down Expand Up @@ -362,7 +362,7 @@ export function castable(fromT: TypeNode, toT: TypeNode, compilerVersion: string
toT.to instanceof ArrayType &&
fromT.to.size !== undefined &&
toT.to.size === undefined &&
toT.location === DataLocation.Storage &&
toT.location === DataLocation.Storage && // @todo (dimo) Update this when arrays are supported in transient
eq(fromT.to.elementT, toT.to.elementT)
) {
return true;
Expand Down
70 changes: 10 additions & 60 deletions test/integration/compile/latest_08.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,11 @@ const encounters = new Map<string, number>([
["ImportDirective", 1],
["StructDefinition", 1],
["StructuredDocumentation", 6],
["VariableDeclaration", 85],
["ElementaryTypeName", 69],
["VariableDeclaration", 86],
["ElementaryTypeName", 70],
["EnumDefinition", 2],
["EnumValue", 6],
["ContractDefinition", 22],
["FunctionDefinition", 36],
["ParameterList", 97],
["Block", 52],
["VariableDeclarationStatement", 16],
["Literal", 43],
["UncheckedBlock", 4],
["ExpressionStatement", 25],
["UnaryOperation", 6],
["Identifier", 112],
["Return", 15],
["InheritanceSpecifier", 1],
["IdentifierPath", 36],
["UsingForDirective", 3],
["UserDefinedTypeName", 27],
["ModifierInvocation", 2],
["FunctionCall", 49],
["MemberAccess", 44],
["OverrideSpecifier", 1],
["ElementaryTypeNameExpression", 4],
["NewExpression", 2],
["TryStatement", 2],
["TryCatchClause", 8],
["IfStatement", 3],
["BinaryOperation", 24],
["EventDefinition", 7],
["ModifierDefinition", 1],
["PlaceholderStatement", 1],
["TupleExpression", 9],
["EmitStatement", 6],
["WhileStatement", 1],
["Continue", 1],
["DoWhileStatement", 1],
["Break", 1],
["ForStatement", 1],
["InlineAssembly", 6],
["ErrorDefinition", 5],
["RevertStatement", 3],
["UserDefinedValueTypeDefinition", 5],
["FunctionTypeName", 4],
["Assignment", 5],
["Mapping", 1],
["IndexAccess", 4],
["SourceUnit", 1],
["PragmaDirective", 2],
["ImportDirective", 1],
["StructDefinition", 1],
["StructuredDocumentation", 6],
["VariableDeclaration", 85],
["ElementaryTypeName", 69],
["EnumDefinition", 2],
["EnumValue", 6],
["ContractDefinition", 22],
["ContractDefinition", 23],
["FunctionDefinition", 36],
["ParameterList", 97],
["Block", 52],
Expand Down Expand Up @@ -172,11 +120,11 @@ for (const compilerKind of PossibleCompilerKinds) {
// console.log(sourceUnit.print());
// console.log(sourceUnit.getChildren().length);

expect(sourceUnit.id).toEqual(878);
expect(sourceUnit.src).toEqual("0:10179:0");
expect(sourceUnit.id).toEqual(881);
expect(sourceUnit.src).toEqual("0:10231:0");
expect(sourceUnit.absolutePath).toEqual(mainSample);
expect(sourceUnit.children.length).toEqual(39);
expect(sourceUnit.getChildren().length).toEqual(868);
expect(sourceUnit.children.length).toEqual(40);
expect(sourceUnit.getChildren().length).toEqual(871);
});

it(`Validate parsed output (${astKind})`, () => {
Expand All @@ -186,9 +134,11 @@ for (const compilerKind of PossibleCompilerKinds) {
expect(sourceUnitImprint.ASTNode).toBeUndefined();

// Uncomment following lines to get the current unit snapshot data:
// let s = "";
// for (const [type, nodes] of Object.entries(sourceUnitImprint)) {
// console.log(`["${type}", ${nodes.length}],`);
// s += `["${type}", ${nodes.length}],\n`;
// }
// console.log(s);

for (const [type, count] of encounters.entries()) {
expect(sourceUnitImprint[type]).toBeDefined();
Expand Down
Loading

0 comments on commit 3e2ca30

Please sign in to comment.