OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-expression-visitor.h" | 8 #include "src/ast/ast-expression-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser.h" | 10 #include "src/parsing/parser.h" |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 CHECK(!cache.kAsmFloat->Is(cache.kAsmFixnum)); | 1925 CHECK(!cache.kAsmFloat->Is(cache.kAsmFixnum)); |
1926 CHECK(!cache.kAsmFloat->Is(cache.kAsmDouble)); | 1926 CHECK(!cache.kAsmFloat->Is(cache.kAsmDouble)); |
1927 | 1927 |
1928 CHECK(cache.kAsmDouble->Is(cache.kAsmDouble)); | 1928 CHECK(cache.kAsmDouble->Is(cache.kAsmDouble)); |
1929 CHECK(!cache.kAsmDouble->Is(cache.kAsmInt)); | 1929 CHECK(!cache.kAsmDouble->Is(cache.kAsmInt)); |
1930 CHECK(!cache.kAsmDouble->Is(cache.kAsmUnsigned)); | 1930 CHECK(!cache.kAsmDouble->Is(cache.kAsmUnsigned)); |
1931 CHECK(!cache.kAsmDouble->Is(cache.kAsmSigned)); | 1931 CHECK(!cache.kAsmDouble->Is(cache.kAsmSigned)); |
1932 CHECK(!cache.kAsmDouble->Is(cache.kAsmFixnum)); | 1932 CHECK(!cache.kAsmDouble->Is(cache.kAsmFixnum)); |
1933 CHECK(!cache.kAsmDouble->Is(cache.kAsmFloat)); | 1933 CHECK(!cache.kAsmDouble->Is(cache.kAsmFloat)); |
1934 } | 1934 } |
| 1935 |
| 1936 |
| 1937 TEST(SwitchTest) { |
| 1938 CHECK_FUNC_TYPES_BEGIN( |
| 1939 "function switcher(x) {\n" |
| 1940 " x = x|0;\n" |
| 1941 " switch (x|0) {\n" |
| 1942 " case 1: return 23;\n" |
| 1943 " case 2: return 43;\n" |
| 1944 " default: return 66;\n" |
| 1945 " }\n" |
| 1946 " return 0;\n" |
| 1947 "}\n" |
| 1948 "function foo() { switcher(1); }") { |
| 1949 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { |
| 1950 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1951 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1952 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 1953 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1954 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1955 } |
| 1956 } |
| 1957 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1958 CHECK_VAR(.switch_tag, Bounds(cache.kAsmInt)); |
| 1959 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 1960 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1961 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1962 } |
| 1963 } |
| 1964 CHECK_EXPR(Literal, Bounds(Type::Undefined(zone))); |
| 1965 CHECK_VAR(.switch_tag, Bounds(cache.kAsmSigned)); |
| 1966 // case 1: return 23; |
| 1967 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1968 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
| 1969 // case 2: return 43; |
| 1970 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1971 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
| 1972 // default: return 66; |
| 1973 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
| 1974 // return 0; |
| 1975 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
| 1976 } |
| 1977 CHECK_SKIP(); |
| 1978 } |
| 1979 CHECK_FUNC_TYPES_END |
| 1980 } |
OLD | NEW |