Skip to content

Commit

Permalink
Use strings for namespace disambiguation in AS3
Browse files Browse the repository at this point in the history
Also cleans up memory rather than leaking it now
  • Loading branch information
piepie62 committed Feb 11, 2023
1 parent 03613ee commit 2fd7ccf
Show file tree
Hide file tree
Showing 51 changed files with 638 additions and 338 deletions.
93 changes: 93 additions & 0 deletions ANEBytecodeEditorSWC.as3proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="CustomBuild" />
<movie input="" />
<movie path="ANEBytecodeEditor.swc" />
<movie fps="0" />
<movie width="0" />
<movie height="0" />
<movie version="17" />
<movie minorVersion="0" />
<movie platform="AIR" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="src" />
</classpaths>
<!-- Build options -->
<build>
<option accessible="False" />
<option advancedTelemetry="False" />
<option allowSourcePathOverlap="False" />
<option benchmark="False" />
<option es="False" />
<option inline="False" />
<option locale="" />
<option loadConfig="" />
<option optimize="True" />
<option omitTraces="True" />
<option showActionScriptWarnings="True" />
<option showBindingWarnings="True" />
<option showInvalidCSS="True" />
<option showDeprecationWarnings="True" />
<option showUnusedTypeSelectorWarnings="True" />
<option strict="True" />
<option useNetwork="True" />
<option useResourceBundleMetadata="True" />
<option warnings="True" />
<option verboseStackTraces="False" />
<option linkReport="" />
<option loadExterns="" />
<option staticLinkRSL="True" />
<option additional="-swf-version=11&#xA;--" />
<option compilerConstants="" />
<option minorVersion="" />
</build>
<!-- SWC Include Libraries -->
<includeLibraries>
<!-- example: <element path="..." /> -->
</includeLibraries>
<!-- SWC Libraries -->
<libraryPaths>
<!-- example: <element path="..." /> -->
</libraryPaths>
<!-- External Libraries -->
<externalLibraryPaths>
<!-- example: <element path="..." /> -->
</externalLibraryPaths>
<!-- Runtime Shared Libraries -->
<rslPaths>
<!-- example: <element path="..." /> -->
</rslPaths>
<!-- Intrinsic Libraries -->
<intrinsics>
<!-- example: <element path="..." /> -->
</intrinsics>
<!-- Assets to embed into the output SWF -->
<library>
<!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
</library>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand>"$(BaseDir)\Tools\swcbuild\swcbuild.exe" "$(ProjectPath)" "-compiler=$(CompilerPath)" "-debug=$(BuildConfig)" "-library=C:\Program Files (x86)\FlashDevelop\Library" -asdoc=true -keep-asdoc=false</preBuildCommand>
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Unknown" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
10 changes: 5 additions & 5 deletions AS3/src/com/cff/anebe/ir/ASNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package com.cff.anebe.ir
/** Namespace name. */
public var name:String;

/** If there are multiple namespaces with the same name, disambiguates them. This should only very rarely be non-zero. */
public var id:int = 0;
/** If there are multiple namespaces with the same name, disambiguates them. This should only very rarely be non-null. */
public var secondaryName:String;

