aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-04-27 21:26:19 +0200
committerLars Knoll <lars.knoll@digia.com>2013-04-29 14:47:35 +0200
commit382509a7f8753e2a11315eeb2086b27b6bc50a61 (patch)
tree1eb3853a9670a92c9ae6b2349ccf35ff296ead9a /src/qml/qml
parent7b8af027e5d4188311429dc8df1de67f44e5252d (diff)
Remove the old v4 and rename v4vm to v4
For archeologists v4 can still be found in the history. Otherwise it is confusing to have both engines in the tree. Change-Id: Ice05afb7013f0fe536aab6bb19114f696c58fc94 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qml.pri6
-rw-r--r--src/qml/qml/v4/llvm_installation.pri (renamed from src/qml/qml/v4vm/llvm_installation.pri)0
-rw-r--r--src/qml/qml/v4/llvm_runtime.cpp (renamed from src/qml/qml/v4vm/llvm_runtime.cpp)0
-rw-r--r--src/qml/qml/v4/moth/moth.pri (renamed from src/qml/qml/v4vm/moth/moth.pri)0
-rw-r--r--src/qml/qml/v4/moth/qv4instr_moth.cpp (renamed from src/qml/qml/v4vm/moth/qv4instr_moth.cpp)0
-rw-r--r--src/qml/qml/v4/moth/qv4instr_moth_p.h (renamed from src/qml/qml/v4vm/moth/qv4instr_moth_p.h)0
-rw-r--r--src/qml/qml/v4/moth/qv4isel_moth.cpp (renamed from src/qml/qml/v4vm/moth/qv4isel_moth.cpp)0
-rw-r--r--src/qml/qml/v4/moth/qv4isel_moth_p.h (renamed from src/qml/qml/v4vm/moth/qv4isel_moth_p.h)0
-rw-r--r--src/qml/qml/v4/moth/qv4vme_moth.cpp (renamed from src/qml/qml/v4vm/moth/qv4vme_moth.cpp)0
-rw-r--r--src/qml/qml/v4/moth/qv4vme_moth_p.h (renamed from src/qml/qml/v4vm/moth/qv4vme_moth_p.h)0
-rw-r--r--src/qml/qml/v4/qcalculatehash_p.h (renamed from src/qml/qml/v4vm/qcalculatehash_p.h)0
-rw-r--r--src/qml/qml/v4/qv4_llvm_p.h (renamed from src/qml/qml/v4vm/qv4_llvm_p.h)0
-rw-r--r--src/qml/qml/v4/qv4alloca_p.h (renamed from src/qml/qml/v4vm/qv4alloca_p.h)0
-rw-r--r--src/qml/qml/v4/qv4argumentsobject.cpp (renamed from src/qml/qml/v4vm/qv4argumentsobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4argumentsobject_p.h (renamed from src/qml/qml/v4vm/qv4argumentsobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4arrayobject.cpp (renamed from src/qml/qml/v4vm/qv4arrayobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4arrayobject_p.h (renamed from src/qml/qml/v4vm/qv4arrayobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp2474
-rw-r--r--src/qml/qml/v4/qv4bindings_p.h172
-rw-r--r--src/qml/qml/v4/qv4booleanobject.cpp (renamed from src/qml/qml/v4vm/qv4booleanobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4booleanobject_p.h (renamed from src/qml/qml/v4vm/qv4booleanobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4codegen.cpp (renamed from src/qml/qml/v4vm/qv4codegen.cpp)0
-rw-r--r--src/qml/qml/v4/qv4codegen_p.h (renamed from src/qml/qml/v4vm/qv4codegen_p.h)0
-rw-r--r--src/qml/qml/v4/qv4compiler.cpp1580
-rw-r--r--src/qml/qml/v4/qv4compiler_p.h105
-rw-r--r--src/qml/qml/v4/qv4compiler_p_p.h245
-rw-r--r--src/qml/qml/v4/qv4context.cpp (renamed from src/qml/qml/v4vm/qv4context.cpp)0
-rw-r--r--src/qml/qml/v4/qv4context_p.h (renamed from src/qml/qml/v4vm/qv4context_p.h)0
-rw-r--r--src/qml/qml/v4/qv4dateobject.cpp (renamed from src/qml/qml/v4vm/qv4dateobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4dateobject_p.h (renamed from src/qml/qml/v4vm/qv4dateobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4debugging.cpp (renamed from src/qml/qml/v4vm/qv4debugging.cpp)0
-rw-r--r--src/qml/qml/v4/qv4debugging_p.h (renamed from src/qml/qml/v4vm/qv4debugging_p.h)0
-rw-r--r--src/qml/qml/v4/qv4engine.cpp (renamed from src/qml/qml/v4vm/qv4engine.cpp)0
-rw-r--r--src/qml/qml/v4/qv4engine_p.h (renamed from src/qml/qml/v4vm/qv4engine_p.h)0
-rw-r--r--src/qml/qml/v4/qv4errorobject.cpp (renamed from src/qml/qml/v4vm/qv4errorobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4errorobject_p.h (renamed from src/qml/qml/v4vm/qv4errorobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4executableallocator.cpp (renamed from src/qml/qml/v4vm/qv4executableallocator.cpp)0
-rw-r--r--src/qml/qml/v4/qv4executableallocator_p.h (renamed from src/qml/qml/v4vm/qv4executableallocator_p.h)0
-rw-r--r--src/qml/qml/v4/qv4functionobject.cpp (renamed from src/qml/qml/v4vm/qv4functionobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4functionobject_p.h (renamed from src/qml/qml/v4vm/qv4functionobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4global_p.h (renamed from src/qml/qml/v4vm/qv4global_p.h)0
-rw-r--r--src/qml/qml/v4/qv4globalobject.cpp (renamed from src/qml/qml/v4vm/qv4globalobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4globalobject_p.h (renamed from src/qml/qml/v4vm/qv4globalobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4identifier_p.h (renamed from src/qml/qml/v4vm/qv4identifier_p.h)0
-rw-r--r--src/qml/qml/v4/qv4instruction.cpp532
-rw-r--r--src/qml/qml/v4/qv4instruction_p.h483
-rw-r--r--src/qml/qml/v4/qv4internalclass.cpp (renamed from src/qml/qml/v4vm/qv4internalclass.cpp)0
-rw-r--r--src/qml/qml/v4/qv4internalclass_p.h (renamed from src/qml/qml/v4vm/qv4internalclass_p.h)0
-rw-r--r--src/qml/qml/v4/qv4ir.cpp919
-rw-r--r--src/qml/qml/v4/qv4ir_p.h615
-rw-r--r--src/qml/qml/v4/qv4irbuilder.cpp1387
-rw-r--r--src/qml/qml/v4/qv4irbuilder_p.h239
-rw-r--r--src/qml/qml/v4/qv4isel_llvm.cpp (renamed from src/qml/qml/v4vm/qv4isel_llvm.cpp)0
-rw-r--r--src/qml/qml/v4/qv4isel_llvm_p.h (renamed from src/qml/qml/v4vm/qv4isel_llvm_p.h)0
-rw-r--r--src/qml/qml/v4/qv4isel_masm.cpp (renamed from src/qml/qml/v4vm/qv4isel_masm.cpp)0
-rw-r--r--src/qml/qml/v4/qv4isel_masm_p.h (renamed from src/qml/qml/v4vm/qv4isel_masm_p.h)0
-rw-r--r--src/qml/qml/v4/qv4isel_p.cpp (renamed from src/qml/qml/v4vm/qv4isel_p.cpp)0
-rw-r--r--src/qml/qml/v4/qv4isel_p.h (renamed from src/qml/qml/v4vm/qv4isel_p.h)0
-rw-r--r--src/qml/qml/v4/qv4isel_util_p.h (renamed from src/qml/qml/v4vm/qv4isel_util_p.h)0
-rw-r--r--src/qml/qml/v4/qv4jsir.cpp (renamed from src/qml/qml/v4vm/qv4jsir.cpp)0
-rw-r--r--src/qml/qml/v4/qv4jsir_p.h (renamed from src/qml/qml/v4vm/qv4jsir_p.h)0
-rw-r--r--src/qml/qml/v4/qv4jsonobject.cpp (renamed from src/qml/qml/v4vm/qv4jsonobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4jsonobject_p.h (renamed from src/qml/qml/v4vm/qv4jsonobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4lookup.cpp (renamed from src/qml/qml/v4vm/qv4lookup.cpp)0
-rw-r--r--src/qml/qml/v4/qv4lookup_p.h (renamed from src/qml/qml/v4vm/qv4lookup_p.h)0
-rw-r--r--src/qml/qml/v4/qv4managed.cpp (renamed from src/qml/qml/v4vm/qv4managed.cpp)0
-rw-r--r--src/qml/qml/v4/qv4managed_p.h (renamed from src/qml/qml/v4vm/qv4managed_p.h)0
-rw-r--r--src/qml/qml/v4/qv4math_p.h (renamed from src/qml/qml/v4vm/qv4math_p.h)0
-rw-r--r--src/qml/qml/v4/qv4mathobject.cpp (renamed from src/qml/qml/v4vm/qv4mathobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4mathobject_p.h (renamed from src/qml/qml/v4vm/qv4mathobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4mm.cpp (renamed from src/qml/qml/v4vm/qv4mm.cpp)0
-rw-r--r--src/qml/qml/v4/qv4mm_p.h (renamed from src/qml/qml/v4vm/qv4mm_p.h)0
-rw-r--r--src/qml/qml/v4/qv4numberobject.cpp (renamed from src/qml/qml/v4vm/qv4numberobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4numberobject_p.h (renamed from src/qml/qml/v4vm/qv4numberobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4object.cpp (renamed from src/qml/qml/v4vm/qv4object.cpp)0
-rw-r--r--src/qml/qml/v4/qv4object_p.h (renamed from src/qml/qml/v4vm/qv4object_p.h)0
-rw-r--r--src/qml/qml/v4/qv4objectiterator.cpp (renamed from src/qml/qml/v4vm/qv4objectiterator.cpp)0
-rw-r--r--src/qml/qml/v4/qv4objectiterator_p.h (renamed from src/qml/qml/v4vm/qv4objectiterator_p.h)0
-rw-r--r--src/qml/qml/v4/qv4objectproto.cpp (renamed from src/qml/qml/v4vm/qv4objectproto.cpp)0
-rw-r--r--src/qml/qml/v4/qv4objectproto_p.h (renamed from src/qml/qml/v4vm/qv4objectproto_p.h)0
-rw-r--r--src/qml/qml/v4/qv4program_p.h128
-rw-r--r--src/qml/qml/v4/qv4property_p.h (renamed from src/qml/qml/v4vm/qv4property_p.h)0
-rw-r--r--src/qml/qml/v4/qv4regexp.cpp (renamed from src/qml/qml/v4vm/qv4regexp.cpp)0
-rw-r--r--src/qml/qml/v4/qv4regexp_p.h (renamed from src/qml/qml/v4vm/qv4regexp_p.h)0
-rw-r--r--src/qml/qml/v4/qv4regexpobject.cpp (renamed from src/qml/qml/v4vm/qv4regexpobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4regexpobject_p.h (renamed from src/qml/qml/v4vm/qv4regexpobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4runtime.cpp (renamed from src/qml/qml/v4vm/qv4runtime.cpp)0
-rw-r--r--src/qml/qml/v4/qv4runtime_p.h (renamed from src/qml/qml/v4vm/qv4runtime_p.h)0
-rw-r--r--src/qml/qml/v4/qv4sparsearray.cpp (renamed from src/qml/qml/v4vm/qv4sparsearray.cpp)0
-rw-r--r--src/qml/qml/v4/qv4sparsearray_p.h (renamed from src/qml/qml/v4vm/qv4sparsearray_p.h)0
-rw-r--r--src/qml/qml/v4/qv4string.cpp (renamed from src/qml/qml/v4vm/qv4string.cpp)0
-rw-r--r--src/qml/qml/v4/qv4string_p.h (renamed from src/qml/qml/v4vm/qv4string_p.h)0
-rw-r--r--src/qml/qml/v4/qv4stringobject.cpp (renamed from src/qml/qml/v4vm/qv4stringobject.cpp)0
-rw-r--r--src/qml/qml/v4/qv4stringobject_p.h (renamed from src/qml/qml/v4vm/qv4stringobject_p.h)0
-rw-r--r--src/qml/qml/v4/qv4syntaxchecker.cpp (renamed from src/qml/qml/v4vm/qv4syntaxchecker.cpp)0
-rw-r--r--src/qml/qml/v4/qv4syntaxchecker_p.h (renamed from src/qml/qml/v4vm/qv4syntaxchecker_p.h)0
-rw-r--r--src/qml/qml/v4/qv4unwindhelper.cpp (renamed from src/qml/qml/v4vm/qv4unwindhelper.cpp)0
-rw-r--r--src/qml/qml/v4/qv4unwindhelper_p-arm.h (renamed from src/qml/qml/v4vm/qv4unwindhelper_p-arm.h)0
-rw-r--r--src/qml/qml/v4/qv4unwindhelper_p-dw2.h (renamed from src/qml/qml/v4vm/qv4unwindhelper_p-dw2.h)0
-rw-r--r--src/qml/qml/v4/qv4unwindhelper_p.h (renamed from src/qml/qml/v4vm/qv4unwindhelper_p.h)0
-rw-r--r--src/qml/qml/v4/qv4util_p.h (renamed from src/qml/qml/v4vm/qv4util_p.h)0
-rw-r--r--src/qml/qml/v4/qv4v8.cpp (renamed from src/qml/qml/v4vm/qv4v8.cpp)0
-rw-r--r--src/qml/qml/v4/qv4v8_p.h (renamed from src/qml/qml/v4vm/qv4v8_p.h)0
-rw-r--r--src/qml/qml/v4/qv4value.cpp (renamed from src/qml/qml/v4vm/qv4value.cpp)0
-rw-r--r--src/qml/qml/v4/qv4value_p.h (renamed from src/qml/qml/v4vm/qv4value_p.h)0
-rw-r--r--src/qml/qml/v4/v4.pri170
-rw-r--r--src/qml/qml/v4vm/v4vm.pri161
107 files changed, 159 insertions, 9057 deletions
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 304e08de92..29cd4374c7 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -130,9 +130,5 @@ HEADERS += \
include(parser/parser.pri)
include(rewriter/rewriter.pri)
include(ftw/ftw.pri)
-use_old_v4 {
- include(v4/v4.pri)
- DEFINES += QT_USE_OLD_V4
-}
include(v8/v8.pri)
-include(v4vm/v4vm.pri)
+include(v4/v4.pri)
diff --git a/src/qml/qml/v4vm/llvm_installation.pri b/src/qml/qml/v4/llvm_installation.pri
index 99e955fd2b..99e955fd2b 100644
--- a/src/qml/qml/v4vm/llvm_installation.pri
+++ b/src/qml/qml/v4/llvm_installation.pri
diff --git a/src/qml/qml/v4vm/llvm_runtime.cpp b/src/qml/qml/v4/llvm_runtime.cpp
index 89d057d2a1..89d057d2a1 100644
--- a/src/qml/qml/v4vm/llvm_runtime.cpp
+++ b/src/qml/qml/v4/llvm_runtime.cpp
diff --git a/src/qml/qml/v4vm/moth/moth.pri b/src/qml/qml/v4/moth/moth.pri
index 73bd893286..73bd893286 100644
--- a/src/qml/qml/v4vm/moth/moth.pri
+++ b/src/qml/qml/v4/moth/moth.pri
diff --git a/src/qml/qml/v4vm/moth/qv4instr_moth.cpp b/src/qml/qml/v4/moth/qv4instr_moth.cpp
index a2bad39e00..a2bad39e00 100644
--- a/src/qml/qml/v4vm/moth/qv4instr_moth.cpp
+++ b/src/qml/qml/v4/moth/qv4instr_moth.cpp
diff --git a/src/qml/qml/v4vm/moth/qv4instr_moth_p.h b/src/qml/qml/v4/moth/qv4instr_moth_p.h
index ed762afb2d..ed762afb2d 100644
--- a/src/qml/qml/v4vm/moth/qv4instr_moth_p.h
+++ b/src/qml/qml/v4/moth/qv4instr_moth_p.h
diff --git a/src/qml/qml/v4vm/moth/qv4isel_moth.cpp b/src/qml/qml/v4/moth/qv4isel_moth.cpp
index 678127a716..678127a716 100644
--- a/src/qml/qml/v4vm/moth/qv4isel_moth.cpp
+++ b/src/qml/qml/v4/moth/qv4isel_moth.cpp
diff --git a/src/qml/qml/v4vm/moth/qv4isel_moth_p.h b/src/qml/qml/v4/moth/qv4isel_moth_p.h
index 23ca9302a8..23ca9302a8 100644
--- a/src/qml/qml/v4vm/moth/qv4isel_moth_p.h
+++ b/src/qml/qml/v4/moth/qv4isel_moth_p.h
diff --git a/src/qml/qml/v4vm/moth/qv4vme_moth.cpp b/src/qml/qml/v4/moth/qv4vme_moth.cpp
index 4a7e1891ea..4a7e1891ea 100644
--- a/src/qml/qml/v4vm/moth/qv4vme_moth.cpp
+++ b/src/qml/qml/v4/moth/qv4vme_moth.cpp
diff --git a/src/qml/qml/v4vm/moth/qv4vme_moth_p.h b/src/qml/qml/v4/moth/qv4vme_moth_p.h
index 3279bc3dd0..3279bc3dd0 100644
--- a/src/qml/qml/v4vm/moth/qv4vme_moth_p.h
+++ b/src/qml/qml/v4/moth/qv4vme_moth_p.h
diff --git a/src/qml/qml/v4vm/qcalculatehash_p.h b/src/qml/qml/v4/qcalculatehash_p.h
index 8cccc5d0d1..8cccc5d0d1 100644
--- a/src/qml/qml/v4vm/qcalculatehash_p.h
+++ b/src/qml/qml/v4/qcalculatehash_p.h
diff --git a/src/qml/qml/v4vm/qv4_llvm_p.h b/src/qml/qml/v4/qv4_llvm_p.h
index 773cdefa45..773cdefa45 100644
--- a/src/qml/qml/v4vm/qv4_llvm_p.h
+++ b/src/qml/qml/v4/qv4_llvm_p.h
diff --git a/src/qml/qml/v4vm/qv4alloca_p.h b/src/qml/qml/v4/qv4alloca_p.h
index 1e9388c48c..1e9388c48c 100644
--- a/src/qml/qml/v4vm/qv4alloca_p.h
+++ b/src/qml/qml/v4/qv4alloca_p.h
diff --git a/src/qml/qml/v4vm/qv4argumentsobject.cpp b/src/qml/qml/v4/qv4argumentsobject.cpp
index 914f219012..914f219012 100644
--- a/src/qml/qml/v4vm/qv4argumentsobject.cpp
+++ b/src/qml/qml/v4/qv4argumentsobject.cpp
diff --git a/src/qml/qml/v4vm/qv4argumentsobject_p.h b/src/qml/qml/v4/qv4argumentsobject_p.h
index b1d5a53bd4..b1d5a53bd4 100644
--- a/src/qml/qml/v4vm/qv4argumentsobject_p.h
+++ b/src/qml/qml/v4/qv4argumentsobject_p.h
diff --git a/src/qml/qml/v4vm/qv4arrayobject.cpp b/src/qml/qml/v4/qv4arrayobject.cpp
index b489c784fc..b489c784fc 100644
--- a/src/qml/qml/v4vm/qv4arrayobject.cpp
+++ b/src/qml/qml/v4/qv4arrayobject.cpp
diff --git a/src/qml/qml/v4vm/qv4arrayobject_p.h b/src/qml/qml/v4/qv4arrayobject_p.h
index a76510c3ad..a76510c3ad 100644
--- a/src/qml/qml/v4vm/qv4arrayobject_p.h
+++ b/src/qml/qml/v4/qv4arrayobject_p.h
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
deleted file mode 100644
index bf7cc0b1bd..0000000000
--- a/src/qml/qml/v4/qv4bindings.cpp
+++ /dev/null
@@ -1,2474 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// #define REGISTER_CLEANUP_DEBUG
-
-#include "qv4bindings_p.h"
-#include "qv4program_p.h"
-#include "qv4compiler_p.h"
-#include "qv4compiler_p_p.h"
-
-#include <private/qqmlglobal_p.h>
-
-#include <private/qv8_p.h>
-#include <private/qjsconverter_p.h>
-#include <private/qv8engine_p.h>
-
-#include <private/qqmlaccessors_p.h>
-#include <private/qqmlprofilerservice_p.h>
-#include <private/qqmlmetatype_p.h>
-#include <private/qqmltrace_p.h>
-#include <private/qqmlstringconverters_p.h>
-#include <private/qqmlproperty_p.h>
-#include <private/qqmlvmemetaobject_p.h>
-
-#include <QtQml/qqmlinfo.h>
-#include <QtCore/qnumeric.h>
-#include <QtCore/qmath.h>
-#include <math.h> // ::fmod
-
-#ifdef Q_CC_MSVC
-// MSVC2010 warns about 'unreferenced formal parameter', even if it's used in p->~T()
-# pragma warning( disable : 4100 )
-#endif
-
-QT_BEGIN_NAMESPACE
-
-using namespace QQmlJS;
-
-QQmlAbstractBinding::VTable QV4Bindings_Binding_vtable = {
- QV4Bindings::Binding::destroy,
- QQmlAbstractBinding::default_expression,
- QV4Bindings::Binding::propertyIndex,
- QV4Bindings::Binding::object,
- QV4Bindings::Binding::setEnabled,
- QV4Bindings::Binding::update,
- QV4Bindings::Binding::retargetBinding
-};
-
-namespace {
-
-// The highest bit is the sign bit, in any endianness
-static const quint64 doubleSignMask = (quint64(0x1) << 63);
-
-inline bool signBitSet(const double &v)
-{
- union { double d; quint64 u; } u;
- u.d = v;
- return (u.u & doubleSignMask);
-}
-
-inline double setSignBit(const double &v, bool b = true)
-{
- union { double d; quint64 u; } u;
-
- u.d = v;
- if (b) {
- u.u |= doubleSignMask;
- } else {
- u.u &= ~doubleSignMask;
- }
- return u.d;
-}
-
-inline double clearSignBit(const double &v, bool b = true)
-{
- return setSignBit(v, !b);
-}
-
-struct Register {
- typedef QQmlRegisterType Type;
-
- enum SpecialNumericValue {
- NegativeZero = 1,
- PositiveInfinity = 2,
- NegativeInfinity = 3,
- NotANumber = 4
- };
-
- inline void setUndefined() { dataType = UndefinedType; }
- inline bool isUndefined() const { return dataType == UndefinedType; }
-
- inline void setNull() { dataType = NullType; }
-
- inline void setNaN() { setnumber(qSNaN()); }
- inline void setNaNType() { dataType = SpecialNumericType; intValue = NotANumber; } // non-numeric representation of NaN
- inline bool isNaN() const { return (((dataType == SpecialNumericType) && (intValue == NotANumber)) ||
- ((dataType == NumberType) && qIsNaN(numberValue))); }
-
- inline void setInf(bool negative) { setnumber(setSignBit(qInf(), negative)); }
- inline void setInfType(bool negative) { dataType = SpecialNumericType; intValue = (negative ? NegativeInfinity : PositiveInfinity); } // non-numeric representation of Inf
- inline bool isInf() const { return (((dataType == SpecialNumericType) && ((intValue == NegativeInfinity) || (intValue == PositiveInfinity))) ||
- ((dataType == NumberType) && qIsInf(numberValue))); }
-
- inline void setNegativeZero() { setnumber(setSignBit(0)); }
- inline void setNegativeZeroType() { dataType = SpecialNumericType; intValue = NegativeZero; } // non-numeric representation of -0
- inline bool isNegativeZero() const { return (((dataType == SpecialNumericType) && (intValue == NegativeZero)) ||
- ((dataType == NumberType) && (numberValue == 0) && signBitSet(numberValue))); }
-
- inline void setQObject(QObject *o) { qobjectValue = o; dataType = QObjectStarType; }
- inline QObject *getQObject() const { return qobjectValue; }
-
- inline void setnumber(double v) { numberValue = v; dataType = NumberType; }
- inline double getnumber() const { return numberValue; }
- inline double &getnumberref() { return numberValue; }
-
- inline void setfloat(float v) { floatValue = v; dataType = FloatType; }
- inline float getfloat() const { return floatValue; }
- inline float &getfloatref() { return floatValue; }
-
- inline void setint(int v) { intValue = v; dataType = IntType; }
- inline int getint() const { return intValue; }
- inline int &getintref() { return intValue; }
-
- inline void setbool(bool v) { boolValue = v; dataType = BoolType; }
- inline bool getbool() const { return boolValue; }
- inline bool &getboolref() { return boolValue; }
-
- inline QVariant *getvariantptr() { return reinterpret_cast<QVariant *>(typeDataPtr()); }
- inline QString *getstringptr() { return reinterpret_cast<QString *>(typeDataPtr()); }
- inline QUrl *geturlptr() { return reinterpret_cast<QUrl *>(typeDataPtr()); }
- inline v8::Handle<v8::Value> *gethandleptr() { return reinterpret_cast<v8::Handle<v8::Value> *>(typeDataPtr()); }
- inline QJSValue *getjsvalueptr() { return reinterpret_cast<QJSValue *>(typeDataPtr()); }
-
- inline const QVariant *getvariantptr() const { return reinterpret_cast<const QVariant *>(typeDataPtr()); }
- inline const QString *getstringptr() const { return reinterpret_cast<const QString *>(typeDataPtr()); }
- inline const QUrl *geturlptr() const { return reinterpret_cast<const QUrl *>(typeDataPtr()); }
- inline const v8::Handle<v8::Value> *gethandleptr() const { return reinterpret_cast<const v8::Handle<v8::Value> *>(typeDataPtr()); }
- inline const QJSValue *getjsvalueptr() const { return reinterpret_cast<const QJSValue *>(typeDataPtr()); }
-
- size_t dataSize() { return sizeof(data); }
- inline void *typeDataPtr() { return (void *)&data; }
- inline void *typeMemory() { return (void *)data; }
- inline const void *typeDataPtr() const { return (void *)&data; }
- inline const void *typeMemory() const { return (void *)data; }
-
- inline Type gettype() const { return dataType; }
- inline void settype(Type t) { dataType = t; }
-
- Type dataType; // Type of data
- union {
- QObject *qobjectValue;
- double numberValue;
- float floatValue;
- int intValue;
- bool boolValue;
- void *data[sizeof(QVariant)];
- qint64 q_for_alignment_1;
- double q_for_alignment_2;
- };
-
- inline void cleanup();
- inline void cleanupString();
- inline void cleanupUrl();
- inline void cleanupColor();
- inline void cleanupVariant();
- inline void cleanupHandle();
- inline void cleanupJSValue();
-
- inline void copy(const Register &other);
- inline void init(Type type);
-#ifdef REGISTER_CLEANUP_DEBUG
- Register() {
- type = 0;
- }
-
- ~Register() {
- if (dataType >= FirstCleanupType)
- qWarning("Register leaked of type %d", dataType);
- }
-#endif
-
- template <typename T>
- inline static void copyConstructPointee(T *p, const T *other)
- {
- new (p) T(*other);
- }
-
- template <typename T>
- inline static void defaultConstructPointee(T *p)
- {
- new (p) T();
- }
-
- template <typename T>
- inline static void destroyPointee(T *p)
- {
- p->~T();
- }
-};
-
-void Register::cleanup()
-{
- if (dataType >= FirstCleanupType) {
- if (dataType == QStringType) {
- destroyPointee(getstringptr());
- } else if (dataType == QUrlType) {
- destroyPointee(geturlptr());
- } else if (dataType == QColorType) {
- QQml_valueTypeProvider()->destroyValueType(QMetaType::QColor, typeDataPtr(), dataSize());
- } else if (dataType == QVariantType) {
- destroyPointee(getvariantptr());
- } else if (dataType == qMetaTypeId<v8::Handle<v8::Value> >()) {
- destroyPointee(gethandleptr());
- } else if (dataType == qMetaTypeId<QJSValue>()) {
- destroyPointee(getjsvalueptr());
- }
- }
- setUndefined();
-}
-
-void Register::cleanupString()
-{
- destroyPointee(getstringptr());
- setUndefined();
-}
-
-void Register::cleanupUrl()
-{
- destroyPointee(geturlptr());
- setUndefined();
-}
-
-void Register::cleanupColor()
-{
- QQml_valueTypeProvider()->destroyValueType(QMetaType::QColor, typeDataPtr(), dataSize());
- setUndefined();
-}
-
-void Register::cleanupVariant()
-{
- destroyPointee(getvariantptr());
- setUndefined();
-}
-
-void Register::cleanupHandle()
-{
- destroyPointee(gethandleptr());
- setUndefined();
-}
-
-void Register::cleanupJSValue()
-{
- destroyPointee(getjsvalueptr());
- setUndefined();
-}
-
-void Register::copy(const Register &other)
-{
- *this = other;
- if (other.dataType >= FirstCleanupType) {
- if (other.dataType == QStringType)
- copyConstructPointee(getstringptr(), other.getstringptr());
- else if (other.dataType == QUrlType)
- copyConstructPointee(geturlptr(), other.geturlptr());
- else if (other.dataType == QColorType)
- QQml_valueTypeProvider()->copyValueType(QMetaType::QColor, other.typeDataPtr(), typeDataPtr(), dataSize());
- else if (other.dataType == QVariantType)
- copyConstructPointee(getvariantptr(), other.getvariantptr());
- else if (other.dataType == qMetaTypeId<v8::Handle<v8::Value> >())
- copyConstructPointee(gethandleptr(), other.gethandleptr());
- else if (other.dataType == qMetaTypeId<QJSValue>())
- copyConstructPointee(getjsvalueptr(), other.getjsvalueptr());
- }
-}
-
-void Register::init(Type type)
-{
- dataType = type;
- if (dataType >= FirstCleanupType) {
- if (dataType == QStringType)
- defaultConstructPointee(getstringptr());
- else if (dataType == QUrlType)
- defaultConstructPointee(geturlptr());
- else if (dataType == QColorType)
- QQml_valueTypeProvider()->initValueType(QMetaType::QColor, typeDataPtr(), dataSize());
- else if (dataType == QVariantType)
- defaultConstructPointee(getvariantptr());
- else if (dataType == qMetaTypeId<v8::Handle<v8::Value> >())
- defaultConstructPointee(gethandleptr());
- else if (dataType == qMetaTypeId<QJSValue>())
- defaultConstructPointee(getjsvalueptr());
- }
-}
-
-} // end of anonymous namespace
-
-QV4Bindings::QV4Bindings(const char *programData, QQmlContextData *context)
-: subscriptions(0), program(0), bindings(0)
-{
- program = (QV4Program *)programData;
- if (program) {
- subscriptions = new Subscription[program->subscriptions];
- bindings = new Binding[program->bindings];
-
- QQmlAbstractExpression::setContext(context);
- }
-}
-
-QV4Bindings::~QV4Bindings()
-{
- delete [] bindings; bindings = 0;
- delete [] subscriptions; subscriptions = 0;
-}
-
-QQmlAbstractBinding *QV4Bindings::configBinding(QObject *target, QObject *scope,
- const QQmlInstruction::instr_assignV4Binding *i)
-{
- Binding *rv = bindings + i->value;
-
- rv->instruction = i;
- rv->target = target;
- rv->scope = scope;
- rv->parent = this;
-
- addref(); // This is decremented in Binding::destroy()
-
- return rv;
-}
-
-void QV4Bindings::Binding::setEnabled(QQmlAbstractBinding *_This,
- bool e, QQmlPropertyPrivate::WriteFlags flags)
-{
- QV4Bindings::Binding *This = static_cast<QV4Bindings::Binding *>(_This);
-
- if (This->enabledFlag() != e) {
- This->setEnabledFlag(e);
-
- if (e) update(_This, flags);
- }
-}
-
-void QV4Bindings::Binding::update(QQmlAbstractBinding *_This, QQmlPropertyPrivate::WriteFlags flags)
-{
- QV4Bindings::Binding *This = static_cast<QV4Bindings::Binding *>(_This);
- This->parent->run(This, flags);
-}
-
-void QV4Bindings::Binding::destroy(QQmlAbstractBinding *_This, QQmlAbstractBinding::DestroyMode mode)
-{
- QV4Bindings::Binding *This = static_cast<QV4Bindings::Binding *>(_This);
-
- if (mode == QQmlAbstractBinding::DisconnectBinding)
- This->disconnect();
-
- This->setEnabledFlag(false);
- This->removeFromObject();
- This->clear();
- This->removeError();
- This->parent->release();
-}
-
-int QV4Bindings::Binding::propertyIndex(const QQmlAbstractBinding *_This)
-{
- const QV4Bindings::Binding *This = static_cast<const QV4Bindings::Binding *>(_This);
-
- if (This->target.hasValue()) return This->target.constValue()->targetProperty;
- else return This->instruction->property;
-}
-
-QObject *QV4Bindings::Binding::object(const QQmlAbstractBinding *_This)
-{
- const QV4Bindings::Binding *This = static_cast<const QV4Bindings::Binding *>(_This);
-
- if (This->target.hasValue()) return This->target.constValue()->target;
- return *This->target;
-}
-
-void QV4Bindings::Binding::retargetBinding(QQmlAbstractBinding *_This, QObject *t, int i)
-{
- QV4Bindings::Binding *This = static_cast<QV4Bindings::Binding *>(_This);
-
- This->target.value().target = t;
- This->target.value().targetProperty = i;
-}
-
-void QV4Bindings::Binding::disconnect()
-{
- // We iterate over the signal table to find all subscriptions associated with this binding.
- // This is slow, but disconnect() is not called in the common case, only in special cases
- // like when the binding is overwritten.
- QV4Program * const program = parent->program;
- for (quint16 subIndex = 0; subIndex < program->subscriptions; subIndex++) {
- QV4Program::BindingReferenceList * const list = program->signalTable(subIndex);
- for (quint32 bindingIndex = 0; bindingIndex < list->count; ++bindingIndex) {
- QV4Program::BindingReference * const bindingRef = list->bindings + bindingIndex;
- Binding * const binding = parent->bindings + bindingRef->binding;
- if (binding == this) {
- Subscription * const sub = parent->subscriptions + subIndex;
- if (sub->active()) {
- sub->setActive(false);
- sub->disconnect();
- }
- }
- }
- }
-}
-
-void QV4Bindings::Binding::dump()
-{
- qWarning() << parent->context()->url << instruction->line << instruction->column;
-}
-
-QV4Bindings::Subscription::Subscription()
- : m_bindings(0)
-{
- setCallback(QQmlNotifierEndpoint::QV4BindingsSubscription);
-}
-
-int QV4Bindings::Subscription::method() const
-{
- Q_ASSERT(bindings() != 0);
- return (this - bindings()->subscriptions);
-}
-
-void QV4Bindings::Subscription::setBindings(QV4Bindings *bindings)
-{
- m_bindings = bindings;
-}
-
-QV4Bindings *QV4Bindings::Subscription::bindings() const
-{
- return *m_bindings;
-}
-
-bool QV4Bindings::Subscription::active() const
-{
- return m_bindings.flag();
-}
-
-void QV4Bindings::Subscription::setActive(bool active)
-{
- m_bindings.setFlagValue(active);
-}
-
-void QV4BindingsSubscription_callback(QQmlNotifierEndpoint *e, void **)
-{
- QV4Bindings::Subscription *s = static_cast<QV4Bindings::Subscription *>(e);
- Q_ASSERT(s->bindings());
- s->bindings()->subscriptionNotify(s->method());
-}
-
-void QV4Bindings::subscriptionNotify(int id)
-{
- QV4Program::BindingReferenceList *list = program->signalTable(id);
-
- for (quint32 ii = 0; ii < list->count; ++ii) {
- QV4Program::BindingReference *bindingRef = list->bindings + ii;
-
- Binding *binding = bindings + bindingRef->binding;
-
- if (binding->executedBlocks & bindingRef->blockMask) {
- run(binding, QQmlPropertyPrivate::DontRemoveBinding);
- }
- }
-}
-
-void QV4Bindings::run(Binding *binding, QQmlPropertyPrivate::WriteFlags flags)
-{
- if (!binding->enabledFlag())
- return;
-
- QQmlContextData *context = QQmlAbstractExpression::context();
- if (!context || !context->isValid())
- return;
-
- // Check that the target has not been deleted
- if (QQmlData::wasDeleted(*binding->target))
- return;
-
- QQmlTrace trace("V4 Binding Update");
- trace.addDetail("URL", context->url);
- trace.addDetail("Line", binding->instruction->line);
- trace.addDetail("Column", binding->instruction->column);
-
- QQmlBindingProfiler prof(context->urlString, binding->instruction->line, binding->instruction->column, QQmlProfilerService::V4Binding);
-
- const int propType = binding->instruction->propType;
- const int property = binding->instruction->property;
-
- if (binding->updatingFlag()) {
- QString name;
- if (propType) {
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(propType);
- Q_ASSERT(vt);
-
- name = QLatin1String(binding->target->metaObject()->property(property & 0x0000FFFF).name());
- name.append(QLatin1Char('.'));
- name.append(QLatin1String(vt->metaObject()->property(property >> 16).name()));
- } else {
- name = QLatin1String(binding->target->metaObject()->property(property).name());
- }
- qmlInfo(*binding->target) << tr("Binding loop detected for property \"%1\"").arg(name);
- return;
- }
-
- int index = binding->instruction->value;
- int fallbackIndex = binding->instruction->fallbackValue;
-
- bool invalidated = false;
- bool *inv = (fallbackIndex != -1) ? &invalidated : 0;
-
- binding->setUpdatingFlag(true);
- if (propType) {
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(propType);
- Q_ASSERT(vt);
- vt->read(*binding->target, property & 0x0000FFFF);
-
- QObject *target = vt;
- run(index, binding->executedBlocks, context, binding, binding->scope, target, flags, inv);
-
- if (!invalidated) {
- vt->write(*binding->target, property & 0x0000FFFF, flags);
- }
- } else {
- QQmlData *data = QQmlData::get(*binding->target);
- QQmlPropertyData *propertyData = (data && data->propertyCache ? data->propertyCache->property(property) : 0);
-
- if (propertyData && propertyData->isVarProperty()) {
- // We will allocate a V8 handle in this conversion/store
- v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(QQmlEnginePrivate::get(context->engine)->v8engine()->context());
-
- run(index, binding->executedBlocks, context, binding, binding->scope, *binding->target, flags, inv);
- } else {
- run(index, binding->executedBlocks, context, binding, binding->scope, *binding->target, flags, inv);
- }
- }
- binding->setUpdatingFlag(false);
-
- if (invalidated) {
- // This binding is no longer valid - fallback to V8
- Q_ASSERT(fallbackIndex > -1);
- QQmlAbstractBinding *b = QQmlPropertyPrivate::activateSharedBinding(context, fallbackIndex, flags);
- Q_ASSERT(b == binding);
- b->destroy();
- }
-}
-
-void QV4Bindings::subscribeId(QQmlContextData *p, int idIndex, int subIndex)
-{
- Subscription *sub = (subscriptions + subIndex);
- sub->disconnect();
-
- if (p->idValues[idIndex]) {
- sub->setBindings(this);
- sub->connect(&p->idValues[idIndex].bindings);
- sub->setActive(true);
- } else {
- sub->setActive(false);
- }
-}
-
-void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex, QQmlEngine *e)
-{
- Subscription *sub = (subscriptions + subIndex);
- if (sub->isConnected(o, notifyIndex))
- return;
- sub->setBindings(this);
- if (o) {
- sub->connect(o, notifyIndex, e);
- sub->setActive(true);
- } else {
- sub->disconnect();
- sub->setActive(false);
- }
-}
-
-static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4)
-{
- QVariant qtscript = qtscriptRaw;
-
- if (qtscript.userType() == v4.userType()) {
- } else if (qtscript.canConvert(v4.userType())) {
- qtscript.convert(v4.userType());
- } else if (qtscript.userType() == QVariant::Invalid && v4.userType() == QMetaType::QObjectStar) {
- qtscript = qVariantFromValue<QObject *>(0);
- } else {
- return false;
- }
-
- int type = qtscript.userType();
-
- if (type == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
- return QQmlMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData());
- } else if (type == QMetaType::Double) {
-
- double la = qvariant_cast<double>(qtscript);
- double lr = qvariant_cast<double>(v4);
-
- return la == lr || (qIsNaN(la) && qIsNaN(lr));
-
- } else if (type == QMetaType::Float) {
-
- float la = qvariant_cast<float>(qtscript);
- float lr = qvariant_cast<float>(v4);
-
- return la == lr || (qIsNaN(la) && qIsNaN(lr));
-
- } else {
- return qtscript == v4;
- }
-}
-
-QByteArray testResultToString(const QVariant &result, bool undefined)
-{
- if (undefined) {
- return "undefined";
- } else {
- QString rv;
- QDebug d(&rv);
- d << result;
- return rv.toUtf8();
- }
-}
-
-static void testBindingResult(const QString &binding, quint16 line, quint16 column,
- QQmlContextData *context, QObject *scope,
- const Register &result, int resultType)
-{
- QQmlExpression expression(context->asQQmlContext(), scope, binding);
- bool isUndefined = false;
- QVariant value = expression.evaluate(&isUndefined);
-
- bool iserror = false;
- QByteArray qtscriptResult;
- QByteArray v4Result;
-
- const int handleType = qMetaTypeId<v8::Handle<v8::Value> >();
-
- if (expression.hasError()) {
- iserror = true;
- qtscriptResult = "exception";
- } else if ((value.userType() != resultType) &&
- (resultType != QMetaType::QVariant) &&
- (resultType != qMetaTypeId<QJSValue>()) &&
- (resultType != handleType)) {
- // Override the QMetaType conversions to make them more JS friendly.
- if (value.userType() == QMetaType::Double && (resultType == QMetaType::QString ||
- resultType == QMetaType::QUrl)) {
- // number to string-like conversion.
- value = QVariant::fromValue<QString>(QString::number(value.toDouble(), 'g', 16));
- } else if (value.userType() == QMetaType::QUrl && resultType == QMetaType::Bool) {
- // url to bool conversion
- value = QVariant::fromValue<bool>(!value.toUrl().isEmpty());
- }
-
- if (!value.isNull() && !value.convert(resultType)) {
- iserror = true;
- qtscriptResult = "exception";
- } else if (resultType == QMetaType::QUrl) {
- // a V8 value was converted to QUrl.
- value = QVariant::fromValue<QUrl>(context->resolvedUrl(value.toUrl()));
- }
- }
-
- if (! iserror)
- qtscriptResult = testResultToString(value, isUndefined);
-
- if (isUndefined && result.isUndefined()) {
- return;
- } else if(isUndefined != result.isUndefined()) {
- iserror = true;
- }
-
- QVariant v4value;
- if (!result.isUndefined()) {
- switch (resultType) {
- case QMetaType::QString:
- v4value = *result.getstringptr();
- break;
- case QMetaType::QUrl:
- v4value = *result.geturlptr();
- break;
- case QMetaType::QObjectStar:
- v4value = qVariantFromValue<QObject *>(result.getQObject());
- break;
- case QMetaType::Bool:
- v4value = result.getbool();
- break;
- case QMetaType::Int:
- v4value = result.getint();
- break;
- case QMetaType::Double:
- v4value = result.getnumber();
- break;
- case QMetaType::QColor:
- v4value = QVariant(QMetaType::QColor, result.typeDataPtr());
- break;
- case QMetaType::QVariant:
- v4value = *result.getvariantptr();
- break;
- default:
- if (resultType == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
- v4value = QVariant(QQmlMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr());
- } else if (resultType == qMetaTypeId<QJSValue>()) {
- v4value = result.getjsvalueptr()->toVariant();
- } else if (resultType == handleType) {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
- v4value = ep->v8engine()->toVariant(*result.gethandleptr(), resultType);
- } else {
- iserror = true;
- v4Result = "Unknown V4 type";
- }
- }
- }
- if (v4Result.isEmpty())
- v4Result = testResultToString(v4value, result.isUndefined());
-
- if (!testCompareVariants(value, v4value))
- iserror = true;
-
- if (iserror) {
- qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ':' << line << ':' << column;
-
- qWarning().nospace() << " Binding: " << binding;
- qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
- qWarning().nospace() << " V4: " << v4Result.constData();
- }
-}
-
-static void testBindingException(const QString &binding, quint16 line, quint16 column,
- QQmlContextData *context, QObject *scope)
-{
- QQmlExpression expression(context->asQQmlContext(), scope, binding);
- bool isUndefined = false;
- QVariant value = expression.evaluate(&isUndefined);
-
- if (!expression.hasError()) {
- QByteArray qtscriptResult = testResultToString(value, isUndefined);
- qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ':' << line << ':' << column;
- qWarning().nospace() << " Binding: " << binding;
- qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
- qWarning().nospace() << " V4: exception";
- }
-}
-
-static void throwException(int id, QQmlDelayedError *error,
- QV4Program *program, QQmlContextData *context,
- const QString &description = QString())
-{
- if (description.isEmpty())
- error->setErrorDescription(QLatin1String("TypeError: Result of expression is not an object"));
- else
- error->setErrorDescription(description);
- if (id != 0xFF) {
- quint32 e = *((quint32 *)(program->data() + program->exceptionDataOffset) + id);
- error->setErrorLocation(context->url, (e >> 16), (e & 0xFFFF));
- } else {
- error->setErrorLocation(context->url, -1, -1);
- }
- if (!context->engine || !error->addError(QQmlEnginePrivate::get(context->engine)))
- QQmlEnginePrivate::warning(context->engine, error);
-}
-
-const double QV4Bindings::D32 = 4294967296.0;
-
-qint32 QV4Bindings::toInt32(double n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- double sign = (n < 0) ? -1.0 : 1.0;
- double abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D32);
- const double D31 = D32 / 2.0;
-
- if (sign == -1 && n < -D31)
- n += D32;
-
- else if (sign != -1 && n >= D31)
- n -= D32;
-
- return qint32 (n);
-}
-
-inline quint32 QV4Bindings::toUint32(double n)
-{
- if (qIsNaN(n) || qIsInf(n) || (n == 0))
- return 0;
-
- double sign = (n < 0) ? -1.0 : 1.0;
- double abs_n = fabs(n);
-
- n = ::fmod(sign * ::floor(abs_n), D32);
-
- if (n < 0)
- n += D32;
-
- return quint32 (n);
-}
-
-#define THROW_EXCEPTION_STR(id, str) { \
- if (testBinding) testBindingException(*testBindingSource, bindingLine, bindingColumn, context, scope); \
- throwException((id), error, program, context, (str)); \
- goto exceptionExit; \
-}
-
-#define THROW_VALUE_EXCEPTION_STR(id, str) { \
- throwException((id), error, program, context, (str)); \
- goto exceptionExit; \
-}
-
-#define THROW_EXCEPTION(id) THROW_EXCEPTION_STR(id, QString())
-
-#define MARK_REGISTER(reg) cleanupRegisterMask |= (1 << (reg))
-#define MARK_CLEAN_REGISTER(reg) cleanupRegisterMask &= ~(1 << (reg))
-
-#define STRING_REGISTER(reg) { \
- registers[(reg)].settype(QStringType); \
- MARK_REGISTER(reg); \
-}
-
-#define URL_REGISTER(reg) { \
- registers[(reg)].settype(QUrlType); \
- MARK_REGISTER(reg); \
-}
-
-#define COLOR_REGISTER(reg) { \
- registers[(reg)].settype(QColorType); \
- MARK_REGISTER(reg); \
-}
-
-#define VARIANT_REGISTER(reg) { \
- registers[(reg)].settype(QVariantType); \
- MARK_REGISTER(reg); \
-}
-
-#define V8HANDLE_REGISTER(reg) { \
- registers[(reg)].settype(V8HandleType); \
- MARK_REGISTER(reg); \
-}
-
-#define JSVALUE_REGISTER(reg) { \
- registers[(reg)].settype(QJSValueType); \
- MARK_REGISTER(reg); \
-}
-
-namespace {
-
-bool bindingInvalidated(bool *invalidated, QObject *obj, QQmlContextData *context, int index)
-{
- if (invalidated != 0) {
- if (QQmlData *data = QQmlData::get(obj, true)) {
- if (!data->propertyCache) {
- data->propertyCache = QQmlEnginePrivate::get(context->engine)->cache(obj);
- if (data->propertyCache) data->propertyCache->addref();
- }
-
- if (QQmlPropertyData *prop = data->propertyCache ? data->propertyCache->property(index) : 0) {
- if (prop->isOverridden()) {
- // TODO: avoid construction of name and name-based lookup
- int resolvedIndex = data->propertyCache->property(prop->name(obj), obj, context)->coreIndex;
- if (index < resolvedIndex) {
- *invalidated = true;
- return true;
- }
- }
- }
- }
- }
-
- return false;
-}
-
-}
-
-#ifdef QML_THREADED_INTERPRETER
-void **QV4Bindings::getDecodeInstrTable()
-{
- static void **decode_instr;
- if (!decode_instr) {
- QV4Bindings *dummy = new QV4Bindings(0, 0);
- quint32 executedBlocks = 0;
- dummy->run(0, executedBlocks, 0, 0, 0, 0,
- QQmlPropertyPrivate::BypassInterceptor,
- 0, &decode_instr);
- dummy->release();
- }
- return decode_instr;
-}
-#endif
-
-void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
- QQmlContextData *context, QQmlDelayedError *error,
- QObject *scope, QObject *output,
- QQmlPropertyPrivate::WriteFlags storeFlags,
- bool *invalidated
-#ifdef QML_THREADED_INTERPRETER
- ,void ***table
-#endif
- )
-{
-#ifdef QML_THREADED_INTERPRETER
- if (table) {
- static void *decode_instr[] = {
- FOR_EACH_V4_INSTR(QML_V4_INSTR_ADDR)
- };
-
- *table = decode_instr;
- return;
- }
-#endif
-
-
- error->removeError();
-
- Register registers[32];
- quint32 cleanupRegisterMask = 0;
-
- executedBlocks = 0;
-
- const char *code = program->instructions();
- code += instrIndex * QML_V4_INSTR_SIZE(Jump, jump);
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
-
- const char *data = program->data();
-
- QString *testBindingSource = 0;
- bool testBinding = false;
- int bindingLine = 0;
- int bindingColumn = 0;
-
-#ifdef QML_THREADED_INTERPRETER
- goto *instr->common.code;
-#else
- for (;;) {
- switch (instr->common.type) {
-#endif
-
- QML_V4_BEGIN_INSTR(Noop, common)
- QML_V4_END_INSTR(Noop, common)
-
- QML_V4_BEGIN_INSTR(BindingId, id)
- bindingLine = instr->id.line;
- bindingColumn = instr->id.column;
- QML_V4_END_INSTR(BindingId, id)
-
- QML_V4_BEGIN_INSTR(SubscribeId, subscribeop)
- subscribeId(context, instr->subscribeop.index, instr->subscribeop.offset);
- QML_V4_END_INSTR(SubscribeId, subscribeop)
-
- QML_V4_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
- {
- Register &reg = registers[instr->fetchAndSubscribe.reg];
-
- if (reg.isUndefined())
- THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
-
- QObject *object = reg.getQObject();
- if (!object) {
- THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
- } else {
- if (bindingInvalidated(invalidated, object, context, instr->fetchAndSubscribe.property.coreIndex))
- goto programExit;
-
- const Register::Type valueType = (Register::Type)instr->fetchAndSubscribe.valueType;
- reg.init(valueType);
- if (instr->fetchAndSubscribe.valueType >= FirstCleanupType)
- MARK_REGISTER(instr->fetchAndSubscribe.reg);
-
- QQmlData::flushPendingBinding(object, instr->fetchAndSubscribe.property.coreIndex);
-
- QQmlAccessors *accessors = instr->fetchAndSubscribe.property.accessors;
- accessors->read(object, instr->fetchAndSubscribe.property.accessorData,
- reg.typeDataPtr());
-
- if (valueType == FloatType) {
- // promote floats
- const double v = reg.getfloat();
- reg.setnumber(v);
- }
-
- if (accessors->notifier) {
- QQmlNotifier *notifier = 0;
- accessors->notifier(object, instr->fetchAndSubscribe.property.accessorData, &notifier);
- if (notifier) {
- int subIdx = instr->fetchAndSubscribe.subscription;
- Subscription *sub = 0;
- if (subIdx != -1) {
- sub = (subscriptions + subIdx);
- sub->setBindings(this);
- }
- sub->connect(notifier);
- }
- } else {
- const int notifyIndex = instr->fetchAndSubscribe.property.notifyIndex;
- if (notifyIndex != -1) {
- const int subIdx = instr->fetchAndSubscribe.subscription;
- subscribe(object, notifyIndex, subIdx, context->engine);
- }
- }
- }
- }
- QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
-
- QML_V4_BEGIN_INSTR(LoadId, load)
- registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
- QML_V4_END_INSTR(LoadId, load)
-
- QML_V4_BEGIN_INSTR(LoadScope, load)
- registers[instr->load.reg].setQObject(scope);
- QML_V4_END_INSTR(LoadScope, load)
-
- QML_V4_BEGIN_INSTR(LoadRoot, load)
- registers[instr->load.reg].setQObject(context->contextObject);
- QML_V4_END_INSTR(LoadRoot, load)
-
- QML_V4_BEGIN_INSTR(LoadSingletonObject, load)
- {
- Register &reg = registers[instr->load.reg];
-
- const QString *name = reg.getstringptr();
- QQmlTypeNameCache::Result r = context->imports->query(*name);
- reg.cleanupString();
-
- if (r.isValid() && r.type) {
- if (r.type->isSingleton()) {
- QQmlEngine *e = context->engine;
- QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo();
- siinfo->init(e); // note: this will also create QJSValue singleton, which is not strictly required here.
- QObject *qobjectSingleton = siinfo->qobjectApi(e);
- if (qobjectSingleton)
- reg.setQObject(qobjectSingleton);
- }
- }
- }
- QML_V4_END_INSTR(LoadSingletonObject, load)
-
- QML_V4_BEGIN_INSTR(LoadAttached, attached)
- {
- const Register &input = registers[instr->attached.reg];
- Register &output = registers[instr->attached.output];
- if (input.isUndefined())
- THROW_EXCEPTION(instr->attached.exceptionId);
-
- QObject *object = registers[instr->attached.reg].getQObject();
- if (!object) {
- output.setUndefined();
- } else {
- QObject *attached = qmlAttachedPropertiesObjectById(instr->attached.id, input.getQObject(), true);
- Q_ASSERT(attached);
- output.setQObject(attached);
- }
- }
- QML_V4_END_INSTR(LoadAttached, attached)
-
- QML_V4_BEGIN_INSTR(UnaryNot, unaryop)
- {
- registers[instr->unaryop.output].setbool(!registers[instr->unaryop.src].getbool());
- }
- QML_V4_END_INSTR(UnaryNot, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryMinusNumber, unaryop)
- {
- registers[instr->unaryop.output].setnumber(-registers[instr->unaryop.src].getnumber());
- }
- QML_V4_END_INSTR(UnaryMinusNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryMinusInt, unaryop)
- {
- registers[instr->unaryop.output].setint(-registers[instr->unaryop.src].getint());
- }
- QML_V4_END_INSTR(UnaryMinusInt, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryPlusNumber, unaryop)
- {
- registers[instr->unaryop.output].setnumber(+registers[instr->unaryop.src].getnumber());
- }
- QML_V4_END_INSTR(UnaryPlusNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(UnaryPlusInt, unaryop)
- {
- registers[instr->unaryop.output].setint(+registers[instr->unaryop.src].getint());
- }
- QML_V4_END_INSTR(UnaryPlusInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(src.getbool());
- }
- QML_V4_END_INSTR(ConvertBoolToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getjsvalueptr()) QJSValue(src.getbool());
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertBoolToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setnumber(src.getbool());
- }
- QML_V4_END_INSTR(ConvertBoolToNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QLatin1String(src.getbool() ? "true" : "false"));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertBoolToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getvariantptr()) QVariant(src.getbool());
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertBoolToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertBoolToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.gethandleptr()) v8::Handle<v8::Value>(v8::Boolean::New(src.getbool()));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertBoolToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setbool(src.getint());
- }
- QML_V4_END_INSTR(ConvertIntToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getjsvalueptr()) QJSValue(src.getint());
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertIntToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else if (src.isNaN()) output.setNaN();
- else if (src.isInf()) output.setInf(src.getint() == Register::NegativeInfinity);
- else if (src.isNegativeZero()) output.setNegativeZero();
- else output.setnumber(double(src.getint()));
- }
- QML_V4_END_INSTR(ConvertIntToNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QString::number(src.getint()));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertIntToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getvariantptr()) QVariant(src.getint());
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertIntToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertIntToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.gethandleptr()) v8::Handle<v8::Value>(v8::Integer::New(src.getint()));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertIntToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertJSValueToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QJSValue tmp(*src.getjsvalueptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupJSValue();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- if (tmp.isUndefined()) {
- output.setUndefined();
- } else {
- QV8Engine *v8engine = QQmlEnginePrivate::get(context->engine)->v8engine();
- new (output.gethandleptr()) v8::Handle<v8::Value>(
- v8::Value::fromV4Value(QJSValuePrivate::get(tmp)->value));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- }
- QML_V4_END_INSTR(ConvertJSValueToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setbool(src.getnumber() != 0);
- }
- QML_V4_END_INSTR(ConvertNumberToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(toInt32(src.getnumber()));
- }
- QML_V4_END_INSTR(ConvertNumberToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getjsvalueptr()) QJSValue(src.getnumber());
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertNumberToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getstringptr()) QString(QString::number(src.getnumber(), 'g', 16));
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertNumberToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.getvariantptr()) QVariant(src.getnumber());
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertNumberToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNumberToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- new (output.gethandleptr()) v8::Handle<v8::Value>(v8::Number::New(src.getnumber()));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertNumberToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setbool(tmp.toBool());
- }
- }
- QML_V4_END_INSTR(ConvertStringToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToInt, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setint(tmp.toInt());
- }
- }
- QML_V4_END_INSTR(ConvertStringToInt, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getjsvalueptr()) QJSValue(tmp);
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
- // Ideally we should just call the methods in the QScript namespace directly.
- QJSValue tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setnumber(tmp.toNumber());
- }
- }
- QML_V4_END_INSTR(ConvertStringToNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToUrl, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QString tmp(*src.getstringptr());
- // Encoded dir-separators defeat QUrl processing - decode them first
- tmp.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive);
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.geturlptr()) QUrl(tmp);
-
- URL_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- QQml_valueTypeProvider()->createValueFromString(QMetaType::QColor, tmp, output.typeDataPtr(), output.dataSize());
-
- COLOR_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToColor, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getvariantptr()) QVariant(tmp);
-
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertStringToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QString tmp(*src.getstringptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupString();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.gethandleptr()) v8::Handle<v8::Value>(QJSConverter::toString(tmp));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertStringToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- output.setbool(!tmp.isEmpty());
- }
- }
- QML_V4_END_INSTR(ConvertUrlToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getjsvalueptr()) QJSValue(tmp.toString());
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertUrlToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getstringptr()) QString(tmp.toString());
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertUrlToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getvariantptr()) QVariant(tmp);
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertUrlToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertUrlToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupUrl();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.gethandleptr()) v8::Handle<v8::Value>(QJSConverter::toString(tmp.toString()));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertUrlToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- // for compatibility with color behavior in v8, always true
- output.setbool(true);
- }
- }
- QML_V4_END_INSTR(ConvertColorToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QVariant tmp(QMetaType::QColor, src.typeDataPtr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupColor();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
-
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
- QV8Engine *v8engine = ep->v8engine();
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(QMetaType::QColor);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
- new (output.getjsvalueptr()) QJSValue(v8engine->scriptValueFromInternal(
- v8engine->valueTypeWrapper()->newValueType(tmp, vt)->v4Value()));
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertColorToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QQml_valueTypeProvider()->createStringFromValue(QMetaType::QColor, src.typeDataPtr(), output.getstringptr());
- STRING_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertColorToString, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QVariant tmp(QMetaType::QColor, src.typeDataPtr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupColor();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- new (output.getvariantptr()) QVariant(tmp);
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertColorToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertColorToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QVariant tmp(QMetaType::QColor, src.typeDataPtr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupColor();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
-
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(QMetaType::QColor);
- new (output.gethandleptr()) v8::Handle<v8::Value>(ep->v8engine()->valueTypeWrapper()->newValueType(tmp, vt));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertColorToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertObjectToBool, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined())
- output.setUndefined();
- else
- output.setbool(src.getQObject() != 0);
- }
- QML_V4_END_INSTR(ConvertObjectToBool, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertObjectToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
- new (output.getjsvalueptr()) QJSValue(context->engine->newQObject(src.getQObject()));
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertObjectToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertObjectToVariant, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined())
- output.setUndefined();
- else {
- new (output.getvariantptr()) QVariant(qVariantFromValue<QObject *>(src.getQObject()));
- VARIANT_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertObjectToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertObjectToVar, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- // ### NaN
- if (src.isUndefined())
- output.setUndefined();
- else {
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
- new (output.gethandleptr()) v8::Handle<v8::Value>(ep->v8engine()->newQObject(src.getQObject()));
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertObjectToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertVarToJSValue, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- v8::Handle<v8::Value> tmp(*src.gethandleptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- output.cleanupHandle();
- MARK_CLEAN_REGISTER(instr->unaryop.output);
- }
- QV8Engine *v8engine = QQmlEnginePrivate::get(context->engine)->v8engine();
- new (output.getjsvalueptr()) QJSValue(v8engine->scriptValueFromInternal(tmp->v4Value()));
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- }
- QML_V4_END_INSTR(ConvertVarToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNullToJSValue, unaryop)
- {
- Register &output = registers[instr->unaryop.output];
- new (output.getjsvalueptr()) QJSValue(QJSValue::NullValue);
- JSVALUE_REGISTER(instr->unaryop.output);
- }
- QML_V4_END_INSTR(ConvertNullToJSValue, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNullToObject, unaryop)
- {
- Register &output = registers[instr->unaryop.output];
- output.setQObject(0);
- }
- QML_V4_END_INSTR(ConvertNullToObject, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNullToVariant, unaryop)
- {
- Register &output = registers[instr->unaryop.output];
- new (output.getvariantptr()) QVariant();
- VARIANT_REGISTER(instr->unaryop.output);
- }
- QML_V4_END_INSTR(ConvertNullToVariant, unaryop)
-
- QML_V4_BEGIN_INSTR(ConvertNullToVar, unaryop)
- {
- Register &output = registers[instr->unaryop.output];
- new (output.gethandleptr()) v8::Handle<v8::Value>(v8::Null());
- V8HANDLE_REGISTER(instr->unaryop.output);
- }
- QML_V4_END_INSTR(ConvertNullToVar, unaryop)
-
- QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) {
- output.setUndefined();
- } else {
- const QUrl tmp(*src.geturlptr());
- if (instr->unaryop.src == instr->unaryop.output) {
- *output.geturlptr() = context->resolvedUrl(tmp);
- } else {
- new (output.geturlptr()) QUrl(context->resolvedUrl(tmp));
- URL_REGISTER(instr->unaryop.output);
- }
- }
- }
- QML_V4_END_INSTR(ResolveUrl, unaryop)
-
- QML_V4_BEGIN_INSTR(MathSinNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setnumber(qSin(src.getnumber()));
- }
- QML_V4_END_INSTR(MathSinNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathCosNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setnumber(qCos(src.getnumber()));
- }
- QML_V4_END_INSTR(MathCosNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathAbsNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setnumber(clearSignBit(qAbs(src.getnumber())));
- }
- QML_V4_END_INSTR(MathAbsNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathRoundNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(qRound(src.getnumber()));
- }
- QML_V4_END_INSTR(MathRoundNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathFloorNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined())
- output.setUndefined();
- else if (src.isNaN())
- // output should be an int, but still NaN
- output.setNaNType();
- else if (src.isInf())
- // output should be an int, but still Inf
- output.setInfType(signBitSet(src.getnumber()));
- else if (src.isNegativeZero())
- // output should be an int, but still -0
- output.setNegativeZeroType();
- else
- output.setint(qFloor(src.getnumber()));
- }
- QML_V4_END_INSTR(MathFloorNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathCeilNumber, unaryop)
- {
- const Register &src = registers[instr->unaryop.src];
- Register &output = registers[instr->unaryop.output];
- if (src.isUndefined())
- output.setUndefined();
- else if (src.isNaN())
- // output should be an int, but still NaN
- output.setNaNType();
- else if (src.isInf())
- // output should be an int, but still Inf
- output.setInfType(signBitSet(src.getnumber()));
- else if (src.isNegativeZero())
- // output should be an int, but still -0
- output.setNegativeZeroType();
- else {
- // Ensure that we preserve the sign bit (Math.ceil(-0) -> -0)
- const double input = src.getnumber();
- const int ceiled = qCeil(input);
- if (ceiled == 0 && signBitSet(input)) {
- output.setNegativeZeroType();
- } else {
- output.setint(ceiled);
- }
- }
- }
- QML_V4_END_INSTR(MathCeilNumber, unaryop)
-
- QML_V4_BEGIN_INSTR(MathPINumber, unaryop)
- {
- static const double qmlPI = 2.0 * qAsin(1.0);
- Register &output = registers[instr->unaryop.output];
- output.setnumber(qmlPI);
- }
- QML_V4_END_INSTR(MathPINumber, unaryop)
-
- QML_V4_BEGIN_INSTR(LoadNull, null_value)
- registers[instr->null_value.reg].setNull();
- QML_V4_END_INSTR(LoadNull, null_value)
-
- QML_V4_BEGIN_INSTR(LoadNumber, number_value)
- registers[instr->number_value.reg].setnumber(instr->number_value.value);
- QML_V4_END_INSTR(LoadNumber, number_value)
-
- QML_V4_BEGIN_INSTR(LoadInt, int_value)
- registers[instr->int_value.reg].setint(instr->int_value.value);
- QML_V4_END_INSTR(LoadInt, int_value)
-
- QML_V4_BEGIN_INSTR(LoadBool, bool_value)
- registers[instr->bool_value.reg].setbool(instr->bool_value.value);
- QML_V4_END_INSTR(LoadBool, bool_value)
-
- QML_V4_BEGIN_INSTR(LoadString, string_value)
- {
- Register &output = registers[instr->string_value.reg];
- QChar *string = (QChar *)(data + instr->string_value.offset);
- new (output.getstringptr()) QString(string, instr->string_value.length);
- STRING_REGISTER(instr->string_value.reg);
- }
- QML_V4_END_INSTR(LoadString, string_value)
-
- QML_V4_BEGIN_INSTR(EnableV4Test, string_value)
- {
- testBindingSource = new QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
- testBinding = true;
- }
- QML_V4_END_INSTR(String, string_value)
-
- QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitAndInt, binaryop)
-
- QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitAndInt, binaryop)
-
- QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(BitXorInt, binaryop)
-
- QML_V4_BEGIN_INSTR(AddNumber, binaryop)
- {
- registers[instr->binaryop.output].setnumber(registers[instr->binaryop.left].getnumber() +
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(AddNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(AddString, binaryop)
- {
- QString &string = *registers[instr->binaryop.output].getstringptr();
- if (instr->binaryop.output == instr->binaryop.left) {
- string += registers[instr->binaryop.right].getstringptr();
- } else {
- string = *registers[instr->binaryop.left].getstringptr() +
- *registers[instr->binaryop.right].getstringptr();
- }
- }
- QML_V4_END_INSTR(AddString, binaryop)
-
- QML_V4_BEGIN_INSTR(SubNumber, binaryop)
- {
- registers[instr->binaryop.output].setnumber(registers[instr->binaryop.left].getnumber() -
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(SubNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(MulNumber, binaryop)
- {
- registers[instr->binaryop.output].setnumber(registers[instr->binaryop.left].getnumber() *
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(MulNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(DivNumber, binaryop)
- {
- registers[instr->binaryop.output].setnumber(registers[instr->binaryop.left].getnumber() /
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(DivNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(ModNumber, binaryop)
- {
- Register &target = registers[instr->binaryop.output];
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- target.setnumber(::fmod(left.getnumber(), right.getnumber()));
- }
- QML_V4_END_INSTR(ModInt, binaryop)
-
- QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(LShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(RShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
- {
- registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
- registers[instr->binaryop.right].getint());
- }
- QML_V4_END_INSTR(URShiftInt, binaryop)
-
- QML_V4_BEGIN_INSTR(GtNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() >
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(GtNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(LtNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() <
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(LtNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(GeNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() >=
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(GeNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(LeNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() <=
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(LeNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(EqualNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() ==
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(EqualNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(NotEqualNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() !=
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(NotEqualNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictEqualNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() ==
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(StrictEqualNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictNotEqualNumber, binaryop)
- {
- registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getnumber() !=
- registers[instr->binaryop.right].getnumber());
- }
- QML_V4_END_INSTR(StrictNotEqualNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(GtString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a > b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(GtString, binaryop)
-
- QML_V4_BEGIN_INSTR(LtString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a < b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(LtString, binaryop)
-
- QML_V4_BEGIN_INSTR(GeString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a >= b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(GeString, binaryop)
-
- QML_V4_BEGIN_INSTR(LeString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a <= b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(LeString, binaryop)
-
- QML_V4_BEGIN_INSTR(EqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a == b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(EqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(NotEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a != b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(NotEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a == b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(StrictEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictNotEqualString, binaryop)
- {
- const QString &a = *registers[instr->binaryop.left].getstringptr();
- const QString &b = *registers[instr->binaryop.right].getstringptr();
- bool result = a != b;
- if (instr->binaryop.left == instr->binaryop.output) {
- registers[instr->binaryop.output].cleanupString();
- MARK_CLEAN_REGISTER(instr->binaryop.output);
- }
- registers[instr->binaryop.output].setbool(result);
- }
- QML_V4_END_INSTR(StrictNotEqualString, binaryop)
-
- QML_V4_BEGIN_INSTR(EqualObject, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- QObject *leftobj = (left.gettype() == NullType) ? 0 : left.getQObject();
- QObject *rightobj = (right.gettype() == NullType) ? 0 : right.getQObject();
- registers[instr->binaryop.output].setbool(leftobj == rightobj);
- }
- QML_V4_END_INSTR(EqualObject, binaryop)
-
- QML_V4_BEGIN_INSTR(NotEqualObject, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- QObject *leftobj = (left.gettype() == NullType) ? 0 : left.getQObject();
- QObject *rightobj = (right.gettype() == NullType) ? 0 : right.getQObject();
- registers[instr->binaryop.output].setbool(leftobj != rightobj);
- }
- QML_V4_END_INSTR(NotEqualObject, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictEqualObject, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- QObject *leftobj = (left.gettype() == NullType) ? 0 : left.getQObject();
- QObject *rightobj = (right.gettype() == NullType) ? 0 : right.getQObject();
- registers[instr->binaryop.output].setbool(leftobj == rightobj);
- }
- QML_V4_END_INSTR(StrictEqualObject, binaryop)
-
- QML_V4_BEGIN_INSTR(StrictNotEqualObject, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- QObject *leftobj = (left.gettype() == NullType) ? 0 : left.getQObject();
- QObject *rightobj = (right.gettype() == NullType) ? 0 : right.getQObject();
- registers[instr->binaryop.output].setbool(leftobj != rightobj);
- }
- QML_V4_END_INSTR(StrictNotEqualObject, binaryop)
-
- QML_V4_BEGIN_INSTR(MathMaxNumber, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- Register &output = registers[instr->binaryop.output];
- if (left.isUndefined() || right.isUndefined()) {
- output.setUndefined();
- } else {
- const double lhs = left.getnumber();
- const double rhs = right.getnumber();
- double result(lhs);
- if (lhs == rhs) {
- // If these are both zero, +0 is greater than -0
- if (signBitSet(lhs) && !signBitSet(rhs))
- result = rhs;
- } else {
- result = qMax(lhs, rhs);
- }
- output.setnumber(result);
- }
- }
- QML_V4_END_INSTR(MathMaxNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(MathMinNumber, binaryop)
- {
- const Register &left = registers[instr->binaryop.left];
- const Register &right = registers[instr->binaryop.right];
- Register &output = registers[instr->binaryop.output];
- if (left.isUndefined() || right.isUndefined()) {
- output.setUndefined();
- } else {
- const double lhs = left.getnumber();
- const double rhs = right.getnumber();
- double result(lhs);
- if (lhs == rhs) {
- // If these are both zero, -0 is lesser than +0
- if (!signBitSet(lhs) && signBitSet(rhs))
- result = rhs;
- } else {
- result = qMin(lhs, rhs);
- }
- output.setnumber(result);
- }
- }
- QML_V4_END_INSTR(MathMinNumber, binaryop)
-
- QML_V4_BEGIN_INSTR(NewString, construct)
- {
- Register &output = registers[instr->construct.reg];
- new (output.getstringptr()) QString;
- STRING_REGISTER(instr->construct.reg);
- }
- QML_V4_END_INSTR(NewString, construct)
-
- QML_V4_BEGIN_INSTR(NewUrl, construct)
- {
- Register &output = registers[instr->construct.reg];
- new (output.geturlptr()) QUrl;
- URL_REGISTER(instr->construct.reg);
- }
- QML_V4_END_INSTR(NewUrl, construct)
-
- QML_V4_BEGIN_INSTR(Fetch, fetch)
- {
- Register &reg = registers[instr->fetch.reg];
-
- if (reg.isUndefined())
- THROW_EXCEPTION(instr->fetch.exceptionId);
-
- QObject *object = reg.getQObject();
- if (!object) {
- THROW_EXCEPTION(instr->fetch.exceptionId);
- } else {
- if (bindingInvalidated(invalidated, object, context, instr->fetch.index))
- goto programExit;
-
- const Register::Type valueType = (Register::Type)instr->fetch.valueType;
- reg.init(valueType);
- if (instr->fetch.valueType >= FirstCleanupType)
- MARK_REGISTER(instr->fetch.reg);
-
- QQmlData::flushPendingBinding(object, instr->fetch.index);
-
- void *argv[] = { reg.typeDataPtr(), 0 };
- QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
- if (valueType == FloatType) {
- // promote floats
- const double v = reg.getfloat();
- reg.setnumber(v);
- }
-
- if (instr->fetch.subIndex != static_cast<quint32>(-1))
- subscribe(object, instr->fetch.subIndex, instr->fetch.subOffset, context->engine);
-
- }
- }
- QML_V4_END_INSTR(Fetch, fetch)
-
- QML_V4_BEGIN_INSTR(TestV4Store, storetest)
- {
- Register &data = registers[instr->storetest.reg];
- testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
- scope, data, instr->storetest.regType);
- }
- QML_V4_END_INSTR(TestV4Store, storetest)
-
- QML_V4_BEGIN_INSTR(Store, store)
- {
- Register &data = registers[instr->store.reg];
-
- if (data.isUndefined())
- THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign undefined value"));
-
- if (data.gettype() == QObjectStarType) {
- if (QObject *dataObject = data.getQObject()) {
- QQmlMetaObject dataMo(dataObject);
-
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
-
- QQmlMetaObject receiverMo;
-
- if (QQmlData::get(output, false) && QQmlData::get(output, false)->propertyCache) {
- QQmlPropertyData *receiver =
- QQmlData::get(output, false)->propertyCache->property(instr->store.index);
- receiverMo = ep->rawMetaObjectForType(receiver->propType);
- } else {
- QMetaProperty receiver = output->metaObject()->property(instr->store.index);
- receiverMo = ep->rawMetaObjectForType(receiver.userType());
- }
-
- // Verify that these types are compatible
- if (!QQmlMetaObject::canConvert(dataMo, receiverMo)) {
- THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign ") +
- QLatin1String(dataMo.className()) +
- QLatin1String(" to ") +
- QLatin1String(receiverMo.className()));
- }
- }
- }
-
- if (instr->store.valueType == FloatType) {
- // cast numbers to floats
- const float v = (float) data.getnumber();
- data.setfloat(v);
- }
-
- if (data.gettype() == V8HandleType) {
- // This property must be a VME var property
- QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(output);
- Q_ASSERT(vmemo);
- vmemo->setVMEProperty(instr->store.index, *data.gethandleptr());
- } else {
- int status = -1;
- void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
- QMetaObject::metacall(output, QMetaObject::WriteProperty,
- instr->store.index, argv);
- }
-
- goto programExit;
- }
- QML_V4_END_INSTR(Store, store)
-
- QML_V4_BEGIN_INSTR(Copy, copy)
- registers[instr->copy.reg].copy(registers[instr->copy.src]);
- if (registers[instr->copy.reg].gettype() >= FirstCleanupType)
- MARK_REGISTER(instr->copy.reg);
- QML_V4_END_INSTR(Copy, copy)
-
- QML_V4_BEGIN_INSTR(Jump, jump)
- if (instr->jump.reg == -1 || !registers[instr->jump.reg].getbool())
- code += instr->jump.count;
- QML_V4_END_INSTR(Jump, jump)
-
- QML_V4_BEGIN_INSTR(BranchTrue, branchop)
- if (registers[instr->branchop.reg].getbool())
- code += instr->branchop.offset;
- QML_V4_END_INSTR(BranchTrue, branchop)
-
- QML_V4_BEGIN_INSTR(BranchFalse, branchop)
- if (! registers[instr->branchop.reg].getbool())
- code += instr->branchop.offset;
- QML_V4_END_INSTR(BranchFalse, branchop)
-
- QML_V4_BEGIN_INSTR(Branch, branchop)
- code += instr->branchop.offset;
- QML_V4_END_INSTR(Branch, branchop)
-
- QML_V4_BEGIN_INSTR(Block, blockop)
- executedBlocks |= instr->blockop.block;
- QML_V4_END_INSTR(Block, blockop)
-
- QML_V4_BEGIN_INSTR(CleanupRegister, cleanup)
- registers[instr->cleanup.reg].cleanup();
- QML_V4_END_INSTR(CleanupRegister, cleanup)
-
- QML_V4_BEGIN_INSTR(Throw, throwop)
- THROW_VALUE_EXCEPTION_STR(instr->throwop.exceptionId, *registers[instr->throwop.message].getstringptr());
- QML_V4_END_INSTR(Throw, throwop)
-
-#ifdef QML_THREADED_INTERPRETER
- // nothing to do
-#else
- default:
- qFatal("QV4: Unknown instruction %d encountered.", instr->common.type);
- break;
- } // switch
-
- } // while
-#endif
-
- Q_ASSERT(!"Unreachable code reached");
-
-programExit:
-exceptionExit:
- delete testBindingSource;
-
- int reg = 0;
- while (cleanupRegisterMask) {
- if (cleanupRegisterMask & 0x1)
- registers[reg].cleanup();
-
- reg++;
- cleanupRegisterMask >>= 1;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4bindings_p.h b/src/qml/qml/v4/qv4bindings_p.h
deleted file mode 100644
index adb05ba1f4..0000000000
--- a/src/qml/qml/v4/qv4bindings_p.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4BINDINGS_P_H
-#define QV4BINDINGS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qqmlexpression_p.h"
-#include "private/qqmlbinding_p.h"
-#include "private/qqmlinstruction_p.h"
-#include "private/qv4instruction_p.h"
-#include "private/qpointervaluepair_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct QV4Program;
-class QV4Bindings : public QQmlAbstractExpression,
- public QQmlRefCount
-{
- Q_DECLARE_TR_FUNCTIONS(QV4Bindings)
-public:
- QV4Bindings(const char *program, QQmlContextData *context);
- virtual ~QV4Bindings();
-
- QQmlAbstractBinding *configBinding(QObject *target, QObject *scope,
- const QQmlInstruction::instr_assignV4Binding *);
-
-#ifdef QML_THREADED_INTERPRETER
- static void **getDecodeInstrTable();
-#endif
-
- struct Binding : public QQmlAbstractBinding, public QQmlDelayedError {
- Binding()
- : QQmlAbstractBinding(V4), target(0), scope(0), instruction(0), executedBlocks(0), parent(0) {}
-
- // Inherited from QQmlAbstractBinding
- static void destroy(QQmlAbstractBinding *, QQmlAbstractBinding::DestroyMode mode);
- static int propertyIndex(const QQmlAbstractBinding *);
- static QObject *object(const QQmlAbstractBinding *);
- static void setEnabled(QQmlAbstractBinding *, bool, QQmlPropertyPrivate::WriteFlags);
- static void update(QQmlAbstractBinding *, QQmlPropertyPrivate::WriteFlags);
- static void retargetBinding(QQmlAbstractBinding *, QObject *, int);
-
- void disconnect();
-
- void dump();
-
- struct Retarget {
- QObject *target;
- int targetProperty;
- };
-
- QPointerValuePair<QObject, Retarget> target;
- QObject *scope;
-
- // To save memory, we store flags inside the instruction pointer.
- // instruction.flag1: enabled
- // instruction.flag2: updating
- QFlagPointer<const QQmlInstruction::instr_assignV4Binding> instruction;
-
- quint32 executedBlocks;
- QV4Bindings *parent;
-
- inline bool enabledFlag() const { return instruction.flag(); }
- inline void setEnabledFlag(bool v) { instruction.setFlagValue(v); }
- inline bool updatingFlag() const { return instruction.flag2(); }
- inline void setUpdatingFlag(bool v) { instruction.setFlag2Value(v); }
- };
-
-private:
- Q_DISABLE_COPY(QV4Bindings)
-
- class Subscription : public QQmlNotifierEndpoint
- {
- public:
- inline Subscription();
-
- // Index of this Subscription into the QV4Bindings::subscriptions array.
- // This may not be used before setBindings() was called.
- inline int method() const;
-
- inline void setBindings(QV4Bindings *bindings);
- inline QV4Bindings *bindings() const;
-
- inline bool active() const;
- inline void setActive(bool active);
-
- // Pointer to the parent QV4Bindings. The flag is used as the 'active' value.
- QFlagPointer<QV4Bindings> m_bindings;
- };
- friend void QV4BindingsSubscription_callback(QQmlNotifierEndpoint *e, void **);
-
- Subscription *subscriptions;
-
- void subscriptionNotify(int);
- void run(Binding *, QQmlPropertyPrivate::WriteFlags flags);
-
- QV4Program *program;
- Binding *bindings;
-
- void init();
- void run(int instr, quint32 &executedBlocks, QQmlContextData *context,
- QQmlDelayedError *error, QObject *scope, QObject *output,
- QQmlPropertyPrivate::WriteFlags storeFlags,
- bool *invalidated
-#ifdef QML_THREADED_INTERPRETER
- , void ***decode_instr = 0
-#endif
- );
-
-
- inline void subscribeId(QQmlContextData *p, int idIndex, int subIndex);
- inline void subscribe(QObject *o, int notifyIndex, int subIndex, QQmlEngine *);
-
- inline static qint32 toInt32(double n);
- static const double D32;
- static quint32 toUint32(double n);
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QV4BINDINGS_P_H
-
diff --git a/src/qml/qml/v4vm/qv4booleanobject.cpp b/src/qml/qml/v4/qv4booleanobject.cpp
index 7c40b81c02..7c40b81c02 100644
--- a/src/qml/qml/v4vm/qv4booleanobject.cpp
+++ b/src/qml/qml/v4/qv4booleanobject.cpp
diff --git a/src/qml/qml/v4vm/qv4booleanobject_p.h b/src/qml/qml/v4/qv4booleanobject_p.h
index 79f5d4aa0b..79f5d4aa0b 100644
--- a/src/qml/qml/v4vm/qv4booleanobject_p.h
+++ b/src/qml/qml/v4/qv4booleanobject_p.h
diff --git a/src/qml/qml/v4vm/qv4codegen.cpp b/src/qml/qml/v4/qv4codegen.cpp
index 6196a03127..6196a03127 100644
--- a/src/qml/qml/v4vm/qv4codegen.cpp
+++ b/src/qml/qml/v4/qv4codegen.cpp
diff --git a/src/qml/qml/v4vm/qv4codegen_p.h b/src/qml/qml/v4/qv4codegen_p.h
index 9e95d89a4e..9e95d89a4e 100644
--- a/src/qml/qml/v4vm/qv4codegen_p.h
+++ b/src/qml/qml/v4/qv4codegen_p.h
diff --git a/src/qml/qml/v4/qv4compiler.cpp b/src/qml/qml/v4/qv4compiler.cpp
deleted file mode 100644
index d6ab73acc2..0000000000
--- a/src/qml/qml/v4/qv4compiler.cpp
+++ /dev/null
@@ -1,1580 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4compiler_p.h"
-#include "qv4compiler_p_p.h"
-#include "qv4program_p.h"
-#include "qv4ir_p.h"
-#include "qv4irbuilder_p.h"
-
-#include <private/qqmlglobal_p.h>
-#include <private/qqmljsast_p.h>
-#include <private/qqmlaccessors_p.h>
-#include <private/qqmljsengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER)
-DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
-DEFINE_BOOL_CONFIG_OPTION(qmlBindingsTestEnv, QML_BINDINGS_TEST)
-
-static bool qmlBindingsTest = false;
-static bool qmlEnableV4 = true;
-
-using namespace QQmlJS;
-QV4CompilerPrivate::QV4CompilerPrivate()
- : subscriptionOffset(0)
- , _function(0) , _block(0) , _discarded(false), registerCount(0)
- , bindingLine(0), bindingColumn(0), invalidatable(false)
-{
-}
-
-//
-// tracing
-//
-void QV4CompilerPrivate::trace(quint16 line, quint16 column)
-{
- bytecode.clear();
-
- this->bindingLine = line;
- this->bindingColumn = column;
- this->currentReg = _function->tempCount;
- this->registerCount = qMax(this->registerCount, this->currentReg);
-
- foreach (IR::BasicBlock *bb, _function->basicBlocks) {
- if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size())
- bb->JUMP(_function->basicBlocks.at(bb->index + 1));
- }
-
- QVector<IR::BasicBlock *> blocks;
- trace(&blocks);
- currentBlockMask = 0x00000001;
-
-
- for (int i = 0; !_discarded && i < blocks.size(); ++i) {
- IR::BasicBlock *block = blocks.at(i);
- IR::BasicBlock *next = i + 1 < blocks.size() ? blocks.at(i + 1) : 0;
- if (IR::Stmt *terminator = block->terminator()) {
- if (IR::CJump *cj = terminator->asCJump()) {
- if (cj->iffalse != next) {
- IR::Jump *jump = _function->pool->New<IR::Jump>();
- jump->init(cj->iffalse);
- block->statements.append(jump);
- }
- } else if (IR::Jump *j = terminator->asJump()) {
- if (j->target == next) {
- block->statements.resize(block->statements.size() - 1);
- }
- }
- }
-
- block->offset = bytecode.size();
-
- if (bytecode.isEmpty()) {
- if (qmlBindingsTest || bindingsDump()) {
- Instr::BindingId id;
- id.column = column;
- id.line = line;
- gen(id);
- }
-
- if (qmlBindingsTest) {
- QString str = expression->expression.asScript();
- QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
- int offset = data.count();
- data += strdata;
-
- Instr::EnableV4Test test;
- test.reg = 0;
- test.offset = offset;
- test.length = str.length();
- gen(test);
- }
- }
-
- bool usic = false;
- int patchesCount = patches.count();
- qSwap(usedSubscriptionIdsChanged, usic);
-
- int blockopIndex = bytecode.size();
- Instr::Block blockop;
- blockop.block = currentBlockMask;
- gen(blockop);
-
- foreach (IR::Stmt *s, block->statements) {
- if (! _discarded)
- s->accept(this);
- }
-
- qSwap(usedSubscriptionIdsChanged, usic);
-
- if (usic) {
- if (currentBlockMask == 0x80000000) {
- discard();
- return;
- }
- currentBlockMask <<= 1;
- } else if (! _discarded) {
- const int adjust = bytecode.remove(blockopIndex);
- // Correct patches
- for (int ii = patchesCount; ii < patches.count(); ++ii)
- patches[ii].offset -= adjust;
- }
- }
-
-#ifdef DEBUG_IR_STRUCTURE
- IR::IRDump dump;
- for (int i = 0; i < blocks.size(); ++i) {
- dump.basicblock(blocks.at(i));
- }
-#endif
-
-
- if (! _discarded) {
- // back patching
- foreach (const Patch &patch, patches) {
- V4Instr &instr = bytecode[patch.offset];
- int size = V4Instr::size(instructionType(&instr));
- instr.branchop.offset = patch.block->offset - patch.offset - size;
- }
-
- patches.clear();
- }
-}
-
-void QV4CompilerPrivate::trace(QVector<IR::BasicBlock *> *blocks)
-{
- for (int i = 0; i < _function->basicBlocks.size(); ++i) {
- IR::BasicBlock *block = _function->basicBlocks.at(i);
-
- while (! blocks->contains(block)) {
- blocks->append(block);
-
- if (IR::Stmt *terminator = block->terminator()) {
- if (IR::CJump *cj = terminator->asCJump())
- block = cj->iffalse;
- else if (IR::Jump *j = terminator->asJump())
- block = j->target;
- }
- }
- }
-}
-
-void QV4CompilerPrivate::traceExpression(IR::Expr *e, quint8 r)
-{
- if (!e) {
- discard();
- } else {
- qSwap(currentReg, r);
- e->accept(this);
- qSwap(currentReg, r);
- }
-}
-
-//
-// expressions
-//
-void QV4CompilerPrivate::visitConst(IR::Const *e)
-{
- switch (e->type) {
- case IR::BoolType: {
- Instr::LoadBool i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- case IR::IntType: {
- Instr::LoadInt i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- case IR::FloatType:
- case IR::NumberType: {
- Instr::LoadNumber i;
- i.reg = currentReg;
- i.value = e->value;
- gen(i);
- } break;
-
- case IR::NullType: {
- Instr::LoadNull i;
- i.reg = currentReg;
- gen(i);
- } break;
-
- default:
- if (qmlVerboseCompiler())
- qWarning() << Q_FUNC_INFO << "unexpected type";
- discard();
- }
-}
-
-void QV4CompilerPrivate::visitString(IR::String *e)
-{
- registerLiteralString(currentReg, e->value);
-}
-
-void QV4CompilerPrivate::visitName(IR::Name *e)
-{
- if (e->base) {
- // fetch the object and store it in reg.
- traceExpression(e->base, currentReg);
- } else {
- _subscribeName.clear();
- }
-
- if (e->storage == IR::Name::RootStorage) {
-
- Instr::LoadRoot instr;
- instr.reg = currentReg;
- gen(instr);
-
- if (e->symbol == IR::Name::IdObject) {
- // The ID is a reference to the root object
- return;
- }
-
- } else if (e->storage == IR::Name::ScopeStorage) {
-
- Instr::LoadScope instr;
- instr.reg = currentReg;
- gen(instr);
-
- _subscribeName << contextName();
-
- } else if (e->storage == IR::Name::IdStorage) {
-
- Instr::LoadId instr;
- instr.reg = currentReg;
- instr.index = e->idObject->idIndex;
- gen(instr);
-
- _subscribeName << QLatin1String("$$$ID_") + *e->id;
-
- if (blockNeedsSubscription(_subscribeName)) {
- Instr::SubscribeId sub;
- sub.reg = currentReg;
- sub.offset = subscriptionIndex(_subscribeName);
- sub.index = instr.index;
- gen(sub);
- }
-
- return;
- } else {
- // No action needed
- }
-
- switch (e->symbol) {
- case IR::Name::Unbound:
- case IR::Name::IdObject:
- case IR::Name::Slot:
- case IR::Name::Object: {
- Q_ASSERT(!"Unreachable");
- discard();
- } break;
-
- case IR::Name::AttachType: {
- _subscribeName << *e->id;
-
- Instr::LoadAttached attached;
- attached.output = currentReg;
- attached.reg = currentReg;
- attached.exceptionId = exceptionId(bindingLine, bindingColumn);
- if (e->declarativeType->attachedPropertiesId() == -1)
- discard();
- attached.id = e->declarativeType->attachedPropertiesId();
- gen(attached);
- } break;
-
- case IR::Name::SingletonObject: {
- /*
- Existing singleton type object lookup methods include:
- 1. string -> singleton object (search via importCache->query(name))
- 2. typeid -> singleton object QQmlType (search via ???)
- We currently use 1, which is not ideal for performance
- */
- _subscribeName << *e->id;
-
- registerLiteralString(currentReg, e->id);
-
- Instr::LoadSingletonObject module;
- module.reg = currentReg;
- gen(module);
- } break;
-
- case IR::Name::Property: {
- _subscribeName << *e->id;
-
- if (e->property->coreIndex == -1) {
- QMetaProperty prop;
- e->property->load(prop, QQmlEnginePrivate::get(engine));
- }
-
- const int propTy = e->property->propType;
- QQmlRegisterType regType;
-
- switch (propTy) {
- case QMetaType::Float:
- regType = FloatType;
- break;
- case QMetaType::Double:
- regType = NumberType;
- break;
- case QMetaType::Bool:
- regType = BoolType;
- break;
- case QMetaType::Int:
- regType = IntType;
- break;
- case QMetaType::QString:
- regType = QStringType;
- break;
- case QMetaType::QUrl:
- regType = QUrlType;
- break;
- case QMetaType::QColor:
- regType = QColorType;
- break;
- case QMetaType::QVariant:
- regType = QVariantType;
- break;
-
- default:
- if (propTy == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
- regType = PODValueType;
- } else if (!engine->metaObjectForType(propTy).isNull()) {
- regType = QObjectStarType;
- } else {
- if (qmlVerboseCompiler())
- qWarning() << "Discard unsupported property type:" << QMetaType::typeName(propTy);
- discard(); // Unsupported type
- return;
- }
-
- break;
- } // switch
-
- if (e->property->hasAccessors()) {
- Instr::FetchAndSubscribe fetch;
- fetch.reg = currentReg;
- fetch.subscription = subscriptionIndex(_subscribeName);
- fetch.exceptionId = exceptionId(e->line, e->column);
- fetch.valueType = regType;
- fetch.property = *e->property;
- gen(fetch);
- } else {
- Instr::Fetch fetch;
- fetch.reg = currentReg;
- fetch.index = e->property->coreIndex;
- fetch.exceptionId = exceptionId(e->line, e->column);
- fetch.valueType = regType;
-
- if (blockNeedsSubscription(_subscribeName) && e->property->notifyIndex != -1) {
- fetch.subOffset = subscriptionIndex(_subscribeName);
- fetch.subIndex = e->property->notifyIndex;
- } else {
- fetch.subOffset = static_cast<quint16>(-1);
- fetch.subIndex = static_cast<quint32>(-1);
- }
-
- gen(fetch);
- }
-
- } break;
- } // switch
-}
-
-void QV4CompilerPrivate::visitTemp(IR::Temp *e)
-{
- if (currentReg != e->index) {
- Instr::Copy i;
- i.reg = currentReg;
- i.src = e->index;
- gen(i);
- }
-}
-
-void QV4CompilerPrivate::visitUnop(IR::Unop *e)
-{
- quint8 src = currentReg;
-
- if (IR::Temp *temp = e->expr->asTemp()) {
- src = temp->index;
- } else {
- traceExpression(e->expr, src);
- }
-
- switch (e->op) {
- case IR::OpInvalid:
- Q_ASSERT(!"unreachable");
- break;
-
- case IR::OpIfTrue:
- convertToBool(e->expr, src);
- if (src != currentReg) {
- Instr::Copy i;
- i.reg = currentReg;
- i.src = src;
- gen(i);
- }
- break;
-
- case IR::OpNot: {
- Instr::UnaryNot i;
- convertToBool(e->expr, src);
- i.output = currentReg;
- i.src = src;
- gen(i);
- } break;
-
- case IR::OpUMinus:
- if (IR::isRealType(e->expr->type)) {
- Instr::UnaryMinusNumber i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else if (e->expr->type == IR::IntType) {
- convertToNumber(e->expr, currentReg);
- Instr::UnaryMinusNumber i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else {
- discard();
- }
- break;
-
- case IR::OpUPlus:
- if (IR::isRealType(e->expr->type)) {
- Instr::UnaryPlusNumber i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else if (e->expr->type == IR::IntType) {
- convertToNumber(e->expr, currentReg);
- Instr::UnaryPlusNumber i;
- i.output = currentReg;
- i.src = src;
- gen(i);
- } else {
- discard();
- }
- break;
-
- case IR::OpCompl:
- // TODO
- discard();
- break;
-
- case IR::OpBitAnd:
- case IR::OpBitOr:
- case IR::OpBitXor:
- case IR::OpAdd:
- case IR::OpSub:
- case IR::OpMul:
- case IR::OpDiv:
- case IR::OpMod:
- case IR::OpLShift:
- case IR::OpRShift:
- case IR::OpURShift:
- case IR::OpGt:
- case IR::OpLt:
- case IR::OpGe:
- case IR::OpLe:
- case IR::OpEqual:
- case IR::OpNotEqual:
- case IR::OpStrictEqual:
- case IR::OpStrictNotEqual:
- case IR::OpAnd:
- case IR::OpOr:
- Q_ASSERT(!"unreachable");
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToNumber(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::NumberType)
- return;
-
- switch (expr->type) {
- case IR::BoolType: {
- Instr::ConvertBoolToNumber i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::IntType: {
- Instr::ConvertIntToNumber i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::FloatType:
- case IR::NumberType:
- // nothing to do
- return;
-
- default:
- discard();
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToInt(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::IntType)
- return;
-
- switch (expr->type) {
- case IR::BoolType: {
- Instr::ConvertBoolToInt i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::IntType:
- // nothing to do
- return;
-
- case IR::FloatType:
- case IR::NumberType: {
- Instr::ConvertNumberToInt i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- default:
- discard();
- break;
- } // switch
-}
-
-void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg)
-{
- if (expr->type == IR::BoolType)
- return;
-
- switch (expr->type) {
- case IR::BoolType:
- // nothing to do
- break;
-
- case IR::IntType: {
- Instr::ConvertIntToBool i;
- i.output = i.src = reg;
- gen(i);
- } break;
-
- case IR::FloatType:
- case IR::NumberType: {
- Instr::ConvertNumberToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- case IR::StringType: {
- Instr::ConvertStringToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- case IR::ColorType: {
- Instr::ConvertColorToBool i;
- i.output = i.src = reg;
- gen(i);
- } return;
-
- default:
- discard();
- break;
- } // switch
-}
-
-quint8 QV4CompilerPrivate::instructionOpcode(IR::Binop *e)
-{
- switch (e->op) {
- case IR::OpInvalid:
- return V4Instr::Noop;
-
- case IR::OpIfTrue:
- case IR::OpNot:
- case IR::OpUMinus:
- case IR::OpUPlus:
- case IR::OpCompl:
- return V4Instr::Noop;
-
- case IR::OpBitAnd:
- return V4Instr::BitAndInt;
-
- case IR::OpBitOr:
- return V4Instr::BitOrInt;
-
- case IR::OpBitXor:
- return V4Instr::BitXorInt;
-
- case IR::OpAdd:
- if (e->type == IR::StringType)
- return V4Instr::AddString;
- return V4Instr::AddNumber;
-
- case IR::OpSub:
- return V4Instr::SubNumber;
-
- case IR::OpMul:
- return V4Instr::MulNumber;
-
- case IR::OpDiv:
- return V4Instr::DivNumber;
-
- case IR::OpMod:
- return V4Instr::ModNumber;
-
- case IR::OpLShift:
- return V4Instr::LShiftInt;
-
- case IR::OpRShift:
- return V4Instr::RShiftInt;
-
- case IR::OpURShift:
- return V4Instr::URShiftInt;
-
- case IR::OpGt:
- if (e->left->type == IR::StringType)
- return V4Instr::GtString;
- return V4Instr::GtNumber;
-
- case IR::OpLt:
- if (e->left->type == IR::StringType)
- return V4Instr::LtString;
- return V4Instr::LtNumber;
-
- case IR::OpGe:
- if (e->left->type == IR::StringType)
- return V4Instr::GeString;
- return V4Instr::GeNumber;
-
- case IR::OpLe:
- if (e->left->type == IR::StringType)
- return V4Instr::LeString;
- return V4Instr::LeNumber;
-
- case IR::OpEqual:
- if (e->left->type == IR::ObjectType || e->right->type == IR::ObjectType)
- return V4Instr::EqualObject;
- if (e->left->type == IR::StringType)
- return V4Instr::EqualString;
- return V4Instr::EqualNumber;
-
- case IR::OpNotEqual:
- if (e->left->type == IR::ObjectType || e->right->type == IR::ObjectType)
- return V4Instr::NotEqualObject;
- if (e->left->type == IR::StringType)
- return V4Instr::NotEqualString;
- return V4Instr::NotEqualNumber;
-
- case IR::OpStrictEqual:
- if (e->left->type == IR::ObjectType || e->right->type == IR::ObjectType)
- return V4Instr::StrictEqualObject;
- if (e->left->type == IR::StringType)
- return V4Instr::StrictEqualString;
- return V4Instr::StrictEqualNumber;
-
- case IR::OpStrictNotEqual:
- if (e->left->type == IR::ObjectType || e->right->type == IR::ObjectType)
- return V4Instr::StrictNotEqualObject;
- if (e->left->type == IR::StringType)
- return V4Instr::StrictNotEqualString;
- return V4Instr::StrictNotEqualNumber;
-
- case IR::OpAnd:
- case IR::OpOr:
- return V4Instr::Noop;
-
- } // switch
-
- return V4Instr::Noop;
-}
-
-void QV4CompilerPrivate::visitBinop(IR::Binop *e)
-{
- if (e->type == IR::InvalidType) {
- discard();
- return;
- }
-
- int left = currentReg;
- int right = currentReg + 1;
-
- if (e->left->asTemp() && e->type != IR::StringType)
- left = e->left->asTemp()->index;
- else
- traceExpression(e->left, left);
-
- if (IR::Temp *t = e->right->asTemp())
- right = t->index;
- else
- traceExpression(e->right, right);
-
- if (e->left->type != e->right->type) {
- if (qmlVerboseCompiler())
- qWarning().nospace() << "invalid operands to binary operator " << IR::binaryOperator(e->op)
- << "(`" << IR::binaryOperator(e->left->type)
- << "' and `"
- << IR::binaryOperator(e->right->type)
- << '\'';
- discard();
- return;
- }
-
- switch (e->op) {
- case IR::OpInvalid:
- discard();
- break;
-
- // unary
- case IR::OpIfTrue:
- case IR::OpNot:
- case IR::OpUMinus:
- case IR::OpUPlus:
- case IR::OpCompl:
- discard();
- break;
-
- case IR::OpBitAnd:
- case IR::OpBitOr:
- case IR::OpBitXor:
- case IR::OpLShift:
- case IR::OpRShift:
- case IR::OpURShift:
- convertToInt(e->left, left);
- convertToInt(e->right, right);
- break;
-
- case IR::OpAdd:
- if (e->type != IR::StringType) {
- convertToNumber(e->left, left);
- convertToNumber(e->right, right);
- }
- break;
-
- case IR::OpSub:
- case IR::OpMul:
- case IR::OpDiv:
- case IR::OpMod:
- convertToNumber(e->left, left);
- convertToNumber(e->right, right);
- break;
-
- case IR::OpGt:
- case IR::OpLt:
- case IR::OpGe:
- case IR::OpLe:
- case IR::OpEqual:
- case IR::OpNotEqual:
- case IR::OpStrictEqual:
- case IR::OpStrictNotEqual:
- if (e->left->type >= IR::FirstNumberType) {
- convertToNumber(e->left, left);
- convertToNumber(e->right, right);
- }
- break;
-
- case IR::OpAnd:
- case IR::OpOr:
- discard(); // ### unreachable
- break;
- } // switch
-
- const quint8 opcode = instructionOpcode(e);
- if (opcode != V4Instr::Noop) {
- V4Instr instr;
- instr.binaryop.output = currentReg;
- instr.binaryop.left = left;
- instr.binaryop.right = right;
- gen(static_cast<V4Instr::Type>(opcode), instr);
- }
-}
-
-void QV4CompilerPrivate::visitCall(IR::Call *call)
-{
- if (IR::Name *name = call->base->asName()) {
- IR::Expr *arg = call->onlyArgument();
- if (arg != 0 && IR::isRealType(arg->type)) {
- traceExpression(arg, currentReg);
-
- switch (name->builtin) {
- case IR::NoBuiltinSymbol:
- break;
-
- case IR::MathSinBultinFunction: {
- Instr::MathSinNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathCosBultinFunction: {
- Instr::MathCosNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathAbsBuiltinFunction: {
- Instr::MathAbsNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathRoundBultinFunction: {
- Instr::MathRoundNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathFloorBultinFunction: {
- Instr::MathFloorNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathCeilBuiltinFunction: {
- Instr::MathCeilNumber i;
- i.output = i.src = currentReg;
- gen(i);
- } return;
-
- case IR::MathPIBuiltinConstant:
- default:
- break;
- } // switch
- } else {
- if (name->builtin == IR::MathMaxBuiltinFunction ||
- name->builtin == IR::MathMinBuiltinFunction) {
-
- //only handles the most common case of exactly two arguments
- if (call->args && call->args->next && !call->args->next->next) {
- IR::Expr *arg1 = call->args->expr;
- IR::Expr *arg2 = call->args->next->expr;
-
- if (arg1 != 0 && IR::isRealType(arg1->type) &&
- arg2 != 0 && IR::isRealType(arg2->type)) {
-
- traceExpression(arg1, currentReg);
- traceExpression(arg2, currentReg + 1);
-
- if (name->builtin == IR::MathMaxBuiltinFunction) {
- Instr::MathMaxNumber i;
- i.left = currentReg;
- i.right = currentReg + 1;
- i.output = currentReg;
- gen(i);
- return;
- } else if (name->builtin == IR::MathMinBuiltinFunction) {
- Instr::MathMinNumber i;
- i.left = currentReg;
- i.right = currentReg + 1;
- i.output = currentReg;
- gen(i);
- return;
- }
- }
- }
- }
- }
- }
-
- if (qmlVerboseCompiler())
- qWarning() << "TODO:" << Q_FUNC_INFO << __LINE__;
- discard();
-}
-
-
-//
-// statements
-//
-void QV4CompilerPrivate::visitExp(IR::Exp *s)
-{
- traceExpression(s->expr, currentReg);
-}
-
-void QV4CompilerPrivate::visitMove(IR::Move *s)
-{
- IR::Temp *target = s->target->asTemp();
- Q_ASSERT(target != 0);
-
- quint8 dest = target->index;
-
- IR::Type targetTy = s->target->type;
- IR::Type sourceTy = s->source->type;
-
- // promote the floats
- if (sourceTy == IR::FloatType)
- sourceTy = IR::NumberType;
-
- if (targetTy == IR::FloatType)
- targetTy = IR::NumberType;
-
- if (sourceTy != targetTy) {
- quint8 src = dest;
-
- if (IR::Temp *t = s->source->asTemp())
- src = t->index;
- else
- traceExpression(s->source, dest);
-
- V4Instr::Type opcode = V4Instr::Noop;
-
- if (sourceTy == IR::UrlType) {
- switch (targetTy) {
- case IR::BoolType:
- case IR::StringType:
- case IR::VariantType:
- case IR::VarType:
- case IR::JSValueType:
- // nothing to do. V4 will generate optimized
- // url-to-xxx conversions.
- break;
- default: {
- if (s->isMoveForReturn) {
- V4Instr instr;
- instr.throwop.exceptionId = exceptionId(bindingLine, bindingColumn);
- registerLiteralString(dest, _function->newString(QString::fromUtf8("Unable to assign %1 to %2")
- .arg(QLatin1String(IR::typeName(sourceTy)))
- .arg(QLatin1String(IR::typeName(targetTy)))));
- instr.throwop.message = dest;
- gen(V4Instr::Throw, instr);
- return;
- }
- // generate a UrlToString conversion and fix
- // the type of the source expression.
- V4Instr conv;
- conv.unaryop.output = src;
- conv.unaryop.src = src;
- gen(V4Instr::ConvertUrlToString, conv);
- sourceTy = IR::StringType;
- break;
- }
- } // switch
- }
-
- if (targetTy == IR::BoolType) {
- switch (sourceTy) {
- case IR::IntType: opcode = V4Instr::ConvertIntToBool; break;
- case IR::NumberType: opcode = V4Instr::ConvertNumberToBool; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
- case IR::ObjectType: opcode = V4Instr::ConvertObjectToBool; break;
- default: break;
- } // switch
- } else if (targetTy == IR::IntType) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToInt; break;
- case IR::NumberType: {
- if (s->isMoveForReturn)
- opcode = V4Instr::MathRoundNumber;
- else
- opcode = V4Instr::ConvertNumberToInt;
- break;
- }
- case IR::StringType: opcode = V4Instr::ConvertStringToInt; break;
- default: break;
- } // switch
- } else if (IR::isRealType(targetTy)) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToNumber; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToNumber; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToNumber; break;
- default: break;
- } // switch
- } else if (targetTy == IR::StringType) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToString; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToString; break;
- case IR::NumberType: opcode = V4Instr::ConvertNumberToString; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToString; break;
- default: break;
- } // switch
- } else if (targetTy == IR::UrlType) {
- if (s->isMoveForReturn && sourceTy != IR::StringType) {
- V4Instr instr;
- instr.throwop.exceptionId = exceptionId(bindingLine, bindingColumn);
- registerLiteralString(dest, _function->newString(QString::fromUtf8("Unable to assign %1 to %2")
- .arg(QLatin1String(IR::typeName(sourceTy)))
- .arg(QLatin1String(IR::typeName(targetTy)))));
- instr.throwop.message = dest;
- gen(V4Instr::Throw, instr);
- return;
- }
-
- V4Instr convToString;
- convToString.unaryop.output = dest;
- convToString.unaryop.src = src;
-
- // try to convert the source expression to a string.
- switch (sourceTy) {
- case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break;
- case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break;
- case IR::NumberType: gen(V4Instr::ConvertNumberToString, convToString); sourceTy = IR::StringType; break;
- case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break;
- default: break;
- } // switch
-
- if (sourceTy == IR::StringType)
- opcode = V4Instr::ConvertStringToUrl;
- } else if (targetTy == IR::ColorType) {
- switch (sourceTy) {
- case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
- default: break;
- } // switch
- } else if (targetTy == IR::ObjectType) {
- switch (sourceTy) {
- case IR::NullType: opcode = V4Instr::ConvertNullToObject; break;
- default: break;
- } // switch
- } else if (targetTy == IR::VariantType) {
- if (s->isMoveForReturn) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToVariant; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToVariant; break;
- case IR::NumberType: opcode = V4Instr::ConvertNumberToVariant; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToVariant; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToVariant; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToVariant; break;
- case IR::ObjectType: opcode = V4Instr::ConvertObjectToVariant; break;
- case IR::NullType: opcode = V4Instr::ConvertNullToVariant; break;
- default: break;
- } // switch
- }
- } else if (targetTy == IR::VarType) {
- if (s->isMoveForReturn) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToVar; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToVar; break;
- case IR::NumberType: opcode = V4Instr::ConvertNumberToVar; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToVar; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToVar; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToVar; break;
- case IR::ObjectType: opcode = V4Instr::ConvertObjectToVar; break;
- case IR::NullType: opcode = V4Instr::ConvertNullToVar; break;
- case IR::JSValueType: opcode = V4Instr::ConvertJSValueToVar; break;
- default: break;
- } // switch
- }
- } else if (targetTy == IR::JSValueType) {
- if (s->isMoveForReturn) {
- switch (sourceTy) {
- case IR::BoolType: opcode = V4Instr::ConvertBoolToJSValue; break;
- case IR::IntType: opcode = V4Instr::ConvertIntToJSValue; break;
- case IR::NumberType: opcode = V4Instr::ConvertNumberToJSValue; break;
- case IR::UrlType: opcode = V4Instr::ConvertUrlToJSValue; break;
- case IR::ColorType: opcode = V4Instr::ConvertColorToJSValue; break;
- case IR::StringType: opcode = V4Instr::ConvertStringToJSValue; break;
- case IR::ObjectType: opcode = V4Instr::ConvertObjectToJSValue; break;
- case IR::VarType: opcode = V4Instr::ConvertVarToJSValue; break;
- case IR::NullType: opcode = V4Instr::ConvertNullToJSValue; break;
- default: break;
- }
- }
- }
- if (opcode != V4Instr::Noop) {
- V4Instr conv;
- conv.unaryop.output = dest;
- conv.unaryop.src = src;
- gen(opcode, conv);
-
- if (s->isMoveForReturn && opcode == V4Instr::ConvertStringToUrl) {
- V4Instr resolveUrl;
- resolveUrl.unaryop.output = dest;
- resolveUrl.unaryop.src = dest;
- gen(V4Instr::ResolveUrl, resolveUrl);
- }
- } else {
- discard();
- }
- } else {
- traceExpression(s->source, dest);
- }
-}
-
-void QV4CompilerPrivate::visitJump(IR::Jump *s)
-{
- patches.append(Patch(s->target, bytecode.size()));
-
- Instr::Branch i;
- i.offset = 0; // ### backpatch
- gen(i);
-}
-
-void QV4CompilerPrivate::visitCJump(IR::CJump *s)
-{
- traceExpression(s->cond, currentReg);
-
- patches.append(Patch(s->iftrue, bytecode.size()));
-
- Instr::BranchTrue i;
- i.reg = currentReg;
- i.offset = 0; // ### backpatch
- gen(i);
-}
-
-void QV4CompilerPrivate::visitRet(IR::Ret *s)
-{
- Q_ASSERT(s->expr != 0);
-
- int storeReg = currentReg;
-
- if (IR::Temp *temp = s->expr->asTemp()) {
- storeReg = temp->index;
- } else {
- traceExpression(s->expr, storeReg);
- }
-
- if (qmlBindingsTest) {
- Instr::TestV4Store test;
- test.reg = storeReg;
- switch (s->type) {
- case IR::StringType:
- test.regType = QMetaType::QString;
- break;
- case IR::UrlType:
- test.regType = QMetaType::QUrl;
- break;
- case IR::ColorType:
- test.regType = QMetaType::QColor;
- break;
- case IR::SGAnchorLineType:
- test.regType = QQmlMetaType::QQuickAnchorLineMetaTypeId();
- break;
- case IR::ObjectType:
- test.regType = QMetaType::QObjectStar;
- break;
- case IR::VariantType:
- test.regType = QMetaType::QVariant;
- break;
- case IR::VarType:
- test.regType = qMetaTypeId<v8::Handle<v8::Value> >();
- break;
- case IR::JSValueType:
- test.regType = qMetaTypeId<QJSValue>();
- break;
- case IR::BoolType:
- test.regType = QMetaType::Bool;
- break;
- case IR::IntType:
- test.regType = QMetaType::Int;
- break;
- case IR::FloatType:
- case IR::NumberType:
- test.regType = QMetaType::Double;
- break;
- default:
- discard();
- return;
- }
- gen(test);
- }
-
- Instr::Store store;
- store.output = 0;
- store.index = expression->property->index;
- store.reg = storeReg;
- store.valueType = s->type == IR::FloatType ? FloatType : 0;
- store.exceptionId = exceptionId(s->line, s->column);
- gen(store);
-}
-
-void QV4Compiler::dump(const QByteArray &programData)
-{
- const QV4Program *program = (const QV4Program *)programData.constData();
-
- qWarning() << "Program.bindings:" << program->bindings;
- qWarning() << "Program.dataLength:" << program->dataLength;
- qWarning() << "Program.subscriptions:" << program->subscriptions;
-
- const int programSize = program->instructionCount;
- const char *start = program->instructions();
- const char *end = start + programSize;
- Bytecode bc;
- bc.dump(start, end);
-}
-
-/*!
-Clear the state associated with attempting to compile a specific binding.
-This does not clear the global "committed binding" states.
-*/
-void QV4CompilerPrivate::resetInstanceState()
-{
- data = committed.data;
- exceptions = committed.exceptions;
- usedSubscriptionIds.clear();
- subscriptionIds.clear();
- subscriptionOffset = committed.subscriptionCount;
- bytecode.clear();
- patches.clear();
- pool.clear();
- currentReg = 0;
- invalidatable = false;
-}
-
-/*!
-Mark the last compile as successful, and add it to the "committed data"
-section.
-
-Returns the index for the committed binding.
-*/
-int QV4CompilerPrivate::commitCompile()
-{
- int rv = committed.count();
- committed.offsets << committed.bytecode.count();
- committed.dependencies << usedSubscriptionIds;
- committed.bytecode.append(bytecode.constData(), bytecode.size());
- committed.data = data;
- committed.exceptions = exceptions;
- committed.subscriptionCount = subscriptionOffset + subscriptionIds.count();
- if (bindingsDump())
- committed.subscriptions.append(subscriptionIds);
- return rv;
-}
-
-bool QV4CompilerPrivate::compile(QQmlJS::AST::Node *node)
-{
- resetInstanceState();
-
- if (expression->property->type == -1)
- return false;
-
- AST::SourceLocation location;
- if (AST::ExpressionNode *astExpression = node->expressionCast()) {
- location = astExpression->firstSourceLocation();
- } else if (AST::Statement *astStatement = node->statementCast()) {
- if (AST::Block *block = AST::cast<AST::Block *>(astStatement))
- location = block->lbraceToken;
- else if (AST::IfStatement *ifStmt = AST::cast<AST::IfStatement *>(astStatement))
- location = ifStmt->ifToken;
- else
- return false;
- } else {
- return false;
- }
-
- IR::Function thisFunction(&pool), *function = &thisFunction;
-
- QV4IRBuilder irBuilder(expression, engine);
- if (!irBuilder(function, node, &invalidatable))
- return false;
-
- bool discarded = false;
- qSwap(_discarded, discarded);
- qSwap(_function, function);
- trace(location.startLine, location.startColumn);
- qSwap(_function, function);
- qSwap(_discarded, discarded);
-
- if (qmlVerboseCompiler()) {
- QTextStream qerr(stderr, QIODevice::WriteOnly);
- if (discarded)
- qerr << "======== TODO ====== " << endl;
- else
- qerr << "==================== " << endl;
- qerr << "\tline: " << location.startLine
- << "\tcolumn: " << location.startColumn
- << endl;
- foreach (IR::BasicBlock *bb, function->basicBlocks)
- bb->dump(qerr);
- qerr << endl;
- }
-
- if (discarded || subscriptionIds.count() > 0xFFFF || registerCount > 31)
- return false;
-
- return true;
-}
-
-// Returns a reg
-int QV4CompilerPrivate::registerLiteralString(quint8 reg, const QStringRef &str)
-{
- // ### string cleanup
-
- QByteArray strdata((const char *)str.constData(), str.length() * sizeof(QChar));
- int offset = data.count();
- data += strdata;
-
- Instr::LoadString string;
- string.reg = reg;
- string.offset = offset;
- string.length = str.length();
- gen(string);
-
- return reg;
-}
-
-/*!
-Returns true if the current expression has not already subscribed to \a sub in currentBlockMask.
-*/
-bool QV4CompilerPrivate::blockNeedsSubscription(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
-
- int *iter = subscriptionIds.value(str);
- if (!iter)
- return true;
-
- quint32 *uiter = usedSubscriptionIds.value(*iter);
- if (!uiter)
- return true;
- else
- return !(*uiter & currentBlockMask);
-}
-
-int QV4CompilerPrivate::subscriptionIndex(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
- int *iter = subscriptionIds.value(str);
- if (!iter) {
- int count = subscriptionOffset + subscriptionIds.count();
- iter = &subscriptionIds[str];
- *iter = count;
- }
- quint32 &u = usedSubscriptionIds[*iter];
- if (!(u & currentBlockMask)) {
- u |= currentBlockMask;
- usedSubscriptionIdsChanged = true;
- }
- return *iter;
-}
-
-quint32 QV4CompilerPrivate::subscriptionBlockMask(const QStringList &sub)
-{
- QString str = sub.join(QLatin1String("."));
-
- int *iter = subscriptionIds.value(str);
- Q_ASSERT(iter != 0);
-
- quint32 *uiter = usedSubscriptionIds.value(*iter);
- Q_ASSERT(uiter != 0);
-
- return *uiter;
-}
-
-quint8 QV4CompilerPrivate::exceptionId(quint16 line, quint16 column)
-{
- quint8 rv = 0xFF;
- if (exceptions.count() < 0xFF) {
- rv = (quint8)exceptions.count();
- quint32 e = line;
- e <<= 16;
- e |= column;
- exceptions.append(e);
- }
- return rv;
-}
-
-quint8 QV4CompilerPrivate::exceptionId(QQmlJS::AST::ExpressionNode *n)
-{
- quint8 rv = 0xFF;
- if (n && exceptions.count() < 0xFF) {
- QQmlJS::AST::SourceLocation l = n->firstSourceLocation();
- rv = exceptionId(l.startLine, l.startColumn);
- }
- return rv;
-}
-
-QV4Compiler::QV4Compiler()
-: d(new QV4CompilerPrivate)
-{
- qmlBindingsTest |= qmlBindingsTestEnv();
-}
-
-QV4Compiler::~QV4Compiler()
-{
- delete d; d = 0;
-}
-
-/*
-Returns true if any bindings were compiled.
-*/
-bool QV4Compiler::isValid() const
-{
- return !d->committed.bytecode.isEmpty();
-}
-
-/*
--1 on failure, otherwise the binding index to use.
-*/
-int QV4Compiler::compile(const Expression &expression, QQmlEnginePrivate *engine, bool *invalidatable)
-{
- if (!expression.expression.asAST()) return false;
-
- if (qmlDisableOptimizer() || !qmlEnableV4)
- return -1;
-
- d->expression = &expression;
- d->engine = engine;
-
- if (d->compile(expression.expression.asAST())) {
- *invalidatable = d->isInvalidatable();
- return d->commitCompile();
- } else {
- return -1;
- }
-}
-
-QByteArray QV4CompilerPrivate::buildSignalTable() const
-{
- QHash<int, QList<QPair<int, quint32> > > table;
-
- for (int ii = 0; ii < committed.count(); ++ii) {
- const QQmlAssociationList<int, quint32> &deps = committed.dependencies.at(ii);
- for (QQmlAssociationList<int, quint32>::const_iterator iter = deps.begin(); iter != deps.end(); ++iter)
- table[iter->first].append(qMakePair(ii, iter->second));
- }
-
- QVector<quint32> header;
- QVector<quint32> data;
- for (int ii = 0; ii < committed.subscriptionCount; ++ii) {
- header.append(committed.subscriptionCount + data.count());
- const QList<QPair<int, quint32> > &bindings = table[ii];
- data.append(bindings.count());
- for (int jj = 0; jj < bindings.count(); ++jj) {
- data.append(bindings.at(jj).first);
- data.append(bindings.at(jj).second);
- }
- }
- header << data;
-
- return QByteArray((const char *)header.constData(), header.count() * sizeof(quint32));
-}
-
-QByteArray QV4CompilerPrivate::buildExceptionData() const
-{
- QByteArray rv;
- rv.resize(committed.exceptions.count() * sizeof(quint32));
- ::memcpy(rv.data(), committed.exceptions.constData(), rv.size());
- return rv;
-}
-
-/*
-Returns the compiled program.
-*/
-QByteArray QV4Compiler::program() const
-{
- QByteArray programData;
-
- if (isValid()) {
- QV4Program prog;
- prog.bindings = d->committed.count();
-
- Bytecode bc;
- QV4CompilerPrivate::Instr::Jump jump;
- jump.reg = -1;
-
- for (int ii = 0; ii < d->committed.count(); ++ii) {
- jump.count = d->committed.count() - ii - 1;
- jump.count*= V4InstrMeta<V4Instr::Jump>::Size;
- jump.count+= d->committed.offsets.at(ii);
- bc.append(jump);
- }
-
-
- QByteArray bytecode;
- bytecode.reserve(bc.size() + d->committed.bytecode.size());
- bytecode.append(bc.constData(), bc.size());
- bytecode.append(d->committed.bytecode.constData(), d->committed.bytecode.size());
-
- QByteArray data = d->committed.data;
- while (data.count() % 4) data.append('\0');
- prog.signalTableOffset = data.count();
- data += d->buildSignalTable();
- while (data.count() % 4) data.append('\0');
- prog.exceptionDataOffset = data.count();
- data += d->buildExceptionData();
-
- prog.dataLength = 4 * ((data.size() + 3) / 4);
- prog.subscriptions = d->committed.subscriptionCount;
- prog.instructionCount = bytecode.count();
- int size = sizeof(QV4Program) + bytecode.count();
- size += prog.dataLength;
-
- programData.resize(size);
- memcpy(programData.data(), &prog, sizeof(QV4Program));
- if (prog.dataLength)
- memcpy((char *)((QV4Program *)programData.data())->data(), data.constData(),
- data.size());
- memcpy((char *)((QV4Program *)programData.data())->instructions(), bytecode.constData(),
- bytecode.count());
- }
-
- if (bindingsDump()) {
- qWarning().nospace() << "Subscription slots:";
-
- QQmlAssociationList<QString, int> subscriptionIds;
- foreach (subscriptionIds, d->committed.subscriptions) {
- for (QQmlAssociationList<QString, int>::ConstIterator iter = subscriptionIds.begin();
- iter != subscriptionIds.end(); ++iter) {
- qWarning().nospace() << " " << iter->first << "\t-> " << iter->second;
- }
- }
- QV4Compiler::dump(programData);
- }
-
- return programData;
-}
-
-void QV4Compiler::enableBindingsTest(bool e)
-{
- if (e)
- qmlBindingsTest = true;
- else
- qmlBindingsTest = qmlBindingsTestEnv();
-}
-
-void QV4Compiler::enableV4(bool e)
-{
- qmlEnableV4 = e;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4compiler_p.h b/src/qml/qml/v4/qv4compiler_p.h
deleted file mode 100644
index 5b6cee2a55..0000000000
--- a/src/qml/qml/v4/qv4compiler_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4COMPILER_P_H
-#define QV4COMPILER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qqmlexpression_p.h>
-#include <private/qqmlbinding_p.h>
-#include <private/qqmlcompiler_p.h>
-
-#include <private/qv8_p.h>
-
-Q_DECLARE_METATYPE(v8::Handle<v8::Value>)
-
-QT_BEGIN_NAMESPACE
-
-class QQmlTypeNameCache;
-class QV4CompilerPrivate;
-class Q_AUTOTEST_EXPORT QV4Compiler
-{
-public:
- QV4Compiler();
- ~QV4Compiler();
-
- // Returns true if bindings were compiled
- bool isValid() const;
-
- struct Expression
- {
- Expression(const QQmlImports &imp) : imports(imp) {}
- QQmlScript::Object *component;
- QQmlScript::Object *context;
- QQmlScript::Property *property;
- QQmlScript::Variant expression;
- QQmlCompilerTypes::IdList *ids;
- QQmlTypeNameCache *importCache;
- QQmlImports imports;
- };
-
- // -1 on failure, otherwise the binding index to use
- int compile(const Expression &, QQmlEnginePrivate *, bool *);
-
- // Returns the compiled program
- QByteArray program() const;
-
- static void dump(const QByteArray &);
- static void enableBindingsTest(bool);
- static void enableV4(bool);
-private:
- QV4CompilerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV4COMPILER_P_H
-
diff --git a/src/qml/qml/v4/qv4compiler_p_p.h b/src/qml/qml/v4/qv4compiler_p_p.h
deleted file mode 100644
index 58ec521a97..0000000000
--- a/src/qml/qml/v4/qv4compiler_p_p.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4COMPILER_P_P_H
-#define QV4COMPILER_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qv4instruction_p.h"
-#include "qv4ir_p.h"
-#include <private/qqmlscript_p.h>
-#include <private/qqmlimport_p.h>
-#include <private/qqmlengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-template <typename _Key, typename _Value>
-class QQmlAssociationList
-{
-public:
- typedef QVarLengthArray<QPair<_Key, _Value>, 8> Container;
- typedef typename Container::const_iterator const_iterator;
- typedef typename Container::const_iterator ConstIterator;
-
- const_iterator begin() const { return _container.begin(); }
- const_iterator end() const { return _container.end(); }
- int count() const { return _container.count(); }
- void clear() { _container.clear(); }
-
- _Value *value(const _Key &key) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key)
- return &p.second;
- }
- return 0;
- }
-
- _Value &operator[](const _Key &key) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key)
- return p.second;
- }
- int index = _container.size();
- _container.append(qMakePair(key, _Value()));
- return _container[index].second;
- }
-
- void insert(const _Key &key, _Value &value) {
- for (int i = 0; i < _container.size(); ++i) {
- QPair<_Key, _Value> &p = _container[i];
- if (p.first == key) {
- p.second = value;
- return;
- }
- }
- _container.append(qMakePair(key, value));
- }
-
-private:
- Container _container;
-};
-
-class QV4CompilerPrivate: protected QQmlJS::IR::ExprVisitor,
- protected QQmlJS::IR::StmtVisitor
-{
-public:
- QV4CompilerPrivate();
-
- void resetInstanceState();
- int commitCompile();
-
- const QV4Compiler::Expression *expression;
- QQmlEnginePrivate *engine;
-
- QString contextName() const { return QLatin1String("$$$SCOPE_") + QString::number((quintptr)expression->context, 16); }
-
- bool compile(QQmlJS::AST::Node *);
-
- bool isInvalidatable() const { return invalidatable; }
-
- int registerLiteralString(quint8 reg, const QStringRef &);
- QByteArray data;
-
- bool blockNeedsSubscription(const QStringList &);
- int subscriptionIndex(const QStringList &);
- quint32 subscriptionBlockMask(const QStringList &);
-
- quint8 exceptionId(quint16 line, quint16 column);
- quint8 exceptionId(QQmlJS::AST::ExpressionNode *);
- QVector<quint32> exceptions;
-
- QQmlAssociationList<int, quint32> usedSubscriptionIds;
- int subscriptionOffset;
- QQmlAssociationList<QString, int> subscriptionIds;
- QQmlJS::Bytecode bytecode;
-
- // back patching
- struct Patch {
- QQmlJS::IR::BasicBlock *block; // the basic block
- int offset; // the index of the instruction to patch
- Patch(QQmlJS::IR::BasicBlock *block = 0, int index = -1)
- : block(block), offset(index) {}
- };
- QVector<Patch> patches;
- QQmlPool pool;
-
- // Committed binding data
- struct Committed {
- Committed(): subscriptionCount(0) {}
- QList<int> offsets;
- QList<QQmlAssociationList<int, quint32> > dependencies;
-
- //QQmlJS::Bytecode bytecode;
- QByteArray bytecode;
- QByteArray data;
- QVector<quint32> exceptions;
- int subscriptionCount;
- QList<QQmlAssociationList<QString, int> > subscriptions;
-
- int count() const { return offsets.count(); }
- } committed;
-
- QByteArray buildSignalTable() const;
- QByteArray buildExceptionData() const;
-
- void convertToNumber(QQmlJS::IR::Expr *expr, int reg);
- void convertToInt(QQmlJS::IR::Expr *expr, int reg);
- void convertToBool(QQmlJS::IR::Expr *expr, int reg);
- quint8 instructionOpcode(QQmlJS::IR::Binop *e);
-
- struct Instr {
-#define QML_V4_INSTR_DATA_TYPEDEF(I, FMT) typedef QQmlJS::V4InstrData<QQmlJS::V4Instr::I> I;
- FOR_EACH_V4_INSTR(QML_V4_INSTR_DATA_TYPEDEF)
-#undef QML_v4_INSTR_DATA_TYPEDEF
- private:
- Instr();
- };
-
-protected:
- //
- // tracing
- //
- void trace(quint16 line, quint16 column);
- void trace(QVector<QQmlJS::IR::BasicBlock *> *blocks);
- void traceExpression(QQmlJS::IR::Expr *e, quint8 r);
-
- template <int Instr>
- inline void gen(const QQmlJS::V4InstrData<Instr> &i)
- { bytecode.append(i); }
- inline void gen(QQmlJS::V4Instr::Type type, QQmlJS::V4Instr &instr)
- { bytecode.append(type, instr); }
-
- inline QQmlJS::V4Instr::Type instructionType(const QQmlJS::V4Instr *i) const
- { return bytecode.instructionType(i); }
-
- //
- // expressions
- //
- virtual void visitConst(QQmlJS::IR::Const *e);
- virtual void visitString(QQmlJS::IR::String *e);
- virtual void visitName(QQmlJS::IR::Name *e);
- virtual void visitTemp(QQmlJS::IR::Temp *e);
- virtual void visitUnop(QQmlJS::IR::Unop *e);
- virtual void visitBinop(QQmlJS::IR::Binop *e);
- virtual void visitCall(QQmlJS::IR::Call *e);
-
- //
- // statements
- //
- virtual void visitExp(QQmlJS::IR::Exp *s);
- virtual void visitMove(QQmlJS::IR::Move *s);
- virtual void visitJump(QQmlJS::IR::Jump *s);
- virtual void visitCJump(QQmlJS::IR::CJump *s);
- virtual void visitRet(QQmlJS::IR::Ret *s);
-
-private:
- QStringList _subscribeName;
- QQmlJS::IR::Function *_function;
- QQmlJS::IR::BasicBlock *_block;
- void discard() { _discarded = true; }
- bool _discarded;
- quint8 currentReg;
- quint8 registerCount;
-
- bool usedSubscriptionIdsChanged;
- quint32 currentBlockMask;
- quint16 bindingLine;
- quint16 bindingColumn;
- bool invalidatable;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QV4COMPILER_P_P_H
-
diff --git a/src/qml/qml/v4vm/qv4context.cpp b/src/qml/qml/v4/qv4context.cpp
index 1c978f8600..1c978f8600 100644
--- a/src/qml/qml/v4vm/qv4context.cpp
+++ b/src/qml/qml/v4/qv4context.cpp
diff --git a/src/qml/qml/v4vm/qv4context_p.h b/src/qml/qml/v4/qv4context_p.h
index 1043965b46..1043965b46 100644
--- a/src/qml/qml/v4vm/qv4context_p.h
+++ b/src/qml/qml/v4/qv4context_p.h
diff --git a/src/qml/qml/v4vm/qv4dateobject.cpp b/src/qml/qml/v4/qv4dateobject.cpp
index 1d6ba4ba0a..1d6ba4ba0a 100644
--- a/src/qml/qml/v4vm/qv4dateobject.cpp
+++ b/src/qml/qml/v4/qv4dateobject.cpp
diff --git a/src/qml/qml/v4vm/qv4dateobject_p.h b/src/qml/qml/v4/qv4dateobject_p.h
index 729e146c96..729e146c96 100644
--- a/src/qml/qml/v4vm/qv4dateobject_p.h
+++ b/src/qml/qml/v4/qv4dateobject_p.h
diff --git a/src/qml/qml/v4vm/qv4debugging.cpp b/src/qml/qml/v4/qv4debugging.cpp
index b68f3875de..b68f3875de 100644
--- a/src/qml/qml/v4vm/qv4debugging.cpp
+++ b/src/qml/qml/v4/qv4debugging.cpp
diff --git a/src/qml/qml/v4vm/qv4debugging_p.h b/src/qml/qml/v4/qv4debugging_p.h
index 94d676796e..94d676796e 100644
--- a/src/qml/qml/v4vm/qv4debugging_p.h
+++ b/src/qml/qml/v4/qv4debugging_p.h
diff --git a/src/qml/qml/v4vm/qv4engine.cpp b/src/qml/qml/v4/qv4engine.cpp
index ac28069119..ac28069119 100644
--- a/src/qml/qml/v4vm/qv4engine.cpp
+++ b/src/qml/qml/v4/qv4engine.cpp
diff --git a/src/qml/qml/v4vm/qv4engine_p.h b/src/qml/qml/v4/qv4engine_p.h
index dc9783f24c..dc9783f24c 100644
--- a/src/qml/qml/v4vm/qv4engine_p.h
+++ b/src/qml/qml/v4/qv4engine_p.h
diff --git a/src/qml/qml/v4vm/qv4errorobject.cpp b/src/qml/qml/v4/qv4errorobject.cpp
index b3c05fa866..b3c05fa866 100644
--- a/src/qml/qml/v4vm/qv4errorobject.cpp
+++ b/src/qml/qml/v4/qv4errorobject.cpp
diff --git a/src/qml/qml/v4vm/qv4errorobject_p.h b/src/qml/qml/v4/qv4errorobject_p.h
index cb5ec3472b..cb5ec3472b 100644
--- a/src/qml/qml/v4vm/qv4errorobject_p.h
+++ b/src/qml/qml/v4/qv4errorobject_p.h
diff --git a/src/qml/qml/v4vm/qv4executableallocator.cpp b/src/qml/qml/v4/qv4executableallocator.cpp
index e710eba21b..e710eba21b 100644
--- a/src/qml/qml/v4vm/qv4executableallocator.cpp
+++ b/src/qml/qml/v4/qv4executableallocator.cpp
diff --git a/src/qml/qml/v4vm/qv4executableallocator_p.h b/src/qml/qml/v4/qv4executableallocator_p.h
index 0defd984a3..0defd984a3 100644
--- a/src/qml/qml/v4vm/qv4executableallocator_p.h
+++ b/src/qml/qml/v4/qv4executableallocator_p.h
diff --git a/src/qml/qml/v4vm/qv4functionobject.cpp b/src/qml/qml/v4/qv4functionobject.cpp
index 0b5c8f00cf..0b5c8f00cf 100644
--- a/src/qml/qml/v4vm/qv4functionobject.cpp
+++ b/src/qml/qml/v4/qv4functionobject.cpp
diff --git a/src/qml/qml/v4vm/qv4functionobject_p.h b/src/qml/qml/v4/qv4functionobject_p.h
index 533c560560..533c560560 100644
--- a/src/qml/qml/v4vm/qv4functionobject_p.h
+++ b/src/qml/qml/v4/qv4functionobject_p.h
diff --git a/src/qml/qml/v4vm/qv4global_p.h b/src/qml/qml/v4/qv4global_p.h
index cd360a51f4..cd360a51f4 100644
--- a/src/qml/qml/v4vm/qv4global_p.h
+++ b/src/qml/qml/v4/qv4global_p.h
diff --git a/src/qml/qml/v4vm/qv4globalobject.cpp b/src/qml/qml/v4/qv4globalobject.cpp
index c2458517cc..c2458517cc 100644
--- a/src/qml/qml/v4vm/qv4globalobject.cpp
+++ b/src/qml/qml/v4/qv4globalobject.cpp
diff --git a/src/qml/qml/v4vm/qv4globalobject_p.h b/src/qml/qml/v4/qv4globalobject_p.h
index 97a8b705f5..97a8b705f5 100644
--- a/src/qml/qml/v4vm/qv4globalobject_p.h
+++ b/src/qml/qml/v4/qv4globalobject_p.h
diff --git a/src/qml/qml/v4vm/qv4identifier_p.h b/src/qml/qml/v4/qv4identifier_p.h
index df1a3abb94..df1a3abb94 100644
--- a/src/qml/qml/v4vm/qv4identifier_p.h
+++ b/src/qml/qml/v4/qv4identifier_p.h
diff --git a/src/qml/qml/v4/qv4instruction.cpp b/src/qml/qml/v4/qv4instruction.cpp
deleted file mode 100644
index 103a43a3a3..0000000000
--- a/src/qml/qml/v4/qv4instruction.cpp
+++ /dev/null
@@ -1,532 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4instruction_p.h"
-#include "qv4bindings_p.h"
-
-#include <QtCore/qdebug.h>
-#include <private/qqmlglobal_p.h>
-
-// Define this to do a test dump of all the instructions at startup. This is
-// helpful to test that each instruction's Instr::dump() case uses the correct
-// number of tabs etc and otherwise looks correct.
-// #define DEBUG_INSTR_DUMP
-
-QT_BEGIN_NAMESPACE
-
-namespace QQmlJS {
-
-#ifdef DEBUG_INSTR_DUMP
-static struct DumpInstrAtStartup {
- DumpInstrAtStartup() {
- Bytecode bc;
-#define DUMP_INSTR_AT_STARTUP(I, FMT) { V4InstrData<V4Instr::I> i; bc.append(i); }
- FOR_EACH_V4_INSTR(DUMP_INSTR_AT_STARTUP);
-#undef DUMP_INSTR_AT_STARTUP
- const char *start = bc.constData();
- const char *end = start + bc.size();
- bc.dump(start, end);
- }
-} dump_instr_at_startup;
-#endif
-
-int V4Instr::size(Type type)
-{
-#define V4_RETURN_INSTR_SIZE(I, FMT) case I: return QML_V4_INSTR_SIZE(I, FMT);
- switch (type) {
- FOR_EACH_V4_INSTR(V4_RETURN_INSTR_SIZE)
- }
-#undef V4_RETURN_INSTR_SIZE
- return 0;
-}
-
-void Bytecode::dump(const V4Instr *i, int address) const
-{
- QByteArray leading;
- if (address != -1) {
- leading = QByteArray::number(address);
- leading.prepend(QByteArray(8 - leading.count(), ' '));
- leading.append('\t');
- }
-
-#define INSTR_DUMP qWarning().nospace() << leading.constData()
-
- switch (instructionType(i)) {
- case V4Instr::Noop:
- INSTR_DUMP << '\t' << "Noop";
- break;
- case V4Instr::BindingId:
- INSTR_DUMP << i->id.line << ':' << i->id.column << ':';
- break;
- case V4Instr::SubscribeId:
- INSTR_DUMP << '\t' << "SubscribeId" << "\t\t" << "Id_Offset(" << i->subscribeop.index << ") -> Subscribe_Slot(" << i->subscribeop.offset << ')';
- break;
- case V4Instr::FetchAndSubscribe:
- INSTR_DUMP << '\t' << "FetchAndSubscribe" << '\t' << "Object_Reg(" << i->fetchAndSubscribe.reg << ") Fast_Accessor(" << i->fetchAndSubscribe.property.accessors << ") -> Output_Reg(" << i->fetchAndSubscribe.reg << ") Subscription_Slot(" << i->fetchAndSubscribe.subscription << ')';
- break;
- case V4Instr::LoadId:
- INSTR_DUMP << '\t' << "LoadId" << "\t\t\t" << "Id_Offset(" << i->load.index << ") -> Output_Reg(" << i->load.reg << ')';
- break;
- case V4Instr::LoadScope:
- INSTR_DUMP << '\t' << "LoadScope" << "\t\t" << "-> Output_Reg(" << i->load.reg << ')';
- break;
- case V4Instr::LoadRoot:
- INSTR_DUMP << '\t' << "LoadRoot" << "\t\t" << "-> Output_Reg(" << i->load.reg << ')';
- break;
- case V4Instr::LoadSingletonObject:
- INSTR_DUMP << '\t' << "LoadSingletonObject" << "\t\t" << ") -> Output_Reg(" << i->load.reg << ')';
- break;
- case V4Instr::LoadAttached:
- INSTR_DUMP << '\t' << "LoadAttached" << "\t\t" << "Object_Reg(" << i->attached.reg << ") Attached_Index(" << i->attached.id << ") -> Output_Reg(" << i->attached.output << ')';
- break;
- case V4Instr::UnaryNot:
- INSTR_DUMP << '\t' << "UnaryNot" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::UnaryMinusNumber:
- INSTR_DUMP << '\t' << "UnaryMinusNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::UnaryMinusInt:
- INSTR_DUMP << '\t' << "UnaryMinusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::UnaryPlusNumber:
- INSTR_DUMP << '\t' << "UnaryPlusNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::UnaryPlusInt:
- INSTR_DUMP << '\t' << "UnaryPlusInt" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToInt:
- INSTR_DUMP << '\t' << "ConvertBoolToInt" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToJSValue:
- INSTR_DUMP << '\t' << "ConvertBoolToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToNumber:
- INSTR_DUMP << '\t' << "ConvertBoolToNumber" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToString:
- INSTR_DUMP << '\t' << "ConvertBoolToString" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToVariant:
- INSTR_DUMP << '\t' << "ConvertBoolToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertBoolToVar:
- INSTR_DUMP << '\t' << "ConvertBoolToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToBool:
- INSTR_DUMP << '\t' << "ConvertIntToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToJSValue:
- INSTR_DUMP << '\t' << "ConvertIntToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToNumber:
- INSTR_DUMP << '\t' << "ConvertIntToNumber" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToString:
- INSTR_DUMP << '\t' << "ConvertIntToString" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToVariant:
- INSTR_DUMP << '\t' << "ConvertIntToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertIntToVar:
- INSTR_DUMP << '\t' << "ConvertIntToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertJSValueToVar:
- INSTR_DUMP << '\t' << "ConvertJSValueToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToBool:
- INSTR_DUMP << '\t' << "ConvertNumberToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToInt:
- INSTR_DUMP << '\t' << "ConvertNumberToInt" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToJSValue:
- INSTR_DUMP << '\t' << "ConvertNumberToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToString:
- INSTR_DUMP << '\t' << "ConvertNumberToString" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToVariant:
- INSTR_DUMP << '\t' << "ConvertNumberToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNumberToVar:
- INSTR_DUMP << '\t' << "ConvertNumberToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToBool:
- INSTR_DUMP << '\t' << "ConvertStringToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToInt:
- INSTR_DUMP << '\t' << "ConvertStringToInt" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToJSValue:
- INSTR_DUMP << '\t' << "ConvertStringToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToNumber:
- INSTR_DUMP << '\t' << "ConvertStringToNumber" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToUrl:
- INSTR_DUMP << '\t' << "ConvertStringToUrl" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToColor:
- INSTR_DUMP << '\t' << "ConvertStringToColor" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToVariant:
- INSTR_DUMP << '\t' << "ConvertStringToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertStringToVar:
- INSTR_DUMP << '\t' << "ConvertStringToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertUrlToBool:
- INSTR_DUMP << '\t' << "ConvertUrlToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertUrlToJSValue:
- INSTR_DUMP << '\t' << "ConvertUrlToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertUrlToString:
- INSTR_DUMP << '\t' << "ConvertUrlToString" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertUrlToVariant:
- INSTR_DUMP << '\t' << "ConvertUrlToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertUrlToVar:
- INSTR_DUMP << '\t' << "ConvertUrlToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertColorToBool:
- INSTR_DUMP << '\t' << "ConvertColorToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertColorToJSValue:
- INSTR_DUMP << '\t' << "ConvertColorToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertColorToString:
- INSTR_DUMP << '\t' << "ConvertColorToString" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertColorToVariant:
- INSTR_DUMP << '\t' << "ConvertColorToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertColorToVar:
- INSTR_DUMP << '\t' << "ConvertColorToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertObjectToBool:
- INSTR_DUMP << '\t' << "ConvertObjectToBool" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertObjectToJSValue:
- INSTR_DUMP << '\t' << "ConvertObjectToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertObjectToVariant:
- INSTR_DUMP << '\t' << "ConvertObjectToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertObjectToVar:
- INSTR_DUMP << '\t' << "ConvertObjectToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertVarToJSValue:
- INSTR_DUMP << '\t' << "ConvertVarToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNullToJSValue:
- INSTR_DUMP << '\t' << "ConvertNullToJSValue" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNullToObject:
- INSTR_DUMP << '\t' << "ConvertNullToObject" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNullToVariant:
- INSTR_DUMP << '\t' << "ConvertNullToVariant" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ConvertNullToVar:
- INSTR_DUMP << '\t' << "ConvertNullToVar" << '\t' << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::ResolveUrl:
- INSTR_DUMP << '\t' << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathSinNumber:
- INSTR_DUMP << '\t' << "MathSinNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathCosNumber:
- INSTR_DUMP << '\t' << "MathCosNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathAbsNumber:
- INSTR_DUMP << '\t' << "MathAbsNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathRoundNumber:
- INSTR_DUMP << '\t' << "MathRoundNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathFloorNumber:
- INSTR_DUMP << '\t' << "MathFloorNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathCeilNumber:
- INSTR_DUMP << '\t' << "MathCeilNumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::MathPINumber:
- INSTR_DUMP << '\t' << "MathPINumber" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ')';
- break;
- case V4Instr::LoadNull:
- INSTR_DUMP << '\t' << "LoadNull" << "\t\t" << "Constant(null) -> Output_Reg(" << i->null_value.reg << ')';
- break;
- case V4Instr::LoadNumber:
- INSTR_DUMP << '\t' << "LoadNumber" << "\t\t" << "Constant(" << i->number_value.value << ") -> Output_Reg(" << i->number_value.reg << ')';
- break;
- case V4Instr::LoadInt:
- INSTR_DUMP << '\t' << "LoadInt" << "\t\t\t" << "Constant(" << i->int_value.value << ") -> Output_Reg(" << i->int_value.reg << ')';
- break;
- case V4Instr::LoadBool:
- INSTR_DUMP << '\t' << "LoadBool" << "\t\t" << "Constant(" << i->bool_value.value << ") -> Output_Reg(" << i->bool_value.reg << ')';
- break;
- case V4Instr::LoadString:
- INSTR_DUMP << '\t' << "LoadString" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ") -> Output_Register(" << i->string_value.reg << ')';
- break;
- case V4Instr::EnableV4Test:
- INSTR_DUMP << '\t' << "EnableV4Test" << "\t\t" << "String_DataIndex(" << i->string_value.offset << ") String_Length(" << i->string_value.length << ')';
- break;
- case V4Instr::TestV4Store:
- INSTR_DUMP << '\t' << "TestV4Store" << "\t\t" << "Input_Reg(" << i->storetest.reg << ") Reg_Type(" << i->storetest.regType << ')';
- break;
- case V4Instr::BitAndInt:
- INSTR_DUMP << '\t' << "BitAndInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::BitOrInt:
- INSTR_DUMP << '\t' << "BitOrInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::BitXorInt:
- INSTR_DUMP << '\t' << "BitXorInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::AddNumber:
- INSTR_DUMP << '\t' << "AddNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::AddString:
- INSTR_DUMP << '\t' << "AddString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::SubNumber:
- INSTR_DUMP << '\t' << "SubNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::MulNumber:
- INSTR_DUMP << '\t' << "MulNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::DivNumber:
- INSTR_DUMP << '\t' << "DivNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::ModNumber:
- INSTR_DUMP << '\t' << "ModNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::LShiftInt:
- INSTR_DUMP << '\t' << "LShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::RShiftInt:
- INSTR_DUMP << '\t' << "RShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::URShiftInt:
- INSTR_DUMP << '\t' << "URShiftInt" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::GtNumber:
- INSTR_DUMP << '\t' << "GtNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::LtNumber:
- INSTR_DUMP << '\t' << "LtNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::GeNumber:
- INSTR_DUMP << '\t' << "GeNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::LeNumber:
- INSTR_DUMP << '\t' << "LeNumber" << "\t\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::EqualNumber:
- INSTR_DUMP << '\t' << "EqualNumber" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::NotEqualNumber:
- INSTR_DUMP << '\t' << "NotEqualNumber" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictEqualNumber:
- INSTR_DUMP << '\t' << "StrictEqualNumber" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictNotEqualNumber:
- INSTR_DUMP << '\t' << "StrictNotEqualNumber" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::GtString:
- INSTR_DUMP << '\t' << "GtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::LtString:
- INSTR_DUMP << '\t' << "LtString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::GeString:
- INSTR_DUMP << '\t' << "GeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::LeString:
- INSTR_DUMP << '\t' << "LeString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::EqualString:
- INSTR_DUMP << '\t' << "EqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::NotEqualString:
- INSTR_DUMP << '\t' << "NotEqualString" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictEqualString:
- INSTR_DUMP << '\t' << "StrictEqualString" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictNotEqualString:
- INSTR_DUMP << '\t' << "StrictNotEqualString" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::EqualObject:
- INSTR_DUMP << '\t' << "EqualObject" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::NotEqualObject:
- INSTR_DUMP << '\t' << "NotEqualObject" << "\t\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictEqualObject:
- INSTR_DUMP << '\t' << "StrictEqualObject" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::StrictNotEqualObject:
- INSTR_DUMP << '\t' << "StrictNotEqualObject" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::MathMaxNumber:
- INSTR_DUMP << '\t' << "MathMaxNumber" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::MathMinNumber:
- INSTR_DUMP << '\t' << "MathMinNumber" << '\t' << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ')';
- break;
- case V4Instr::NewString:
- INSTR_DUMP << '\t' << "NewString" << "\t\t" << "Register(" << i->construct.reg << ')';
- break;
- case V4Instr::NewUrl:
- INSTR_DUMP << '\t' << "NewUrl" << "\t\t\t" << "Register(" << i->construct.reg << ')';
- break;
- case V4Instr::CleanupRegister:
- INSTR_DUMP << '\t' << "CleanupRegister" << "\t\t" << "Register(" << i->cleanup.reg << ')';
- break;
- case V4Instr::Fetch:
- INSTR_DUMP << '\t' << "Fetch" << "\t\t\t" << "Object_Reg(" << i->fetch.reg << ") Property_Index(" << i->fetch.index << ") -> Output_Reg(" << i->fetch.reg << ')';
- break;
- case V4Instr::Store:
- INSTR_DUMP << '\t' << "Store" << "\t\t\t" << "Input_Reg(" << i->store.reg << ") -> Object_Reg(" << i->store.output << ") Property_Index(" << i->store.index << ')';
- break;
- case V4Instr::Copy:
- INSTR_DUMP << '\t' << "Copy" << "\t\t\t" << "Input_Reg(" << i->copy.src << ") -> Output_Reg(" << i->copy.reg << ')';
- break;
- case V4Instr::Jump:
- if (i->jump.reg != -1) {
- INSTR_DUMP << '\t' << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ") [if false == Input_Reg(" << i->jump.reg << ")]";
- } else {
- INSTR_DUMP << '\t' << "Jump" << "\t\t\t" << "Address(" << (address + size() + i->jump.count) << ')';
- }
- break;
- case V4Instr::BranchFalse:
- INSTR_DUMP << '\t' << "BranchFalse" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if false == Input_Reg(" << i->branchop.reg << ")]";
- break;
- case V4Instr::BranchTrue:
- INSTR_DUMP << '\t' << "BranchTrue" << "\t\t" << "Address(" << (address + size() + i->branchop.offset) << ") [if true == Input_Reg(" << i->branchop.reg << ")]";
- break;
- case V4Instr::Branch:
- INSTR_DUMP << '\t' << "Branch" << "\t\t\t" << "Address(" << (address + size() + i->branchop.offset) << ')';
- break;
- case V4Instr::Block:
- INSTR_DUMP << '\t' << "Block" << "\t\t\t" << "Mask(" << QByteArray::number(i->blockop.block, 16).constData() << ')';
- break;
- case V4Instr::Throw:
- INSTR_DUMP << '\t' << "Throw" << "\t\t\t" << "InputReg(" << i->throwop.message << ')';
- break;
- default:
- INSTR_DUMP << '\t' << "Unknown";
- break;
- }
-}
-
-void Bytecode::dump(const char *start, const char *end) const
-{
- const char *code = start;
- while (code < end) {
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
- dump(instr, code - start);
- code += V4Instr::size(instructionType(instr));
- }
-}
-
-Bytecode::Bytecode()
-{
-#ifdef QML_THREADED_INTERPRETER
- decodeInstr = QV4Bindings::getDecodeInstrTable();
-#endif
-}
-
-V4Instr::Type Bytecode::instructionType(const V4Instr *instr) const
-{
-#ifdef QML_THREADED_INTERPRETER
- void *code = instr->common.code;
-
-# define CHECK_V4_INSTR_CODE(I, FMT) \
- if (decodeInstr[static_cast<int>(V4Instr::I)] == code) \
- return V4Instr::I;
-
- FOR_EACH_V4_INSTR(CHECK_V4_INSTR_CODE)
- Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
- return static_cast<V4Instr::Type>(0);
-# undef CHECK_V4_INSTR_CODE
-#else
- return static_cast<V4Instr::Type>(instr->common.type);
-#endif
-
-}
-
-void Bytecode::append(V4Instr::Type type, V4Instr &instr)
-{
-#ifdef QML_THREADED_INTERPRETER
- instr.common.code = decodeInstr[static_cast<int>(type)];
-#else
- instr.common.type = type;
-#endif
- d.append(reinterpret_cast<const char *>(&instr), V4Instr::size(type));
-}
-
-int Bytecode::remove(int offset)
-{
- const V4Instr *instr = reinterpret_cast<const V4Instr *>(d.begin() + offset);
- const int instrSize = V4Instr::size(instructionType(instr));
- d.remove(offset, instrSize);
- return instrSize;
-}
-
-const V4Instr &Bytecode::operator[](int offset) const
-{
- return *(reinterpret_cast<const V4Instr *>(d.begin() + offset));
-}
-
-V4Instr &Bytecode::operator[](int offset)
-{
- return *(reinterpret_cast<V4Instr *>(d.begin() + offset));
-}
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4instruction_p.h b/src/qml/qml/v4/qv4instruction_p.h
deleted file mode 100644
index 9797abf69d..0000000000
--- a/src/qml/qml/v4/qv4instruction_p.h
+++ /dev/null
@@ -1,483 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4INSTRUCTION_P_H
-#define QV4INSTRUCTION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qbytearray.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvarlengtharray.h>
-
-#include <private/qqmlpropertycache_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#define FOR_EACH_V4_INSTR(F) \
- F(Noop, common) \
- F(BindingId, id) \
- F(SubscribeId, subscribeop) \
- F(FetchAndSubscribe, fetchAndSubscribe) \
- F(LoadId, load) \
- F(LoadScope, load) \
- F(LoadRoot, load) \
- F(LoadSingletonObject, load) \
- F(LoadAttached, attached) \
- F(UnaryNot, unaryop) \
- F(UnaryMinusNumber, unaryop) \
- F(UnaryMinusInt, unaryop) \
- F(UnaryPlusNumber, unaryop) \
- F(UnaryPlusInt, unaryop) \
- F(ConvertBoolToInt, unaryop) \
- F(ConvertBoolToJSValue, unaryop) \
- F(ConvertBoolToNumber, unaryop) \
- F(ConvertBoolToString, unaryop) \
- F(ConvertBoolToVariant, unaryop) \
- F(ConvertBoolToVar, unaryop) \
- F(ConvertIntToBool, unaryop) \
- F(ConvertIntToJSValue, unaryop) \
- F(ConvertIntToNumber, unaryop) \
- F(ConvertIntToString, unaryop) \
- F(ConvertIntToVariant, unaryop) \
- F(ConvertIntToVar, unaryop) \
- F(ConvertJSValueToVar, unaryop) \
- F(ConvertNumberToBool, unaryop) \
- F(ConvertNumberToInt, unaryop) \
- F(ConvertNumberToJSValue, unaryop) \
- F(ConvertNumberToString, unaryop) \
- F(ConvertNumberToVariant, unaryop) \
- F(ConvertNumberToVar, unaryop) \
- F(ConvertStringToBool, unaryop) \
- F(ConvertStringToInt, unaryop) \
- F(ConvertStringToJSValue, unaryop) \
- F(ConvertStringToNumber, unaryop) \
- F(ConvertStringToUrl, unaryop) \
- F(ConvertStringToColor, unaryop) \
- F(ConvertStringToVariant, unaryop) \
- F(ConvertStringToVar, unaryop) \
- F(ConvertUrlToBool, unaryop) \
- F(ConvertUrlToJSValue, unaryop) \
- F(ConvertUrlToString, unaryop) \
- F(ConvertUrlToVariant, unaryop) \
- F(ConvertUrlToVar, unaryop) \
- F(ConvertColorToBool, unaryop) \
- F(ConvertColorToJSValue, unaryop) \
- F(ConvertColorToString, unaryop) \
- F(ConvertColorToVariant, unaryop) \
- F(ConvertColorToVar, unaryop) \
- F(ConvertObjectToBool, unaryop) \
- F(ConvertObjectToJSValue, unaryop) \
- F(ConvertObjectToVariant, unaryop) \
- F(ConvertObjectToVar, unaryop) \
- F(ConvertVarToJSValue, unaryop) \
- F(ConvertNullToJSValue, unaryop) \
- F(ConvertNullToObject, unaryop) \
- F(ConvertNullToVariant, unaryop) \
- F(ConvertNullToVar, unaryop) \
- F(ResolveUrl, unaryop) \
- F(MathSinNumber, unaryop) \
- F(MathCosNumber, unaryop) \
- F(MathAbsNumber, unaryop) \
- F(MathRoundNumber, unaryop) \
- F(MathFloorNumber, unaryop) \
- F(MathCeilNumber, unaryop) \
- F(MathPINumber, unaryop) \
- F(LoadNull, null_value) \
- F(LoadNumber, number_value) \
- F(LoadInt, int_value) \
- F(LoadBool, bool_value) \
- F(LoadString, string_value) \
- F(EnableV4Test, string_value) \
- F(TestV4Store, storetest) \
- F(BitAndInt, binaryop) \
- F(BitOrInt, binaryop) \
- F(BitXorInt, binaryop) \
- F(AddNumber, binaryop) \
- F(AddString, binaryop) \
- F(SubNumber, binaryop) \
- F(MulNumber, binaryop) \
- F(DivNumber, binaryop) \
- F(ModNumber, binaryop) \
- F(LShiftInt, binaryop) \
- F(RShiftInt, binaryop) \
- F(URShiftInt, binaryop) \
- F(GtNumber, binaryop) \
- F(LtNumber, binaryop) \
- F(GeNumber, binaryop) \
- F(LeNumber, binaryop) \
- F(EqualNumber, binaryop) \
- F(NotEqualNumber, binaryop) \
- F(StrictEqualNumber, binaryop) \
- F(StrictNotEqualNumber, binaryop) \
- F(GtString, binaryop) \
- F(LtString, binaryop) \
- F(GeString, binaryop) \
- F(LeString, binaryop) \
- F(EqualString, binaryop) \
- F(NotEqualString, binaryop) \
- F(StrictEqualString, binaryop) \
- F(StrictNotEqualString, binaryop) \
- F(EqualObject, binaryop) \
- F(NotEqualObject, binaryop) \
- F(StrictEqualObject, binaryop) \
- F(StrictNotEqualObject, binaryop) \
- F(MathMaxNumber, binaryop) \
- F(MathMinNumber, binaryop) \
- F(NewString, construct) \
- F(NewUrl, construct) \
- F(CleanupRegister, cleanup) \
- F(Copy, copy) \
- F(Fetch, fetch) \
- F(Store, store) \
- F(Jump, jump) \
- F(BranchTrue, branchop) \
- F(BranchFalse, branchop) \
- F(Branch, branchop) \
- F(Block, blockop) \
- F(Throw, throwop)
-
-#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
-# define QML_THREADED_INTERPRETER
-#endif
-
-#ifdef Q_ALIGNOF
-# define QML_V4_INSTR_ALIGN_MASK (Q_ALIGNOF(V4Instr) - 1)
-#else
-# define QML_V4_INSTR_ALIGN_MASK (sizeof(void *) - 1)
-#endif
-
-#define QML_V4_INSTR_ENUM(I, FMT) I,
-#define QML_V4_INSTR_ADDR(I, FMT) &&op_##I,
-#define QML_V4_INSTR_SIZE(I, FMT) ((sizeof(V4Instr::instr_##FMT) + QML_V4_INSTR_ALIGN_MASK) & ~QML_V4_INSTR_ALIGN_MASK)
-
-#ifdef QML_THREADED_INTERPRETER
-# define QML_V4_BEGIN_INSTR(I,FMT) op_##I:
-# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; goto *instr->common.code;
-# define QML_V4_INSTR_HEADER void *code;
-#else
-# define QML_V4_BEGIN_INSTR(I,FMT) case V4Instr::I:
-# define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const V4Instr *) code; break;
-# define QML_V4_INSTR_HEADER quint8 type;
-#endif
-
-class QObject;
-class QQmlNotifier;
-
-namespace QQmlJS {
-
-union Q_AUTOTEST_EXPORT V4Instr {
- enum Type {
- FOR_EACH_V4_INSTR(QML_V4_INSTR_ENUM)
- };
-
- static int size(Type type);
-
- struct instr_common {
- QML_V4_INSTR_HEADER
- };
-
- struct instr_id {
- QML_V4_INSTR_HEADER
- quint16 column;
- quint16 line;
- };
-
- struct instr_init {
- QML_V4_INSTR_HEADER
- quint16 subscriptions;
- quint16 identifiers;
- };
-
- struct instr_subscribeop {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint16 offset;
- quint32 index;
- };
-
- struct instr_load {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint32 index;
- };
-
- struct instr_attached {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint32 id;
- };
-
- struct instr_store {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 reg;
- quint8 exceptionId;
- quint8 valueType;
- quint32 index;
- };
-
- struct instr_storetest {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint32 regType;
- };
-
- struct instr_fetchAndSubscribe {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint8 exceptionId;
- quint8 valueType;
- quint16 subscription;
- QQmlPropertyRawData property;
- };
-
- struct instr_fetch{
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint8 exceptionId;
- quint8 valueType;
- quint32 index;
- quint16 subOffset;
- quint32 subIndex;
- };
-
- struct instr_copy {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint8 src;
- };
-
- struct instr_construct {
- QML_V4_INSTR_HEADER
- qint8 reg;
- };
-
- struct instr_null_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- };
-
- struct instr_number_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- double value; // XXX Makes the instruction 12 bytes
- };
-
- struct instr_int_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- int value;
- };
-
- struct instr_bool_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- bool value;
- };
-
- struct instr_string_value {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint16 length;
- quint32 offset;
- };
-
- struct instr_binaryop {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 left;
- qint8 right;
- };
-
- struct instr_unaryop {
- QML_V4_INSTR_HEADER
- qint8 output;
- qint8 src;
- };
-
- struct instr_jump {
- QML_V4_INSTR_HEADER
- qint8 reg;
- quint32 count;
- };
-
- struct instr_find {
- QML_V4_INSTR_HEADER
- qint8 reg;
- qint8 src;
- quint8 exceptionId;
- quint16 name;
- quint16 subscribeIndex;
- };
-
- struct instr_cleanup {
- QML_V4_INSTR_HEADER
- qint8 reg;
- };
-
- struct instr_initstring {
- QML_V4_INSTR_HEADER
- quint16 offset;
- quint32 dataIdx;
- };
-
- struct instr_branchop {
- QML_V4_INSTR_HEADER
- quint8 reg;
- qint16 offset;
- };
-
- struct instr_blockop {
- QML_V4_INSTR_HEADER
- quint32 block;
- };
-
- struct instr_throwop {
- QML_V4_INSTR_HEADER
- quint8 exceptionId;
- quint32 message;
- };
-
- instr_common common;
- instr_id id;
- instr_init init;
- instr_subscribeop subscribeop;
- instr_load load;
- instr_attached attached;
- instr_store store;
- instr_storetest storetest;
- instr_fetchAndSubscribe fetchAndSubscribe;
- instr_fetch fetch;
- instr_copy copy;
- instr_construct construct;
- instr_null_value null_value;
- instr_number_value number_value;
- instr_int_value int_value;
- instr_bool_value bool_value;
- instr_string_value string_value;
- instr_binaryop binaryop;
- instr_unaryop unaryop;
- instr_jump jump;
- instr_find find;
- instr_cleanup cleanup;
- instr_initstring initstring;
- instr_branchop branchop;
- instr_blockop blockop;
- instr_throwop throwop;
-};
-
-template<int N>
-struct V4InstrMeta {
-};
-
-#define QML_V4_INSTR_META_TEMPLATE(I, FMT) \
- template<> struct V4InstrMeta<(int)V4Instr::I> { \
- enum { Size = QML_V4_INSTR_SIZE(I, FMT) }; \
- typedef V4Instr::instr_##FMT DataType; \
- static const DataType &data(const V4Instr &instr) { return instr.FMT; } \
- static void setData(V4Instr &instr, const DataType &v) { instr.FMT = v; } \
- };
-FOR_EACH_V4_INSTR(QML_V4_INSTR_META_TEMPLATE);
-#undef QML_V4_INSTR_META_TEMPLATE
-
-template<int Instr>
-class Q_AUTOTEST_EXPORT V4InstrData : public V4InstrMeta<Instr>::DataType
-{
-};
-
-class Q_AUTOTEST_EXPORT Bytecode
-{
- Q_DISABLE_COPY(Bytecode)
-
-public:
- Bytecode();
-
- const char *constData() const { return d.constData(); }
- int size() const { return d.size(); }
- int count() const { return d.count(); }
- void clear() { d.clear(); }
- bool isEmpty() const { return d.isEmpty(); }
- V4Instr::Type instructionType(const V4Instr *instr) const;
-
- template <int Instr>
- void append(const V4InstrData<Instr> &data)
- {
- V4Instr genericInstr;
- V4InstrMeta<Instr>::setData(genericInstr, data);
- return append(static_cast<V4Instr::Type>(Instr), genericInstr);
- }
- void append(V4Instr::Type type, V4Instr &instr);
-
- int remove(int index);
-
- const V4Instr &operator[](int offset) const;
- V4Instr &operator[](int offset);
-
- void dump(const char *start, const char *end) const;
-
-private:
- void dump(const V4Instr *instr, int = -1) const;
-
- QVarLengthArray<char, 4 * 1024> d;
-#ifdef QML_THREADED_INTERPRETER
- void **decodeInstr;
-#endif
-};
-
-}
-
-QT_END_NAMESPACE
-
-#endif // QV4INSTRUCTION_P_H
-
diff --git a/src/qml/qml/v4vm/qv4internalclass.cpp b/src/qml/qml/v4/qv4internalclass.cpp
index f078c51076..f078c51076 100644
--- a/src/qml/qml/v4vm/qv4internalclass.cpp
+++ b/src/qml/qml/v4/qv4internalclass.cpp
diff --git a/src/qml/qml/v4vm/qv4internalclass_p.h b/src/qml/qml/v4/qv4internalclass_p.h
index beb8e2dbae..beb8e2dbae 100644
--- a/src/qml/qml/v4vm/qv4internalclass_p.h
+++ b/src/qml/qml/v4/qv4internalclass_p.h
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp
deleted file mode 100644
index 3159cf0d5f..0000000000
--- a/src/qml/qml/v4/qv4ir.cpp
+++ /dev/null
@@ -1,919 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4ir_p.h"
-
-#include <QtCore/qtextstream.h>
-#include <QtCore/qdebug.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QQmlJS {
-namespace IR {
-
-const char *typeName(Type t)
-{
- switch (t) {
- case InvalidType: return "invalid";
- case UndefinedType: return "undefined";
- case NullType: return "null";
- case VoidType: return "void";
- case StringType: return "string";
- case UrlType: return "QUrl";
- case ColorType: return "QColor";
- case SGAnchorLineType: return "SGAnchorLine";
- case AttachType: return "AttachType";
- case ObjectType: return "object";
- case VariantType: return "variant";
- case VarType: return "var";
- case JSValueType: return "QJSValue";
- case BoolType: return "bool";
- case IntType: return "int";
- case FloatType: return "float";
- case NumberType: return "number";
- default: return "invalid";
- }
-}
-
-inline bool isNumberType(IR::Type ty)
-{
- return ty >= IR::FirstNumberType;
-}
-
-inline bool isStringType(IR::Type ty)
-{
- return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType;
-}
-
-IR::Type maxType(IR::Type left, IR::Type right)
-{
- if (isStringType(left) && isStringType(right)) {
- // String promotions (url to string) are more specific than
- // identity conversions (AKA left == right). That's because
- // we want to ensure we convert urls to strings in binary
- // expressions.
- return IR::StringType;
- } else if (left == right)
- return left;
- else if (isNumberType(left) && isNumberType(right)) {
- IR::Type ty = qMax(left, right);
- return ty == FloatType ? NumberType : ty; // promote floats
- } else if ((isNumberType(left) && isStringType(right)) ||
- (isNumberType(right) && isStringType(left)))
- return IR::StringType;
- else
- return IR::InvalidType;
-}
-
-bool isRealType(IR::Type type)
-{
- return type == IR::NumberType || type == IR::FloatType;
-}
-
-const char *opname(AluOp op)
-{
- switch (op) {
- case OpInvalid: return "?";
-
- case OpIfTrue: return "(bool)";
- case OpNot: return "!";
- case OpUMinus: return "-";
- case OpUPlus: return "+";
- case OpCompl: return "~";
-
- case OpBitAnd: return "&";
- case OpBitOr: return "|";
- case OpBitXor: return "^";
-
- case OpAdd: return "+";
- case OpSub: return "-";
- case OpMul: return "*";
- case OpDiv: return "/";
- case OpMod: return "%";
-
- case OpLShift: return "<<";
- case OpRShift: return ">>";
- case OpURShift: return ">>>";
-
- case OpGt: return ">";
- case OpLt: return "<";
- case OpGe: return ">=";
- case OpLe: return "<=";
- case OpEqual: return "==";
- case OpNotEqual: return "!=";
- case OpStrictEqual: return "===";
- case OpStrictNotEqual: return "!==";
-
- case OpAnd: return "&&";
- case OpOr: return "||";
-
- default: return "?";
-
- } // switch
-}
-
-AluOp binaryOperator(int op)
-{
- switch (static_cast<QSOperator::Op>(op)) {
- case QSOperator::Add: return OpAdd;
- case QSOperator::And: return OpAnd;
- case QSOperator::BitAnd: return OpBitAnd;
- case QSOperator::BitOr: return OpBitOr;
- case QSOperator::BitXor: return OpBitXor;
- case QSOperator::Div: return OpDiv;
- case QSOperator::Equal: return OpEqual;
- case QSOperator::Ge: return OpGe;
- case QSOperator::Gt: return OpGt;
- case QSOperator::Le: return OpLe;
- case QSOperator::LShift: return OpLShift;
- case QSOperator::Lt: return OpLt;
- case QSOperator::Mod: return OpMod;
- case QSOperator::Mul: return OpMul;
- case QSOperator::NotEqual: return OpNotEqual;
- case QSOperator::Or: return OpOr;
- case QSOperator::RShift: return OpRShift;
- case QSOperator::StrictEqual: return OpStrictEqual;
- case QSOperator::StrictNotEqual: return OpStrictNotEqual;
- case QSOperator::Sub: return OpSub;
- case QSOperator::URShift: return OpURShift;
- default: return OpInvalid;
- }
-}
-
-void Const::dump(QTextStream &out)
-{
- out << value;
-}
-
-void String::dump(QTextStream &out)
-{
- out << '"' << escape(value) << '"';
-}
-
-QString String::escape(const QStringRef &s)
-{
- QString r;
- for (int i = 0; i < s.length(); ++i) {
- const QChar ch = s.at(i);
- if (ch == QLatin1Char('\n'))
- r += QLatin1String("\\n");
- else if (ch == QLatin1Char('\r'))
- r += QLatin1String("\\r");
- else if (ch == QLatin1Char('\\'))
- r += QLatin1String("\\\\");
- else if (ch == QLatin1Char('"'))
- r += QLatin1String("\\\"");
- else if (ch == QLatin1Char('\''))
- r += QLatin1String("\\'");
- else
- r += ch;
- }
- return r;
-}
-
-void Name::init(Name *base, Type type, const QString *id, Symbol symbol, quint16 line, quint16 column)
-{
- this->type = type;
- this->base = base;
- this->id = id;
- this->symbol = symbol;
- this->ptr = 0;
- this->property = 0;
- this->storage = MemberStorage;
- this->builtin = NoBuiltinSymbol;
- this->line = line;
- this->column = column;
-
- if (id->length() == 8 && *id == QLatin1String("Math.sin")) {
- builtin = MathSinBultinFunction;
- } else if (id->length() == 8 && *id == QLatin1String("Math.cos")) {
- builtin = MathCosBultinFunction;
- } else if (id->length() == 8 && *id == QLatin1String("Math.abs")) {
- builtin = MathAbsBuiltinFunction;
- } else if (id->length() == 10 && *id == QLatin1String("Math.round")) {
- builtin = MathRoundBultinFunction;
- } else if (id->length() == 10 && *id == QLatin1String("Math.floor")) {
- builtin = MathFloorBultinFunction;
- } else if (id->length() == 9 && *id == QLatin1String("Math.ceil")) {
- builtin = MathCeilBuiltinFunction;
- } else if (id->length() == 8 && *id == QLatin1String("Math.max")) {
- builtin = MathMaxBuiltinFunction;
- } else if (id->length() == 8 && *id == QLatin1String("Math.min")) {
- builtin = MathMinBuiltinFunction;
- } else if (id->length() == 7 && *id == QLatin1String("Math.PI")) {
- builtin = MathPIBuiltinConstant;
- this->type = NumberType;
- }
-}
-
-void Name::dump(QTextStream &out)
-{
- if (base) {
- base->dump(out);
- out << '.';
- }
-
- out << *id;
-}
-
-void Temp::dump(QTextStream &out)
-{
- out << 't' << index;
-}
-
-void Unop::dump(QTextStream &out)
-{
- out << opname(op);
- expr->dump(out);
-}
-
-Type Unop::typeForOp(AluOp op, Expr *expr)
-{
- switch (op) {
- case OpIfTrue: return BoolType;
- case OpNot: return BoolType;
-
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- return maxType(expr->type, NumberType);
-
- default:
- break;
- }
-
- return InvalidType;
-}
-
-void Binop::dump(QTextStream &out)
-{
- left->dump(out);
- out << ' ' << opname(op) << ' ';
- right->dump(out);
-}
-
-Type Binop::typeForOp(AluOp op, Expr *left, Expr *right)
-{
- if (! (left && right))
- return InvalidType;
-
- switch (op) {
- case OpInvalid:
- return InvalidType;
-
- // unary operators
- case OpIfTrue:
- case OpNot:
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- return InvalidType;
-
- // bit fields
- case OpBitAnd:
- case OpBitOr:
- case OpBitXor:
- return IntType;
-
- case OpAdd:
- if (left->type == StringType)
- return StringType;
- return NumberType;
-
- case OpSub:
- case OpMul:
- case OpDiv:
- case OpMod:
- return NumberType;
-
- case OpLShift:
- case OpRShift:
- case OpURShift:
- return IntType;
-
- case OpAnd:
- case OpOr:
- return BoolType;
-
- case OpGt:
- case OpLt:
- case OpGe:
- case OpLe:
- case OpEqual:
- case OpNotEqual:
- case OpStrictEqual:
- case OpStrictNotEqual:
- return BoolType;
- } // switch
-
- return InvalidType;
-}
-
-void Call::dump(QTextStream &out)
-{
- base->dump(out);
- out << '(';
- for (ExprList *it = args; it; it = it->next) {
- if (it != args)
- out << ", ";
- it->expr->dump(out);
- }
- out << ')';
-}
-
-Type Call::typeForFunction(Expr *base)
-{
- if (! base)
- return InvalidType;
-
- if (Name *name = base->asName()) {
- switch (name->builtin) {
- case MathSinBultinFunction:
- case MathCosBultinFunction:
- case MathAbsBuiltinFunction: //### type could also be Int if input was Int
- case MathMaxBuiltinFunction:
- case MathMinBuiltinFunction:
- return NumberType;
-
- case MathRoundBultinFunction:
- case MathFloorBultinFunction:
- case MathCeilBuiltinFunction:
- return IntType;
-
- case NoBuiltinSymbol:
- case MathPIBuiltinConstant:
- break;
- }
- } // switch
-
- return InvalidType;
-}
-
-void Exp::dump(QTextStream &out, Mode)
-{
- out << "(void) ";
- expr->dump(out);
- out << ';';
-}
-
-void Move::dump(QTextStream &out, Mode)
-{
- target->dump(out);
- out << " = ";
- if (source->type != target->type)
- out << typeName(source->type) << "_to_" << typeName(target->type) << '(';
- source->dump(out);
- if (source->type != target->type)
- out << ')';
- out << ';';
-}
-
-void Jump::dump(QTextStream &out, Mode mode)
-{
- Q_UNUSED(mode);
- out << "goto " << 'L' << target << ';';
-}
-
-void CJump::dump(QTextStream &out, Mode mode)
-{
- Q_UNUSED(mode);
- out << "if (";
- cond->dump(out);
- out << ") goto " << 'L' << iftrue << "; else goto " << 'L' << iffalse << ';';
-}
-
-void Ret::dump(QTextStream &out, Mode)
-{
- out << "return";
- if (expr) {
- out << ' ';
- expr->dump(out);
- }
- out << ';';
-}
-
-Function::~Function()
-{
- qDeleteAll(basicBlocks);
-}
-
-QString *Function::newString(const QString &text)
-{
- return pool->NewString(text);
-}
-
-BasicBlock *Function::newBasicBlock()
-{
- const int index = basicBlocks.size();
- return i(new BasicBlock(this, index));
-}
-
-void Function::dump(QTextStream &out)
-{
- out << "function () {" << endl;
- foreach (BasicBlock *bb, basicBlocks) {
- bb->dump(out);
- }
- out << '}' << endl;
-}
-
-Temp *BasicBlock::TEMP(Type type, int index)
-{
- Temp *e = function->pool->New<Temp>();
- e->init(type, index);
- return e;
-}
-
-Temp *BasicBlock::TEMP(Type type)
-{
- return TEMP(type, function->tempCount++);
-}
-
-Expr *BasicBlock::CONST(Type type, double value)
-{
- Const *e = function->pool->New<Const>();
- e->init(type, value);
- return e;
-}
-
-Expr *BasicBlock::STRING(const QStringRef &value)
-{
- String *e = function->pool->New<String>();
- e->init(value);
- return e;
-}
-
-Name *BasicBlock::NAME(const QString &id, quint16 line, quint16 column)
-{
- return NAME(0, id, line, column);
-}
-
-Name *BasicBlock::NAME(Name *base, const QString &id, quint16 line, quint16 column)
-{
- Name *e = function->pool->New<Name>();
- e->init(base, InvalidType,
- function->newString(id),
- Name::Unbound, line, column);
- return e;
-}
-
-Name *BasicBlock::SYMBOL(Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property, Name::Storage storage,
- quint16 line, quint16 column)
-{
- Name *name = SYMBOL(/*base = */ 0, type, id, meta, property, line, column);
- name->storage = storage;
- return name;
-}
-
-Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property, Name::Storage storage,
- quint16 line, quint16 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(base, type, function->newString(id),
- Name::Property, line, column);
- name->meta = meta;
- name->property = property;
- name->storage = storage;
- return name;
-}
-
-Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property,
- quint16 line, quint16 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(base, type, function->newString(id),
- Name::Property, line, column);
- name->meta = meta;
- name->property = property;
- return name;
-}
-
-Name *BasicBlock::ID_OBJECT(const QString &id, const QQmlScript::Object *object, quint16 line, quint16 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(/*base = */ 0, IR::ObjectType,
- function->newString(id),
- Name::IdObject, line, column);
- name->idObject = object;
- name->property = 0;
- name->storage = Name::IdStorage;
- return name;
-}
-
-Name *BasicBlock::ATTACH_TYPE(const QString &id, const QQmlType *attachType, Name::Storage storage,
- quint16 line, quint16 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(/*base = */ 0, IR::AttachType,
- function->newString(id),
- Name::AttachType, line, column);
- name->declarativeType = attachType;
- name->storage = storage;
- return name;
-}
-
-Name *BasicBlock::SINGLETON_OBJECT(const QString &id, const QQmlMetaObject &meta, Name::Storage storage,
- quint16 line, quint16 column)
-{
- Name *name = function->pool->New<Name>();
- name->init(/*base = */ 0, IR::ObjectType,
- function->newString(id),
- Name::SingletonObject, line, column);
- name->meta = meta;
- name->storage = storage;
- return name;
-}
-
-Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
-{
- Unop *e = function->pool->New<Unop>();
- e->init(op, expr);
- return e;
-}
-
-Expr *BasicBlock::BINOP(AluOp op, Expr *left, Expr *right)
-{
- if (left && right) {
- if (Const *c1 = left->asConst()) {
- if (Const *c2 = right->asConst()) {
- const IR::Type ty = Binop::typeForOp(op, left, right);
-
- switch (op) {
- case OpAdd: return CONST(ty, c1->value + c2->value);
- case OpAnd: return CONST(ty, c1->value ? c2->value : 0);
- case OpBitAnd: return CONST(ty, int(c1->value) & int(c2->value));
- case OpBitOr: return CONST(ty, int(c1->value) | int(c2->value));
- case OpBitXor: return CONST(ty, int(c1->value) ^ int(c2->value));
- case OpDiv: return CONST(ty, c1->value / c2->value);
- case OpEqual: return CONST(ty, c1->value == c2->value);
- case OpGe: return CONST(ty, c1->value >= c2->value);
- case OpGt: return CONST(ty, c1->value > c2->value);
- case OpLe: return CONST(ty, c1->value <= c2->value);
- case OpLShift: return CONST(ty, int(c1->value) << int(c2->value));
- case OpLt: return CONST(ty, c1->value < c2->value);
- case OpMod: return CONST(ty, ::fmod(c1->value, c2->value));
- case OpMul: return CONST(ty, c1->value * c2->value);
- case OpNotEqual: return CONST(ty, c1->value != c2->value);
- case OpOr: return CONST(ty, c1->value ? c1->value : c2->value);
- case OpRShift: return CONST(ty, int(c1->value) >> int(c2->value));
- case OpStrictEqual: return CONST(ty, c1->value == c2->value);
- case OpStrictNotEqual: return CONST(ty, c1->value != c2->value);
- case OpSub: return CONST(ty, c1->value - c2->value);
- case OpURShift: return CONST(ty, unsigned(c1->value) >> int(c2->value));
-
- case OpIfTrue: // unary ops
- case OpNot:
- case OpUMinus:
- case OpUPlus:
- case OpCompl:
- case OpInvalid:
- break;
- }
- }
- } else if (op == OpAdd) {
- if (String *s1 = left->asString()) {
- if (String *s2 = right->asString()) {
- return STRING(function->newString(s1->value.toString() + s2->value));
- }
- }
- }
- }
-
- Binop *e = function->pool->New<Binop>();
- e->init(op, left, right);
- return e;
-}
-
-Expr *BasicBlock::CALL(Expr *base, ExprList *args)
-{
- Call *e = function->pool->New<Call>();
- e->init(base, args);
- return e;
-}
-
-Stmt *BasicBlock::EXP(Expr *expr)
-{
- Exp *s = function->pool->New<Exp>();
- s->init(expr);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::MOVE(Expr *target, Expr *source, bool isMoveForReturn)
-{
- Move *s = function->pool->New<Move>();
- s->init(target, source, isMoveForReturn);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::JUMP(BasicBlock *target)
-{
- if (isTerminated())
- return 0;
-
- Jump *s = function->pool->New<Jump>();
- s->init(target);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
-{
- if (isTerminated())
- return 0;
-
- CJump *s = function->pool->New<CJump>();
- s->init(cond, iftrue, iffalse);
- statements.append(s);
- return s;
-}
-
-Stmt *BasicBlock::RET(Expr *expr, Type type, quint16 line, quint16 column)
-{
- if (isTerminated())
- return 0;
-
- Ret *s = function->pool->New<Ret>();
- s->init(expr, type, line, column);
- statements.append(s);
- return s;
-}
-
-void BasicBlock::dump(QTextStream &out)
-{
- out << 'L' << this << ':' << endl;
- foreach (Stmt *s, statements) {
- out << '\t';
- s->dump(out);
- out << endl;
- }
-}
-
-#ifdef DEBUG_IR_STRUCTURE
-
-static const char *symbolname(Name::Symbol s)
-{
- switch (s) {
- case Name::Unbound:
- return "Unbound";
- case Name::IdObject:
- return "IdObject";
- case Name::AttachType:
- return "AttachType";
- case Name::SingletonObject:
- return "SingletonObject";
- case Name::Object:
- return "Object";
- case Name::Property:
- return "Property";
- case Name::Slot:
- return "Slot";
- default:
- Q_ASSERT(!"Unreachable");
- return "Unknown";
- }
-}
-
-static const char *storagename(Name::Storage s)
-{
- switch (s) {
- case Name::MemberStorage:
- return "MemberStorage";
- case Name::IdStorage:
- return "IdStorage";
- case Name::RootStorage:
- return "RootStorage";
- case Name::ScopeStorage:
- return "ScopeStorage";
- default:
- Q_ASSERT(!"Unreachable");
- return "UnknownStorage";
- }
-}
-
-IRDump::IRDump()
-: indentSize(0)
-{
-}
-
-void IRDump::inc()
-{
- indentSize++;
- indentData = QByteArray(indentSize * 4, ' ');
-}
-
-void IRDump::dec()
-{
- indentSize--;
- indentData = QByteArray(indentSize * 4, ' ');
-}
-
-void IRDump::dec();
-
-void IRDump::expression(QQmlJS::IR::Expr *e)
-{
- inc();
-
- e->accept(this);
-
- dec();
-}
-
-void IRDump::basicblock(QQmlJS::IR::BasicBlock *b)
-{
- inc();
-
- qWarning().nospace() << indent() << "BasicBlock " << b << " {";
- for (int ii = 0; ii < b->statements.count(); ++ii) {
- statement(b->statements.at(ii));
- if (ii != (b->statements.count() - 1))
- qWarning();
- }
- qWarning().nospace() << indent() << '}';
-
- dec();
-}
-
-void IRDump::statement(QQmlJS::IR::Stmt *s)
-{
- inc();
-
- s->accept(this);
-
- dec();
-}
-
-void IRDump::function(QQmlJS::IR::Function *f)
-{
- inc();
-
- qWarning().nospace() << indent() << "Function {";
- for (int ii = 0; ii < f->basicBlocks.count(); ++ii) {
- basicblock(f->basicBlocks.at(ii));
- }
- qWarning().nospace() << indent() << '}';
-
- dec();
-}
-
-const char *IRDump::indent()
-{
- return indentData.constData();
-}
-
-void IRDump::visitConst(QQmlJS::IR::Const *e)
-{
- qWarning().nospace() << indent() << "Const:Expr { type: " << typeName(e->type) << ", value: " << e->value << '}';
-}
-
-void IRDump::visitString(QQmlJS::IR::String *e)
-{
- qWarning().nospace() << indent() << "String:Expr { type: " << typeName(e->type) << ", value: " << e->value << '}';
-}
-
-static void namedumprecur(QQmlJS::IR::Name *e, const char *indent)
-{
- if (e->base) namedumprecur(e->base, indent);
- qWarning().nospace() << indent << " { type: " << typeName(e->type) << ", symbol: " << symbolname(e->symbol) << ", storage: " << storagename(e->storage) << ", id: " << e->id << '}';
-}
-
-void IRDump::visitName(QQmlJS::IR::Name *e)
-{
- qWarning().nospace() << indent() << "Name:Expr {";
- namedumprecur(e, indent());
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitTemp(QQmlJS::IR::Temp *e)
-{
- qWarning().nospace() << indent() << "Temp:Expr { type: " << typeName(e->type) << ", index: " << e->index << " }";
-}
-
-void IRDump::visitUnop(QQmlJS::IR::Unop *e)
-{
- qWarning().nospace() << indent() << "Unop:Expr { ";
- qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
- qWarning().nospace() << indent() << " expr: {";
- expression(e->expr);
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitBinop(QQmlJS::IR::Binop *e)
-{
- qWarning().nospace() << indent() << "Binop:Expr { ";
- qWarning().nospace() << indent() << " type: " << typeName(e->type) << ", op: " << opname(e->op);
- qWarning().nospace() << indent() << " left: {";
- inc();
- expression(e->left);
- dec();
- qWarning().nospace() << indent() << " },";
- qWarning().nospace() << indent() << " right: {";
- inc();
- expression(e->right);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitCall(QQmlJS::IR::Call *e)
-{
- Q_UNUSED(e);
- qWarning().nospace() << indent() << "Exp::Call { }";
-}
-
-void IRDump::visitExp(QQmlJS::IR::Exp *s)
-{
- qWarning().nospace() << indent() << "Exp:Stmt {";
- expression(s->expr);
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitMove(QQmlJS::IR::Move *s)
-{
- qWarning().nospace() << indent() << "Move:Stmt {";
- qWarning().nospace() << indent() << " isMoveForReturn: " << s->isMoveForReturn;
- qWarning().nospace() << indent() << " target: {";
- inc();
- expression(s->target);
- dec();
- qWarning().nospace() << indent() << " },";
- qWarning().nospace() << indent() << " source: {";
- inc();
- expression(s->source);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitJump(QQmlJS::IR::Jump *s)
-{
- qWarning().nospace() << indent() << "Jump:Stmt { BasicBlock(" << s->target << ") }";
-}
-
-void IRDump::visitCJump(QQmlJS::IR::CJump *s)
-{
- qWarning().nospace() << indent() << "CJump:Stmt {";
- qWarning().nospace() << indent() << " cond: {";
- inc();
- expression(s->cond);
- dec();
- qWarning().nospace() << indent() << " }";
- qWarning().nospace() << indent() << " iftrue: BasicBlock(" << s->iftrue << ')';
- qWarning().nospace() << indent() << " iffalse: BasicBlock(" << s->iffalse << ')';
- qWarning().nospace() << indent() << '}';
-}
-
-void IRDump::visitRet(QQmlJS::IR::Ret *s)
-{
- qWarning().nospace() << indent() << "Ret:Stmt {";
- qWarning().nospace() << indent() << " type: " << typeName(s->type);
- expression(s->expr);
- qWarning().nospace() << indent() << '}';
-}
-#endif
-
-} // end of namespace IR
-} // end of namespace QQmlJS
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4ir_p.h b/src/qml/qml/v4/qv4ir_p.h
deleted file mode 100644
index 701f76d9e4..0000000000
--- a/src/qml/qml/v4/qv4ir_p.h
+++ /dev/null
@@ -1,615 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4IR_P_H
-#define QV4IR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qqmljsast_p.h>
-#include <private/qqmljsengine_p.h>
-#include <private/qqmlscript_p.h>
-#include <private/qqmlimport_p.h>
-#include <private/qqmlengine_p.h>
-#include <private/qv4compiler_p.h>
-
-#include <private/qqmlpool_p.h>
-#include <QtCore/qvarlengtharray.h>
-
-// #define DEBUG_IR_STRUCTURE
-
-#ifdef CONST
-# undef CONST
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class QQmlType;
-
-namespace QQmlJS {
-
-namespace IR {
-
-struct BasicBlock;
-struct Function;
-
-struct Stmt;
-struct Expr;
-
-// expressions
-struct Const;
-struct String;
-struct Name;
-struct Temp;
-struct Unop;
-struct Binop;
-struct Call;
-
-// statements
-struct Exp;
-struct Move;
-struct Jump;
-struct CJump;
-struct Ret;
-
-enum AluOp {
- OpInvalid = 0,
-
- OpIfTrue,
- OpNot,
- OpUMinus,
- OpUPlus,
- OpCompl,
-
- OpBitAnd,
- OpBitOr,
- OpBitXor,
-
- OpAdd,
- OpSub,
- OpMul,
- OpDiv,
- OpMod,
-
- OpLShift,
- OpRShift,
- OpURShift,
-
- OpGt,
- OpLt,
- OpGe,
- OpLe,
- OpEqual,
- OpNotEqual,
- OpStrictEqual,
- OpStrictNotEqual,
-
- OpAnd,
- OpOr
-};
-AluOp binaryOperator(int op);
-
-enum Type {
- InvalidType,
- UndefinedType,
- NullType,
- VoidType,
- StringType,
- UrlType,
- ColorType,
- SGAnchorLineType,
- AttachType,
- ObjectType,
- VariantType,
- VarType,
- JSValueType,
-
- FirstNumberType,
- BoolType = FirstNumberType,
- IntType,
- FloatType,
- NumberType
-};
-Type maxType(IR::Type left, IR::Type right);
-bool isRealType(IR::Type type);
-const char *typeName(IR::Type t);
-
-struct ExprVisitor {
- virtual ~ExprVisitor() {}
- virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitName(Name *) {}
- virtual void visitTemp(Temp *) {}
- virtual void visitUnop(Unop *) {}
- virtual void visitBinop(Binop *) {}
- virtual void visitCall(Call *) {}
-};
-
-struct StmtVisitor {
- virtual ~StmtVisitor() {}
- virtual void visitExp(Exp *) {}
- virtual void visitMove(Move *) {}
- virtual void visitJump(Jump *) {}
- virtual void visitCJump(CJump *) {}
- virtual void visitRet(Ret *) {}
-};
-
-struct Expr: QQmlPool::POD {
- Type type;
-
- Expr(): type(InvalidType) {}
- virtual ~Expr() {}
- virtual void accept(ExprVisitor *) = 0;
- virtual Const *asConst() { return 0; }
- virtual String *asString() { return 0; }
- virtual Name *asName() { return 0; }
- virtual Temp *asTemp() { return 0; }
- virtual Unop *asUnop() { return 0; }
- virtual Binop *asBinop() { return 0; }
- virtual Call *asCall() { return 0; }
- virtual void dump(QTextStream &out) = 0;
-};
-
-struct ExprList: QQmlPool::POD {
- Expr *expr;
- ExprList *next;
-
- void init(Expr *expr, ExprList *next = 0)
- {
- this->expr = expr;
- this->next = next;
- }
-};
-
-struct Const: Expr {
- double value;
-
- void init(Type type, double value)
- {
- this->type = type;
- this->value = value;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitConst(this); }
- virtual Const *asConst() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct String: Expr {
- QStringRef value;
-
- void init(const QStringRef &value)
- {
- this->type = StringType;
- this->value = value;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitString(this); }
- virtual String *asString() { return this; }
-
- virtual void dump(QTextStream &out);
- static QString escape(const QStringRef &s);
-};
-
-enum BuiltinSymbol {
- NoBuiltinSymbol,
- MathSinBultinFunction,
- MathCosBultinFunction,
- MathRoundBultinFunction,
- MathFloorBultinFunction,
- MathCeilBuiltinFunction,
- MathAbsBuiltinFunction,
- MathMaxBuiltinFunction,
- MathMinBuiltinFunction,
-
- MathPIBuiltinConstant
-};
-
-struct Name: Expr {
- enum Symbol {
- Unbound,
- IdObject, // This is a load of a id object. Storage will always be IdStorage
- AttachType, // This is a load of an attached object
- SingletonObject, // This is a load of a singleton object
- Object, // XXX what is this for?
- Property, // This is a load of a regular property
- Slot // XXX what is this for?
- };
-
- enum Storage {
- MemberStorage, // This is a property of a previously fetched object
- IdStorage, // This is a load of a id object. Symbol will always be IdObject
- RootStorage, // This is a property of the root object
- ScopeStorage // This is a property of the scope object
- };
-
- Name *base;
- const QString *id;
- Symbol symbol;
- union {
- void *ptr;
- const QQmlType *declarativeType;
- const QQmlScript::Object *idObject;
- };
-
- QQmlMetaObject meta;
- QQmlPropertyData *property;
- Storage storage;
- BuiltinSymbol builtin;
- quint16 line;
- quint16 column;
-
- void init(Name *base, Type type, const QString *id, Symbol symbol, quint16 line, quint16 column);
-
- inline bool is(Symbol s) const { return s == symbol; }
- inline bool isNot(Symbol s) const { return s != symbol; }
-
- virtual void accept(ExprVisitor *v) { v->visitName(this); }
- virtual Name *asName() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct Temp: Expr {
- int index;
-
- void init(Type type, int index)
- {
- this->type = type;
- this->index = index;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitTemp(this); }
- virtual Temp *asTemp() { return this; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct Unop: Expr {
- AluOp op;
- Expr *expr;
-
- void init(AluOp op, Expr *expr)
- {
- this->type = this->typeForOp(op, expr);
- this->op = op;
- this->expr = expr;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitUnop(this); }
- virtual Unop *asUnop() { return this; }
-
- virtual void dump(QTextStream &out);
-
-private:
- static Type typeForOp(AluOp op, Expr *expr);
-};
-
-struct Binop: Expr {
- AluOp op;
- Expr *left;
- Expr *right;
-
- void init(AluOp op, Expr *left, Expr *right)
- {
- this->type = typeForOp(op, left, right);
- this->op = op;
- this->left = left;
- this->right = right;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitBinop(this); }
- virtual Binop *asBinop() { return this; }
-
- virtual void dump(QTextStream &out);
-
- static Type typeForOp(AluOp op, Expr *left, Expr *right);
-};
-
-struct Call: Expr {
- Expr *base;
- ExprList *args;
-
- void init(Expr *base, ExprList *args)
- {
- this->type = typeForFunction(base);
- this->base = base;
- this->args = args;
- }
-
- Expr *onlyArgument() const {
- if (args && ! args->next)
- return args->expr;
- return 0;
- }
-
- virtual void accept(ExprVisitor *v) { v->visitCall(this); }
- virtual Call *asCall() { return this; }
-
- virtual void dump(QTextStream &out);
-
-private:
- static Type typeForFunction(Expr *base);
-};
-
-struct Stmt: QQmlPool::POD {
- enum Mode {
- HIR,
- MIR
- };
-
- virtual ~Stmt() {}
- virtual Stmt *asTerminator() { return 0; }
-
- virtual void accept(StmtVisitor *) = 0;
- virtual Exp *asExp() { return 0; }
- virtual Move *asMove() { return 0; }
- virtual Jump *asJump() { return 0; }
- virtual CJump *asCJump() { return 0; }
- virtual Ret *asRet() { return 0; }
- virtual void dump(QTextStream &out, Mode mode = HIR) = 0;
-};
-
-struct Exp: Stmt {
- Expr *expr;
-
- void init(Expr *expr)
- {
- this->expr = expr;
- }
-
- virtual void accept(StmtVisitor *v) { v->visitExp(this); }
- virtual Exp *asExp() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Move: Stmt {
- Expr *target;
- Expr *source;
- bool isMoveForReturn;
-
- void init(Expr *target, Expr *source, bool isMoveForReturn)
- {
- this->target = target;
- this->source = source;
- this->isMoveForReturn = isMoveForReturn;
- }
-
- virtual void accept(StmtVisitor *v) { v->visitMove(this); }
- virtual Move *asMove() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Jump: Stmt {
- BasicBlock *target;
-
- void init(BasicBlock *target)
- {
- this->target = target;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitJump(this); }
- virtual Jump *asJump() { return this; }
-
- virtual void dump(QTextStream &out, Mode mode);
-};
-
-struct CJump: Stmt {
- Expr *cond;
- BasicBlock *iftrue;
- BasicBlock *iffalse;
-
- void init(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
- {
- this->cond = cond;
- this->iftrue = iftrue;
- this->iffalse = iffalse;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitCJump(this); }
- virtual CJump *asCJump() { return this; }
-
- virtual void dump(QTextStream &out, Mode mode);
-};
-
-struct Ret: Stmt {
- Expr *expr;
- Type type;
- quint16 line;
- quint16 column;
-
- void init(Expr *expr, Type type, quint16 line, quint16 column)
- {
- this->expr = expr;
- this->type = type;
- this->line = line;
- this->column = column;
- }
-
- virtual Stmt *asTerminator() { return this; }
-
- virtual void accept(StmtVisitor *v) { v->visitRet(this); }
- virtual Ret *asRet() { return this; }
-
- virtual void dump(QTextStream &out, Mode);
-};
-
-struct Function {
- QQmlPool *pool;
- QVarLengthArray<BasicBlock *, 8> basicBlocks;
- int tempCount;
-
- Function(QQmlPool *pool)
- : pool(pool), tempCount(0) {}
-
- virtual ~Function();
-
- BasicBlock *newBasicBlock();
- QString *newString(const QString &text);
-
- inline BasicBlock *i(BasicBlock *block) { basicBlocks.append(block); return block; }
-
- virtual void dump(QTextStream &out);
-};
-
-struct BasicBlock {
- Function *function;
- int index;
- int offset;
- QVarLengthArray<Stmt *, 32> statements;
-
- BasicBlock(Function *function, int index): function(function), index(index), offset(-1) {}
- ~BasicBlock() {}
-
- template <typename Instr> inline Instr i(Instr i) { statements.append(i); return i; }
-
- inline bool isEmpty() const {
- return statements.isEmpty();
- }
-
- inline Stmt *terminator() const {
- if (! statements.isEmpty() && statements.at(statements.size() - 1)->asTerminator() != 0)
- return statements.at(statements.size() - 1);
- return 0;
- }
-
- inline bool isTerminated() const {
- if (terminator() != 0)
- return true;
- return false;
- }
-
- Temp *TEMP(Type type, int index);
- Temp *TEMP(Type type);
-
- Expr *CONST(Type type, double value);
- Expr *STRING(const QStringRef &value);
-
- Name *NAME(const QString &id, quint16 line, quint16 column);
- Name *NAME(Name *base, const QString &id, quint16 line, quint16 column);
- Name *SYMBOL(Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property, Name::Storage storage, quint16 line, quint16 column);
- Name *SYMBOL(Name *base, Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property, quint16 line, quint16 column);
- Name *SYMBOL(Name *base, Type type, const QString &id, const QQmlMetaObject &meta, QQmlPropertyData *property, Name::Storage storage, quint16 line, quint16 column);
- Name *ID_OBJECT(const QString &id, const QQmlScript::Object *object, quint16 line, quint16 column);
- Name *ATTACH_TYPE(const QString &id, const QQmlType *attachType, Name::Storage storage, quint16 line, quint16 column);
- Name *SINGLETON_OBJECT(const QString &id, const QQmlMetaObject &meta, Name::Storage storage, quint16 line, quint16 column);
-
- Expr *UNOP(AluOp op, Expr *expr);
- Expr *BINOP(AluOp op, Expr *left, Expr *right);
- Expr *CALL(Expr *base, ExprList *args);
-
- Stmt *EXP(Expr *expr);
- Stmt *MOVE(Expr *target, Expr *source, bool = false);
-
- Stmt *JUMP(BasicBlock *target);
- Stmt *CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse);
- Stmt *RET(Expr *expr, Type type, quint16 line, quint16 column);
-
- void dump(QTextStream &out);
-};
-
-#ifdef DEBUG_IR_STRUCTURE
-struct IRDump : public ExprVisitor,
- public StmtVisitor
-{
-public:
- IRDump();
-
- void expression(QQmlJS::IR::Expr *);
- void basicblock(QQmlJS::IR::BasicBlock *);
- void statement(QQmlJS::IR::Stmt *);
- void function(QQmlJS::IR::Function *);
-protected:
-
- const char *indent();
-
- //
- // expressions
- //
- virtual void visitConst(QQmlJS::IR::Const *e);
- virtual void visitString(QQmlJS::IR::String *e);
- virtual void visitName(QQmlJS::IR::Name *e);
- virtual void visitTemp(QQmlJS::IR::Temp *e);
- virtual void visitUnop(QQmlJS::IR::Unop *e);
- virtual void visitBinop(QQmlJS::IR::Binop *e);
- virtual void visitCall(QQmlJS::IR::Call *e);
-
- //
- // statements
- //
- virtual void visitExp(QQmlJS::IR::Exp *s);
- virtual void visitMove(QQmlJS::IR::Move *s);
- virtual void visitJump(QQmlJS::IR::Jump *s);
- virtual void visitCJump(QQmlJS::IR::CJump *s);
- virtual void visitRet(QQmlJS::IR::Ret *s);
-
-private:
- int indentSize;
- QByteArray indentData;
- void inc();
- void dec();
-};
-#endif
-
-} // end of namespace IR
-
-} // end of namespace QQmlJS
-
-QT_END_NAMESPACE
-
-#endif // QV4IR_P_H
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp
deleted file mode 100644
index 4aa257d54a..0000000000
--- a/src/qml/qml/v4/qv4irbuilder.cpp
+++ /dev/null
@@ -1,1387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4irbuilder_p.h"
-#include "qv4compiler_p_p.h"
-
-#include <private/qqmlglobal_p.h>
-#include <private/qqmlmetatype_p.h>
-#include <private/qqmltypenamecache_p.h>
-
-DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER)
-
-QT_BEGIN_NAMESPACE
-
-using namespace QQmlJS;
-
-static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine)
-{
- switch (t) {
- case QMetaType::Bool:
- return IR::BoolType;
-
- case QMetaType::Int:
- return IR::IntType;
-
- case QMetaType::Float:
- return IR::FloatType;
-
- case QMetaType::Double:
- return IR::NumberType;
-
- case QMetaType::QString:
- return IR::StringType;
-
- case QMetaType::QUrl:
- return IR::UrlType;
-
- case QMetaType::QColor:
- return IR::ColorType;
-
- default:
- if (t == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
- return IR::SGAnchorLineType;
- } else if (!engine->metaObjectForType(t).isNull()) {
- return IR::ObjectType;
- } else if (t == qMetaTypeId<QJSValue>()) {
- return IR::JSValueType;
- }
-
- return IR::InvalidType;
- }
-}
-
-QV4IRBuilder::QV4IRBuilder(const QV4Compiler::Expression *expr,
- QQmlEnginePrivate *engine)
-: m_expression(expr), m_engine(engine), _function(0), _block(0), _discard(false),
- _invalidatable(false)
-{
-}
-
-bool QV4IRBuilder::operator()(QQmlJS::IR::Function *function,
- QQmlJS::AST::Node *ast, bool *invalidatable)
-{
- bool discarded = false;
-
- IR::BasicBlock *block = function->newBasicBlock();
-
- qSwap(_discard, discarded);
- qSwap(_function, function);
- qSwap(_block, block);
-
- ExprResult r;
- AST::SourceLocation location;
- if (AST::ExpressionNode *asExpr = ast->expressionCast()) {
- r = expression(asExpr);
- location = asExpr->firstSourceLocation();
- } else if (AST::Statement *asStmt = ast->statementCast()) {
- r = statement(asStmt);
- location = asStmt->firstSourceLocation();
- }
-
- //_block->MOVE(_block->TEMP(IR::InvalidType), r.code);
- if (r.code) {
- IR::Type targetType = IR::InvalidType;
-
- // This is the only operation where variant is supported:
- QQmlPropertyData *data = &m_expression->property->core;
- if (data->propType == QMetaType::QVariant) {
- targetType = (data->isVarProperty() ? IR::VarType : IR::VariantType);
- } else {
- targetType = irTypeFromVariantType(data->propType, m_engine);
- }
-
- if (targetType != r.type()) {
- IR::Expr *x = _block->TEMP(targetType);
- _block->MOVE(x, r, true);
- r.code = x;
- }
- _block->RET(r.code, targetType, location.startLine, location.startColumn);
- }
-
- qSwap(_block, block);
- qSwap(_function, function);
- qSwap(_discard, discarded);
-
- *invalidatable = _invalidatable;
- return !discarded;
-}
-
-bool QV4IRBuilder::buildName(QList<QStringRef> &name,
- AST::Node *node,
- QList<AST::ExpressionNode *> *nodes)
-{
- if (node->kind == AST::Node::Kind_IdentifierExpression) {
- name << static_cast<AST::IdentifierExpression*>(node)->name;
- if (nodes) *nodes << static_cast<AST::IdentifierExpression*>(node);
- } else if (node->kind == AST::Node::Kind_FieldMemberExpression) {
- AST::FieldMemberExpression *expr =
- static_cast<AST::FieldMemberExpression *>(node);
-
- if (!buildName(name, expr->base, nodes))
- return false;
-
- name << expr->name;
- if (nodes) *nodes << expr;
- } else {
- return false;
- }
-
- return true;
-}
-
-void QV4IRBuilder::discard()
-{
- _discard = true;
-}
-
-QV4IRBuilder::ExprResult
-QV4IRBuilder::expression(AST::ExpressionNode *ast)
-{
- ExprResult r;
- if (ast) {
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.is(IR::InvalidType))
- discard();
- else {
- Q_ASSERT(r.hint == r.format);
- }
- }
-
- return r;
-}
-
-void QV4IRBuilder::condition(AST::ExpressionNode *ast, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
-{
- if (! ast)
- return;
- ExprResult r(iftrue, iffalse);
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.format != ExprResult::cx) {
- if (! r.code)
- discard();
-
- Q_ASSERT(r.hint == ExprResult::cx);
- Q_ASSERT(r.format == ExprResult::ex);
-
- if (r.type() != IR::BoolType) {
- IR::Temp *t = _block->TEMP(IR::BoolType);
- _block->MOVE(t, r);
- r = t;
- }
-
- _block->CJUMP(_block->UNOP(IR::OpIfTrue, r), iftrue, iffalse);
- }
-}
-
-QV4IRBuilder::ExprResult
-QV4IRBuilder::statement(AST::Statement *ast)
-{
- ExprResult r;
- if (ast) {
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
-
- if (r.is(IR::InvalidType))
- discard();
- else {
- Q_ASSERT(r.hint == r.format);
- }
- }
-
- return r;
-}
-
-void QV4IRBuilder::sourceElement(AST::SourceElement *ast)
-{
- accept(ast);
-}
-
-void QV4IRBuilder::implicitCvt(ExprResult &expr, IR::Type type)
-{
- if (expr.type() == type)
- return; // nothing to do
-
- IR::Expr *x = _block->TEMP(type);
- _block->MOVE(x, expr.code);
- expr.code = x;
-}
-
-// QML
-bool QV4IRBuilder::visit(AST::UiProgram *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiImportList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiImport *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiPublicMember *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectDefinition *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectInitializer *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiScriptBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiArrayBinding *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiObjectMemberList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiArrayMemberList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UiQualifiedId *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// JS
-bool QV4IRBuilder::visit(AST::Program *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::SourceElements *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StatementSourceElement *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-// object literals
-bool QV4IRBuilder::visit(AST::PropertyAssignmentList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PropertyNameAndValue *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PropertyGetterSetter *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IdentifierPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StringLiteralPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NumericLiteralPropertyName *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// array literals
-bool QV4IRBuilder::visit(AST::ElementList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Elision *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-
-// function calls
-bool QV4IRBuilder::visit(AST::ArgumentList *)
-{
- Q_ASSERT(!"unreachable");
- return false;
-}
-
-// expressions
-bool QV4IRBuilder::visit(AST::ObjectLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ArrayLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ThisExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
-{
- const quint16 line = ast->identifierToken.startLine;
- const quint16 column = ast->identifierToken.startColumn;
-
- const QString name = ast->name.toString();
-
- if (name.at(0) == QLatin1Char('u') && name.length() == 9 && name == QLatin1String("undefined")) {
- _expr.code = _block->CONST(IR::UndefinedType, 0); // ### undefined value
- } else if (m_engine->v8engine()->illegalNames().contains(name) ) {
- if (qmlVerboseCompiler()) qWarning() << "*** illegal symbol:" << name;
- return false;
- } else if (const QQmlScript::Object *obj = m_expression->ids->value(name)) {
- IR::Name *code = _block->ID_OBJECT(name, obj, line, column);
- if (obj == m_expression->component)
- code->storage = IR::Name::RootStorage;
- _expr.code = code;
- } else {
-
- QQmlTypeNameCache::Result r = m_expression->importCache->query(name);
- if (r.isValid()) {
- if (r.type) {
- if (r.type->isSingleton()) {
- // Note: we don't need to check singletonType->qobjectCallback here, since
- // we did that check in registerSingletonType() in qqmlmetatype.cpp.
- // We cannot create the QObject Singleton Type Instance here,
- // as we might be running in a loader thread.
- // Thus, V4 can only handle bindings which use Singleton Types which
- // were registered with the templated registration function.
- _expr.code = _block->SINGLETON_OBJECT(name, r.type->singletonInstanceInfo()->instanceMetaObject, IR::Name::MemberStorage, line, column);
- } else {
- _expr.code = _block->ATTACH_TYPE(name, r.type, IR::Name::ScopeStorage, line, column);
- }
- }
- } else {
- bool found = false;
-
- if (m_expression->context != m_expression->component) {
- // RootStorage is more efficient than ScopeStorage, so prefer that if they are the same
- QQmlPropertyCache *cache = m_expression->context->synthCache;
- if (!cache) cache = m_expression->context->metatype;
-
- QQmlPropertyData *data = cache->property(name, 0, 0);
-
- if (data && data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- if (data && !data->isFunction()) {
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(irType, name, QQmlMetaObject(cache), data, IR::Name::ScopeStorage, line, column);
- found = true;
- }
- }
-
- if (!found) {
- QQmlPropertyCache *cache = m_expression->component->synthCache;
- if (!cache) cache = m_expression->component->metatype;
-
- QQmlPropertyData *data = cache->property(name, 0, 0);
-
- if (data && data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- if (data && !data->isFunction()) {
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(irType, name, QQmlMetaObject(cache), data, IR::Name::RootStorage, line, column);
- found = true;
- }
- }
-
- if (!found && qmlVerboseCompiler())
- qWarning() << "*** unknown symbol:" << name;
- }
- }
-
- if (_expr.code && _expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
-
- if (_expr.type() != IR::BoolType) {
- IR::Temp *t = _block->TEMP(IR::BoolType);
- _block->MOVE(t, _expr);
- _expr.code = t;
- }
-
- _block->CJUMP(_expr.code, _expr.iftrue, _expr.iffalse);
- _expr.code = 0;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NullExpression *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::NullType, 0);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TrueLiteral *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::BoolType, 1);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FalseLiteral *)
-{
- // ### TODO: cx format
- _expr.code = _block->CONST(IR::BoolType, 0);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StringLiteral *ast)
-{
- // ### TODO: cx format
- _expr.code = _block->STRING(ast->value);
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NumericLiteral *ast)
-{
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(ast->value ? _expr.iftrue : _expr.iffalse);
- } else {
- _expr.code = _block->CONST(IR::NumberType, ast->value);
- }
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::RegExpLiteral *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NestedExpression *)
-{
- return true; // the value of the nested expression
-}
-
-bool QV4IRBuilder::visit(AST::ArrayMemberExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
-{
- if (IR::Expr *left = expression(ast->base)) {
- if (IR::Name *baseName = left->asName()) {
- const quint32 line = ast->identifierToken.startLine;
- const quint32 column = ast->identifierToken.startColumn;
-
- QString name = ast->name.toString();
-
- switch(baseName->symbol) {
- case IR::Name::Unbound:
- break;
-
- case IR::Name::AttachType:
- if (name.at(0).isUpper()) {
- QByteArray utf8Name = name.toUtf8();
- const char *enumName = utf8Name.constData();
-
- const QMetaObject *meta = baseName->declarativeType->metaObject();
- bool found = false;
- for (int ii = 0; !found && ii < meta->enumeratorCount(); ++ii) {
- QMetaEnum e = meta->enumerator(ii);
- for (int jj = 0; !found && jj < e.keyCount(); ++jj) {
- if (0 == strcmp(e.key(jj), enumName)) {
- found = true;
- _expr.code = _block->CONST(IR::IntType, e.value(jj));
- }
- }
- }
-
- if (!found && qmlVerboseCompiler())
- qWarning() << "*** unresolved enum:"
- << (*baseName->id + QLatin1Char('.') + ast->name.toString());
- } else if(const QMetaObject *attachedMeta = baseName->declarativeType->attachedPropertiesType()) {
- QQmlPropertyCache *cache = m_engine->cache(attachedMeta);
- QQmlPropertyData *data = cache->property(name, 0, 0);
-
- if (!data || data->isFunction())
- return false; // Don't support methods (or non-existing properties ;)
-
- if (!data->isFinal())
- _invalidatable = true;
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data, line, column);
- }
- break;
-
- case IR::Name::SingletonObject: {
- if (name.at(0).isUpper()) {
- QByteArray utf8Name = name.toUtf8();
- const char *enumName = utf8Name.constData();
-
- const QMetaObject *meta = baseName->meta.propertyCache(m_engine)->firstCppMetaObject();
- bool found = false;
- for (int ii = 0; !found && ii < meta->enumeratorCount(); ++ii) {
- QMetaEnum e = meta->enumerator(ii);
- for (int jj = 0; !found && jj < e.keyCount(); ++jj) {
- if (0 == strcmp(e.key(jj), enumName)) {
- found = true;
- _expr.code = _block->CONST(IR::IntType, e.value(jj));
- }
- }
- }
- if (!found && qmlVerboseCompiler())
- qWarning() << "*** unresolved enum:"
- << (*baseName->id + QLatin1Char('.') + ast->name.toString());
- } else {
- QQmlPropertyCache *cache = baseName->meta.propertyCache(m_engine);
- if (!cache) return false;
- QQmlPropertyData *data = cache->property(name, 0, 0);
-
- if (!data || data->isFunction())
- return false; // Don't support methods (or non-existing properties ;)
-
- if (!data->isFinal())
- _invalidatable = true;
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(baseName, irType, name, baseName->meta, data, line, column);
- }
- }
- break;
-
- case IR::Name::IdObject: {
- const QQmlScript::Object *idObject = baseName->idObject;
- QQmlPropertyCache *cache =
- idObject->synthCache?idObject->synthCache:idObject->metatype;
-
- QQmlPropertyData *data = cache->property(name, 0, 0);
-
- if (!data || data->isFunction())
- return false; // Don't support methods (or non-existing properties ;)
-
- if (data->hasRevision()) {
- if (qmlVerboseCompiler())
- qWarning() << "*** versioned symbol:" << name;
- discard();
- return false;
- }
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(baseName, irType, name, QQmlMetaObject(cache), data, line, column);
- }
- break;
-
- case IR::Name::Property:
- if (baseName->type == IR::ObjectType && !baseName->meta.isNull()) {
- QQmlMetaObject meta = m_engine->metaObjectForType(baseName->property->propType);
- QQmlPropertyCache *cache = meta.propertyCache(m_engine);
- if (!cache)
- return false;
-
- if (QQmlPropertyData *data = cache->property(name, 0, 0)) {
- if (!baseName->property->isFinal() || !data->isFinal())
- _invalidatable = true;
-
- IR::Type irType = irTypeFromVariantType(data->propType, m_engine);
- _expr.code = _block->SYMBOL(baseName, irType, name,
- meta, data, line, column);
- }
- }
- break;
-
- case IR::Name::Object:
- case IR::Name::Slot:
- break;
- }
- }
- }
-
- return false;
-}
-
-bool QV4IRBuilder::preVisit(AST::Node *)
-{
- return ! _discard;
-}
-
-bool QV4IRBuilder::visit(AST::NewMemberExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NewExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CallExpression *ast)
-{
- QList<QStringRef> names;
- QList<AST::ExpressionNode *> nameNodes;
-
- names.reserve(4);
- nameNodes.reserve(4);
-
- if (buildName(names, ast->base, &nameNodes)) {
- //ExprResult base = expression(ast->base);
- QString id;
- for (int i = 0; i < names.size(); ++i) {
- if (i)
- id += QLatin1Char('.');
- id += names.at(i);
- }
- const AST::SourceLocation loc = nameNodes.last()->firstSourceLocation();
- IR::Expr *base = _block->NAME(id, loc.startLine, loc.startColumn);
-
- IR::ExprList *args = 0, **argsInserter = &args;
- for (AST::ArgumentList *it = ast->arguments; it; it = it->next) {
- IR::Expr *arg = expression(it->expression);
- *argsInserter = _function->pool->New<IR::ExprList>();
- (*argsInserter)->init(arg);
- argsInserter = &(*argsInserter)->next;
- }
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
- IR::Expr *call = _block->CALL(base, args);
- _block->MOVE(r, call);
- r->type = call->type;
- _expr.code = r;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PostIncrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PostDecrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DeleteExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VoidExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TypeOfExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PreIncrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::PreDecrementExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UnaryPlusExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (expr.code->asConst() != 0) {
- _expr = expr;
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpUPlus, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::UnaryMinusExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(expr->type, -c->value);
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpUMinus, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TildeExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(expr->type, ~int(c->value));
- return false;
- }
- IR::Expr *code = _block->UNOP(IR::OpCompl, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::NotExpression *ast)
-{
- ExprResult expr = expression(ast->expression);
-
- if (expr.isNot(IR::InvalidType)) {
- if (IR::Const *c = expr.code->asConst()) {
- _expr = expr;
- _expr.code = _block->CONST(IR::BoolType, !c->value);
- return false;
- }
-
- IR::Expr *code = _block->UNOP(IR::OpNot, expr);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr, code);
-
- } else if (expr.hint == ExprResult::cx) {
- expr.format = ExprResult::cx;
- _block->CJUMP(_block->UNOP(IR::OpNot, expr), _expr.iftrue, _expr.iffalse);
- return false;
- }
-
- return false;
-}
-
-void QV4IRBuilder::binop(AST::BinaryExpression *ast, ExprResult left, ExprResult right)
-{
- if (IR::Type t = maxType(left.type(), right.type())) {
- if (!left->asConst() && !right->asConst()) {
- // the implicit conversions are needed only
- // when compiling non-constant expressions.
- implicitCvt(left, t);
- implicitCvt(right, t);
- }
- } else if ((left.type() != IR::ObjectType && left.type() != IR::NullType) ||
- (right.type() != IR::ObjectType && right.type() != IR::NullType))
- return;
-
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->CJUMP(_block->BINOP(IR::binaryOperator(ast->op), left, right), _expr.iftrue, _expr.iffalse);
- } else {
- IR::Expr *e = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- if (e->asConst() != 0 || e->asString() != 0)
- _expr.code = e;
- else {
- IR::Temp *t = _block->TEMP(e->type);
- _block->MOVE(t, e);
- _expr.code = t;
- }
- }
-}
-
-bool QV4IRBuilder::visit(AST::BinaryExpression *ast)
-{
- switch (ast->op) {
- case QSOperator::And: {
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
-
- Q_ASSERT(_expr.iffalse != 0);
- Q_ASSERT(_expr.iftrue != 0);
-
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- condition(ast->left, iftrue, _expr.iffalse);
-
- _block = iftrue;
- condition(ast->right, _expr.iftrue, _expr.iffalse);
- } else {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- ExprResult left = expression(ast->left);
- IR::Temp *cond = _block->TEMP(IR::BoolType);
- _block->MOVE(cond, left);
- _block->CJUMP(cond, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- _block = iffalse;
- _block->MOVE(r, cond);
- _block->JUMP(endif);
-
- _block = iftrue;
- ExprResult right = expression(ast->right);
- _block->MOVE(r, right);
- _block->JUMP(endif);
-
- if (left.type() != right.type())
- discard();
-
- _block = endif;
-
- r->type = right.type();
- _expr.code = r;
- }
- } break;
-
- case QSOperator::Or: {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- ExprResult left = expression(ast->left);
- IR::Temp *r = _block->TEMP(left.type());
- _block->MOVE(r, left);
-
- IR::Expr *cond = r;
- if (r->type != IR::BoolType) {
- cond = _block->TEMP(IR::BoolType);
- _block->MOVE(cond, r);
- }
-
- _block->CJUMP(_block->UNOP(IR::OpNot, cond), iftrue, endif);
-
- _block = iftrue;
- ExprResult right = expression(ast->right);
- _block->MOVE(r, right);
- _block->JUMP(endif);
-
- if (left.type() != right.type())
- discard();
-
- _expr.code = r;
-
- _block = endif;
- } break;
-
- case QSOperator::Lt:
- case QSOperator::Gt:
- case QSOperator::Le:
- case QSOperator::Ge: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if (left.type() == IR::StringType && right.type() == IR::StringType) {
- binop(ast, left, right);
- } else if (left.isValid() && right.isValid()) {
- implicitCvt(left, IR::NumberType);
- implicitCvt(right, IR::NumberType);
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::NotEqual:
- case QSOperator::Equal: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if ((left.type() == IR::NullType || left.type() == IR::UndefinedType) &&
- (right.type() == IR::NullType || right.type() == IR::UndefinedType)) {
- const bool isEq = ast->op == QSOperator::Equal;
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(isEq ? _expr.iftrue : _expr.iffalse);
- } else {
- _expr.code = _block->CONST(IR::BoolType, isEq ? 1 : 0);
- }
- } else if ((left.type() == IR::StringType && right.type() >= IR::FirstNumberType) ||
- (left.type() >= IR::FirstNumberType && right.type() == IR::StringType)) {
- implicitCvt(left, IR::NumberType);
- implicitCvt(right, IR::NumberType);
- binop(ast, left, right);
- } else if (left.isValid() && right.isValid()) {
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::StrictEqual:
- case QSOperator::StrictNotEqual: {
- ExprResult left = expression(ast->left);
- ExprResult right = expression(ast->right);
- if (left.type() == right.type()) {
- binop(ast, left, right);
- } else if (left.type() > IR::BoolType && right.type() > IR::BoolType) {
- // left and right have numeric type (int or real)
- binop(ast, left, right);
- } else if ((left.type() == IR::ObjectType && right.type() == IR::NullType) ||
- (right.type() == IR::ObjectType && left.type() == IR::NullType)) {
- // comparing a qobject with null
- binop(ast, left, right);
- } else if (left.isValid() && right.isValid()) {
- // left and right have different types
- const bool isEq = ast->op == QSOperator::StrictEqual;
- if (_expr.hint == ExprResult::cx) {
- _expr.format = ExprResult::cx;
- _block->JUMP(isEq ? _expr.iffalse : _expr.iftrue);
- } else {
- _expr.code = _block->CONST(IR::BoolType, isEq ? 0 : 1);
- }
- }
- } break;
-
- case QSOperator::BitAnd:
- case QSOperator::BitOr:
- case QSOperator::BitXor:
- case QSOperator::LShift:
- case QSOperator::RShift:
- case QSOperator::URShift: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- implicitCvt(left, IR::IntType);
- implicitCvt(right, IR::IntType);
-
- IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr.code, code);
-
- } break;
-
- case QSOperator::Add: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- if (left.isPrimitive() && right.isPrimitive()) {
- if (left.type() == IR::StringType || right.type() == IR::StringType) {
- implicitCvt(left, IR::StringType);
- implicitCvt(right, IR::StringType);
- }
- binop(ast, left, right);
- }
- } break;
-
- case QSOperator::Div:
- case QSOperator::Mod:
- case QSOperator::Mul:
- case QSOperator::Sub: {
- ExprResult left = expression(ast->left);
- if (left.is(IR::InvalidType))
- return false;
-
- ExprResult right = expression(ast->right);
- if (right.is(IR::InvalidType))
- return false;
-
- IR::Type t = maxType(left.type(), right.type());
- if (t >= IR::FirstNumberType) {
- implicitCvt(left, IR::NumberType);
- implicitCvt(right, IR::NumberType);
-
- IR::Expr *code = _block->BINOP(IR::binaryOperator(ast->op), left, right);
- _expr.code = _block->TEMP(code->type);
- _block->MOVE(_expr.code, code);
- }
- } break;
-
- case QSOperator::In:
- case QSOperator::InstanceOf:
- case QSOperator::Assign:
- case QSOperator::InplaceAnd:
- case QSOperator::InplaceSub:
- case QSOperator::InplaceDiv:
- case QSOperator::InplaceAdd:
- case QSOperator::InplaceLeftShift:
- case QSOperator::InplaceMod:
- case QSOperator::InplaceMul:
- case QSOperator::InplaceOr:
- case QSOperator::InplaceRightShift:
- case QSOperator::InplaceURightShift:
- case QSOperator::InplaceXor:
- // yup, we don't do those.
- break;
- } // switch
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ConditionalExpression *ast)
-{
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- condition(ast->expression, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- qSwap(_block, iftrue);
- ExprResult ok = expression(ast->ok);
- _block->MOVE(r, ok);
- _block->JUMP(endif);
- qSwap(_block, iftrue);
-
- qSwap(_block, iffalse);
- ExprResult ko = expression(ast->ko);
- _block->MOVE(r, ko);
- _block->JUMP(endif);
- qSwap(_block, iffalse);
-
- r->type = maxType(ok.type(), ko.type());
- _expr.code = r;
-
- _block = endif;
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Expression *ast)
-{
- _block->EXP(expression(ast->left));
- _expr = expression(ast->right);
-
- return false;
-}
-
-
-// statements
-bool QV4IRBuilder::visit(AST::Block *ast)
-{
- if (ast->statements && ! ast->statements->next) {
- // we have one and only one statement
- accept(ast->statements->statement);
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::StatementList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableDeclarationList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::VariableDeclaration *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::EmptyStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ExpressionStatement *ast)
-{
- if (ast->expression) {
- // return the value of this expression
- return true;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::IfStatement *ast)
-{
- if (! ast->ko) {
- // This is an if statement without an else branch.
- discard();
- } else {
- IR::BasicBlock *iftrue = _function->newBasicBlock();
- IR::BasicBlock *iffalse = _function->newBasicBlock();
- IR::BasicBlock *endif = _function->newBasicBlock();
-
- condition(ast->expression, iftrue, iffalse);
-
- IR::Temp *r = _block->TEMP(IR::InvalidType);
-
- qSwap(_block, iftrue);
- ExprResult ok = statement(ast->ok);
- _block->MOVE(r, ok);
- _block->JUMP(endif);
- qSwap(_block, iftrue);
-
- qSwap(_block, iffalse);
- ExprResult ko = statement(ast->ko);
- _block->MOVE(r, ko);
- _block->JUMP(endif);
- qSwap(_block, iffalse);
-
- r->type = maxType(ok.type(), ko.type());
- _expr.code = r;
-
- _block = endif;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DoWhileStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::WhileStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ForStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LocalForStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ForEachStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LocalForEachStatement *)
-{
- discard();
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ContinueStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::BreakStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ReturnStatement *ast)
-{
- if (ast->expression) {
- // return the value of the expression
- return true;
- }
-
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::WithStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::SwitchStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseBlock *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseClauses *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::CaseClause *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DefaultClause *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::LabelledStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::ThrowStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::TryStatement *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Catch *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::Finally *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionDeclaration *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionExpression *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FormalParameterList *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::FunctionBody *)
-{
- return false;
-}
-
-bool QV4IRBuilder::visit(AST::DebuggerStatement *)
-{
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/v4/qv4irbuilder_p.h b/src/qml/qml/v4/qv4irbuilder_p.h
deleted file mode 100644
index 86baae463d..0000000000
--- a/src/qml/qml/v4/qv4irbuilder_p.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4IRBUILDER_P_H
-#define QV4IRBUILDER_P_H
-
-#include <QtCore/qglobal.h>
-
-#include "qv4ir_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QV4IRBuilder : public QQmlJS::AST::Visitor
-{
-public:
- QV4IRBuilder(const QV4Compiler::Expression *, QQmlEnginePrivate *);
-
- bool operator()(QQmlJS::IR::Function *, QQmlJS::AST::Node *, bool *invalidatable);
-
-protected:
- struct ExprResult {
- enum Format {
- ex, // expression
- cx // condition
- };
-
- QQmlJS::IR::Expr *code;
- QQmlJS::IR::BasicBlock *iftrue;
- QQmlJS::IR::BasicBlock *iffalse;
- Format hint; // requested format
- Format format; // instruction format
-
- ExprResult(QQmlJS::IR::Expr *expr = 0)
- : code(expr), iftrue(0), iffalse(0), hint(ex), format(ex) {}
-
- ExprResult(QQmlJS::IR::BasicBlock *iftrue, QQmlJS::IR::BasicBlock *iffalse)
- : code(0), iftrue(iftrue), iffalse(iffalse), hint(cx), format(ex) {}
-
- inline QQmlJS::IR::Type type() const { return code ? code->type : QQmlJS::IR::InvalidType; }
-
- inline QQmlJS::IR::Expr *get() const { return code; }
- inline operator QQmlJS::IR::Expr *() const { return get(); }
- inline QQmlJS::IR::Expr *operator->() const { return get(); }
- inline bool isValid() const { return code ? code->type != QQmlJS::IR::InvalidType : false; }
- inline bool is(QQmlJS::IR::Type t) const { return type() == t; }
- inline bool isNot(QQmlJS::IR::Type t) const { return type() != t; }
-
- bool isPrimitive() const {
- switch (type()) {
- case QQmlJS::IR::UndefinedType: // ### TODO
- case QQmlJS::IR::NullType: // ### TODO
- case QQmlJS::IR::UrlType: // ### TODO
- return false;
-
- case QQmlJS::IR::StringType:
- case QQmlJS::IR::BoolType:
- case QQmlJS::IR::IntType:
- case QQmlJS::IR::FloatType:
- case QQmlJS::IR::NumberType:
- return true;
-
- default:
- return false;
- } // switch
- }
- };
-
- inline void accept(QQmlJS::AST::Node *ast) { QQmlJS::AST::Node::accept(ast, this); }
-
- ExprResult expression(QQmlJS::AST::ExpressionNode *ast);
- ExprResult statement(QQmlJS::AST::Statement *ast);
- void sourceElement(QQmlJS::AST::SourceElement *ast);
- void condition(QQmlJS::AST::ExpressionNode *ast, QQmlJS::IR::BasicBlock *iftrue, QQmlJS::IR::BasicBlock *iffalse);
- void binop(QQmlJS::AST::BinaryExpression *ast, ExprResult left, ExprResult right);
-
- void implicitCvt(ExprResult &expr, QQmlJS::IR::Type type);
-
- virtual bool preVisit(QQmlJS::AST::Node *ast);
-
- // QML
- virtual bool visit(QQmlJS::AST::UiProgram *ast);
- virtual bool visit(QQmlJS::AST::UiImportList *ast);
- virtual bool visit(QQmlJS::AST::UiImport *ast);
- virtual bool visit(QQmlJS::AST::UiPublicMember *ast);
- virtual bool visit(QQmlJS::AST::UiSourceElement *ast);
- virtual bool visit(QQmlJS::AST::UiObjectDefinition *ast);
- virtual bool visit(QQmlJS::AST::UiObjectInitializer *ast);
- virtual bool visit(QQmlJS::AST::UiObjectBinding *ast);
- virtual bool visit(QQmlJS::AST::UiScriptBinding *ast);
- virtual bool visit(QQmlJS::AST::UiArrayBinding *ast);
- virtual bool visit(QQmlJS::AST::UiObjectMemberList *ast);
- virtual bool visit(QQmlJS::AST::UiArrayMemberList *ast);
- virtual bool visit(QQmlJS::AST::UiQualifiedId *ast);
-
- // JS
- virtual bool visit(QQmlJS::AST::Program *ast);
- virtual bool visit(QQmlJS::AST::SourceElements *ast);
- virtual bool visit(QQmlJS::AST::FunctionSourceElement *ast);
- virtual bool visit(QQmlJS::AST::StatementSourceElement *ast);
-
- // object literals
- virtual bool visit(QQmlJS::AST::PropertyAssignmentList *ast);
- virtual bool visit(QQmlJS::AST::PropertyNameAndValue *ast);
- virtual bool visit(QQmlJS::AST::PropertyGetterSetter *ast);
- virtual bool visit(QQmlJS::AST::IdentifierPropertyName *ast);
- virtual bool visit(QQmlJS::AST::StringLiteralPropertyName *ast);
- virtual bool visit(QQmlJS::AST::NumericLiteralPropertyName *ast);
-
- // array literals
- virtual bool visit(QQmlJS::AST::ElementList *ast);
- virtual bool visit(QQmlJS::AST::Elision *ast);
-
- // function calls
- virtual bool visit(QQmlJS::AST::ArgumentList *ast);
-
- // expressions
- virtual bool visit(QQmlJS::AST::ObjectLiteral *ast);
- virtual bool visit(QQmlJS::AST::ArrayLiteral *ast);
- virtual bool visit(QQmlJS::AST::ThisExpression *ast);
- virtual bool visit(QQmlJS::AST::IdentifierExpression *ast);
- virtual bool visit(QQmlJS::AST::NullExpression *ast);
- virtual bool visit(QQmlJS::AST::TrueLiteral *ast);
- virtual bool visit(QQmlJS::AST::FalseLiteral *ast);
- virtual bool visit(QQmlJS::AST::StringLiteral *ast);
- virtual bool visit(QQmlJS::AST::NumericLiteral *ast);
- virtual bool visit(QQmlJS::AST::RegExpLiteral *ast);
- virtual bool visit(QQmlJS::AST::NestedExpression *ast);
- virtual bool visit(QQmlJS::AST::ArrayMemberExpression *ast);
- virtual bool visit(QQmlJS::AST::FieldMemberExpression *ast);
- virtual bool visit(QQmlJS::AST::NewMemberExpression *ast);
- virtual bool visit(QQmlJS::AST::NewExpression *ast);
- virtual bool visit(QQmlJS::AST::CallExpression *ast);
- virtual bool visit(QQmlJS::AST::PostIncrementExpression *ast);
- virtual bool visit(QQmlJS::AST::PostDecrementExpression *ast);
- virtual bool visit(QQmlJS::AST::DeleteExpression *ast);
- virtual bool visit(QQmlJS::AST::VoidExpression *ast);
- virtual bool visit(QQmlJS::AST::TypeOfExpression *ast);
- virtual bool visit(QQmlJS::AST::PreIncrementExpression *ast);
- virtual bool visit(QQmlJS::AST::PreDecrementExpression *ast);
- virtual bool visit(QQmlJS::AST::UnaryPlusExpression *ast);
- virtual bool visit(QQmlJS::AST::UnaryMinusExpression *ast);
- virtual bool visit(QQmlJS::AST::TildeExpression *ast);
- virtual bool visit(QQmlJS::AST::NotExpression *ast);
- virtual bool visit(QQmlJS::AST::BinaryExpression *ast);
- virtual bool visit(QQmlJS::AST::ConditionalExpression *ast);
- virtual bool visit(QQmlJS::AST::Expression *ast);
-
- // statements
- virtual bool visit(QQmlJS::AST::Block *ast);
- virtual bool visit(QQmlJS::AST::StatementList *ast);
- virtual bool visit(QQmlJS::AST::VariableStatement *ast);
- virtual bool visit(QQmlJS::AST::VariableDeclarationList *ast);
- virtual bool visit(QQmlJS::AST::VariableDeclaration *ast);
- virtual bool visit(QQmlJS::AST::EmptyStatement *ast);
- virtual bool visit(QQmlJS::AST::ExpressionStatement *ast);
- virtual bool visit(QQmlJS::AST::IfStatement *ast);
- virtual bool visit(QQmlJS::AST::DoWhileStatement *ast);
- virtual bool visit(QQmlJS::AST::WhileStatement *ast);
- virtual bool visit(QQmlJS::AST::ForStatement *ast);
- virtual bool visit(QQmlJS::AST::LocalForStatement *ast);
- virtual bool visit(QQmlJS::AST::ForEachStatement *ast);
- virtual bool visit(QQmlJS::AST::LocalForEachStatement *ast);
- virtual bool visit(QQmlJS::AST::ContinueStatement *ast);
- virtual bool visit(QQmlJS::AST::BreakStatement *ast);
- virtual bool visit(QQmlJS::AST::ReturnStatement *ast);
- virtual bool visit(QQmlJS::AST::WithStatement *ast);
- virtual bool visit(QQmlJS::AST::SwitchStatement *ast);
- virtual bool visit(QQmlJS::AST::CaseBlock *ast);
- virtual bool visit(QQmlJS::AST::CaseClauses *ast);
- virtual bool visit(QQmlJS::AST::CaseClause *ast);
- virtual bool visit(QQmlJS::AST::DefaultClause *ast);
- virtual bool visit(QQmlJS::AST::LabelledStatement *ast);
- virtual bool visit(QQmlJS::AST::ThrowStatement *ast);
- virtual bool visit(QQmlJS::AST::TryStatement *ast);
- virtual bool visit(QQmlJS::AST::Catch *ast);
- virtual bool visit(QQmlJS::AST::Finally *ast);
- virtual bool visit(QQmlJS::AST::FunctionDeclaration *ast);
- virtual bool visit(QQmlJS::AST::FunctionExpression *ast);
- virtual bool visit(QQmlJS::AST::FormalParameterList *ast);
- virtual bool visit(QQmlJS::AST::FunctionBody *ast);
- virtual bool visit(QQmlJS::AST::DebuggerStatement *ast);
-
-private:
- bool buildName(QList<QStringRef> &name, QQmlJS::AST::Node *node,
- QList<QQmlJS::AST::ExpressionNode *> *nodes);
- void discard();
-
- const QV4Compiler::Expression *m_expression;
- QQmlEnginePrivate *m_engine;
-
- QQmlJS::IR::Function *_function;
- QQmlJS::IR::BasicBlock *_block;
- bool _discard;
- bool _invalidatable;
-
- ExprResult _expr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV4IRBUILDER_P_H
diff --git a/src/qml/qml/v4vm/qv4isel_llvm.cpp b/src/qml/qml/v4/qv4isel_llvm.cpp
index 7e4b80956f..7e4b80956f 100644
--- a/src/qml/qml/v4vm/qv4isel_llvm.cpp
+++ b/src/qml/qml/v4/qv4isel_llvm.cpp
diff --git a/src/qml/qml/v4vm/qv4isel_llvm_p.h b/src/qml/qml/v4/qv4isel_llvm_p.h
index bdda28c510..bdda28c510 100644
--- a/src/qml/qml/v4vm/qv4isel_llvm_p.h
+++ b/src/qml/qml/v4/qv4isel_llvm_p.h
diff --git a/src/qml/qml/v4vm/qv4isel_masm.cpp b/src/qml/qml/v4/qv4isel_masm.cpp
index b2016b2672..b2016b2672 100644
--- a/src/qml/qml/v4vm/qv4isel_masm.cpp
+++ b/src/qml/qml/v4/qv4isel_masm.cpp
diff --git a/src/qml/qml/v4vm/qv4isel_masm_p.h b/src/qml/qml/v4/qv4isel_masm_p.h
index 396801b229..396801b229 100644
--- a/src/qml/qml/v4vm/qv4isel_masm_p.h
+++ b/src/qml/qml/v4/qv4isel_masm_p.h
diff --git a/src/qml/qml/v4vm/qv4isel_p.cpp b/src/qml/qml/v4/qv4isel_p.cpp
index 478fea4a7c..478fea4a7c 100644
--- a/src/qml/qml/v4vm/qv4isel_p.cpp
+++ b/src/qml/qml/v4/qv4isel_p.cpp
diff --git a/src/qml/qml/v4vm/qv4isel_p.h b/src/qml/qml/v4/qv4isel_p.h
index b3efaccd3e..b3efaccd3e 100644
--- a/src/qml/qml/v4vm/qv4isel_p.h
+++ b/src/qml/qml/v4/qv4isel_p.h
diff --git a/src/qml/qml/v4vm/qv4isel_util_p.h b/src/qml/qml/v4/qv4isel_util_p.h
index 54e646402f..54e646402f 100644
--- a/src/qml/qml/v4vm/qv4isel_util_p.h
+++ b/src/qml/qml/v4/qv4isel_util_p.h
diff --git a/src/qml/qml/v4vm/qv4jsir.cpp b/src/qml/qml/v4/qv4jsir.cpp
index e94aa1be2f..e94aa1be2f 100644
--- a/src/qml/qml/v4vm/qv4jsir.cpp
+++ b/src/qml/qml/v4/qv4jsir.cpp
diff --git a/src/qml/qml/v4vm/qv4jsir_p.h b/src/qml/qml/v4/qv4jsir_p.h
index cc0f2e9da6..cc0f2e9da6 100644
--- a/src/qml/qml/v4vm/qv4jsir_p.h
+++ b/src/qml/qml/v4/qv4jsir_p.h
diff --git a/src/qml/qml/v4vm/qv4jsonobject.cpp b/src/qml/qml/v4/qv4jsonobject.cpp
index 2e9122980c..2e9122980c 100644
--- a/src/qml/qml/v4vm/qv4jsonobject.cpp
+++ b/src/qml/qml/v4/qv4jsonobject.cpp
diff --git a/src/qml/qml/v4vm/qv4jsonobject_p.h b/src/qml/qml/v4/qv4jsonobject_p.h
index 2a923fb6c6..2a923fb6c6 100644
--- a/src/qml/qml/v4vm/qv4jsonobject_p.h
+++ b/src/qml/qml/v4/qv4jsonobject_p.h
diff --git a/src/qml/qml/v4vm/qv4lookup.cpp b/src/qml/qml/v4/qv4lookup.cpp
index d5e8cc8e11..d5e8cc8e11 100644
--- a/src/qml/qml/v4vm/qv4lookup.cpp
+++ b/src/qml/qml/v4/qv4lookup.cpp
diff --git a/src/qml/qml/v4vm/qv4lookup_p.h b/src/qml/qml/v4/qv4lookup_p.h
index 80fbff2372..80fbff2372 100644
--- a/src/qml/qml/v4vm/qv4lookup_p.h
+++ b/src/qml/qml/v4/qv4lookup_p.h
diff --git a/src/qml/qml/v4vm/qv4managed.cpp b/src/qml/qml/v4/qv4managed.cpp
index 8347674664..8347674664 100644
--- a/src/qml/qml/v4vm/qv4managed.cpp
+++ b/src/qml/qml/v4/qv4managed.cpp
diff --git a/src/qml/qml/v4vm/qv4managed_p.h b/src/qml/qml/v4/qv4managed_p.h
index 678c034d26..678c034d26 100644
--- a/src/qml/qml/v4vm/qv4managed_p.h
+++ b/src/qml/qml/v4/qv4managed_p.h
diff --git a/src/qml/qml/v4vm/qv4math_p.h b/src/qml/qml/v4/qv4math_p.h
index 2460c048ed..2460c048ed 100644
--- a/src/qml/qml/v4vm/qv4math_p.h
+++ b/src/qml/qml/v4/qv4math_p.h
diff --git a/src/qml/qml/v4vm/qv4mathobject.cpp b/src/qml/qml/v4/qv4mathobject.cpp
index ac7437d709..ac7437d709 100644
--- a/src/qml/qml/v4vm/qv4mathobject.cpp
+++ b/src/qml/qml/v4/qv4mathobject.cpp
diff --git a/src/qml/qml/v4vm/qv4mathobject_p.h b/src/qml/qml/v4/qv4mathobject_p.h
index 1a1e43b4cc..1a1e43b4cc 100644
--- a/src/qml/qml/v4vm/qv4mathobject_p.h
+++ b/src/qml/qml/v4/qv4mathobject_p.h
diff --git a/src/qml/qml/v4vm/qv4mm.cpp b/src/qml/qml/v4/qv4mm.cpp
index 572a90f12e..572a90f12e 100644
--- a/src/qml/qml/v4vm/qv4mm.cpp
+++ b/src/qml/qml/v4/qv4mm.cpp
diff --git a/src/qml/qml/v4vm/qv4mm_p.h b/src/qml/qml/v4/qv4mm_p.h
index fe858d8f7f..fe858d8f7f 100644
--- a/src/qml/qml/v4vm/qv4mm_p.h
+++ b/src/qml/qml/v4/qv4mm_p.h
diff --git a/src/qml/qml/v4vm/qv4numberobject.cpp b/src/qml/qml/v4/qv4numberobject.cpp
index e9e5c7e4fa..e9e5c7e4fa 100644
--- a/src/qml/qml/v4vm/qv4numberobject.cpp
+++ b/src/qml/qml/v4/qv4numberobject.cpp
diff --git a/src/qml/qml/v4vm/qv4numberobject_p.h b/src/qml/qml/v4/qv4numberobject_p.h
index f7f5ed7110..f7f5ed7110 100644
--- a/src/qml/qml/v4vm/qv4numberobject_p.h
+++ b/src/qml/qml/v4/qv4numberobject_p.h
diff --git a/src/qml/qml/v4vm/qv4object.cpp b/src/qml/qml/v4/qv4object.cpp
index 42ec8f2aac..42ec8f2aac 100644
--- a/src/qml/qml/v4vm/qv4object.cpp
+++ b/src/qml/qml/v4/qv4object.cpp
diff --git a/src/qml/qml/v4vm/qv4object_p.h b/src/qml/qml/v4/qv4object_p.h
index 675c149936..675c149936 100644
--- a/src/qml/qml/v4vm/qv4object_p.h
+++ b/src/qml/qml/v4/qv4object_p.h
diff --git a/src/qml/qml/v4vm/qv4objectiterator.cpp b/src/qml/qml/v4/qv4objectiterator.cpp
index 83d95a37eb..83d95a37eb 100644
--- a/src/qml/qml/v4vm/qv4objectiterator.cpp
+++ b/src/qml/qml/v4/qv4objectiterator.cpp
diff --git a/src/qml/qml/v4vm/qv4objectiterator_p.h b/src/qml/qml/v4/qv4objectiterator_p.h
index 8b8a440c1c..8b8a440c1c 100644
--- a/src/qml/qml/v4vm/qv4objectiterator_p.h
+++ b/src/qml/qml/v4/qv4objectiterator_p.h
diff --git a/src/qml/qml/v4vm/qv4objectproto.cpp b/src/qml/qml/v4/qv4objectproto.cpp
index 01e14cf72b..01e14cf72b 100644
--- a/src/qml/qml/v4vm/qv4objectproto.cpp
+++ b/src/qml/qml/v4/qv4objectproto.cpp
diff --git a/src/qml/qml/v4vm/qv4objectproto_p.h b/src/qml/qml/v4/qv4objectproto_p.h
index 87f6b0095c..87f6b0095c 100644
--- a/src/qml/qml/v4vm/qv4objectproto_p.h
+++ b/src/qml/qml/v4/qv4objectproto_p.h
diff --git a/src/qml/qml/v4/qv4program_p.h b/src/qml/qml/v4/qv4program_p.h
deleted file mode 100644
index fb23e863af..0000000000
--- a/src/qml/qml/v4/qv4program_p.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QV4PROGRAM_P_H
-#define QV4PROGRAM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qv4instruction_p.h"
-
-#ifdef Q_CC_MSVC
-// nonstandard extension used : zero-sized array in struct/union.
-# pragma warning( disable : 4200 )
-#endif
-
-QT_BEGIN_NAMESPACE
-
-struct QV4Program {
- quint32 bindings;
- quint32 dataLength;
- quint32 signalTableOffset;
- quint32 exceptionDataOffset;
- quint16 subscriptions;
- quint16 instructionCount;
-
- struct BindingReference {
- quint32 binding;
- quint32 blockMask;
- };
-
- struct BindingReferenceList {
- quint32 count;
- BindingReference bindings[];
- };
-
- inline const char *data() const;
- inline const char *instructions() const;
- inline BindingReferenceList *signalTable(int signalIndex) const;
-};
-
-enum QQmlRegisterType {
- UndefinedType,
- NullType,
- QObjectStarType,
- NumberType,
- FloatType,
- IntType,
- BoolType,
- SpecialNumericType,
-
- PODValueType,
-
- FirstCleanupType,
- QStringType = FirstCleanupType,
- QUrlType,
- QVariantType,
- QColorType,
- V8HandleType,
- QJSValueType
-};
-
-const char *QV4Program::data() const
-{
- return ((const char *)this) + sizeof(QV4Program);
-}
-
-const char *QV4Program::instructions() const
-{
- return (const char *)(data() + dataLength);
-}
-
-QV4Program::BindingReferenceList *QV4Program::signalTable(int signalIndex) const
-{
- quint32 *signalTable = (quint32 *)(data() + signalTableOffset);
- return (BindingReferenceList *)(signalTable + signalTable[signalIndex]);
-}
-
-QT_END_NAMESPACE
-
-#endif // QV4PROGRAM_P_H
-
diff --git a/src/qml/qml/v4vm/qv4property_p.h b/src/qml/qml/v4/qv4property_p.h
index 2a3c5bf976..2a3c5bf976 100644
--- a/src/qml/qml/v4vm/qv4property_p.h
+++ b/src/qml/qml/v4/qv4property_p.h
diff --git a/src/qml/qml/v4vm/qv4regexp.cpp b/src/qml/qml/v4/qv4regexp.cpp
index 0dfbad3c3b..0dfbad3c3b 100644
--- a/src/qml/qml/v4vm/qv4regexp.cpp
+++ b/src/qml/qml/v4/qv4regexp.cpp
diff --git a/src/qml/qml/v4vm/qv4regexp_p.h b/src/qml/qml/v4/qv4regexp_p.h
index 0ae46e7278..0ae46e7278 100644
--- a/src/qml/qml/v4vm/qv4regexp_p.h
+++ b/src/qml/qml/v4/qv4regexp_p.h
diff --git a/src/qml/qml/v4vm/qv4regexpobject.cpp b/src/qml/qml/v4/qv4regexpobject.cpp
index 622c46e328..622c46e328 100644
--- a/src/qml/qml/v4vm/qv4regexpobject.cpp
+++ b/src/qml/qml/v4/qv4regexpobject.cpp
diff --git a/src/qml/qml/v4vm/qv4regexpobject_p.h b/src/qml/qml/v4/qv4regexpobject_p.h
index 27ef2c87eb..27ef2c87eb 100644
--- a/src/qml/qml/v4vm/qv4regexpobject_p.h
+++ b/src/qml/qml/v4/qv4regexpobject_p.h
diff --git a/src/qml/qml/v4vm/qv4runtime.cpp b/src/qml/qml/v4/qv4runtime.cpp
index b510d4c5ee..b510d4c5ee 100644
--- a/src/qml/qml/v4vm/qv4runtime.cpp
+++ b/src/qml/qml/v4/qv4runtime.cpp
diff --git a/src/qml/qml/v4vm/qv4runtime_p.h b/src/qml/qml/v4/qv4runtime_p.h
index 61a6bb099b..61a6bb099b 100644
--- a/src/qml/qml/v4vm/qv4runtime_p.h
+++ b/src/qml/qml/v4/qv4runtime_p.h
diff --git a/src/qml/qml/v4vm/qv4sparsearray.cpp b/src/qml/qml/v4/qv4sparsearray.cpp
index 262b79db0c..262b79db0c 100644
--- a/src/qml/qml/v4vm/qv4sparsearray.cpp
+++ b/src/qml/qml/v4/qv4sparsearray.cpp
diff --git a/src/qml/qml/v4vm/qv4sparsearray_p.h b/src/qml/qml/v4/qv4sparsearray_p.h
index d9b4c4defb..d9b4c4defb 100644
--- a/src/qml/qml/v4vm/qv4sparsearray_p.h
+++ b/src/qml/qml/v4/qv4sparsearray_p.h
diff --git a/src/qml/qml/v4vm/qv4string.cpp b/src/qml/qml/v4/qv4string.cpp
index 12a66a50a0..12a66a50a0 100644
--- a/src/qml/qml/v4vm/qv4string.cpp
+++ b/src/qml/qml/v4/qv4string.cpp
diff --git a/src/qml/qml/v4vm/qv4string_p.h b/src/qml/qml/v4/qv4string_p.h
index a681330a0a..a681330a0a 100644
--- a/src/qml/qml/v4vm/qv4string_p.h
+++ b/src/qml/qml/v4/qv4string_p.h
diff --git a/src/qml/qml/v4vm/qv4stringobject.cpp b/src/qml/qml/v4/qv4stringobject.cpp
index 53a0fcf66b..53a0fcf66b 100644
--- a/src/qml/qml/v4vm/qv4stringobject.cpp
+++ b/src/qml/qml/v4/qv4stringobject.cpp
diff --git a/src/qml/qml/v4vm/qv4stringobject_p.h b/src/qml/qml/v4/qv4stringobject_p.h
index d53de77e8f..d53de77e8f 100644
--- a/src/qml/qml/v4vm/qv4stringobject_p.h
+++ b/src/qml/qml/v4/qv4stringobject_p.h
diff --git a/src/qml/qml/v4vm/qv4syntaxchecker.cpp b/src/qml/qml/v4/qv4syntaxchecker.cpp
index fcda486af2..fcda486af2 100644
--- a/src/qml/qml/v4vm/qv4syntaxchecker.cpp
+++ b/src/qml/qml/v4/qv4syntaxchecker.cpp
diff --git a/src/qml/qml/v4vm/qv4syntaxchecker_p.h b/src/qml/qml/v4/qv4syntaxchecker_p.h
index 38e123762e..38e123762e 100644
--- a/src/qml/qml/v4vm/qv4syntaxchecker_p.h
+++ b/src/qml/qml/v4/qv4syntaxchecker_p.h
diff --git a/src/qml/qml/v4vm/qv4unwindhelper.cpp b/src/qml/qml/v4/qv4unwindhelper.cpp
index 0476eb324c..0476eb324c 100644
--- a/src/qml/qml/v4vm/qv4unwindhelper.cpp
+++ b/src/qml/qml/v4/qv4unwindhelper.cpp
diff --git a/src/qml/qml/v4vm/qv4unwindhelper_p-arm.h b/src/qml/qml/v4/qv4unwindhelper_p-arm.h
index 69d02a2ba8..69d02a2ba8 100644
--- a/src/qml/qml/v4vm/qv4unwindhelper_p-arm.h
+++ b/src/qml/qml/v4/qv4unwindhelper_p-arm.h
diff --git a/src/qml/qml/v4vm/qv4unwindhelper_p-dw2.h b/src/qml/qml/v4/qv4unwindhelper_p-dw2.h
index b2b2495e5b..b2b2495e5b 100644
--- a/src/qml/qml/v4vm/qv4unwindhelper_p-dw2.h
+++ b/src/qml/qml/v4/qv4unwindhelper_p-dw2.h
diff --git a/src/qml/qml/v4vm/qv4unwindhelper_p.h b/src/qml/qml/v4/qv4unwindhelper_p.h
index 04c8c0ac94..04c8c0ac94 100644
--- a/src/qml/qml/v4vm/qv4unwindhelper_p.h
+++ b/src/qml/qml/v4/qv4unwindhelper_p.h
diff --git a/src/qml/qml/v4vm/qv4util_p.h b/src/qml/qml/v4/qv4util_p.h
index b735c27bac..b735c27bac 100644
--- a/src/qml/qml/v4vm/qv4util_p.h
+++ b/src/qml/qml/v4/qv4util_p.h
diff --git a/src/qml/qml/v4vm/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp
index b476f3903b..b476f3903b 100644
--- a/src/qml/qml/v4vm/qv4v8.cpp
+++ b/src/qml/qml/v4/qv4v8.cpp
diff --git a/src/qml/qml/v4vm/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h
index 5523866362..5523866362 100644
--- a/src/qml/qml/v4vm/qv4v8_p.h
+++ b/src/qml/qml/v4/qv4v8_p.h
diff --git a/src/qml/qml/v4vm/qv4value.cpp b/src/qml/qml/v4/qv4value.cpp
index 73ed5d3849..73ed5d3849 100644
--- a/src/qml/qml/v4vm/qv4value.cpp
+++ b/src/qml/qml/v4/qv4value.cpp
diff --git a/src/qml/qml/v4vm/qv4value_p.h b/src/qml/qml/v4/qv4value_p.h
index 0100b6bc0f..0100b6bc0f 100644
--- a/src/qml/qml/v4vm/qv4value_p.h
+++ b/src/qml/qml/v4/qv4value_p.h
diff --git a/src/qml/qml/v4/v4.pri b/src/qml/qml/v4/v4.pri
index b6784851d8..92f13ab92f 100644
--- a/src/qml/qml/v4/v4.pri
+++ b/src/qml/qml/v4/v4.pri
@@ -1,15 +1,161 @@
+include(llvm_installation.pri)
+include(../../../3rdparty/masm/masm-defs.pri)
+
+CONFIG += exceptions
+
+!llvm: DEFINES += QMLJS_NO_LLVM
+
+CONFIG += warn_off
+
+INCLUDEPATH += $$PWD
+INCLUDEPATH += $$OUT_PWD
+
+SOURCES += \
+ $$PWD/qv4codegen.cpp \
+ $$PWD/qv4jsir.cpp \
+ $$PWD/qv4engine.cpp \
+ $$PWD/qv4context.cpp \
+ $$PWD/qv4runtime.cpp \
+ $$PWD/qv4value.cpp \
+ $$PWD/qv4syntaxchecker.cpp \
+ $$PWD/qv4isel_masm.cpp \
+ $$PWD/llvm_runtime.cpp \
+ $$PWD/qv4isel_p.cpp \
+ $$PWD/qv4debugging.cpp \
+ $$PWD/qv4lookup.cpp \
+ $$PWD/qv4mm.cpp \
+ $$PWD/qv4managed.cpp \
+ $$PWD/qv4internalclass.cpp \
+ $$PWD/qv4sparsearray.cpp \
+ $$PWD/qv4arrayobject.cpp \
+ $$PWD/qv4argumentsobject.cpp \
+ $$PWD/qv4booleanobject.cpp \
+ $$PWD/qv4dateobject.cpp \
+ $$PWD/qv4errorobject.cpp \
+ $$PWD/qv4functionobject.cpp \
+ $$PWD/qv4globalobject.cpp \
+ $$PWD/qv4jsonobject.cpp \
+ $$PWD/qv4mathobject.cpp \
+ $$PWD/qv4numberobject.cpp \
+ $$PWD/qv4object.cpp \
+ $$PWD/qv4objectproto.cpp \
+ $$PWD/qv4regexpobject.cpp \
+ $$PWD/qv4stringobject.cpp \
+ $$PWD/qv4string.cpp \
+ $$PWD/qv4objectiterator.cpp \
+ $$PWD/qv4regexp.cpp \
+ $$PWD/qv4unwindhelper.cpp \
+ $$PWD/qv4v8.cpp \
+ $$PWD/qv4executableallocator.cpp
+
HEADERS += \
- $$PWD/qv4compiler_p.h \
- $$PWD/qv4compiler_p_p.h \
- $$PWD/qv4ir_p.h \
- $$PWD/qv4irbuilder_p.h \
- $$PWD/qv4instruction_p.h \
- $$PWD/qv4bindings_p.h \
- $$PWD/qv4program_p.h \
+ $$PWD/qv4global_p.h \
+ $$PWD/qv4codegen_p.h \
+ $$PWD/qv4jsir_p.h \
+ $$PWD/qv4engine_p.h \
+ $$PWD/qv4context_p.h \
+ $$PWD/qv4runtime_p.h \
+ $$PWD/qv4math_p.h \
+ $$PWD/qv4value_p.h \
+ $$PWD/qv4syntaxchecker_p.h \
+ $$PWD/qv4isel_masm_p.h \
+ $$PWD/qv4isel_p.h \
+ $$PWD/qv4isel_util_p.h \
+ $$PWD/qv4debugging_p.h \
+ $$PWD/qv4lookup_p.h \
+ $$PWD/qv4identifier_p.h \
+ $$PWD/qv4mm_p.h \
+ $$PWD/qv4managed_p.h \
+ $$PWD/qv4internalclass_p.h \
+ $$PWD/qv4sparsearray_p.h \
+ $$PWD/qv4arrayobject_p.h \
+ $$PWD/qv4argumentsobject_p.h \
+ $$PWD/qv4booleanobject_p.h \
+ $$PWD/qv4dateobject_p.h \
+ $$PWD/qv4errorobject_p.h \
+ $$PWD/qv4functionobject_p.h \
+ $$PWD/qv4globalobject_p.h \
+ $$PWD/qv4jsonobject_p.h \
+ $$PWD/qv4mathobject_p.h \
+ $$PWD/qv4numberobject_p.h \
+ $$PWD/qv4object_p.h \
+ $$PWD/qv4objectproto_p.h \
+ $$PWD/qv4regexpobject_p.h \
+ $$PWD/qv4stringobject_p.h \
+ $$PWD/qv4string_p.h \
+ $$PWD/qv4property_p.h \
+ $$PWD/qv4objectiterator_p.h \
+ $$PWD/qv4regexp_p.h \
+ $$PWD/qv4unwindhelper_p.h \
+ $$PWD/qv4unwindhelper_p-dw2.h \
+ $$PWD/qv4unwindhelper_p-arm.h \
+ $$PWD/qv4v8_p.h \
+ $$PWD/qcalculatehash_p.h \
+ $$PWD/qv4util_p.h \
+ $$PWD/qv4executableallocator_p.h
+
+llvm-libs {
SOURCES += \
- $$PWD/qv4compiler.cpp \
- $$PWD/qv4ir.cpp \
- $$PWD/qv4irbuilder.cpp \
- $$PWD/qv4instruction.cpp \
- $$PWD/qv4bindings.cpp \
+ $$PWD/qv4isel_llvm.cpp
+
+HEADERS += \
+ $$PWD/qv4isel_llvm_p.h \
+ $$PWD/qv4_llvm_p.h
+
+LLVM_RUNTIME_BC = $$PWD/llvm_runtime.bc
+DEFINES += LLVM_RUNTIME="\"\\\"$$LLVM_RUNTIME_BC\\\"\""
+DEFINES += QMLJS_WITH_LLVM
+
+INCLUDEPATH += \
+ $$system($$LLVM_CONFIG --includedir)
+
+QMAKE_CXXFLAGS += $$system($$LLVM_CONFIG --cppflags) -fvisibility-inlines-hidden
+QMAKE_CXXFLAGS -= -pedantic
+QMAKE_CXXFLAGS -= -Wcovered-switch-default
+
+LIBS += \
+ $$system($$LLVM_CONFIG --ldflags) \
+ $$system($$LLVM_CONFIG --libs core jit bitreader linker ipo target x86 arm native)
+
+QMAKE_EXTRA_TARGETS += gen_llvm_runtime
+
+GEN_LLVM_RUNTIME_FLAGS = $$system($$LLVM_CONFIG --cppflags)
+GEN_LLVM_RUNTIME_FLAGS -= -pedantic
+
+gen_llvm_runtime.target = llvm_runtime
+gen_llvm_runtime.commands = clang -O2 -emit-llvm -c -I$$PWD -I$$PWD/../3rdparty/masm $$join(QT.core.includes, " -I", "-I") $$GEN_LLVM_RUNTIME_FLAGS -DQMLJS_LLVM_RUNTIME llvm_runtime.cpp -o $$LLVM_RUNTIME_BC
+}
+
+# Use SSE2 floating point math on 32 bit instead of the default
+# 387 to make test results pass on 32 and on 64 bit builds.
+linux-g++*:isEqual(QT_ARCH,i386) {
+ QMAKE_CFLAGS += -march=pentium4 -msse2 -mfpmath=sse
+ QMAKE_CXXFLAGS += -march=pentium4 -msse2 -mfpmath=sse
+}
+
+linux*|mac {
+ LIBS += -ldl
+}
+
+debug-with-libunwind {
+ UW_INC=$$(LIBUNWIND_INCLUDES)
+ isEmpty(UW_INC): error("Please set LIBUNWIND_INCLUDES")
+ INCLUDEPATH += $$UW_INC
+ UW_LIBS=$$(LIBUNWIND_LIBS)
+ isEmpty(UW_LIBS): error("Please set LIBUNWIND_LIBS")
+ LIBS += -L$$UW_LIBS
+ equals(QT_ARCH, arm): LIBS += -lunwind-arm
+ LIBS += -lunwind-dwarf-common -lunwind-dwarf-local -lunwind-elf32 -lunwind
+ DEFINES += WTF_USE_LIBUNWIND_DEBUG=1
+}
+
+valgrind {
+ DEFINES += V4_USE_VALGRIND
+}
+
+ios: DEFINES += ENABLE_ASSEMBLER_WX_EXCLUSIVE=1
+
+include(moth/moth.pri)
+include(../../../3rdparty/masm/masm.pri)
+include(../../../3rdparty/double-conversion/double-conversion.pri)
diff --git a/src/qml/qml/v4vm/v4vm.pri b/src/qml/qml/v4vm/v4vm.pri
deleted file mode 100644
index 92f13ab92f..0000000000
--- a/src/qml/qml/v4vm/v4vm.pri
+++ /dev/null
@@ -1,161 +0,0 @@
-include(llvm_installation.pri)
-include(../../../3rdparty/masm/masm-defs.pri)
-
-CONFIG += exceptions
-
-!llvm: DEFINES += QMLJS_NO_LLVM
-
-CONFIG += warn_off
-
-INCLUDEPATH += $$PWD
-INCLUDEPATH += $$OUT_PWD
-
-SOURCES += \
- $$PWD/qv4codegen.cpp \
- $$PWD/qv4jsir.cpp \
- $$PWD/qv4engine.cpp \
- $$PWD/qv4context.cpp \
- $$PWD/qv4runtime.cpp \
- $$PWD/qv4value.cpp \
- $$PWD/qv4syntaxchecker.cpp \
- $$PWD/qv4isel_masm.cpp \
- $$PWD/llvm_runtime.cpp \
- $$PWD/qv4isel_p.cpp \
- $$PWD/qv4debugging.cpp \
- $$PWD/qv4lookup.cpp \
- $$PWD/qv4mm.cpp \
- $$PWD/qv4managed.cpp \
- $$PWD/qv4internalclass.cpp \
- $$PWD/qv4sparsearray.cpp \
- $$PWD/qv4arrayobject.cpp \
- $$PWD/qv4argumentsobject.cpp \
- $$PWD/qv4booleanobject.cpp \
- $$PWD/qv4dateobject.cpp \
- $$PWD/qv4errorobject.cpp \
- $$PWD/qv4functionobject.cpp \
- $$PWD/qv4globalobject.cpp \
- $$PWD/qv4jsonobject.cpp \
- $$PWD/qv4mathobject.cpp \
- $$PWD/qv4numberobject.cpp \
- $$PWD/qv4object.cpp \
- $$PWD/qv4objectproto.cpp \
- $$PWD/qv4regexpobject.cpp \
- $$PWD/qv4stringobject.cpp \
- $$PWD/qv4string.cpp \
- $$PWD/qv4objectiterator.cpp \
- $$PWD/qv4regexp.cpp \
- $$PWD/qv4unwindhelper.cpp \
- $$PWD/qv4v8.cpp \
- $$PWD/qv4executableallocator.cpp
-
-HEADERS += \
- $$PWD/qv4global_p.h \
- $$PWD/qv4codegen_p.h \
- $$PWD/qv4jsir_p.h \
- $$PWD/qv4engine_p.h \
- $$PWD/qv4context_p.h \
- $$PWD/qv4runtime_p.h \
- $$PWD/qv4math_p.h \
- $$PWD/qv4value_p.h \
- $$PWD/qv4syntaxchecker_p.h \
- $$PWD/qv4isel_masm_p.h \
- $$PWD/qv4isel_p.h \
- $$PWD/qv4isel_util_p.h \
- $$PWD/qv4debugging_p.h \
- $$PWD/qv4lookup_p.h \
- $$PWD/qv4identifier_p.h \
- $$PWD/qv4mm_p.h \
- $$PWD/qv4managed_p.h \
- $$PWD/qv4internalclass_p.h \
- $$PWD/qv4sparsearray_p.h \
- $$PWD/qv4arrayobject_p.h \
- $$PWD/qv4argumentsobject_p.h \
- $$PWD/qv4booleanobject_p.h \
- $$PWD/qv4dateobject_p.h \
- $$PWD/qv4errorobject_p.h \
- $$PWD/qv4functionobject_p.h \
- $$PWD/qv4globalobject_p.h \
- $$PWD/qv4jsonobject_p.h \
- $$PWD/qv4mathobject_p.h \
- $$PWD/qv4numberobject_p.h \
- $$PWD/qv4object_p.h \
- $$PWD/qv4objectproto_p.h \
- $$PWD/qv4regexpobject_p.h \
- $$PWD/qv4stringobject_p.h \
- $$PWD/qv4string_p.h \
- $$PWD/qv4property_p.h \
- $$PWD/qv4objectiterator_p.h \
- $$PWD/qv4regexp_p.h \
- $$PWD/qv4unwindhelper_p.h \
- $$PWD/qv4unwindhelper_p-dw2.h \
- $$PWD/qv4unwindhelper_p-arm.h \
- $$PWD/qv4v8_p.h \
- $$PWD/qcalculatehash_p.h \
- $$PWD/qv4util_p.h \
- $$PWD/qv4executableallocator_p.h
-
-llvm-libs {
-
-SOURCES += \
- $$PWD/qv4isel_llvm.cpp
-
-HEADERS += \
- $$PWD/qv4isel_llvm_p.h \
- $$PWD/qv4_llvm_p.h
-
-LLVM_RUNTIME_BC = $$PWD/llvm_runtime.bc
-DEFINES += LLVM_RUNTIME="\"\\\"$$LLVM_RUNTIME_BC\\\"\""
-DEFINES += QMLJS_WITH_LLVM
-
-INCLUDEPATH += \
- $$system($$LLVM_CONFIG --includedir)
-
-QMAKE_CXXFLAGS += $$system($$LLVM_CONFIG --cppflags) -fvisibility-inlines-hidden
-QMAKE_CXXFLAGS -= -pedantic
-QMAKE_CXXFLAGS -= -Wcovered-switch-default
-
-LIBS += \
- $$system($$LLVM_CONFIG --ldflags) \
- $$system($$LLVM_CONFIG --libs core jit bitreader linker ipo target x86 arm native)
-
-QMAKE_EXTRA_TARGETS += gen_llvm_runtime
-
-GEN_LLVM_RUNTIME_FLAGS = $$system($$LLVM_CONFIG --cppflags)
-GEN_LLVM_RUNTIME_FLAGS -= -pedantic
-
-gen_llvm_runtime.target = llvm_runtime
-gen_llvm_runtime.commands = clang -O2 -emit-llvm -c -I$$PWD -I$$PWD/../3rdparty/masm $$join(QT.core.includes, " -I", "-I") $$GEN_LLVM_RUNTIME_FLAGS -DQMLJS_LLVM_RUNTIME llvm_runtime.cpp -o $$LLVM_RUNTIME_BC
-}
-
-# Use SSE2 floating point math on 32 bit instead of the default
-# 387 to make test results pass on 32 and on 64 bit builds.
-linux-g++*:isEqual(QT_ARCH,i386) {
- QMAKE_CFLAGS += -march=pentium4 -msse2 -mfpmath=sse
- QMAKE_CXXFLAGS += -march=pentium4 -msse2 -mfpmath=sse
-}
-
-linux*|mac {
- LIBS += -ldl
-}
-
-debug-with-libunwind {
- UW_INC=$$(LIBUNWIND_INCLUDES)
- isEmpty(UW_INC): error("Please set LIBUNWIND_INCLUDES")
- INCLUDEPATH += $$UW_INC
- UW_LIBS=$$(LIBUNWIND_LIBS)
- isEmpty(UW_LIBS): error("Please set LIBUNWIND_LIBS")
- LIBS += -L$$UW_LIBS
- equals(QT_ARCH, arm): LIBS += -lunwind-arm
- LIBS += -lunwind-dwarf-common -lunwind-dwarf-local -lunwind-elf32 -lunwind
- DEFINES += WTF_USE_LIBUNWIND_DEBUG=1
-}
-
-valgrind {
- DEFINES += V4_USE_VALGRIND
-}
-
-ios: DEFINES += ENABLE_ASSEMBLER_WX_EXCLUSIVE=1
-
-include(moth/moth.pri)
-include(../../../3rdparty/masm/masm.pri)
-include(../../../3rdparty/double-conversion/double-conversion.pri)