diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 71b94d91db03ed717883d2fb94b1b0e28737f8b3..3bcccb3222f904ac987e6a55ca5427864b789d73 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -27,7 +27,7 @@ fileprivate let RunNearStackLimitGenerator = CodeGenerator("RunNearStackLimitGen /// ArkTS Generators fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstanceGenerator") { b, n in - let builtin = chooseUniform(from: ["Stack", "HashMap"]) + let builtin = chooseUniform(from: ["Stack", "HashMap", "HashSet"]) let constructor = b.loadBuiltin(builtin) b.construct(constructor) } @@ -36,11 +36,15 @@ fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstan fileprivate let arkTSStack = ILType.iterable + ILType.object(ofGroup: "Stack", withProperties: ["length"], withMethods: ["push", "pop", "peek", "locate", "forEach", "isEmpty"]) /// Type of a ArkTS HashMap object. fileprivate let arkTSHashMap = ILType.iterable + ILType.object(ofGroup: "HashMap", withProperties: ["length"], withMethods: ["isEmpty", "hasKey", "hasValue", "get", "setAll", "set", "remove", "clear", "keys", "values", "replace", "forEach", "entries"]) +/// Type of a ArkTS HashSet object. +fileprivate let arkTSHashSet = ILType.iterable + ILType.object(ofGroup: "HashSet", withProperties: ["length"], withMethods: ["isEmpty", "has", "add", "remove", "clear", "values", "forEach", "entries"]) /// Type of the ArkTS Stack constructor builtin. fileprivate let arkTSStackConstructor = ILType.constructor([] => arkTSStack) /// Type of the ArkTS HashMap constructor builtin. fileprivate let arkTSHashMapConstructor = ILType.constructor([] => arkTSHashMap) +/// Type of the ArkTS HashMap constructor builtin. +fileprivate let arkTSHashSetConstructor = ILType.constructor([] => arkTSHashSet) /// ObjectGroup modelling ArkTS Stack objects fileprivate let arkTSStacks = ObjectGroup( @@ -83,6 +87,25 @@ fileprivate let arkTSHashMaps = ObjectGroup( ] ) +/// ObjectGroup modelling ArkTS HashSet objects +fileprivate let arkTSHashSets = ObjectGroup( + name: "HashSet", + instanceType: arkTSHashSet, + properties: [ + "length" : .number, + ], + methods: [ + "isEmpty" : [] => .boolean, + "has" : [.anything] => .boolean, + "add" : [.anything] => .boolean, + "remove" : [.anything] => .boolean, + "clear" : [] => .undefined, + "values" : [] => .object(), // returns an array iterator + "forEach" : [.function([.opt(.anything), .opt(.anything), .opt(arkTSHashSet)] => .undefined), .opt(.object())] => .undefined, + "entries" : [] => .object(), + ] +) + let arkProfile = Profile( processArgs: { randomize in var args = [ @@ -100,8 +123,9 @@ let arkProfile = Profile( codePrefix: """ let arkPrivate = globalThis.ArkPrivate; - arkPrivate.Load(arkPrivate.Stack); - arkPrivate.Load(arkPrivate.HashMap); + var Stack = arkPrivate.Load(arkPrivate.Stack); + var HashMap = arkPrivate.Load(arkPrivate.HashMap); + var HashSet = arkPrivate.Load(arkPrivate.HashSet); function bgc() { for(let i=0; i<0x10000; i+=1) {new String();} @@ -146,11 +170,13 @@ let arkProfile = Profile( "bgc" : .function([] => .undefined), "Stack" : arkTSStackConstructor, "HashMap" : arkTSHashMapConstructor, + "HashSet" : arkTSHashSetConstructor, ], additionalObjectGroups: [ arkTSStacks, arkTSHashMaps, + arkTSHashSets, ], optionalPostProcessor: nil