public OptFlag getOptFlag(byte b) { OptFlag temp = new OptFlag(); temp.flagbyte = (byte)((b & 0x0F) >> 0); temp.optbyte = (byte)((b & 0xF0) >> 4); return(temp); }
public string CondInt(byte[] buffer) { string s = ""; OptFlag Flags = getOptFlag(buffer[0]); switch (Flags.flagbyte) { case 1: //int { switch (Flags.optbyte) { case 1: //int { s = "i" + BitConverter.ToInt32(buffer, 1); break; } case 3: //argument { var value = BitConverter.ToInt32(buffer, 1); s = "a" + value; break; } case 5: //expression { return("(" + CondIntExp(buffer) + ")"); } case 6: //table { currefint.Add(BitConverter.ToInt32(buffer, 1)); s = "plot.ints[" + BitConverter.ToInt32(buffer, 1) + "]"; break; } default: { break; } } break; } case 2: //float { s = CondFloat(buffer); break; } default: { break; } } return(s); }
public string CondFloat(byte[] buffer) { string s = ""; OptFlag Flags = getOptFlag(buffer[0]); switch (Flags.flagbyte) { case 1: //int { s = CondInt(buffer); break; } case 2: //float { switch (Flags.optbyte) { case 2: //float { s = "f" + BitConverter.ToSingle(buffer, 1); break; } case 5: //expression { return("(" + CondFloatExp(buffer) + ")"); } case 6: //table { s = "plot.floats[" + BitConverter.ToInt32(buffer, 1) + "]"; break; } default: { break; } } break; } default: { break; } } return(s); }
public string CondGen(byte[] buffer) { OptFlag Flags = getOptFlag(buffer[0]); switch (Flags.flagbyte) { case 0: //bool { return(CondBool(buffer)); } case 1: //int { return(CondInt(buffer)); } default: { return(CondFloat(buffer)); } } }
public string CondBool(byte[] buffer) { string s = ""; OptFlag Flags = getOptFlag(buffer[0]); switch (Flags.flagbyte) { case 0: //bool { switch (Flags.optbyte) { case 0: //bool { s = (buffer[1] == 1 ? "Bool true" : "Bool false"); break; } case 3: //Argument { var value = BitConverter.ToInt32(buffer, 1); if (value == -1) { s = "(arg == -1)"; break; } var functionLength = BitConverter.ToInt16(buffer, 5); var tagLength = BitConverter.ToInt16(buffer, 7); string function = ""; for (int i = 0; i < functionLength; i++) { function += (char)buffer[9 + i]; } s = "Function :" + function + " Value:" + value; if (tagLength > 0) { string tag = ""; for (int i = 0; i < tagLength; i++) { function += (char)buffer[9 + functionLength + i]; } s += " Tag:" + tag; } break; } case 5: //expression { return("(" + CondBoolExp(buffer) + ")"); } case 6: //table { currefbool.Add(BitConverter.ToInt32(buffer, 1)); return("plot.bools[" + BitConverter.ToInt32(buffer, 1) + "]"); } default: { break; } } break; } case 1: //int { s = CondInt(buffer) + " != 0"; break; } case 2: //float { s = CondFloat(buffer) + " != 0"; break; } default: { break; } } return(s); }
public OptFlag getOptFlag(byte b) { OptFlag temp = new OptFlag(); temp.flagbyte = (byte)((b & 0x0F) >> 0); temp.optbyte = (byte)((b & 0xF0) >> 4); return temp; }