//utility functions for working with array initilizations private int GetArrayInitilizationElementCount(AtlasParser.ArrayInitilizerContext context) { if (context.OSQUAREBRACE() != null) { var bytes = BigInteger.Parse(context.INT().GetText()).ToByteArray(); return(AtlasCPU.IntFromBytes(bytes.ElementAtOrDefault(3), bytes.ElementAtOrDefault(2), bytes.ElementAtOrDefault(1), bytes.ElementAtOrDefault(0))); } else { return(context.literal().Count); } }
//codegen Pass private void EmitArray(AtlasParser.ArrayInitilizerContext context) { if (context.OSQUAREBRACE() != null) { //emit zeros eqal to the number of elements in the array int size = GetArrayInitilizationElementCount(context); for (int i = 0; i < size; i++) { EmitWord(0); } } else { foreach (var literal in context.literal()) { EmitLiteral(literal); } } }