public TokenValue(Arguments arguments, Block block) { _integer1 = 0; _double = 0.0; node = arguments; obj = block; _type = TokenValueType.None; }
public void InitToken(JavaMethod method, Instruction ins) { this.code = ins.NormalizedOpCode; this.arg1 = ins.Arg1; this.arg2 = ins.Arg2; this.addr = ins.PC; if (method.method.LineNumberTableAttribute == null || method.method.LineNumberTableAttribute.TryGetValue(this.addr, out this.debugline) == false) { this.debugline = -1; } if (this.debugline >= 0) { if (this.debugline - 1 < method.DeclaringType.srcfile.Length) { this.debugcode = method.DeclaringType.srcfile[this.debugline - 1]; } } switch (code) { case javaloader.NormalizedByteCode.__iconst: this.tokenI32 = this.arg1; break; //case javaloader.NormalizedByteCode.__newarray: // var c = method.DeclaringType.classfile.constantpool[this.arg1]; // break; case javaloader.NormalizedByteCode.__astore: break; default: this.tokenUnknown = ins; this.tokenValueType = TokenValueType.Nothing; break; } }
public TokenValue(List<Expression> comparisons, Expression comparisonArray) { _integer1 = 0; _double = 0.0; node = comparisonArray; obj = comparisons; _type = TokenValueType.None; }
public static TokenValueType GetValueType(string content) { TokenValueType valueType = TokenValueType.None; string str = content.Trim(); float f; int i; if (str == "true" || str == "false") { valueType = TokenValueType.Boolean; } else if (str.Contains(".") && float.TryParse(str, out f)) { valueType = TokenValueType.Float; } else if (int.TryParse(str, out i)) { valueType = TokenValueType.Integer; } else if (str.StartsWith("\"") && str.EndsWith("\"")) { valueType = TokenValueType.String; } else if (str.Contains(".") && enumRegex.Match(str).Success) { valueType = TokenValueType.Enum; } return(valueType); }
internal void SetString(string /*!*/ value, StringLiteralEncoding encoding) { Assert.NotNull(value); String = value; _integer1 = (int)encoding; _type = TokenValueType.String; }
public AssertTokenizer /*!*/ Read(Tokens token, TokenValueType tokenValue) { Next(); Tests.Assert(_actualToken == token); Tests.Assert(_actualValue.Type == tokenValue); return(this); }
private static int ParseInteger(RubyContext /*!*/ context, string /*!*/ str) { bool isNegative = false; if (str[0] == '-') { isNegative = true; str = str.Remove(0, 1); } Tokenizer tokenizer = new Tokenizer(false, ErrorSink.Null); tokenizer.Initialize(context.CreateSnippet(str, SourceCodeKind.File)); tokenizer.GetNextToken(); TokenValue value = tokenizer.TokenValue; TokenValueType type = value.Type; tokenizer.GetNextToken(); TokenValueType nextType = tokenizer.TokenValue.Type; // We are only interested in the whole string being a valid Integer if (type == TokenValueType.Integer && nextType == TokenValueType.None) { return(isNegative ? -value.Integer : value.Integer); } else { throw RubyExceptions.CreateTypeConversionError("String", "Integer"); } }
public TokenValue(List <Expression> comparisons, Expression comparisonArray) { _integer1 = 0; _double = 0.0; node = comparisonArray; obj = comparisons; _type = TokenValueType.None; }
public Token(TokenType tokenType, TokenValueType tokenValueType, string tokenValue) { if ((tokenType == TokenType.FIELD || tokenType == TokenType.VALUE) && (tokenValueType == TokenValueType.None)) { throw new ArgumentException("TokenValueType None is not allowed with TokenType VALUE or FIELD."); } if ((tokenType != TokenType.FIELD && tokenType != TokenType.VALUE) && (tokenValueType != TokenValueType.None)) { throw new ArgumentException("Only TokenValueType is allowed for this TokenType."); } _ttype = tokenType; _valueType = tokenValueType; _value = tokenValue; }
public Token(TokenType tokenType, TokenValueType tokenValueType, string tokenValue) { if ((tokenType == TokenType.FIELD || tokenType == TokenType.VALUE) && (tokenValueType == TokenValueType.None)) { throw new ArgumentException("TokenValueType None is not allowed with TokenType VALUE or FIELD."); } if ((tokenType != TokenType.FIELD && tokenType != TokenType.VALUE) && (tokenValueType != TokenValueType.None)) { throw new ArgumentException("Only TokenValueType is allowed for this TokenType."); } Ttype = tokenType; ValueType = tokenValueType; Value = tokenValue; }
internal void SetString(string/*!*/ value, StringLiteralEncoding encoding) { Assert.NotNull(value); String = value; _integer1 = (int)encoding; _type = TokenValueType.String; }
internal void SetStringTokenizer(StringTokenizer value) { StringTokenizer = value; _type = TokenValueType.StringTokenizer; }
internal void SetBigInteger(BigInteger value) { BigInteger = value; _type = TokenValueType.BigInteger; }
internal void SetDouble(double value) { Double = value; _type = TokenValueType.Double; }
public Token(TokenType type, int start, int length, string source, int line, TokenValueType valueType) { this.type = type; this.substring_start = start; this.substring_length = length; this.source = source; this.line = line; this.valueType = valueType; }
internal void SetInteger(int value) { Integer = value; _type = TokenValueType.Integer; }
internal void SetRegexOptions(RubyRegexOptions value) { Integer = (int)value; _type = TokenValueType.RegexOptions; }
public BinaryTokenFlags(TokenValueType valueType = TokenValueType.Unknown, TokenOpType opType = TokenOpType.Unknown) : this() { ValueType = valueType; OpType = opType; }
public TokenValue(string v) { Number = 0.0; String = v; Type = TokenValueType.String; }
public AssertTokenizer/*!*/ Read(Tokens token, TokenValueType tokenValue) { Next(); Tests.Assert(_actualToken == token); Tests.Assert(_actualValue.Type == tokenValue); return this; }
public void InitToken(object _p) { this.tokenUnknown = _p; switch (code) { case CodeEx.Leave: case CodeEx.Leave_S: case CodeEx.Br: case CodeEx.Br_S: case CodeEx.Brtrue: case CodeEx.Brtrue_S: case CodeEx.Brfalse: case CodeEx.Brfalse_S: //比较流程控制 case CodeEx.Beq: case CodeEx.Beq_S: case CodeEx.Bne_Un: case CodeEx.Bne_Un_S: case CodeEx.Bge: case CodeEx.Bge_S: case CodeEx.Bge_Un: case CodeEx.Bge_Un_S: case CodeEx.Bgt: case CodeEx.Bgt_S: case CodeEx.Bgt_Un: case CodeEx.Bgt_Un_S: case CodeEx.Ble: case CodeEx.Ble_S: case CodeEx.Ble_Un: case CodeEx.Ble_Un_S: case CodeEx.Blt: case CodeEx.Blt_S: case CodeEx.Blt_Un: case CodeEx.Blt_Un_S: //this.tokenAddr = ((Mono.Cecil.Cil.Instruction)_p).Offset; this.tokenAddr_Index = ((Mono.Cecil.Cil.Instruction)_p).Offset; this.tokenValueType = TokenValueType.Addr; break; case CodeEx.Isinst: case CodeEx.Constrained: case CodeEx.Box: case CodeEx.Initobj: case CodeEx.Castclass: case CodeEx.Newarr: this.tokenType = (_p as Mono.Cecil.TypeReference).FullName; this.tokenValueType = TokenValueType.Type; this.tokenUnknown = _p; break; case CodeEx.Ldfld: case CodeEx.Ldflda: case CodeEx.Ldsfld: case CodeEx.Ldsflda: case CodeEx.Stfld: case CodeEx.Stsfld: this.tokenField = (_p as Mono.Cecil.FieldReference).FullName; this.tokenUnknown = _p; this.tokenValueType = TokenValueType.Field; break; case CodeEx.Call: case CodeEx.Callvirt: case CodeEx.Newobj: case CodeEx.Ldftn: case CodeEx.Ldvirtftn: this.tokenMethod = (_p as Mono.Cecil.MethodReference).FullName; this.tokenUnknown = _p; this.tokenValueType = TokenValueType.Method; break; case CodeEx.Ldc_I4: this.tokenI32 = (int)_p; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_S: this.tokenI32 = (int)Convert.ToDecimal(_p); this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_M1: this.tokenI32 = -1; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_0: this.tokenI32 = 0; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_1: this.tokenI32 = 1; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_2: this.tokenI32 = 2; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_3: this.tokenI32 = 3; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_4: this.tokenI32 = 4; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_5: this.tokenI32 = 5; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_6: this.tokenI32 = 6; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_7: this.tokenI32 = 7; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I4_8: this.tokenI32 = 8; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldc_I8: this.tokenI64 = (Int64)_p; this.tokenValueType = TokenValueType.I64; break; case CodeEx.Ldc_R4: this.tokenR32 = (float)_p; this.tokenValueType = TokenValueType.OTher; break; case CodeEx.Ldc_R8: this.tokenR64 = (double)_p; this.tokenValueType = TokenValueType.OTher; break; case CodeEx.Ldstr: this.tokenStr = _p as string; this.tokenValueType = TokenValueType.String; break; case CodeEx.Ldloca: case CodeEx.Ldloca_S: case CodeEx.Ldloc_S: case CodeEx.Stloc_S: this.tokenI32 = ((Mono.Cecil.Cil.VariableDefinition)_p).Index; this.tokenValueType = TokenValueType.I32; //this.tokenUnknown = _p; break; case CodeEx.Ldloc: case CodeEx.Stloc: this.tokenI32 = (int)_p; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Stloc_0: case CodeEx.Ldloc_0: this.tokenI32 = 0; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Stloc_1: case CodeEx.Ldloc_1: this.tokenI32 = 1; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Stloc_2: case CodeEx.Ldloc_2: this.tokenI32 = 2; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Stloc_3: case CodeEx.Ldloc_3: this.tokenI32 = 3; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldarga: case CodeEx.Ldarga_S: case CodeEx.Starg: case CodeEx.Starg_S: this.tokenI32 = (_p as Mono.Cecil.ParameterDefinition).Index; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Switch: { Mono.Cecil.Cil.Instruction[] e = _p as Mono.Cecil.Cil.Instruction[]; tokenAddr_Switch = new int[e.Length]; for (int i = 0; i < e.Length; i++) { tokenAddr_Switch[i] = (e[i].Offset); } this.tokenValueType = TokenValueType.AddrArray; } break; case CodeEx.Ldarg: this.tokenI32 = (int)_p; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Ldarg_S: this.tokenI32 = (_p as Mono.Cecil.ParameterReference).Index; this.tokenValueType = TokenValueType.I32; break; case CodeEx.Volatile: case CodeEx.Ldind_I1: case CodeEx.Ldind_U1: case CodeEx.Ldind_I2: case CodeEx.Ldind_U2: case CodeEx.Ldind_I4: case CodeEx.Ldind_U4: case CodeEx.Ldind_I8: case CodeEx.Ldind_I: case CodeEx.Ldind_R4: case CodeEx.Ldind_R8: case CodeEx.Ldind_Ref: this.tokenValueType = TokenValueType.Nothing; break; case CodeEx.Ldtoken: var def = (_p as Mono.Cecil.FieldDefinition); this.tokenUnknown = def.InitialValue; this.tokenValueType = TokenValueType.Nothing; break; default: this.tokenUnknown = _p; this.tokenValueType = TokenValueType.Nothing; break; } }
public TokenValue(double v) { Number = v; String = ""; Type = TokenValueType.Number; }
/// <summary> /// 重写ToString方法 /// </summary> /// <returns></returns> public override string ToString() { return(this.GetType().Name + "_" + GetValueString() + "_" + TokenValueType.ToString()); }
private void Assert_ValueToken(Token token, string value, TokenValueType type) { Assert.IsTrue(token.Ttype == TokenType.VALUE); Assert.AreEqual(value, token.Value); Assert.AreEqual(type, token.ValueType); }