Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

72
LINES

< > BotCompany Repo | #1006146 // Bit Analysis 2 [evaluate expressions, works]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (4471L/29K).

!7

sS bla = [[
The images "9176714c9a935fc91e14595dbb3adddf 35731666e72dd0c9448f616ff3a7464a da9bc5a24bd503e898f69ad43bb9b92e" are the characters "yet".
  The images "412f9e0f8e177817a4fa285415c5a13f 386b289407599f31e3a7c57c3adb2587 6cd2a2284a5a6fda3a7cad3e3a048671 b0c47c014d665ec5b658f510c258dc47 b273ff598fe6afa04cfed9f9e8fb4109" are the grouped characters "[Ob]ject".
  The images "175116b749670b7b65707c10c935b42c ddaf2b9c198818c49628387ecc2910ed 3777597e39eb0de16c022293c8c91cc0 fad86bda3f716ef4e7fa9d199f6c4383 35731666e72dd0c9448f616ff3a7464a 03b96c30adaaed5b60cea4ab9bc37263" are the characters "images".
]];

p-typewriter {
  Bits bits = new Bits(bla);
  print(bits.n);
  printStruct(bits.toByteArray());
  print(quote(bits.getString()));
  
  S exp = [[chunks(8).splitAt("\"")]];
  calcPrint(exp, bits);
  exp = [[chunks(8).splitAt("\"").get(1)]];
  calcPrint(exp, bits);
  exp += [[.chunks(8).splitAt(" ")]];
  calcPrint(exp, bits);
}

static void calcPrint(S exp, O obj) {
  print(exp);
  print("  " + structureOrText(bits_prettyPrint(calcExp(exp, obj))));
}

static O calcExp(S exp, O obj) {
  L<S> tok = javaTokC(exp);
  while (nempty(tok)) {
    S f = first(tok);
    assertIsIdentifier(f);
    if (eq(get(tok, 1), "(")) {
      assertEquals("(", tok.get(1));
      assertEquals(")", tok.get(3));
      S t = tok.get(2);
      O arg; 
      if (isQuoted(t)) arg = unquote(t);
      else if (isInteger(t)) arg = parseInt(t);
      else fail("Unknown argument: " + quote(t));
      obj = call(mc(), "bits_" + f, obj, arg);
      tok = subList(tok, 4);
    } else {
      obj = call(mc(), "bits_" + f, obj);
      tok = subList(tok, 1);
    }
    if (l(tok) == 0) break;
    assertEquals(".", tok.get(0));
    tok = subList(tok, 1);
  }
  ret obj;
}

static S bits_prettyPrint(O o) {
  if (o instanceof Bits)
    ret o/Bits.getString();
  if (isListOfElementType(o, Bits))
    ret struct(map(func(Bits b) { b.getString() }, (L) o));
  ret struct(o);
}

static L<Bits> bits_chunks(Bits bits, int width) {
  ret bitsFullChunks(bits, width);
}

static L<Bits> bits_splitAt(L<Bits> l, S s) {
  ret splitBitsAtElement(l, new Bits(s));
}

static O bits_get(L l, int idx) {
  ret get(l, idx);
}

Author comment

Began life as a copy of #1006137

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006146
Snippet name: Bit Analysis 2 [evaluate expressions, works]
Eternal ID of this version: #1006146/2
Text MD5: 0a848aedf657891775b42bccd2fb7e1b
Transpilation MD5: 8175ac289e645b14d40540598867e5e2
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-19 22:44:27
Source code size: 2272 bytes / 72 lines
Pitched / IR pitched: No / No
Views / Downloads: 511 / 981
Version history: 1 change(s)
Referenced in: [show references]