/** Type string for private namespaces */
public static const TYPE_PRIVATE:String = "PrivateNamespace";
Expand All @@ -40,13 +40,13 @@ package com.cff.anebe.ir
* Builds an ASNamespace from scratch. Should probably not be used; see instead helper functions in the package com.cff.anebe.ir.namespaces
* @param type Namespace type
* @param name Namespace name
* @param id Disambiguation ID
* @param secondaryName Namespace secondary name, if disambiguation is required
*/
public function ASNamespace(type:String, name:String, id:int = 0)
public function ASNamespace(type:String, name:String, secondaryName:String = null)
{
this.type = type;
this.name = name;
this.id = id;
this.secondaryName = secondaryName;
}
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/ExplicitNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents an ExplicitNamespace
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function ExplicitNamespace(name:String, id:int = 0):ASNamespace
public function ExplicitNamespace(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_EXPLICIT, name, id);
return new ASNamespace(ASNamespace.TYPE_EXPLICIT, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/NormalNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents a Namespace
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function NormalNamespace(name:String, id:int = 0):ASNamespace
public function NormalNamespace(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_NORMAL, name, id);
return new ASNamespace(ASNamespace.TYPE_NORMAL, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/PackageInternalNs.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents a PackageInternalNs
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function PackageInternalNs(name:String, id:int = 0):ASNamespace
public function PackageInternalNs(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_PACKAGEINTERNAL, name, id);
return new ASNamespace(ASNamespace.TYPE_PACKAGEINTERNAL, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/PackageNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents a PackageNamespace
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function PackageNamespace(name:String, id:int = 0):ASNamespace
public function PackageNamespace(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_PACKAGE, name, id);
return new ASNamespace(ASNamespace.TYPE_PACKAGE, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/PrivateNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents an PrivateNamespace
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function PrivateNamespace(name:String, id:int = 0):ASNamespace
public function PrivateNamespace(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_PRIVATE, name, id);
return new ASNamespace(ASNamespace.TYPE_PRIVATE, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/ProtectedNamespace.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents a ProtectedNamespace
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function ProtectedNamespace(name:String, id:int = 0):ASNamespace
public function ProtectedNamespace(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_PROTECTED, name, id);
return new ASNamespace(ASNamespace.TYPE_PROTECTED, name, disambiguator);
}
}
6 changes: 3 additions & 3 deletions AS3/src/com/cff/anebe/ir/namespaces/StaticProtectedNs.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.cff.anebe.ir.namespaces
/**
* Builds an ASNamespace that represents a StaticProtectedNs
* @param name Name of the namespace
* @param id If there are multiple of the same namespace name and type, disambiguates between them; should almost always be zero
* @param disambiguator If there are multiple of the same namespace name and type, disambiguates between them; should almost always be null
* @return Built ASNamespace
*/
public function StaticProtectedNs(name:String, id:int = 0):ASNamespace
public function StaticProtectedNs(name:String, disambiguator:String = null):ASNamespace
{
return new ASNamespace(ASNamespace.TYPE_STATICPROTECTED, name, id);
return new ASNamespace(ASNamespace.TYPE_STATICPROTECTED, name, disambiguator);
}
}
2 changes: 2 additions & 0 deletions Native/BytecodeEditor/BytecodeEditor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@
<ClInclude Include="include\enums\TraitAttribute.hpp" />
<ClInclude Include="include\enums\TraitKind.hpp" />
<ClInclude Include="include\SWF\SWFFile.hpp" />
<ClInclude Include="include\utils\ANEFunctionContext.hpp" />
<ClInclude Include="include\utils\ANEUtils.hpp" />
<ClInclude Include="include\utils\BidirectionalMap.hpp" />
<ClInclude Include="include\utils\generic_hash.hpp" />
<ClInclude Include="include\utils\RefBuilder.hpp" />
<ClInclude Include="include\utils\SmallTrivialVector.hpp" />
<ClInclude Include="include\utils\StringBuilder.hpp" />
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/ABCFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdint.h>
#include <string>

namespace ABC
namespace SWFABC
{
struct ABCFile
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/ABCReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <stdint.h>
#include <string>

namespace ABC
namespace SWFABC
{
class ABCReader
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/ABCWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <stdint.h>
#include <string>

namespace ABC
namespace SWFABC
{
class ABCWriter
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Class
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ABC/Label.hpp"
#include <string>

namespace ABC
namespace SWFABC
{
struct Error
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/ExceptionInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ABC/Label.hpp"
#include <stdint.h>

namespace ABC
namespace SWFABC
{
struct ExceptionInfo
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Instance
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <variant>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Instruction
{
Expand Down
4 changes: 2 additions & 2 deletions Native/BytecodeEditor/include/ABC/Label.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <stdint.h>
#include <compare>
#include <stdint.h>

namespace ABC
namespace SWFABC
{
struct Label
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Metadata
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/MethodBody.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct MethodBody
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/MethodInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct MethodInfo
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Multiname.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <variant>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Multiname
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Namespace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "enums/ABCType.hpp"
#include <stdint.h>

namespace ABC
namespace SWFABC
{
struct Namespace
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/OptionDetail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "enums/ABCType.hpp"
#include <stdint.h>

namespace ABC
namespace SWFABC
{
struct OptionDetail
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/Script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct Script
{
Expand Down
2 changes: 1 addition & 1 deletion Native/BytecodeEditor/include/ABC/TraitsInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdint.h>
#include <vector>

namespace ABC
namespace SWFABC
{
struct TraitsInfo
{
Expand Down
Loading

0 comments on commit 2fd7ccf

Please sign in to comment.