public override byte[] ToBytes() { // 1. (1 byte) - is: const (0), var (1) or instruction (2) // 2. (3 bytes) - Instruction number // 3. (3 bytes) - Instrcution index // 3. (3 * n byte) - Arguments: 1st byte - (1) or (2): constant or variable // - 2st and 3d bytes: index of constant of variable List <byte> bytes = new List <byte>(); bytes.Add(Element_Instruction); //Its a instrucion bytes.AddRange(InstructionNumber.ToBytes()); //Instrucion number if (Parameters == null) { return(bytes.ToArray()); } bytes.AddRange(ProgramIndex.ToBytes()); //Instrucion index foreach (var item in Parameters) { bytes.Add(item.Type == ReferenceType.Constant ? Parameter_Const : Parameter_Var); //Const or variable bytes.AddRange(item.Index.ToBytes()); //Index of argument } return(bytes.ToArray()); }
private int[] InstructionSparsity(InstructionNumber instr, SparsityInfo[] children, Dictionary <Variable, SparsityInfo> mapping) { // Just check for zero value if (System.Math.Abs(instr.Value) <= double.Epsilon) { return(new int[] { 0 }); } return(new int[0]); }
protected virtual string Translate(InstructionNumber instruction, Context context) { return(context.TranslateNumber(instruction.Value)); }
protected override string Translate(InstructionNumber instruction, CLike.Context context) { return(NumberTranslator.Translate(instruction.Value, (Context)context)); }