Skip to content

Commit 68d2124

Browse files
committed
Use instruction references instead of labels
Allows editing methods without having to edit every single label-bearing instruction
1 parent 4b249a3 commit 68d2124

8 files changed

Lines changed: 304 additions & 164 deletions

File tree

AS3/src/com/cff/anebe/ir/ASError.as

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,14 @@ package com.cff.anebe.ir
77
public class ASError
88
{
99
/** The instruction at which this error occurred */
10-
public var loc:ASLabel;
10+
public var loc:ASInstruction;
1111

1212
/** The message that the assembler gave for this error */
1313
public var message:String;
1414

15-
public function ASError(loc:ASLabel = null, message:String = "")
15+
public function ASError(loc:ASInstruction, message:String = "")
1616
{
17-
if (loc != null)
18-
{
19-
this.loc = loc;
20-
}
21-
else
22-
{
23-
this.loc = new ASLabel(0, 0);
24-
}
25-
17+
this.loc = loc;
2618
this.message = message;
2719
}
2820
}

AS3/src/com/cff/anebe/ir/ASException.as

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ package com.cff.anebe.ir
77
public class ASException
88
{
99
/** The instruction where the exception catch range starts */
10-
public var from:ASLabel;
10+
public var from:ASInstruction;
1111

1212
/** The instruction where the exception catch range stops */
13-
public var to:ASLabel;
13+
public var to:ASInstruction;
1414

1515
/** The target instruction for the catch block */
16-
public var target:ASLabel;
16+
public var target:ASInstruction;
1717

1818
/** The type of the exception caught by this handler. Null means the any type. */
1919
public var exceptionType:ASMultiname;
@@ -29,35 +29,11 @@ package com.cff.anebe.ir
2929
* @param exceptionType The type of the exception caught by this handler. Null is interpreted as the any type
3030
* @param exceptionName The name of the variable the exception will be assigned to for this catch block. Null is interpreted as no name
3131
*/
32-
public function ASException(from:ASLabel = null, to:ASLabel = null, target:ASLabel = null, exceptionType:ASMultiname = null, exceptionName:ASMultiname = null)
32+
public function ASException(from:ASInstruction, to:ASInstruction, target:ASInstruction, exceptionType:ASMultiname = null, exceptionName:ASMultiname = null)
3333
{
34-
if (from != null)
35-
{
36-
this.from = from;
37-
}
38-
else
39-
{
40-
this.from = new ASLabel(0, 0);
41-
}
42-
43-
if (to != null)
44-
{
45-
this.to = to;
46-
}
47-
else
48-
{
49-
this.to = new ASLabel(0, 0);
50-
}
51-
52-
if (target != null)
53-
{
54-
this.target = target;
55-
}
56-
else
57-
{
58-
this.target = new ASLabel(0, 0);
59-
}
60-
34+
this.from = from;
35+
this.to = to;
36+
this.target = target;
6137
this.exceptionType = exceptionType;
6238
this.exceptionName = exceptionName;
6339
}

AS3/src/com/cff/anebe/ir/ASInstruction.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ package com.cff.anebe.ir
1010
public var opcode:String;
1111

1212
/**
13-
* A list of the arguments this instruction takes. The exact format of each OPCode is not currently listed here,
14-
* but the valid types inside this array are int, uint, Number, String, ASNamespace, ASMultiname, ASClass, ASMethod, ASLabel, or Vector.<ASLabel>.
13+
* A list of the arguments this instruction takes.
14+
* The exact format of each OPCode is not currently listed here, but the valid types inside this array are int, uint,
15+
* Number, String, ASNamespace, ASMultiname, ASClass, ASMethod, ASInstruction, or Vector.<ASInstruction>.
16+
* Any ASInstruction contained in this array must be a reference to an instruction in the body of the method in which this instruction appears.
1517
*/
1618
public var args:Array;
1719

AS3/src/com/cff/anebe/ir/ASLabel.as

Lines changed: 0 additions & 27 deletions
This file was deleted.

Native/BytecodeEditor/include/utils/ANEUtils.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ std::shared_ptr<ASASM::Method> ConvertMethod(FREObject o);
176176
FREObject ConvertMethod(const ASASM::Method& m);
177177
ASASM::MethodBody ConvertMethodBody(FREObject o);
178178
FREObject ConvertMethodBody(const ASASM::MethodBody& b);
179-
ASASM::Exception ConvertException(FREObject o);
180-
FREObject ConvertException(const ASASM::Exception& e);
181-
ABC::Error ConvertError(FREObject o);
182-
FREObject ConvertError(const ABC::Error& e);
183-
ABC::Label ConvertLabel(FREObject o);
184-
FREObject ConvertLabel(const ABC::Label& l);
185-
ASASM::Instruction ConvertInstruction(FREObject o);
186-
FREObject ConvertInstruction(const ASASM::Instruction& i);
179+
ASASM::Exception ConvertException(FREObject o, const std::vector<FREObject>& allInstrs);
180+
FREObject ConvertException(const ASASM::Exception& e, const std::vector<FREObject>& allInstrs);
181+
ABC::Error ConvertError(FREObject o, const std::vector<FREObject>& allInstrs);
182+
FREObject ConvertError(const ABC::Error& e, const std::vector<FREObject>& allInstrs);
183+
ABC::Label ConvertLabel(FREObject o, const std::vector<FREObject>& allInstrs);
184+
FREObject ConvertLabel(const ABC::Label& l, const std::vector<FREObject>& allInstrs);
185+
ASASM::Instruction ConvertInstruction(FREObject o, const std::vector<FREObject>& allInstrs);
186+
std::pair<FREObject, bool> ConvertInstruction(const ASASM::Instruction& i);
187187
ASASM::Value ConvertValue(FREObject o);
188188
FREObject ConvertValue(const ASASM::Value& v);
189189

0 commit comments

Comments
 (0)