emitted.
* *Instr.cs: Adjust emit method to accept a methoddef
svn path=/trunk/mcs/; revision=16824
public class BranchInstr : IInstr {
private PEAPI.BranchOp op;
- private MethodDef method;
private string label;
- public BranchInstr (PEAPI.BranchOp op, MethodDef method, string label)
+ public BranchInstr (PEAPI.BranchOp op, string label)
{
this.op = op;
- this.method = method;
this.label = label;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
- cil.Branch (op, method.GetLabelDef (label));
+ cil.Branch (op, meth.GetLabelDef (label));
}
}
this.param = param;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
PEAPI.Type[] param_array;
PEAPI.CalliSig callisig;
+2003-07-29 Jackson Harper <jackson@latitudegeo.com>
+
+ * IInstr.cs: Instructions now get their parent method when being
+ emitted.
+ * *Instr.cs: Adjust emit method to accept a methoddef
+
2003-07-27 Jackson Harper <jackson@latitudegeo.com>
* CodeGen.cs: Set the assembly name when creating the PEFile.
this.operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
operand.Resolve (code_gen);
-
cil.FieldInst (op, operand.PeapiField);
}
/// <summary>
/// Add this instruction to the supplied codebuffer
/// </summary>
- void Emit (CodeGen code_gen, PEAPI.CILInstructions cil);
+ void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil);
}
}
this.operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
cil.IntInst (op, operand);
}
l_operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
switch (op) {
case MiscInstr.ldc_r8:
this.operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
cil.ldstr (operand);
}
this.type_ref = type_ref;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
if (field_ref != null) {
field_ref.Resolve (code_gen);
if (label_pos >= label_info.Length)
next_label_pos = -1;
}
- instr.Emit (code_gen, cil);
+ instr.Emit (code_gen, this, cil);
}
}
this.operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
operand.Resolve (code_gen);
cil.MethInst (op, operand.PeapiMethod);
this.op = op;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
cil.Inst (op);
}
public class SwitchInstr : IInstr {
private ArrayList label_list;
- private MethodDef method;
- public SwitchInstr (ArrayList label_list, MethodDef method)
+ public SwitchInstr (ArrayList label_list)
{
this.label_list = label_list;
- this.method = method;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth, PEAPI.CILInstructions cil)
{
int count = 0;
PEAPI.CILLabel[] label_array = new PEAPI.CILLabel[label_list.Count];
foreach (object lab in label_list) {
if (lab is string) {
- label_array[count++] = method.GetLabelDef ((string) lab);
+ label_array[count++] = meth.GetLabelDef ((string) lab);
} else {
// TODO: int32 labels
throw new NotImplementedException ("offsets in switch statements.");
public class TryBlock : IInstr {
- private MethodDef method;
private string from_label;
private string to_label;
private ArrayList clause_list;
}
- public void SetMethod (MethodDef method)
- {
- this.method = method;
- }
-
public void AddSehClause (ISehClause clause)
{
clause_list.Add (clause);
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
- PEAPI.CILLabel from = method.GetLabelDef (from_label);
- PEAPI.CILLabel to = method.GetLabelDef (to_label);
+ PEAPI.CILLabel from = meth.GetLabelDef (from_label);
+ PEAPI.CILLabel to = meth.GetLabelDef (to_label);
PEAPI.TryBlock try_block = new PEAPI.TryBlock (from, to);
foreach (ISehClause clause in clause_list)
- try_block.AddHandler (clause.Resolve (code_gen, method));
+ try_block.AddHandler (clause.Resolve (code_gen, meth));
cil.AddTryBlock (try_block);
}
this.operand = operand;
}
- public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ public void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
operand.Resolve (code_gen);
-
cil.TypeInst (op, operand.PeapiType);
}