internal void GenerateByteCode() { this.currentItem = currentItem.GetHighest(); this.currentItem.Cleanup(); Context context = new Context(); this.commands = GetCommands(context, currentItem.subItems, 0); this.StackSize = context.nextAddress; commands.Insert(0, new Command(ECommand.STACKALLOC, StackSize)); }
public Function() { currentItem = new SyntaxItem(null, null, -1, this); }
public SyntaxItem(string data, SyntaxItem parent, int line, Function function) { if (data != null) { data = data.Trim(); } this.line = line; this.parent = parent; this.data = data; this.function = function; if (parent != null) { parentPosition = parent.subItems.Count; parent.subItems.Add(this); } if (string.IsNullOrWhiteSpace(data)) { itemType = ESyntaxItemType.NOP; } else if (new string[] { "varbit", "3bit", "num" }.Contains(data)) { itemType = ESyntaxItemType.TYPE; } else if (new string[] { "here" }.Contains(data)) { itemType = ESyntaxItemType.HERE; } else if (new string[] { "+", "-", "*", "/", "%", "&", "|", "^" }.Contains(data)) { itemType = ESyntaxItemType.AB_OPERATOR; } else if ("=" == (data)) { itemType = ESyntaxItemType.ASSIGN; } else if ("," == (data)) { itemType = ESyntaxItemType.COMMA; } else if (new string[] { "(", ")", "[", "]" }.Contains(data)) { itemType = ESyntaxItemType.BRACKET; } else if (";" == (data)) { itemType = ESyntaxItemType.LINE_END; } else if ("if" == data) { itemType = ESyntaxItemType.IF; } else if ("ifn" == (data)) { itemType = ESyntaxItemType.IFNOT; } else if ("goto" == (data)) { itemType = ESyntaxItemType.GOTO; } else if ("cast" == (data)) { itemType = ESyntaxItemType.CAST; } else if (new string[] { "set", "get", "split", "close", "isleaf", "exec", "move", "pull", "push" }.Contains(data)) { itemType = ESyntaxItemType.FUNCTION; } else if (char.IsDigit(data[0])) { itemType = ESyntaxItemType.VALUE; } else { itemType = ESyntaxItemType.NAME; } }