+2003-04-30 Jackson Harper <jackson@latitudegeo.com>
+
+ * MethodDef.cs: Accept and emit instructions.
+ * CodeGen.cs: Fix typo
+ * IInstr.cs: New file - Interface for instructions that are added to methods
+ * IntInstr.cs: New file - Instruction that takes a single int
+ param
+ * LdstrInstr.cs: New file - ldstr instruction (the only
+ instruction that takes a string parameter)
+
2003-04-28 Jackson Harper <jackson@latitudegeo.com>
* InstrTable.cs: Much simpler system. All tokens go into one
get { return current_typedef; }\r
}\r
\r
- public MethodDef CurrentMethoDef {\r
+ public MethodDef CurrentMethodDef {\r
get { return current_methoddef; }\r
}\r
\r
--- /dev/null
+//
+// Mono.ILASM.IInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public interface IInstr {
+
+ /// <summary>
+ /// Add this instruction to the supplied codebuffer
+ /// </summary>
+ void Emit (CodeGen code_gen, PEAPI.CILInstructions cil);
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.IntInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class IntInstr : IInstr {
+
+ private PEAPI.IntOp op;
+ private int operand;
+
+ public IntInstr (PEAPI.IntOp op, int operand)
+ {
+ this.op = op;
+ this.operand = operand;
+ }
+
+ public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ {
+ cil.IntInst (op, operand);
+ }
+
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.LdstrInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class LdstrInstr : IInstr {
+
+ private string operand;
+
+ public LdstrInstr (string operand)
+ {
+ this.operand = operand;
+ }
+
+ public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+ {
+ cil.ldstr (operand);
+ }
+
+ }
+
+}
+
private string signature;
private ITypeRef ret_type;
private ArrayList param_list;
+ private ArrayList inst_list;
private PEAPI.MethodDef methoddef;
private bool is_defined;
this.ret_type = ret_type;
this.param_list = param_list;
+ inst_list = new ArrayList ();
is_defined = false;
CreateSignature ();
}
methoddef = classdef.AddMethod (meth_attr, impl_attr,
name, ret_type.PeapiType, param_array);
+ if (inst_list.Count > 0) {
+ PEAPI.CILInstructions cil = methoddef.CreateCodeBuffer ();
+ foreach (IInstr instr in inst_list)
+ instr.Emit (code_gen, cil);
+ }
+
is_defined = true;
}
+ public void AddInstr (IInstr instr)
+ {
+ inst_list.Add (instr);
+ }
+
private void CreateSignature ()
{
StringBuilder builder = new StringBuilder ();