1

I have been reading the ECMA CLI spec:

http://www.ecma-international.org/publications/standards/Ecma-335.htm

and I'm puzzled by the use of commas within the stack transition diagrams for some of the instructions. For example, here is the documented stack transition for ldloc (load argument onto the stack):

… => …, value

And here is the stack transition for ldsfld (load static field of a class):

…, => …, value

My question has to do with the extra comma before the instruction: Does it have any significance? Another example is jmp (jump to method):

… => …

and br.<length> (unconditional branch):

…, => …

There are also examples of trailing commas such as for nop and starg.<length>. Is this just an inconsistency or is there a nuance to this notation that I don't understand?

Wizard Brony
  • 111
  • 5
  • 1
    It's safe to say this holds no significance. The online docs for the individual opcodes for [`jmp`](https://docs.microsoft.com/dotnet/api/system.reflection.emit.opcodes.jmp) and [`br.S`](https://docs.microsoft.com/dotnet/api/system.reflection.emit.opcodes.br_s) both use the much more explicit description "no evaluation stack behaviors are performed by this operation". (`ldloc` and `ldsfld` likewise both state, in words, that a single value is pushed onto the stack.) Fortunately the commas appear to be superfluous rather than [blasphemous](https://en.wikipedia.org/wiki/Bible_errata#King_James). – Jeroen Mostert Apr 15 '20 at 12:42

1 Answers1

0

The commas are simply there to show you that the rest of the evaluation stack doesn't change. The stack could have values before (it's very common to put stuff on the stack and do other operations while they're there). If you see … => … - this instruction doesn't change the stack at all. If you see … => …, value - this instruction adds one value to the stack If you see …, value => … - this instruction removes one value from the stack

Egozy
  • 380
  • 2
  • 13
  • That doesn't answer my question. Basically my question is what's the difference between `… => …` and `…, => …` – Wizard Brony Jun 17 '20 at 13:45
  • Oh, I totally missed that. I can only assume that this is a mistake in the document. They absolutely have no meaning. – Egozy Jun 17 '20 at 13:47