private static Expression makeSimpleOperand(Token token, ArgsList argsList) { switch (token.Type) { case TokenType.DecLiteral: return(new LiteralNode(ExpressionValue.makeValue(long.Parse(token.Value)))); case TokenType.HexLiteral: return(new LiteralNode(ExpressionValue.makeValue( long.Parse(token.Value.Substring(1), NumberStyles.HexNumber)))); case TokenType.CharLiteral: return(new LiteralNode(ExpressionValue.makeValue( token.Value.Substring(1, token.Value.Length - 2)[0]))); case TokenType.StringLiteral: return(new LiteralNode(ExpressionValue.makeValue( token.Value.Substring(1, token.Value.Length - 2)))); case TokenType.SpecialRegister: return(new LiteralNode(ExpressionValue.makeSpecialRegister(token.Value))); case TokenType.LocationPtr: if (!argsList.Contains(token.Value)) { argsList.Add(token.Value); } return(new ArgumentRefNode(ExpressionValue.makeVaribleRef(token.Value))); case TokenType.LocalBackRef: { var refName = "@" + token.Value + "_" + (++_uniqSeed); if (!argsList.Contains(token.Value)) { argsList.Add(refName); } return(new ArgumentRefNode(ExpressionValue.makeVaribleRef(refName))); } case TokenType.LocalForwRef: { var refName = "@" + token.Value + "_" + (++_uniqSeed); if (!argsList.Contains(token.Value)) { argsList.Add(refName); } return(new ArgumentRefNode(ExpressionValue.makeVaribleRef(refName))); } case TokenType.LabelRef: if (!argsList.Contains(token.Value)) { argsList.Add(token.Value); } return(new ArgumentRefNode(ExpressionValue.makeVaribleRef(token.Value))); default: throw new Exception("Can't make operand from token " + token); } }
public static Expression makePointer(long arg) { return(new LiteralNode(ExpressionValue.makeValue(arg))); }