public long ActualMemoryDistanceFrom(Placeholder other) { //these requires might be wrong for some specific cases Require.True(region.MemoryLocation != 0); Require.True(other.region.MemoryLocation != 0); return((region.MemoryLocation + offset) - (other.region.MemoryLocation + other.offset)); }
public void AddVariable(Identifier name, TypeReference type, int slot, bool readOnly) { if (name.Data == "this") { Require.True(readOnly); } contexts.Peek().AddVariable(name, type, slot, readOnly); }
public void Align(int alignment, byte fill) { Require.True(alignment >= 1); Require.True(alignment <= 16); while ((stream.Position % alignment) != 0) { WriteByte(fill); } }
public void RevertLookahead() { Require.True(lookaheadEnabled); lookaheadEnabled = false; while (lookahead.Count > 0) { buffer.Insert(0, lookahead.Pop()); } }
public void EnterDefinitionContext(Definition definition) { Require.True(contexts.Count == 0); Require.Unassigned(currentDefinition); currentDefinition = definition; Context context = CreateContext(); context.Setup(null, false); contexts.Push(context); }
public void CheckEmpty() { foreach (Field field in fieldWritten.Keys) { Require.True(field.GetModifiers.Static); } Require.True(variables.Count == 0); Require.True(varBySlot.Count == 0); Require.True(variableIncomplete.Count == 0); Require.True(variableWrite.Count == 0); Require.True(variableRead.Count == 0); }
public void SetValue(int data) { Require.True(data <= short.MaxValue); Require.True(data >= short.MinValue); long pos = stream.Position; stream.Position = position; unchecked { stream.WriteByte((byte)((data >> 0) & 0xff)); stream.WriteByte((byte)((data >> 8) & 0xff)); } stream.Position = pos; }
private void FillBuf() { if (length == -1) { return; // eof } Require.True(length - offset == 0); length = reader.Read(rbuffer, 0, rbuffer.Length); if (length == 0) { length = -1; } offset = 0; }
public string FirstFromSet(Set <string> filenames) { Require.True(filenames.Count > 0); while (true) { lock (responses_lock) { foreach (var file in responses.Keys) { if (filenames.Contains(file)) { return(file); } } } newResponse.WaitOne(); } }
public static byte[] GetBytes(string hex) { if (hex == null) { throw new ArgumentNullException("hex"); } Require.True((hex.Length & 1) == 0); byte[] result = new byte[hex.Length / 2]; for (int i = 0; i < result.Length; ++i) { byte c = byte.Parse(hex.Substring(i * 2, 1), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture); byte d = byte.Parse(hex.Substring(i * 2 + 1, 1), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture); result[i] = (byte)((c << 4) + d); } return(result); }
public void WriteULEB(long data) { Require.True(data >= 0); while (true) { byte x = (byte)(data & 0x7f); data = data >> 7; if (data != 0) { x |= 0x80; } WriteByte(x); if (data == 0) { break; } } }
public void SetImplicitFields(int slot, TypeReference type) { Require.True(type.IsDefinition || type.IsStatic); contexts.Peek().SetImplicitFields(slot, type); }
public Expression Reduce() { int level = 0; while (list.Count > 1) { Require.True(level <= precedence.highestLevel); // needs to be a for loop, the list gets modified in action //forward Opera_nd_tor item; for (int j = 0; j < 2; ++j) { bool leftToRight = j == 0; int i; if (leftToRight) i = -1; else i = list.Count; while (true) { if (leftToRight) { i++; if (i == list.Count) break; } else { if (i == 0) break; i--; } item = list[i]; if (item.IsOperator && (item.Precedence == level) && (item.LeftToRight == leftToRight)) { switch (item.Kind) { case OperatorKind.Infix: { i = i - 1; Expression left = list[i].Expression; Expression right = list[i + 2].Expression; list.RemoveRange(i, 3); list.Insert(i, item.ReduceInfix(left, right)); break; } case OperatorKind.Prefix: { Expression right = list[i + 1].Expression; list.RemoveRange(i, 2); list.Insert(i, item.ReducePrefix(right)); break; } case OperatorKind.Postfix: { i = i - 1; Expression left = list[i].Expression; list.RemoveRange(i, 2); list.Insert(i, item.ReducePostFix(left)); break; } default: { Require.NotCalled(); break; } } } } } level++; } Expression result = list[0].Expression; list.Clear(); return result; }
public long MemoryDistanceFrom(Placeholder other) { Require.True(region == other.region); return(offset - other.offset); }