diff --git a/accessible/src/xul/nsXULTreeGridAccessible.cpp b/accessible/src/xul/nsXULTreeGridAccessible.cpp index c84af3d49578..6d5d7ef1e231 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -1170,8 +1170,7 @@ nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt if (!grandParent) return NS_OK; - nsCOMPtr tableAccessible = - do_QueryInterface(static_cast(grandParent)); + nsCOMPtr tableAccessible = do_QueryObject(grandParent); // XXX - temp fix for crash bug 516047 if (!tableAccessible) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 86facf7900e9..77de372695a2 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -798,12 +798,6 @@ pref("accessibility.blockautorefresh", false); // Whether history is enabled or not. pref("places.history.enabled", true); -// The percentage of system memory that the Places database can use. Out of the -// allowed cache size it will at most use the size of the database file. -// Changes to this value are effective after an application restart. -// Acceptable values are between 0 and 50. -pref("places.database.cache_to_memory_percentage", 6); - // the (maximum) number of the recent visits to sample // when calculating frecency pref("places.frecency.numVisits", 10); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 878cda64b30d..a696a12a7436 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2213,8 +2213,12 @@ var gLastOpenDirectory = { return this._lastDir; }, set path(val) { - if (!val || !val.exists() || !val.isDirectory()) + try { + if (!val || !val.isDirectory()) + return; + } catch(e) { return; + } this._lastDir = val.clone(); // Don't save the last open directory pref inside the Private Browsing mode @@ -2239,8 +2243,11 @@ function BrowserOpenFileWindow() fp.displayDirectory = gLastOpenDirectory.path; if (fp.show() == nsIFilePicker.returnOK) { - if (fp.file && fp.file.exists()) - gLastOpenDirectory.path = fp.file.parent.QueryInterface(Ci.nsILocalFile); + try { + if (fp.file) + gLastOpenDirectory.path = fp.file.parent.QueryInterface(Ci.nsILocalFile); + } catch(e) { + } openTopWin(fp.fileURL.spec); } } catch (ex) { diff --git a/browser/base/content/safeMode.js b/browser/base/content/safeMode.js index 412005931adb..b01925b75371 100644 --- a/browser/base/content/safeMode.js +++ b/browser/base/content/safeMode.js @@ -75,8 +75,11 @@ function deleteLocalstore() { var directoryService = Components.classes[nsIDirectoryServiceContractID] .getService(nsIProperties); var localstoreFile = directoryService.get("LStoreS", Components.interfaces.nsIFile); - if (localstoreFile.exists()) + try { localstoreFile.remove(false); + } catch(e) { + Components.utils.reportError(e); + } } function disableAddons() { diff --git a/browser/base/content/tabbrowser.css b/browser/base/content/tabbrowser.css index b945be2e9e3f..33c02f7a4f44 100644 --- a/browser/base/content/tabbrowser.css +++ b/browser/base/content/tabbrowser.css @@ -16,12 +16,6 @@ display: -moz-box; } -.tab-close-button[selected="true"] { - /* Make this button focusable so clicking on it will not focus the tab while - it's getting closed */ - -moz-user-focus: normal; -} - .tab-label[pinned] { width: 0; margin-left: 0 !important; diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index a23a89c7e7d0..368345232048 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -4002,7 +4002,6 @@ role="presentation"/> @@ -4040,25 +4039,14 @@ this.style.MozUserFocus = ''; - + - - this.style.MozUserFocus = 'ignore'; - this.clientTop; - - - this.style.MozUserFocus = 'ignore'; - this.clientTop; - this.style.MozUserFocus = ''; diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 3a3ba68ab2c1..7fc4a5fb349d 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -344,9 +344,11 @@ nsWindowsShellService::IsDefaultBrowserVista(PRBool* aIsDefaultBrowser) (void**)&pAAR); if (SUCCEEDED(hr)) { + BOOL res; hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE, APP_REG_NAME, - aIsDefaultBrowser); + &res); + *aIsDefaultBrowser = res; pAAR->Release(); return PR_TRUE; diff --git a/browser/themes/winstripe/browser/browser.css b/browser/themes/winstripe/browser/browser.css index 130a6c5c3d5d..7ade136dac25 100644 --- a/browser/themes/winstripe/browser/browser.css +++ b/browser/themes/winstripe/browser/browser.css @@ -1868,10 +1868,6 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- -moz-image-region: rect(0, 16px, 16px, 0); } -.tab-close-button:focus { - outline: none !important; -} - /* Tab scrollbox arrow, tabstrip new tab and all-tabs buttons */ @media all and (-moz-touch-enabled) { diff --git a/build/automation.py.in b/build/automation.py.in index b4b6628eed1e..c570afb4f31a 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -336,6 +336,7 @@ user_pref("browser.console.showInPanel", true); user_pref("browser.dom.window.dump.enabled", true); user_pref("browser.firstrun.show.localepicker", false); user_pref("browser.firstrun.show.uidiscovery", false); +user_pref("browser.ui.layout.tablet", 0); // force tablet UI off user_pref("dom.allow_scripts_to_close_windows", true); user_pref("dom.disable_open_during_load", false); user_pref("dom.max_script_run_time", 0); // no slow script dialogs diff --git a/build/mobile/sutagent/android/watcher/AndroidManifest.xml b/build/mobile/sutagent/android/watcher/AndroidManifest.xml index 655634b7fc8c..44668a6b2f82 100644 --- a/build/mobile/sutagent/android/watcher/AndroidManifest.xml +++ b/build/mobile/sutagent/android/watcher/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.mozilla.watcher" android:versionCode="1" android:versionName="1.0"> + diff --git a/build/mobile/sutagent/android/watcher/WatcherService.java b/build/mobile/sutagent/android/watcher/WatcherService.java index 2b1e4c8695ac..b1beb29b10e6 100644 --- a/build/mobile/sutagent/android/watcher/WatcherService.java +++ b/build/mobile/sutagent/android/watcher/WatcherService.java @@ -58,6 +58,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ActivityNotFoundException; +import android.content.ContentResolver; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; @@ -65,9 +66,12 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.os.BatteryManager; +import android.os.Debug; import android.os.IBinder; import android.os.PowerManager; import android.os.RemoteException; +import android.provider.Settings; import android.util.Log; import android.view.Gravity; import android.widget.Toast; @@ -134,11 +138,26 @@ public class WatcherService extends Service this.sPingTarget = GetIniData("watcher", "PingTarget", sIniFile, "www.mozilla.org"); sHold = GetIniData("watcher", "delay", sIniFile, "60000"); - this.lDelay = Long.parseLong(sHold.trim()); + this.lDelay = Long.parseLong(sHold.trim()); sHold = GetIniData("watcher", "period", sIniFile,"300000"); - this.lPeriod = Long.parseLong(sHold.trim()); + this.lPeriod = Long.parseLong(sHold.trim()); sHold = GetIniData("watcher", "strikes", sIniFile,"3"); - this.nMaxStrikes = Integer.parseInt(sHold.trim()); + this.nMaxStrikes = Integer.parseInt(sHold.trim()); + + sHold = GetIniData("watcher", "stayon", sIniFile,"0"); + int nStayOn = Integer.parseInt(sHold.trim()); + + try { + if (nStayOn != 0) { + if (!Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)) { + doToast("Screen couldn't be set to Always On [stay on while plugged in]"); + } + } + } catch (Exception e) { + e.printStackTrace(); + String sExcept = e.getMessage(); + doToast("Screen couldn't be set to Always On [exception " + sExcept + "]"); + } doToast("WatcherService created"); } diff --git a/config/makefiles/target_export.mk b/config/makefiles/target_export.mk new file mode 100644 index 000000000000..318feb8f949a --- /dev/null +++ b/config/makefiles/target_export.mk @@ -0,0 +1,68 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS)) + +.PHONY: export $(PARALLEL_DIRS_export) + +############### +## TIER targets +############### +export_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +export:: $(PARALLEL_DIRS_export) + +$(PARALLEL_DIRS_export): %_export: %/Makefile + +@$(call SUBMAKE,export,$*) +endif + +export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR)) + $(LOOP_OVER_DIRS) + $(LOOP_OVER_TOOL_DIRS) diff --git a/config/makefiles/target_libs.mk b/config/makefiles/target_libs.mk new file mode 100644 index 000000000000..707fdd179d83 --- /dev/null +++ b/config/makefiles/target_libs.mk @@ -0,0 +1,141 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS)) + +.PHONY: libs $(PARALLEL_DIRS_libs) + +############### +## TIER targets +############### +libs_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +libs:: $(PARALLEL_DIRS_libs) + +$(PARALLEL_DIRS_libs): %_libs: %/Makefile + +@$(call SUBMAKE,libs,$*) +endif + + +#################### +## +#################### +ifdef EXPORT_LIBRARY +ifeq ($(EXPORT_LIBRARY),1) +ifdef IS_COMPONENT +EXPORT_LIBRARY = $(DEPTH)/staticlib/components +else +EXPORT_LIBRARY = $(DEPTH)/staticlib +endif +else +# If EXPORT_LIBRARY has a value, we'll be installing there. We also need to cleanup there +GARBAGE += $(foreach lib,$(LIBRARY),$(EXPORT_LIBRARY)/$(lib)) +endif +endif # EXPORT_LIBRARY + +libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY) +ifndef NO_DIST_INSTALL +ifdef LIBRARY +ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build + $(INSTALL) $(IFLAGS1) $(LIBRARY) $(EXPORT_LIBRARY) +endif # EXPORT_LIBRARY +ifdef DIST_INSTALL +ifdef IS_COMPONENT + $(error Shipping static component libs makes no sense.) +else + $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib +endif +endif # DIST_INSTALL +endif # LIBRARY +ifdef SHARED_LIBRARY +ifdef IS_COMPONENT + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components + $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY) +ifndef NO_COMPONENTS_MANIFEST + @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest" + @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)" +endif +else # ! IS_COMPONENT +ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) +ifndef NO_INSTALL_IMPORT_LIBRARY + $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib +endif +else + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib +endif + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET) +endif # IS_COMPONENT +endif # SHARED_LIBRARY +ifdef PROGRAM + $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET) +endif +ifdef SIMPLE_PROGRAMS + $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET) +endif +ifdef HOST_PROGRAM + $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin +endif +ifdef HOST_SIMPLE_PROGRAMS + $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin +endif +ifdef HOST_LIBRARY + $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib +endif +ifdef JAVA_LIBRARY +ifdef IS_COMPONENT + $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components +else + $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET) +endif +endif # JAVA_LIBRARY +endif # !NO_DIST_INSTALL + $(LOOP_OVER_DIRS) + +# EOF diff --git a/config/makefiles/target_tools.mk b/config/makefiles/target_tools.mk new file mode 100644 index 000000000000..1147d910d0de --- /dev/null +++ b/config/makefiles/target_tools.mk @@ -0,0 +1,72 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS)) + +.PHONY: tools $(PARALLEL_DIRS_tools) + +############### +## TIER targets +############### +tools_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +tools:: $(PARALLEL_DIRS_tools) + +$(PARALLEL_DIRS_tools): %_tools: %/Makefile + +@$(call SUBMAKE,tools,$*) +endif + +tools:: $(SUBMAKEFILES) $(MAKE_DIRS) + $(LOOP_OVER_DIRS) +ifneq (,$(strip $(TOOL_DIRS))) + $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir))) +endif + +# EOF diff --git a/config/rules.mk b/config/rules.mk index 230a638f643c..88eb6fc2ba84 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1,3 +1,4 @@ +# -*- makefile -*- # vim:set ts=8 sw=8 sts=8 noet: # # ***** BEGIN LICENSE BLOCK ***** @@ -24,6 +25,7 @@ # Chase Phillips # Benjamin Smedberg # Jeff Walden +# Joey Armstrong # # Alternatively, the contents of this file may be used under the terms of # either of the GNU General Public License Version 2 or later (the "GPL"), @@ -489,15 +491,6 @@ LOOP_OVER_TOOL_DIRS = \ $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir))) endif -ifdef PARALLEL_DIRS -# create a bunch of fake targets for order-only processing -PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS)) -PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS)) -PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS)) - -.PHONY: $(PARALLEL_DIRS_export) $(PARALLEL_DIRS_libs) $(PARALLEL_DIRS_tools) -endif - # # Now we can differentiate between objects used to build a library, and # objects used to build an executable in the same directory. @@ -736,21 +729,6 @@ endif MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs))) -export_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir))) - -libs_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir))) - -tools_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir))) - $(foreach tier,$(TIERS),tier_$(tier)):: @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)" $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir))) @@ -774,29 +752,8 @@ ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS)) $(LOOP_OVER_TOOL_DIRS) endif -ifdef PARALLEL_DIRS -export:: $(PARALLEL_DIRS_export) - -$(PARALLEL_DIRS_export): %_export: %/Makefile - +@$(call SUBMAKE,export,$*) -endif - -export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR)) - $(LOOP_OVER_DIRS) - $(LOOP_OVER_TOOL_DIRS) - -ifdef PARALLEL_DIRS -tools:: $(PARALLEL_DIRS_tools) - -$(PARALLEL_DIRS_tools): %_tools: %/Makefile - +@$(call SUBMAKE,tools,$*) -endif - -tools:: $(SUBMAKEFILES) $(MAKE_DIRS) - $(LOOP_OVER_DIRS) -ifneq (,$(strip $(TOOL_DIRS))) - $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir))) -endif +include $(topsrcdir)/config/makefiles/target_export.mk +include $(topsrcdir)/config/makefiles/target_tools.mk # # Rule to create list of libraries for final link @@ -826,86 +783,9 @@ DSO_LDOPTS_DEPS = $(call DO_EXPAND_LIBS,$(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFI GLOBAL_DEPS += Makefile Makefile.in $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk ############################################## -ifdef PARALLEL_DIRS -libs:: $(PARALLEL_DIRS_libs) - -$(PARALLEL_DIRS_libs): %_libs: %/Makefile - +@$(call SUBMAKE,libs,$*) -endif - -ifdef EXPORT_LIBRARY -ifeq ($(EXPORT_LIBRARY),1) -ifdef IS_COMPONENT -EXPORT_LIBRARY = $(DEPTH)/staticlib/components -else -EXPORT_LIBRARY = $(DEPTH)/staticlib -endif -else -# If EXPORT_LIBRARY has a value, we'll be installing there. We also need to cleanup there -GARBAGE += $(foreach lib,$(LIBRARY),$(EXPORT_LIBRARY)/$(lib)) -endif -endif # EXPORT_LIBRARY - -libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY) -ifndef NO_DIST_INSTALL -ifdef LIBRARY -ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build - $(INSTALL) $(IFLAGS1) $(LIBRARY) $(EXPORT_LIBRARY) -endif # EXPORT_LIBRARY -ifdef DIST_INSTALL -ifdef IS_COMPONENT - $(error Shipping static component libs makes no sense.) -else - $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib -endif -endif # DIST_INSTALL -endif # LIBRARY -ifdef SHARED_LIBRARY -ifdef IS_COMPONENT - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components - $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY) -ifndef NO_COMPONENTS_MANIFEST - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest" - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)" -endif -else # ! IS_COMPONENT -ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) -ifndef NO_INSTALL_IMPORT_LIBRARY - $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib -endif -else - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib -endif - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET) -endif # IS_COMPONENT -endif # SHARED_LIBRARY -ifdef PROGRAM - $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET) -endif -ifdef SIMPLE_PROGRAMS - $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET) -endif -ifdef HOST_PROGRAM - $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin -endif -ifdef HOST_SIMPLE_PROGRAMS - $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin -endif -ifdef HOST_LIBRARY - $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib -endif -ifdef JAVA_LIBRARY -ifdef IS_COMPONENT - $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components -else - $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET) -endif -endif # JAVA_LIBRARY -endif # !NO_DIST_INSTALL - $(LOOP_OVER_DIRS) +include $(topsrcdir)/config/makefiles/target_libs.mk ############################################## - ifndef NO_PROFILE_GUIDED_OPTIMIZE ifdef MOZ_PROFILE_USE ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 392670328b47..7a0c6a012652 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2739,8 +2739,7 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement) } // No focused element anywhere in this document. Try to get the BODY. - nsCOMPtr htmlDoc = - do_QueryInterface(static_cast(this)); + nsCOMPtr htmlDoc = do_QueryObject(this); if (htmlDoc) { nsCOMPtr bodyElement; htmlDoc->GetBody(getter_AddRefs(bodyElement)); diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 9c0e9b57d29d..480dc8c43b48 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -457,8 +457,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, // messageManager is wrapped in TabChildGlobal. nsCOMPtr defaultThisValue; if (mChrome) { - defaultThisValue = - do_QueryInterface(static_cast(this)); + defaultThisValue = do_QueryObject(this); } else { defaultThisValue = aTarget; } diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 3453d82c1099..5a7406438888 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -4874,8 +4874,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, NS_ENSURE_SUCCESS(rv, rv); if (hasMutationListeners) { - nsCOMPtr node = - do_QueryInterface(static_cast(this)); + nsCOMPtr node = do_QueryObject(this); nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED); mutation.mRelatedNode = attrNode; diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 1b6211946e6b..51d54845f518 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -3969,6 +3969,7 @@ WebGLContext::CompileShader(nsIWebGLShader *sobj) compiler = ShConstructCompiler((ShShaderType) shader->ShaderType(), SH_WEBGL_SPEC, + gl->IsGLES2() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT, &resources); nsPromiseFlatCString src(shader->Source()); diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index c764f27bb189..96da8dd931af 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -339,7 +339,9 @@ public: // nsICanvasRenderingContextInternal NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas); NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height); + void Initialize(nsIDocShell *shell, PRInt32 width, PRInt32 height); NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height); + PRBool EnsureSurface(); NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter); NS_IMETHOD GetInputStream(const char* aMimeType, const PRUnichar* aEncoderOptions, @@ -380,7 +382,7 @@ public: { public: PathAutoSaveRestore(nsCanvasRenderingContext2D* aCtx) : - mContext(aCtx->mThebes) + mContext(aCtx->mThebes) { if (aCtx->mHasPath) { mPath = mContext->CopyPath(); @@ -460,12 +462,16 @@ protected: return static_cast(mCanvasElement.get()); } + // Initialize the Thebes rendering context + void CreateThebes(); + // If mCanvasElement is not provided, then a docshell is nsCOMPtr mDocShell; // our drawing surfaces, contexts, and layers nsRefPtr mThebes; nsRefPtr mSurface; + PRPackedBool mSurfaceCreated; PRUint32 mSaveCount; @@ -527,6 +533,11 @@ protected: */ PRBool NeedToUseIntermediateSurface() { + if (!mThebes) { + // Haven't created a surface yet, default is OVER. + return OperatorAffectsUncoveredAreas(gfxContext::OPERATOR_OVER); + } + // certain operators always need an intermediate surface, except // with quartz since quartz does compositing differently than cairo return OperatorAffectsUncoveredAreas(mThebes->CurrentOperator()); @@ -541,6 +552,11 @@ protected: */ void ClearSurfaceForUnboundedSource() { + if (!mThebes) { + // Haven't created a surface yet, default is OVER. + return; + } + gfxContext::GraphicsOperator current = mThebes->CurrentOperator(); if (current != gfxContext::OPERATOR_SOURCE) return; @@ -597,8 +613,7 @@ protected: * Gets the pres shell from either the canvas element or the doc shell */ nsIPresShell *GetPresShell() { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); if (content) { nsIDocument* ownerDoc = content->GetOwnerDoc(); return ownerDoc ? ownerDoc->GetShell() : nsnull; @@ -965,6 +980,10 @@ nsCanvasRenderingContext2D::ApplyStyle(Style aWhichStyle, return; } + if (!EnsureSurface()) { + return; + } + // if not using global alpha, don't optimize with dirty bit if (aUseGlobalAlpha) mDirtyStyle[aWhichStyle] = PR_FALSE; @@ -1059,70 +1078,13 @@ nsCanvasRenderingContext2D::RedrawUser(const gfxRect& r) NS_IMETHODIMP nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height) { - nsRefPtr surface; - - // Check that the dimensions are sane - gfxIntSize size(width, height); - if (gfxASurface::CheckSurfaceSize(size, 0xffff)) { - // Zero sized surfaces have problems, so just use a 1 by 1. - if (height == 0 || width == 0) { - mZero = PR_TRUE; - height = 1; - width = 1; - } else { - mZero = PR_FALSE; - } - - gfxASurface::gfxImageFormat format = GetImageFormat(); - - if (!PR_GetEnv("MOZ_CANVAS_IMAGE_SURFACE")) { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); - nsIDocument* ownerDoc = nsnull; - if (content) - ownerDoc = content->GetOwnerDoc(); - nsRefPtr layerManager = nsnull; - - if (ownerDoc) - layerManager = - nsContentUtils::PersistentLayerManagerForDocument(ownerDoc); - - if (layerManager) { - surface = layerManager->CreateOptimalSurface(gfxIntSize(width, height), format); - } else { - surface = gfxPlatform::GetPlatform()-> - CreateOffscreenSurface(gfxIntSize(width, height), gfxASurface::ContentFromFormat(format)); - } - } - - if (!surface || surface->CairoStatus()) { - // If we couldn't create a surface of the type we want, fall back - // to an image surface. This lets us handle surface sizes that - // the underlying cairo backend might not handle. - surface = new gfxImageSurface(gfxIntSize(width, height), format); - if (!surface || surface->CairoStatus()) { - surface = nsnull; - } - } - } - if (surface) { - if (gCanvasMemoryReporter == nsnull) { - gCanvasMemoryReporter = new NS_MEMORY_REPORTER_NAME(CanvasMemory); - NS_RegisterMemoryReporter(gCanvasMemoryReporter); - } - - gCanvasMemoryUsed += width * height * 4; - JSContext* context = nsContentUtils::GetCurrentJSContext(); - if (context) { - JS_updateMallocCounter(context, width * height * 4); - } - } - - return InitializeWithSurface(NULL, surface, width, height); + Initialize(NULL, width, height); + return NS_OK; } -NS_IMETHODIMP -nsCanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, PRInt32 width, PRInt32 height) { +void +nsCanvasRenderingContext2D::Initialize(nsIDocShell *docShell, PRInt32 width, PRInt32 height) +{ Reset(); NS_ASSERTION(!docShell ^ !mCanvasElement, "Cannot set both docshell and canvas element"); @@ -1131,19 +1093,9 @@ nsCanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *docShell, gfxASur mWidth = width; mHeight = height; - mSurface = surface; - mThebes = surface ? new gfxContext(mSurface) : nsnull; mResetLayer = PR_TRUE; - - /* Create dummy surfaces here */ - if (mSurface == nsnull || mSurface->CairoStatus() != 0 || - mThebes == nsnull || mThebes->HasError()) - { - mSurface = new gfxImageSurface(gfxIntSize(1,1), gfxASurface::ImageFormatARGB32); - mThebes = new gfxContext(mSurface); - } else { - mValid = PR_TRUE; - } + mValid = PR_TRUE; + mSurfaceCreated = PR_FALSE; // set up the initial canvas defaults mStyleStack.Clear(); @@ -1157,6 +1109,19 @@ nsCanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *docShell, gfxASur state->colorStyles[STYLE_SHADOW] = NS_RGBA(0,0,0,0); DirtyAllStyles(); + // always force a redraw, because if the surface dimensions were reset + // then the surface became cleared, and we need to redraw everything. + Redraw(); + + return; +} + +void +nsCanvasRenderingContext2D::CreateThebes() +{ + mThebes = new gfxContext(mSurface); + mSurfaceCreated = PR_TRUE; + mThebes->SetOperator(gfxContext::OPERATOR_CLEAR); mThebes->NewPath(); mThebes->Rectangle(gfxRect(0, 0, mWidth, mHeight)); @@ -1167,17 +1132,105 @@ nsCanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *docShell, gfxASur mThebes->SetMiterLimit(10.0); mThebes->SetLineCap(gfxContext::LINE_CAP_BUTT); mThebes->SetLineJoin(gfxContext::LINE_JOIN_MITER); - mThebes->SetFillRule(gfxContext::FILL_RULE_WINDING); mThebes->NewPath(); +} - // always force a redraw, because if the surface dimensions were reset - // then the surface became cleared, and we need to redraw everything. - Redraw(); - +NS_IMETHODIMP +nsCanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *docShell, + gfxASurface *surface, + PRInt32 width, + PRInt32 height) +{ + Initialize(docShell, width, height); + + mSurface = surface; + CreateThebes(); return mValid ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } +PRBool +nsCanvasRenderingContext2D::EnsureSurface() +{ + if (!mValid) { + return PR_FALSE; + } + + if (mSurface && mThebes && mSurfaceCreated) { + if (mSurface->CairoStatus()) { + return PR_FALSE; + } + return PR_TRUE; + } + + nsRefPtr surface; + + // Check that the dimensions are sane + if (gfxASurface::CheckSurfaceSize(gfxIntSize(mWidth, mHeight), 0xffff)) { + // Zero sized surfaces have problems, so just use a 1 by 1. + if (mHeight == 0 || mWidth == 0) { + mZero = PR_TRUE; + mHeight = 1; + mWidth = 1; + } else { + mZero = PR_FALSE; + } + + gfxASurface::gfxImageFormat format = GetImageFormat(); + + if (!PR_GetEnv("MOZ_CANVAS_IMAGE_SURFACE")) { + nsCOMPtr content = do_QueryObject(mCanvasElement); + nsIDocument* ownerDoc = nsnull; + if (content) + ownerDoc = content->GetOwnerDoc(); + nsRefPtr layerManager = nsnull; + + if (ownerDoc) + layerManager = + nsContentUtils::PersistentLayerManagerForDocument(ownerDoc); + + if (layerManager) { + surface = layerManager->CreateOptimalSurface(gfxIntSize(mWidth, mHeight), format); + } else { + surface = gfxPlatform::GetPlatform()-> + CreateOffscreenSurface(gfxIntSize(mWidth, mHeight), gfxASurface::ContentFromFormat(format)); + } + } + + if (!surface || surface->CairoStatus()) { + // If we couldn't create a surface of the type we want, fall back + // to an image surface. This lets us handle surface sizes that + // the underlying cairo backend might not handle. + surface = new gfxImageSurface(gfxIntSize(mWidth, mHeight), format); + if (!surface || surface->CairoStatus()) { + surface = nsnull; + } + } + } + if (surface) { + if (gCanvasMemoryReporter == nsnull) { + gCanvasMemoryReporter = new NS_MEMORY_REPORTER_NAME(CanvasMemory); + NS_RegisterMemoryReporter(gCanvasMemoryReporter); + } + + gCanvasMemoryUsed += mWidth * mHeight * 4; + JSContext* context = nsContentUtils::GetCurrentJSContext(); + if (context) { + JS_updateMallocCounter(context, mWidth * mHeight * 4); + } + } else { + return PR_FALSE; + } + + mSurface = surface; + CreateThebes(); + + if (mSurface->CairoStatus()) { + return PR_FALSE; + } + return PR_TRUE; +} + NS_IMETHODIMP nsCanvasRenderingContext2D::SetIsOpaque(PRBool isOpaque) { @@ -1219,9 +1272,7 @@ nsCanvasRenderingContext2D::Render(gfxContext *ctx, gfxPattern::GraphicsFilter a { nsresult rv = NS_OK; - if (!mValid || !mSurface || - mSurface->CairoStatus() || - mThebes->HasError()) + if (!EnsureSurface()) return NS_ERROR_FAILURE; nsRefPtr pat = new gfxPattern(mSurface); @@ -1250,9 +1301,7 @@ nsCanvasRenderingContext2D::GetInputStream(const char *aMimeType, const PRUnichar *aEncoderOptions, nsIInputStream **aStream) { - if (!mValid || !mSurface || - mSurface->CairoStatus() || - mThebes->HasError()) + if (!EnsureSurface()) return NS_ERROR_FAILURE; nsresult rv; @@ -1337,6 +1386,9 @@ nsCanvasRenderingContext2D::GetCanvas(nsIDOMHTMLCanvasElement **canvas) NS_IMETHODIMP nsCanvasRenderingContext2D::Save() { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + ContextState state = CurrentState(); mStyleStack.AppendElement(state); mThebes->Save(); @@ -1347,6 +1399,9 @@ nsCanvasRenderingContext2D::Save() NS_IMETHODIMP nsCanvasRenderingContext2D::Restore() { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (mSaveCount == 0) return NS_OK; @@ -1367,6 +1422,9 @@ nsCanvasRenderingContext2D::Restore() NS_IMETHODIMP nsCanvasRenderingContext2D::Scale(float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y)) return NS_OK; @@ -1377,6 +1435,9 @@ nsCanvasRenderingContext2D::Scale(float x, float y) NS_IMETHODIMP nsCanvasRenderingContext2D::Rotate(float angle) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(angle)) return NS_OK; @@ -1387,6 +1448,9 @@ nsCanvasRenderingContext2D::Rotate(float angle) NS_IMETHODIMP nsCanvasRenderingContext2D::Translate(float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y)) return NS_OK; @@ -1397,6 +1461,9 @@ nsCanvasRenderingContext2D::Translate(float x, float y) NS_IMETHODIMP nsCanvasRenderingContext2D::Transform(float m11, float m12, float m21, float m22, float dx, float dy) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(m11,m12,m21,m22,dx,dy)) return NS_OK; @@ -1409,6 +1476,9 @@ nsCanvasRenderingContext2D::Transform(float m11, float m12, float m21, float m22 NS_IMETHODIMP nsCanvasRenderingContext2D::SetTransform(float m11, float m12, float m21, float m22, float dx, float dy) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(m11,m12,m21,m22,dx,dy)) return NS_OK; @@ -1424,6 +1494,9 @@ nsCanvasRenderingContext2D::SetMozCurrentTransform(JSContext* cx, { nsresult rv; gfxMatrix newCTM; + + if (!EnsureSurface()) + return NS_ERROR_FAILURE; if (!JSValToMatrix(cx, matrix, &newCTM, &rv)) { return rv; @@ -1438,6 +1511,9 @@ NS_IMETHODIMP nsCanvasRenderingContext2D::GetMozCurrentTransform(JSContext* cx, jsval* matrix) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + return MatrixToJSVal(mThebes->CurrentMatrix(), cx, matrix); } @@ -1447,6 +1523,9 @@ nsCanvasRenderingContext2D::SetMozCurrentTransformInverse(JSContext* cx, { nsresult rv; gfxMatrix newCTMInverse; + + if (!EnsureSurface()) + return NS_ERROR_FAILURE; if (!JSValToMatrix(cx, matrix, &newCTMInverse, &rv)) { return rv; @@ -1648,6 +1727,9 @@ NS_IMETHODIMP nsCanvasRenderingContext2D::SetMozFillRule(const nsAString& aString) { gfxContext::FillRule rule; + + if (!EnsureSurface()) + return NS_ERROR_FAILURE; if (aString.EqualsLiteral("evenodd")) rule = gfxContext::FILL_RULE_EVEN_ODD; @@ -1664,6 +1746,9 @@ nsCanvasRenderingContext2D::SetMozFillRule(const nsAString& aString) NS_IMETHODIMP nsCanvasRenderingContext2D::GetMozFillRule(nsAString& aString) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + switch (mThebes->CurrentFillRule()) { case gfxContext::FILL_RULE_WINDING: aString.AssignLiteral("nonzero"); break; @@ -1888,6 +1973,9 @@ nsCanvasRenderingContext2D::ShadowInitialize(const gfxRect& extents, gfxAlphaBox void nsCanvasRenderingContext2D::ShadowFinalize(gfxAlphaBoxBlur& blur) { + if (!EnsureSurface()) + return; + ApplyStyle(STYLE_SHADOW); // canvas matrix was already applied, don't apply it twice, but do // apply the shadow offset @@ -1902,6 +1990,9 @@ nsCanvasRenderingContext2D::ShadowFinalize(gfxAlphaBoxBlur& blur) nsresult nsCanvasRenderingContext2D::DrawPath(Style style, gfxRect *dirtyRect) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + PRBool doUseIntermediateSurface = PR_FALSE; if (mSurface->GetType() == gfxASurface::SurfaceTypeD2D) { @@ -2029,6 +2120,9 @@ nsCanvasRenderingContext2D::DrawPath(Style style, gfxRect *dirtyRect) NS_IMETHODIMP nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h) { + if (!mSurfaceCreated) + return NS_OK; + if (!FloatValidate(x,y,w,h)) return NS_OK; @@ -2046,6 +2140,9 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h) nsresult nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(rect.X(), rect.Y(), rect.Width(), rect.Height())) return NS_OK; @@ -2084,6 +2181,9 @@ nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h) NS_IMETHODIMP nsCanvasRenderingContext2D::BeginPath() { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + mHasPath = PR_FALSE; mThebes->NewPath(); return NS_OK; @@ -2092,6 +2192,9 @@ nsCanvasRenderingContext2D::BeginPath() NS_IMETHODIMP nsCanvasRenderingContext2D::ClosePath() { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + mThebes->ClosePath(); return NS_OK; } @@ -2119,6 +2222,9 @@ nsCanvasRenderingContext2D::Stroke() NS_IMETHODIMP nsCanvasRenderingContext2D::Clip() { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + mThebes->Clip(); return NS_OK; } @@ -2126,6 +2232,9 @@ nsCanvasRenderingContext2D::Clip() NS_IMETHODIMP nsCanvasRenderingContext2D::MoveTo(float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y)) return NS_OK; @@ -2137,6 +2246,9 @@ nsCanvasRenderingContext2D::MoveTo(float x, float y) NS_IMETHODIMP nsCanvasRenderingContext2D::LineTo(float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y)) return NS_OK; @@ -2148,6 +2260,9 @@ nsCanvasRenderingContext2D::LineTo(float x, float y) NS_IMETHODIMP nsCanvasRenderingContext2D::QuadraticCurveTo(float cpx, float cpy, float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(cpx,cpy,x,y)) return NS_OK; @@ -2168,6 +2283,9 @@ nsCanvasRenderingContext2D::BezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(cp1x,cp1y,cp2x,cp2y,x,y)) return NS_OK; @@ -2182,6 +2300,9 @@ nsCanvasRenderingContext2D::BezierCurveTo(float cp1x, float cp1y, NS_IMETHODIMP nsCanvasRenderingContext2D::ArcTo(float x1, float y1, float x2, float y2, float radius) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x1,y1,x2,y2,radius)) return NS_OK; @@ -2241,6 +2362,9 @@ nsCanvasRenderingContext2D::ArcTo(float x1, float y1, float x2, float y2, float NS_IMETHODIMP nsCanvasRenderingContext2D::Arc(float x, float y, float r, float startAngle, float endAngle, PRBool ccw) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y,r,startAngle,endAngle)) return NS_OK; @@ -2260,6 +2384,9 @@ nsCanvasRenderingContext2D::Arc(float x, float y, float r, float startAngle, flo NS_IMETHODIMP nsCanvasRenderingContext2D::Rect(float x, float y, float w, float h) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y,w,h)) return NS_OK; @@ -2772,7 +2899,13 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText, GetAppUnitsValues(&processor.mAppUnitsPerDevPixel, NULL); processor.mPt = gfxPoint(aX, aY); - processor.mThebes = mThebes; + nsRefPtr ctx; + if (mThebes) { + processor.mThebes = mThebes; + } else { + ctx = presShell->GetReferenceRenderingContext(); + processor.mThebes = ctx->ThebesContext(); + } processor.mOp = aOp; processor.mBoundingBox = gfxRect(0, 0, 0, 0); processor.mDoMeasureBoundingBox = doDrawShadow || !mIsEntireFrameInvalid; @@ -2806,6 +2939,11 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText, if (aOp==TEXT_DRAW_OPERATION_MEASURE) return NS_OK; + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + + processor.mThebes = mThebes; + // offset pt.x based on text align gfxFloat anchorX; @@ -3026,6 +3164,9 @@ nsCanvasRenderingContext2D::MakeTextRun(const PRUnichar* aText, NS_IMETHODIMP nsCanvasRenderingContext2D::SetLineWidth(float width) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(width) || width <= 0.0) return NS_OK; @@ -3036,6 +3177,9 @@ nsCanvasRenderingContext2D::SetLineWidth(float width) NS_IMETHODIMP nsCanvasRenderingContext2D::GetLineWidth(float *width) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxFloat d = mThebes->CurrentLineWidth(); *width = static_cast(d); return NS_OK; @@ -3044,6 +3188,9 @@ nsCanvasRenderingContext2D::GetLineWidth(float *width) NS_IMETHODIMP nsCanvasRenderingContext2D::SetLineCap(const nsAString& capstyle) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsLineCap cap; if (capstyle.EqualsLiteral("butt")) @@ -3063,6 +3210,9 @@ nsCanvasRenderingContext2D::SetLineCap(const nsAString& capstyle) NS_IMETHODIMP nsCanvasRenderingContext2D::GetLineCap(nsAString& capstyle) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsLineCap cap = mThebes->CurrentLineCap(); if (cap == gfxContext::LINE_CAP_BUTT) @@ -3080,6 +3230,9 @@ nsCanvasRenderingContext2D::GetLineCap(nsAString& capstyle) NS_IMETHODIMP nsCanvasRenderingContext2D::SetLineJoin(const nsAString& joinstyle) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsLineJoin j; if (joinstyle.EqualsLiteral("round")) @@ -3099,6 +3252,9 @@ nsCanvasRenderingContext2D::SetLineJoin(const nsAString& joinstyle) NS_IMETHODIMP nsCanvasRenderingContext2D::GetLineJoin(nsAString& joinstyle) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsLineJoin j = mThebes->CurrentLineJoin(); if (j == gfxContext::LINE_JOIN_ROUND) @@ -3116,6 +3272,9 @@ nsCanvasRenderingContext2D::GetLineJoin(nsAString& joinstyle) NS_IMETHODIMP nsCanvasRenderingContext2D::SetMiterLimit(float miter) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(miter) || miter <= 0.0) return NS_OK; @@ -3126,6 +3285,9 @@ nsCanvasRenderingContext2D::SetMiterLimit(float miter) NS_IMETHODIMP nsCanvasRenderingContext2D::GetMiterLimit(float *miter) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxFloat d = mThebes->CurrentMiterLimit(); *miter = static_cast(d); return NS_OK; @@ -3134,6 +3296,9 @@ nsCanvasRenderingContext2D::GetMiterLimit(float *miter) NS_IMETHODIMP nsCanvasRenderingContext2D::SetMozDash(JSContext *cx, const jsval& patternArray) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + AutoFallibleTArray dashes; nsresult rv = JSValToDashArray(cx, patternArray, dashes); if (NS_SUCCEEDED(rv)) { @@ -3146,6 +3311,9 @@ nsCanvasRenderingContext2D::SetMozDash(JSContext *cx, const jsval& patternArray) NS_IMETHODIMP nsCanvasRenderingContext2D::GetMozDash(JSContext* cx, jsval* dashArray) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + AutoFallibleTArray dashes; if (!mThebes->CurrentDash(dashes, nsnull)) { dashes.SetLength(0); @@ -3156,6 +3324,9 @@ nsCanvasRenderingContext2D::GetMozDash(JSContext* cx, jsval* dashArray) NS_IMETHODIMP nsCanvasRenderingContext2D::SetMozDashOffset(float offset) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(offset)) { return NS_ERROR_ILLEGAL_VALUE; } @@ -3180,6 +3351,9 @@ nsCanvasRenderingContext2D::SetMozDashOffset(float offset) NS_IMETHODIMP nsCanvasRenderingContext2D::GetMozDashOffset(float* offset) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + *offset = float(mThebes->CurrentDashOffset()); return NS_OK; } @@ -3187,6 +3361,9 @@ nsCanvasRenderingContext2D::GetMozDashOffset(float* offset) NS_IMETHODIMP nsCanvasRenderingContext2D::IsPointInPath(float x, float y, PRBool *retVal) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!FloatValidate(x,y)) { *retVal = PR_FALSE; return NS_OK; @@ -3214,6 +3391,9 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1, float a6, float a7, float a8, PRUint8 optional_argc) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + if (!imgElt) { return NS_ERROR_DOM_TYPE_MISMATCH_ERR; } @@ -3398,6 +3578,9 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1, NS_IMETHODIMP nsCanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsOperator thebes_op; #define CANVAS_OP_TO_THEBES_OP(cvsop,thebesop) \ @@ -3427,6 +3610,9 @@ nsCanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op) NS_IMETHODIMP nsCanvasRenderingContext2D::GetGlobalCompositeOperation(nsAString& op) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + gfxContext::GraphicsOperator thebes_op = mThebes->CurrentOperator(); #define CANVAS_OP_TO_THEBES_OP(cvsop,thebesop) \ @@ -3457,6 +3643,9 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY const nsAString& aBGColor, PRUint32 flags) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + NS_ENSURE_ARG(aWindow != nsnull); // protect against too-large surfaces that will cause allocation @@ -3547,6 +3736,9 @@ nsCanvasRenderingContext2D::AsyncDrawXULElement(nsIDOMXULElement* aElem, float a const nsAString& aBGColor, PRUint32 flags) { + if (!EnsureSurface()) + return NS_ERROR_FAILURE; + NS_ENSURE_ARG(aElem != nsnull); // We can't allow web apps to call this until we fix at least the @@ -3660,7 +3852,7 @@ NS_IMETHODIMP nsCanvasRenderingContext2D::GetImageData_explicit(PRInt32 x, PRInt32 y, PRUint32 w, PRUint32 h, PRUint8 *aData, PRUint32 aDataLen) { - if (!mValid) + if (!EnsureSurface()) return NS_ERROR_FAILURE; if (!mCanvasElement && !mDocShell) { @@ -3792,7 +3984,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32 PRBool hasDirtyRect, PRInt32 dirtyX, PRInt32 dirtyY, PRInt32 dirtyWidth, PRInt32 dirtyHeight) { - if (!mValid) + if (!EnsureSurface()) return NS_ERROR_FAILURE; if (w == 0 || h == 0) @@ -3898,7 +4090,7 @@ nsCanvasRenderingContext2D::PutImageData_explicit(PRInt32 x, PRInt32 y, PRUint32 NS_IMETHODIMP nsCanvasRenderingContext2D::GetThebesSurface(gfxASurface **surface) { - if (!mSurface) { + if (!EnsureSurface()) { *surface = nsnull; return NS_ERROR_NOT_AVAILABLE; } @@ -3954,7 +4146,7 @@ nsCanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder, CanvasLayer *aOldLayer, LayerManager *aManager) { - if (!mValid) + if (!EnsureSurface()) return nsnull; if (!mResetLayer && aOldLayer && diff --git a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp index a4b0ee49bdf5..5fc2a303ac11 100644 --- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp @@ -605,8 +605,7 @@ protected: * Gets the pres shell from either the canvas element or the doc shell */ nsIPresShell *GetPresShell() { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); if (content) { nsIDocument* ownerDoc = content->GetOwnerDoc(); return ownerDoc ? ownerDoc->GetShell() : nsnull; @@ -1235,8 +1234,7 @@ nsCanvasRenderingContext2DAzure::SetDimensions(PRInt32 width, PRInt32 height) if (size.width <= 0xFFFF && size.height <= 0xFFFF && size.width >= 0 && size.height >= 0) { SurfaceFormat format = GetSurfaceFormat(); - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); nsIDocument* ownerDoc = nsnull; if (content) { ownerDoc = content->GetOwnerDoc(); diff --git a/content/canvas/test/webgl/conformance/oes-texture-float.html b/content/canvas/test/webgl/conformance/oes-texture-float.html index 18da6183b85d..68773ffb0155 100644 --- a/content/canvas/test/webgl/conformance/oes-texture-float.html +++ b/content/canvas/test/webgl/conformance/oes-texture-float.html @@ -85,7 +85,8 @@ if (!gl) { testPassed("Successfully enabled OES_texture_float extension"); runTextureCreationTest(testProgram, true); runRenderTargetTest(testProgram); - runUniqueObjectTest(); + // bug 683216, see the discussion in bug 630672 + // runUniqueObjectTest(); } } diff --git a/content/canvas/test/webgl/remove-uniqueObjectTest.patch b/content/canvas/test/webgl/remove-uniqueObjectTest.patch new file mode 100644 index 000000000000..e1b8a498ac56 --- /dev/null +++ b/content/canvas/test/webgl/remove-uniqueObjectTest.patch @@ -0,0 +1,25 @@ +# HG changeset patch +# Parent 6c8a909977d32284bbddd60a45e1780e824b5d7c +diff --git a/content/canvas/test/webgl/conformance/oes-texture-float.html b/content/canvas/test/webgl/conformance/oes-texture-float.html +--- a/content/canvas/test/webgl/conformance/oes-texture-float.html ++++ b/content/canvas/test/webgl/conformance/oes-texture-float.html +@@ -80,17 +80,18 @@ if (!gl) { + runTextureCreationTest(testProgram, false); + + if (!gl.getExtension("OES_texture_float")) { + testPassed("No OES_texture_float support -- this is legal"); + } else { + testPassed("Successfully enabled OES_texture_float extension"); + runTextureCreationTest(testProgram, true); + runRenderTargetTest(testProgram); +- runUniqueObjectTest(); ++ // bug 683216, see the discussion in bug 630672 ++ // runUniqueObjectTest(); + } + } + + // Needs to be global for shouldBe to see it. + var pixels; + + function allocateTexture() + { diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index d976dca57587..9fbc66601a0b 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -1214,8 +1214,7 @@ nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild, // If the element is subject to constraint validaton and is invalid, we need // to update our internal counter. if (aUpdateValidity) { - nsCOMPtr cvElmt = - do_QueryInterface(static_cast(aChild)); + nsCOMPtr cvElmt = do_QueryObject(aChild); if (cvElmt && cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) { UpdateValidity(PR_FALSE); @@ -1301,8 +1300,7 @@ nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild, // If the element was subject to constraint validaton and is invalid, we need // to update our internal counter. if (aUpdateValidity) { - nsCOMPtr cvElmt = - do_QueryInterface(static_cast(aChild)); + nsCOMPtr cvElmt = do_QueryObject(aChild); if (cvElmt && cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) { UpdateValidity(PR_TRUE); @@ -2350,8 +2348,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild, list->AppendElement(newFirst ? content : aChild); - nsCOMPtr listSupports = - do_QueryInterface(static_cast(list)); + nsCOMPtr listSupports = do_QueryObject(list); // Replace the element with the list. NS_ENSURE_TRUE(mNameLookupTable.Put(aName, listSupports), diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 5e4ab31b1c5f..2e8e4316c7db 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -2255,8 +2255,7 @@ ImageContainer* nsHTMLMediaElement::GetImageContainer() return nsnull; // Only video frames need an image container. - nsCOMPtr video = - do_QueryInterface(static_cast(this)); + nsCOMPtr video = do_QueryObject(this); if (!video) return nsnull; @@ -2283,7 +2282,7 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer, nsAutoArrayPtr frameBuffer(aFrameBuffer); nsCOMPtr domDoc = do_QueryInterface(GetOwnerDoc()); - nsCOMPtr target(do_QueryInterface(static_cast(this))); + nsCOMPtr target(do_QueryObject(this)); NS_ENSURE_TRUE(domDoc && target, NS_ERROR_INVALID_ARG); nsCOMPtr event; @@ -2496,8 +2495,7 @@ void nsHTMLMediaElement::NotifyAddedSource() nsIContent* nsHTMLMediaElement::GetNextSource() { nsresult rv = NS_OK; - nsCOMPtr thisDomNode = - do_QueryInterface(static_cast(this)); + nsCOMPtr thisDomNode = do_QueryObject(this); mSourceLoadCandidate = nsnull; diff --git a/content/media/test/manifest.js b/content/media/test/manifest.js index bae8665cae5c..7405ce4c6d19 100644 --- a/content/media/test/manifest.js +++ b/content/media/test/manifest.js @@ -330,10 +330,13 @@ function MediaTestManager() { // to start every test, but if you call started() you *must* call finish() // else you'll timeout. this.runTests = function(tests, startTest) { + this.startTime = new Date(); + SimpleTest.info("Started " + this.startTime + " (" + this.startTime.getTime()/1000 + "s)"); this.testNum = 0; this.tests = tests; this.startTest = startTest; this.tokens = []; + this.isShutdown = false; // Always wait for explicit finish. SimpleTest.waitForExplicitFinish(); this.nextTest(); @@ -355,7 +358,7 @@ function MediaTestManager() { // Remove the element from the list of running tests. this.tokens.splice(i, 1); } - if (this.tokens.length == 0) { + if (this.tokens.length < PARALLEL_TESTS) { this.nextTest(); } } @@ -368,14 +371,7 @@ function MediaTestManager() { // thread stacks' address space. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); Components.utils.forceGC(); - if (this.testNum == this.tests.length && !DEBUG_TEST_LOOP_FOREVER) { - if (this.onFinished) { - this.onFinished(); - } - mediaTestCleanup(); - SimpleTest.finish(); - return; - } + while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) { var test = this.tests[this.testNum]; var token = (test.name ? (test.name + "-"): "") + this.testNum; @@ -391,11 +387,23 @@ function MediaTestManager() { // Do the init. This should start the test. this.startTest(test, token); - } - if (this.tokens.length == 0) { - // No tests were added, we must have tried everything, exit. + + if (this.testNum == this.tests.length && + !DEBUG_TEST_LOOP_FOREVER && + this.tokens.length == 0 && + !this.isShutdown) + { + this.isShutdown = true; + if (this.onFinished) { + this.onFinished(); + } + mediaTestCleanup(); + var end = new Date(); + SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)"); + SimpleTest.info("Running time: " + (end.getTime() - this.startTime.getTime())/1000 + "s"); SimpleTest.finish(); + return; } } } diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 9cde1644f5ed..eb4ac66131e8 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -2343,16 +2343,14 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) // Transforms: nsCOMPtr transformList; if (aName == nsGkAtoms::transform) { - nsCOMPtr transformable( - do_QueryInterface(static_cast(this))); + nsCOMPtr transformable(do_QueryObject(this)); if (!transformable) return nsnull; nsresult rv = transformable->GetTransform(getter_AddRefs(transformList)); NS_ENSURE_SUCCESS(rv, nsnull); } if (aName == nsGkAtoms::gradientTransform) { - nsCOMPtr gradientElement( - do_QueryInterface(static_cast(this))); + nsCOMPtr gradientElement(do_QueryObject(this)); if (!gradientElement) return nsnull; @@ -2360,8 +2358,7 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) NS_ENSURE_SUCCESS(rv, nsnull); } if (aName == nsGkAtoms::patternTransform) { - nsCOMPtr patternElement( - do_QueryInterface(static_cast(this))); + nsCOMPtr patternElement(do_QueryObject(this)); if (!patternElement) return nsnull; diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 4789ab9f0661..5dce59212d58 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -580,8 +580,7 @@ nsXULElement::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse) return PR_FALSE; #endif - nsCOMPtr xulControl = - do_QueryInterface(static_cast(this)); + nsCOMPtr xulControl = do_QueryObject(this); if (xulControl) { // a disabled element cannot be focused and is not part of the tab order PRBool disabled; @@ -958,7 +957,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) // and cells going away. // First, retrieve the tree. // Check first whether this element IS the tree - controlElement = do_QueryInterface(static_cast(this)); + controlElement = do_QueryObject(this); // If it's not, look at our parent if (!controlElement) @@ -2057,7 +2056,7 @@ NS_IMETHODIMP nsXULElement::Focus() { nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - nsCOMPtr elem = do_QueryInterface(static_cast(this)); + nsCOMPtr elem = do_QueryObject(this); return fm ? fm->SetFocus(this, 0) : NS_OK; } diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 49867123e178..e3f91b33ac38 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -379,7 +379,7 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest* request) // cancel the load and display about:blank httpChannel->Cancel(NS_BINDING_ABORTED); - nsCOMPtr webNav(do_QueryInterface(static_cast(mDocShell))); + nsCOMPtr webNav(do_QueryObject(mDocShell)); if (webNav) { webNav->LoadURI(NS_LITERAL_STRING("about:blank").get(), 0, nsnull, nsnull, nsnull); diff --git a/dom/base/nsDOMMemoryReporter.cpp b/dom/base/nsDOMMemoryReporter.cpp index efb2d7650f51..1bc30507080b 100644 --- a/dom/base/nsDOMMemoryReporter.cpp +++ b/dom/base/nsDOMMemoryReporter.cpp @@ -103,6 +103,8 @@ nsDOMMemoryReporter::GetAmount(PRInt64* aAmount) { *aAmount = 0; nsGlobalWindow::WindowByIdTable* windows = nsGlobalWindow::GetWindowsTable(); + NS_ENSURE_TRUE(windows, NS_OK); + windows->Enumerate(GetWindowsMemoryUsage, aAmount); return NS_OK; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index ff2efe0aa2d9..2ff53998c8d1 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1101,8 +1101,7 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog) { if (IsOuterWindow() && !aIgnoreModalDialog) { nsGlobalWindow* inner = GetCurrentInnerWindowInternal(); - nsCOMPtr - dlg(do_QueryInterface(static_cast(inner))); + nsCOMPtr dlg(do_QueryObject(inner)); if (dlg) { // The window we're trying to clean up is the outer window of a // modal dialog. Defer cleanup until the window closes, and let @@ -9779,8 +9778,7 @@ nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI, if (!scx || !mDocument) return NS_ERROR_FAILURE; - nsCOMPtr chrome_win = - do_QueryInterface(static_cast(this)); + nsCOMPtr chrome_win = do_QueryObject(this); if (nsContentUtils::IsCallerChrome() && !chrome_win) { // If open() is called from chrome on a non-chrome window, we'll diff --git a/dom/indexedDB/AsyncConnectionHelper.cpp b/dom/indexedDB/AsyncConnectionHelper.cpp index 8dcd7eba1d8d..d1f94fe9ed68 100644 --- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -290,8 +290,7 @@ AsyncConnectionHelper::Run() #ifdef DEBUG if (NS_SUCCEEDED(rv)) { nsCOMPtr handlerSupports(do_QueryInterface(handler)); - nsCOMPtr thisSupports = - do_QueryInterface(static_cast(this)); + nsCOMPtr thisSupports = do_QueryObject(this); NS_ASSERTION(thisSupports == handlerSupports, "Mismatch!"); } #endif diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 7df66b27877b..3a8799fa0463 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -687,8 +687,10 @@ bool ContentChild::RecvAddPermission(const IPC::Permission& permission) { #if MOZ_PERMISSIONS - nsRefPtr permissionManager = - nsPermissionManager::GetSingleton(); + nsCOMPtr permissionManagerIface = + do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); + nsPermissionManager* permissionManager = + static_cast(permissionManagerIface.get()); NS_ABORT_IF_FALSE(permissionManager, "We have no permissionManager in the Content process !"); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 6eb464243f6f..3fd4e6e9d540 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -269,6 +269,7 @@ ContentParent::OnChannelConnected(int32 pid) } namespace { + void DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess) { @@ -276,6 +277,20 @@ DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess) ->PostTask(FROM_HERE, new DeleteTask(aSubprocess)); } + +// This runnable only exists to delegate ownership of the +// ContentParent to this runnable, until it's deleted by the event +// system. +struct DelayedDeleteContentParentTask : public nsRunnable +{ + DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { } + + // No-op + NS_IMETHODIMP Run() { return NS_OK; } + + nsRefPtr mObj; +}; + } void @@ -366,6 +381,15 @@ ContentParent::ActorDestroy(ActorDestroyReason why) PostTask(FROM_HERE, NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess)); mSubprocess = NULL; + + // IPDL rules require actors to live on past ActorDestroy, but it + // may be that the kungFuDeathGrip above is the last reference to + // |this|. If so, when we go out of scope here, we're deleted and + // all hell breaks loose. + // + // This runnable ensures that a reference to |this| lives on at + // least until after the current task finishes running. + NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this)); } TabParent* @@ -455,8 +479,10 @@ bool ContentParent::RecvReadPermissions(InfallibleTArray* aPermissions) { #ifdef MOZ_PERMISSIONS - nsRefPtr permissionManager = - nsPermissionManager::GetSingleton(); + nsCOMPtr permissionManagerIface = + do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); + nsPermissionManager* permissionManager = + static_cast(permissionManagerIface.get()); NS_ABORT_IF_FALSE(permissionManager, "We have no permissionManager in the Chrome process !"); diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index 8476b6b2c5d4..682087105d97 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -69,7 +69,7 @@ #endif class nsIInputStream; -class nsIntRect; +struct nsIntRect; class nsPluginDOMContextMenuListener; class nsObjectFrame; class nsDisplayListBuilder; diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index 09d9453c4901..a9d0718c9183 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -408,7 +408,7 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) nsCOMPtr mailEditor; if (ctrlKey) - mailEditor = do_QueryInterface(static_cast(mEditor)); + mailEditor = do_QueryObject(mEditor); PRInt32 clipboard; diff --git a/editor/libeditor/html/nsHTMLEditorEventListener.cpp b/editor/libeditor/html/nsHTMLEditorEventListener.cpp index 0df32c2b6a6e..9632dda75142 100644 --- a/editor/libeditor/html/nsHTMLEditorEventListener.cpp +++ b/editor/libeditor/html/nsHTMLEditorEventListener.cpp @@ -67,10 +67,8 @@ nsresult nsHTMLEditorEventListener::Connect(nsEditor* aEditor) { - nsCOMPtr htmlEditor = - do_QueryInterface(static_cast(aEditor)); - nsCOMPtr htmlInlineTableEditor = - do_QueryInterface(static_cast(aEditor)); + nsCOMPtr htmlEditor = do_QueryObject(aEditor); + nsCOMPtr htmlInlineTableEditor = do_QueryObject(aEditor); NS_PRECONDITION(htmlEditor && htmlInlineTableEditor, "Set nsHTMLEditor or its sub class"); return nsEditorEventListener::Connect(aEditor); diff --git a/extensions/cookie/nsCookiePermission.cpp b/extensions/cookie/nsCookiePermission.cpp index 6170d327d825..8062d7640870 100644 --- a/extensions/cookie/nsCookiePermission.cpp +++ b/extensions/cookie/nsCookiePermission.cpp @@ -367,16 +367,18 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI, } PRBool rememberDecision = PR_FALSE; + PRInt32 dialogRes = nsICookiePromptService::DENY_COOKIE; rv = cookiePromptService->CookieDialog(parent, aCookie, hostPort, countFromHost, foundCookie, - &rememberDecision, aResult); + &rememberDecision, &dialogRes); if (NS_FAILED(rv)) return rv; - - if (*aResult == nsICookiePromptService::ACCEPT_SESSION_COOKIE) + + *aResult = !!dialogRes; + if (dialogRes == nsICookiePromptService::ACCEPT_SESSION_COOKIE) *aIsSession = PR_TRUE; if (rememberDecision) { - switch (*aResult) { + switch (dialogRes) { case nsICookiePromptService::DENY_COOKIE: mPermMgr->Add(aURI, kPermissionType, (PRUint32) nsIPermissionManager::DENY_ACTION, nsIPermissionManager::EXPIRE_NEVER, 0); diff --git a/extensions/cookie/nsCookiePromptService.cpp b/extensions/cookie/nsCookiePromptService.cpp index 7d59790b3cb9..3159ecc6f130 100644 --- a/extensions/cookie/nsCookiePromptService.cpp +++ b/extensions/cookie/nsCookiePromptService.cpp @@ -114,7 +114,7 @@ nsCookiePromptService::CookieDialog(nsIDOMWindow *aParent, if (NS_FAILED(rv)) return rv; // get back output parameters - PRBool tempValue; + PRInt32 tempValue; block->GetInt(nsICookieAcceptDialog::ACCEPT_COOKIE, &tempValue); *aAccept = tempValue; diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 486327dac96e..d72b794a29ea 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -159,18 +159,12 @@ nsPermissionManager::nsPermissionManager() nsPermissionManager::~nsPermissionManager() { RemoveAllFromMemory(); + gPermissionManager = nsnull; } // static nsIPermissionManager* nsPermissionManager::GetXPCOMSingleton() -{ - return GetSingleton().get(); -} - -// static -already_AddRefed -nsPermissionManager::GetSingleton() { if (gPermissionManager) { NS_ADDREF(gPermissionManager); @@ -798,7 +792,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT } else { RemoveAllFromMemory(); } - } + } else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // the profile has already changed; init the db from the new location InitDB(PR_FALSE); diff --git a/extensions/cookie/nsPermissionManager.h b/extensions/cookie/nsPermissionManager.h index 79f9b3f0bbb3..5936b61fdb70 100644 --- a/extensions/cookie/nsPermissionManager.h +++ b/extensions/cookie/nsPermissionManager.h @@ -168,7 +168,6 @@ public: nsPermissionManager(); virtual ~nsPermissionManager(); static nsIPermissionManager* GetXPCOMSingleton(); - static already_AddRefed GetSingleton(); nsresult Init(); // enums for AddInternal() diff --git a/gfx/angle/CONTRIBUTORS b/gfx/angle/CONTRIBUTORS index 64157d6f388a..51221b1290ed 100644 --- a/gfx/angle/CONTRIBUTORS +++ b/gfx/angle/CONTRIBUTORS @@ -1,38 +1,42 @@ -# This is the official list of people who can contribute -# (and who have contributed) code to the ANGLE project -# repository. -# The AUTHORS file lists the copyright holders; this file -# lists people. For example, Google employees are listed here -# but not in AUTHORS, because Google holds the copyright. -# - -TransGaming Inc. - Nicolas Capens - Daniel Koch - Andrew Lewycky - Gavriel State - Shannon Woods - -Google Inc. - Brent Austin - John Bauman - Henry Bridge - Nat Duca - Vangelis Kokkevis - Alastair Patrick - Alok Priyadarshi - Kenneth Russell - Ben Vanik - Adrienne Walker - -Mozilla Corp. - Vladimir Vukicevic - Benoit Jacob - -Apple Inc. - David Kilzer - -Aitor Moreno -Jim Hauxwell -ddefrostt -timeless +# This is the official list of people who can contribute +# (and who have contributed) code to the ANGLE project +# repository. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# + +TransGaming Inc. + Nicolas Capens + Daniel Koch + Andrew Lewycky + Gavriel State + Shannon Woods + +Google Inc. + Brent Austin + John Bauman + Henry Bridge + Nat Duca + Vangelis Kokkevis + Zhenyao Mo + Daniel Nicoara + Alastair Patrick + Alok Priyadarshi + Kenneth Russell + Ben Vanik + Adrienne Walker + +Mozilla Corp. + Benoit Jacob + Makoto Kato + Vladimir Vukicevic + +Apple Inc. + David Kilzer + +Aitor Moreno +Jim Hauxwell +ddefrostt +timeless +Yore Apex diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in index 2df1850c59a0..c829642af5d1 100644 --- a/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in @@ -77,27 +77,31 @@ CPPSRCS = \ RemoveTree.cpp \ ShaderLang.cpp \ SymbolTable.cpp \ - VariableInfo.cpp \ - compilerdebug.cpp \ - ossource_nspr.cpp \ - util.cpp \ - ValidateLimitations.cpp \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - $(NULL) + VariableInfo.cpp \ + compilerdebug.cpp \ + ossource_nspr.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + ForLoopUnroll.cpp \ + MapLongVariableNames.cpp \ + BuiltInFunctionEmulator.cpp \ + $(NULL) # flex/yacc generated files CPPSRCS += \ - glslang_lex.cpp \ - glslang_tab.cpp \ - $(NULL) + glslang_lex.cpp \ + glslang_tab.cpp \ + $(NULL) # GLSL translator backend CPPSRCS += \ - CodeGenGLSL.cpp \ - OutputGLSL.cpp \ - TranslatorGLSL.cpp \ - VersionGLSL.cpp \ + CodeGenGLSL.cpp \ + OutputGLSL.cpp \ + TranslatorGLSL.cpp \ + VersionGLSL.cpp \ + OutputESSL.cpp \ + OutputGLSLBase.cpp \ + TranslatorESSL.cpp \ $(NULL) # Currently, only one or the other diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla index 9b7b14ffc588..079364c7893a 100644 --- a/gfx/angle/README.mozilla +++ b/gfx/angle/README.mozilla @@ -1,6 +1,6 @@ This is the ANGLE project, from http://code.google.com/p/angleproject/. -Current revision: r686 +Current revision: r740 == Applied local patches == @@ -8,15 +8,7 @@ In this order: angle-nspr-misc.patch - don't bother with ANGLE_OS detection with NSPR angle-renaming.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error - angle-amap-arev-fix.patch - plain bug fix, this is ANGLE r699 - angle-r702.patch - this is ANGLE r702 angle-limit-identifiers-to-250-chars.patch - see bug 675625 - angle-r712.patch - this is ANGLE r712 - angle-win64.patch - Win64 support. This is ANGLE r697 - angle-r707.patch - this is ANGLE r707 for Win64 bug fix - angle-r719.patch - this is ANGLE r719 - angle-r711.patch - this is ANGLE r711 - fix-angle-surface-assert.patch - this is ANGLE r739 In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE. diff --git a/gfx/angle/angle-amap-arev-fix.patch b/gfx/angle/angle-amap-arev-fix.patch deleted file mode 100644 index 6333b2b6d282..000000000000 --- a/gfx/angle/angle-amap-arev-fix.patch +++ /dev/null @@ -1,28 +0,0 @@ -# HG changeset patch -# Parent c88f8e8921fb6399cf95b5899d2acc60951dddd1 -Bug 665934 - fix bug: arev was meant instead of amap - r=upstream - -This patch has been taken in ANGLE upstream as r699. - -diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c ---- a/gfx/angle/src/compiler/preprocessor/atom.c -+++ b/gfx/angle/src/compiler/preprocessor/atom.c -@@ -330,17 +330,17 @@ static int GrowAtomTable(AtomTable *atab - newrev = malloc(sizeof(int)*size); - atable->size = 0; - } - if (!newmap || !newrev) { - /* failed to grow -- error */ - if (newmap) - atable->amap = newmap; - if (newrev) -- atable->amap = newrev; -+ atable->arev = newrev; - return -1; - } - memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int)); - memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int)); - atable->amap = newmap; - atable->arev = newrev; - atable->size = size; - } diff --git a/gfx/angle/angle-r702.patch b/gfx/angle/angle-r702.patch deleted file mode 100644 index 6538adc06f90..000000000000 --- a/gfx/angle/angle-r702.patch +++ /dev/null @@ -1,84 +0,0 @@ -# HG changeset patch -# Parent b410077eaab7f6f851ebefa26fd9e1df938026bb - -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp ---- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp -@@ -134,19 +134,33 @@ GLenum VertexDataManager::prepareVertexD - if (staticBuffer->size() == 0) - { - int totalCount = buffer->size() / attribs[i].stride(); - staticBuffer->addRequiredSpace(spaceRequired(attribs[i], totalCount)); - } - else if (staticBuffer->lookupAttribute(attribs[i]) == -1) - { - // This static buffer doesn't have matching attributes, so fall back to using the streaming buffer -- mStreamingBuffer->addRequiredSpaceFor(staticBuffer); - buffer->invalidateStaticData(); - -+ // Add the space of all previous attributes belonging to the invalidated static buffer to the streaming buffer -+ for (int previous = 0; previous < i; previous++) -+ { -+ if (translated[previous].active && attribs[previous].mArrayEnabled) -+ { -+ Buffer *previousBuffer = attribs[previous].mBoundBuffer.get(); -+ StaticVertexBuffer *previousStaticBuffer = previousBuffer ? previousBuffer->getStaticVertexBuffer() : NULL; -+ -+ if (staticBuffer == previousStaticBuffer) -+ { -+ mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[previous], count)); -+ } -+ } -+ } -+ - mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count)); - } - } - else - { - mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count)); - } - } -@@ -578,21 +592,16 @@ ArrayVertexBuffer::~ArrayVertexBuffer() - { - } - - void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace) - { - mRequiredSpace += requiredSpace; - } - --void ArrayVertexBuffer::addRequiredSpaceFor(ArrayVertexBuffer *buffer) --{ -- mRequiredSpace += buffer->mRequiredSpace; --} -- - StreamingVertexBuffer::StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize) : ArrayVertexBuffer(device, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY) - { - } - - StreamingVertexBuffer::~StreamingVertexBuffer() - { - } - -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h ---- a/gfx/angle/src/libGLESv2/VertexDataManager.h -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h -@@ -62,17 +62,16 @@ class ArrayVertexBuffer : public VertexB - public: - ArrayVertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags); - ~ArrayVertexBuffer(); - - UINT size() const { return mBufferSize; } - virtual void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset) = 0; - virtual void reserveRequiredSpace() = 0; - void addRequiredSpace(UINT requiredSpace); -- void addRequiredSpaceFor(ArrayVertexBuffer *buffer); - - protected: - UINT mBufferSize; - UINT mWritePosition; - UINT mRequiredSpace; - }; - - class StreamingVertexBuffer : public ArrayVertexBuffer diff --git a/gfx/angle/angle-r707.patch b/gfx/angle/angle-r707.patch deleted file mode 100644 index 22e585de2878..000000000000 --- a/gfx/angle/angle-r707.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp ---- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp -@@ -714,17 +714,17 @@ void StaticVertexBuffer::reserveRequired - { - // Already allocated - } - else UNREACHABLE(); // Static vertex buffers can't be resized - - mRequiredSpace = 0; - } - --UINT StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute) -+std::size_t StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute) - { - for (unsigned int element = 0; element < mCache.size(); element++) - { - if (mCache[element].type == attribute.mType && mCache[element].size == attribute.mSize && mCache[element].normalized == attribute.mNormalized) - { - if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride()) - { - return mCache[element].streamOffset; -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h ---- a/gfx/angle/src/libGLESv2/VertexDataManager.h -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h -@@ -88,17 +88,17 @@ class StaticVertexBuffer : public ArrayV - { - public: - explicit StaticVertexBuffer(IDirect3DDevice9 *device); - ~StaticVertexBuffer(); - - void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset); - void reserveRequiredSpace(); - -- UINT lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found -+ std::size_t lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found - - private: - struct VertexElement - { - GLenum type; - GLint size; - bool normalized; - int attributeOffset; - diff --git a/gfx/angle/angle-r712.patch b/gfx/angle/angle-r712.patch deleted file mode 100644 index 57614f716201..000000000000 --- a/gfx/angle/angle-r712.patch +++ /dev/null @@ -1,42 +0,0 @@ -# HG changeset patch -# Parent 88a5c8710f5cffd568bc21226118cb567850ce28 -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp ---- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp -@@ -134,34 +134,34 @@ GLenum VertexDataManager::prepareVertexD - if (staticBuffer->size() == 0) - { - int totalCount = buffer->size() / attribs[i].stride(); - staticBuffer->addRequiredSpace(spaceRequired(attribs[i], totalCount)); - } - else if (staticBuffer->lookupAttribute(attribs[i]) == -1) - { - // This static buffer doesn't have matching attributes, so fall back to using the streaming buffer -- buffer->invalidateStaticData(); -- - // Add the space of all previous attributes belonging to the invalidated static buffer to the streaming buffer - for (int previous = 0; previous < i; previous++) - { - if (translated[previous].active && attribs[previous].mArrayEnabled) - { - Buffer *previousBuffer = attribs[previous].mBoundBuffer.get(); - StaticVertexBuffer *previousStaticBuffer = previousBuffer ? previousBuffer->getStaticVertexBuffer() : NULL; - - if (staticBuffer == previousStaticBuffer) - { - mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[previous], count)); - } - } - } - - mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count)); -+ -+ buffer->invalidateStaticData(); - } - } - else - { - mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count)); - } - } - } diff --git a/gfx/angle/angle-renaming-debug.patch b/gfx/angle/angle-renaming-debug.patch index 9d83a527d417..036d1c382341 100644 --- a/gfx/angle/angle-renaming-debug.patch +++ b/gfx/angle/angle-renaming-debug.patch @@ -1,9 +1,10 @@ # HG changeset patch -# Parent a0dd1332c0e6ebaf429f9a3732b8901f9e46cde0 +# Parent 96359f46b01fdb37e791f564495e8b2755a05233 + diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in --- a/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in -@@ -72,17 +72,17 @@ CPPSRCS = \ +@@ -73,17 +73,17 @@ CPPSRCS = \ parseConst.cpp \ ParseHelper.cpp \ PoolAlloc.cpp \ @@ -11,44 +12,20 @@ diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in RemoveTree.cpp \ ShaderLang.cpp \ SymbolTable.cpp \ - VariableInfo.cpp \ -- debug.cpp \ -+ compilerdebug.cpp \ - ossource_nspr.cpp \ - util.cpp \ - ValidateLimitations.cpp \ - ForLoopUnroll.cpp \ - MapLongVariableNames.cpp \ - $(NULL) + VariableInfo.cpp \ +- debug.cpp \ ++ compilerdebug.cpp \ + ossource_nspr.cpp \ + util.cpp \ + ValidateLimitations.cpp \ + ForLoopUnroll.cpp \ + MapLongVariableNames.cpp \ + BuiltInFunctionEmulator.cpp \ + $(NULL) - # flex/yacc generated files -diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp ---- a/gfx/angle/src/build_angle.gyp -+++ b/gfx/angle/src/build_angle.gyp -@@ -17,18 +17,18 @@ - '.', - '../include', - ], - 'sources': [ - 'compiler/BaseTypes.h', - 'compiler/Common.h', - 'compiler/Compiler.cpp', - 'compiler/ConstantUnion.h', -- 'compiler/debug.cpp', -- 'compiler/debug.h', -+ 'compiler/compilerdebug.cpp', -+ 'compiler/compilerdebug.h', - 'compiler/glslang.h', - 'compiler/glslang_lex.cpp', - 'compiler/glslang_tab.cpp', - 'compiler/glslang_tab.h', - 'compiler/InfoSink.cpp', - 'compiler/InfoSink.h', - 'compiler/Initialize.cpp', - 'compiler/Initialize.h', -diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/OutputGLSL.cpp ---- a/gfx/angle/src/compiler/OutputGLSL.cpp -+++ b/gfx/angle/src/compiler/OutputGLSL.cpp +diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/OutputGLSLBase.cpp +--- a/gfx/angle/src/compiler/OutputGLSLBase.cpp ++++ b/gfx/angle/src/compiler/OutputGLSLBase.cpp @@ -1,16 +1,16 @@ // // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. @@ -56,7 +33,7 @@ diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/Outp // found in the LICENSE file. // - #include "compiler/OutputGLSL.h" + #include "compiler/OutputGLSLBase.h" -#include "compiler/debug.h" +#include "compiler/compilerdebug.h" @@ -157,7 +134,7 @@ diff --git a/gfx/angle/src/compiler/compilerdebug.h b/gfx/angle/src/compiler/com diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h --- a/gfx/angle/src/compiler/osinclude.h +++ b/gfx/angle/src/compiler/osinclude.h -@@ -30,17 +30,17 @@ +@@ -32,17 +32,17 @@ #include #elif defined(ANGLE_OS_POSIX) #include diff --git a/gfx/angle/angle-win64.patch b/gfx/angle/angle-win64.patch deleted file mode 100644 index 38863486cfcd..000000000000 --- a/gfx/angle/angle-win64.patch +++ /dev/null @@ -1,235 +0,0 @@ -diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp ---- a/gfx/angle/src/libEGL/Surface.cpp -+++ b/gfx/angle/src/libEGL/Surface.cpp -@@ -285,17 +285,17 @@ void Surface::subclassWindow() - DWORD processId; - DWORD threadId = GetWindowThreadProcessId(mWindow, &processId); - if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId()) - { - return; - } - - SetLastError(0); -- LONG oldWndProc = SetWindowLong(mWindow, GWL_WNDPROC, reinterpret_cast(SurfaceWindowProc)); -+ LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast(SurfaceWindowProc)); - if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS) - { - mWindowSubclassed = false; - return; - } - - SetProp(mWindow, kSurfaceProperty, reinterpret_cast(this)); - SetProp(mWindow, kParentWndProc, reinterpret_cast(oldWndProc)); -@@ -305,27 +305,27 @@ void Surface::subclassWindow() - void Surface::unsubclassWindow() - { - if(!mWindowSubclassed) - { - return; - } - - // un-subclass -- LONG parentWndFunc = reinterpret_cast(GetProp(mWindow, kParentWndProc)); -+ LONG_PTR parentWndFunc = reinterpret_cast(GetProp(mWindow, kParentWndProc)); - - // Check the windowproc is still SurfaceWindowProc. - // If this assert fails, then it is likely the application has subclassed the - // hwnd as well and did not unsubclass before destroying its EGL context. The - // application should be modified to either subclass before initializing the - // EGL context, or to unsubclass before destroying the EGL context. - if(parentWndFunc) - { -- LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc); -- ASSERT(prevWndFunc == reinterpret_cast(SurfaceWindowProc)); -+ LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc); -+ ASSERT(prevWndFunc == reinterpret_cast(SurfaceWindowProc)); - } - - RemoveProp(mWindow, kSurfaceProperty); - RemoveProp(mWindow, kParentWndProc); - mWindowSubclassed = false; - } - - bool Surface::checkForOutOfDateSwapChain() -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp ---- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp -@@ -50,24 +50,24 @@ VertexDataManager::~VertexDataManager() - delete mStreamingBuffer; - - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - delete mCurrentValueBuffer[i]; - } - } - --UINT VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute) -+std::size_t VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute) - { - Buffer *buffer = attribute.mBoundBuffer.get(); - - int inputStride = attribute.stride(); - int elementSize = attribute.typeSize(); - const FormatConverter &converter = formatConverter(attribute); -- UINT streamOffset = 0; -+ std::size_t streamOffset = 0; - - void *output = NULL; - - if (vertexBuffer) - { - output = vertexBuffer->map(attribute, spaceRequired(attribute, count), &streamOffset); - } - -@@ -198,17 +198,17 @@ GLenum VertexDataManager::prepareVertexD - return GL_INVALID_OPERATION; - } - - const FormatConverter &converter = formatConverter(attribs[i]); - - StaticVertexBuffer *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL; - ArrayVertexBuffer *vertexBuffer = staticBuffer ? staticBuffer : static_cast(mStreamingBuffer); - -- UINT streamOffset = -1; -+ std::size_t streamOffset = -1; - - if (staticBuffer) - { - streamOffset = staticBuffer->lookupAttribute(attribs[i]); - - if (streamOffset == -1) - { - // Convert the entire buffer -@@ -666,17 +666,17 @@ void StreamingVertexBuffer::reserveRequi - StaticVertexBuffer::StaticVertexBuffer(IDirect3DDevice9 *device) : ArrayVertexBuffer(device, 0, D3DUSAGE_WRITEONLY) - { - } - - StaticVertexBuffer::~StaticVertexBuffer() - { - } - --void *StaticVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, UINT *streamOffset) -+void *StaticVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset) - { - void *mapPtr = NULL; - - if (mVertexBuffer) - { - HRESULT result = mVertexBuffer->Lock(mWritePosition, requiredSpace, &mapPtr, 0); - - if (FAILED(result)) -diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h ---- a/gfx/angle/src/libGLESv2/VertexDataManager.h -+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h -@@ -30,17 +30,17 @@ struct TranslatedAttribute - UINT stride; // 0 means not to advance the read pointer at all - - IDirect3DVertexBuffer9 *vertexBuffer; - }; - - class VertexBuffer - { - public: -- VertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags); -+ VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags); - virtual ~VertexBuffer(); - - void unmap(); - - IDirect3DVertexBuffer9 *getBuffer() const; - - protected: - IDirect3DDevice9 *const mDevice; -@@ -55,60 +55,60 @@ class ConstantVertexBuffer : public Vert - public: - ConstantVertexBuffer(IDirect3DDevice9 *device, float x, float y, float z, float w); - ~ConstantVertexBuffer(); - }; - - class ArrayVertexBuffer : public VertexBuffer - { - public: -- ArrayVertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags); -+ ArrayVertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags); - ~ArrayVertexBuffer(); - -- UINT size() const { return mBufferSize; } -- virtual void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset) = 0; -+ std::size_t size() const { return mBufferSize; } -+ virtual void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset) = 0; - virtual void reserveRequiredSpace() = 0; - void addRequiredSpace(UINT requiredSpace); - - protected: -- UINT mBufferSize; -- UINT mWritePosition; -- UINT mRequiredSpace; -+ std::size_t mBufferSize; -+ std::size_t mWritePosition; -+ std::size_t mRequiredSpace; - }; - - class StreamingVertexBuffer : public ArrayVertexBuffer - { - public: -- StreamingVertexBuffer(IDirect3DDevice9 *device, UINT initialSize); -+ StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize); - ~StreamingVertexBuffer(); - -- void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset); -+ void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset); - void reserveRequiredSpace(); - }; - - class StaticVertexBuffer : public ArrayVertexBuffer - { - public: - explicit StaticVertexBuffer(IDirect3DDevice9 *device); - ~StaticVertexBuffer(); - -- void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset); -+ void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset); - void reserveRequiredSpace(); - - UINT lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found - - private: - struct VertexElement - { - GLenum type; - GLint size; - bool normalized; - int attributeOffset; - -- UINT streamOffset; -+ std::size_t streamOffset; - }; - - std::vector mCache; - }; - - class VertexDataManager - { - public: -@@ -117,18 +117,18 @@ class VertexDataManager - - void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; } - - GLenum prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *outAttribs); - - private: - DISALLOW_COPY_AND_ASSIGN(VertexDataManager); - -- UINT spaceRequired(const VertexAttribute &attrib, std::size_t count) const; -- UINT writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute); -+ std::size_t spaceRequired(const VertexAttribute &attrib, std::size_t count) const; -+ std::size_t writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute); - - Context *const mContext; - IDirect3DDevice9 *const mDevice; - - StreamingVertexBuffer *mStreamingBuffer; - - bool mDirtyCurrentValue[MAX_VERTEX_ATTRIBS]; - ConstantVertexBuffer *mCurrentValueBuffer[MAX_VERTEX_ATTRIBS]; diff --git a/gfx/angle/extensions/ANGLE_texture_compression_dxt.txt b/gfx/angle/extensions/ANGLE_texture_compression_dxt.txt new file mode 100644 index 000000000000..d1557300db89 --- /dev/null +++ b/gfx/angle/extensions/ANGLE_texture_compression_dxt.txt @@ -0,0 +1,73 @@ +Name + + ANGLE_texture_compression_dxt + +Name Strings + + GL_ANGLE_texture_compression_dxt3 + GL_ANGLE_texture_compression_dxt5 + +Contributors + + Gregg Tavares, Google Inc. + Daniel Koch, TransGaming Inc. + Al Patrick, Google Inc. + +Contacts + + Gregg Tavares, Google Inc. (gman 'at' google 'dot' com) + +Status + + Implemented in ANGLE ES2 + +Version + + Last Modified Date: Aug 2, 2011 + +Number + + OpenGL ES Extension #.. + +Dependencies + + Requires OpenGL ES 2.0. + + The extension is written against the OpenGL ES 2.0 specification. + +Overview + + These extensions are exactly the same as EXT_texture_compression_dxt1 + except they expose the formats COMPRESSED_RGBA_S3TC_DXT3_ANGLE and + COMPRESSED_RGBA_S3TC_DXT5_ANGLE respectively. + + See EXT_texture_compression_dxt1 for the full list of changes. Also + see EXT_texture_compression_s3tc for a description of the formats. + +New Procedures and Functions + + None. + +New Types + + None. + +New Tokens + + Accepted by the parameter of CompressedTexImage2D + and the parameter of CompressedTexSubImage2D: + + COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 + COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 + +Errors + + None. + +New State + + None. + +Revision History + + diff --git a/gfx/angle/extensions/EGL_ANGLE_software_display.txt b/gfx/angle/extensions/EGL_ANGLE_software_display.txt new file mode 100644 index 000000000000..c584817fc7c3 --- /dev/null +++ b/gfx/angle/extensions/EGL_ANGLE_software_display.txt @@ -0,0 +1,63 @@ +Name + + ANGLE_software_display + +Name Strings + + EGL_ANGLE_software_display + +Contributors + + John Bauman + Daniel Koch + +Contacts + + John Bauman, Google Inc. (jbauman 'at' chromium.org) + +Status + + In progress + +Version + + Version 1, July 12, 2011 + +Number + + EGL Extension #?? + +Dependencies + + This extension is written against the wording of the EGL 1.4 + Specification. + +Overview + + This extension allows for receiving a device that uses software rendering. + +New Types + + None + +New Procedures and Functions + + None + +New Tokens + + None + +Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors) + + Add before the last sentence of the first paragraph of section 3.2, + "Initialization": + + "If is EGL_SOFTWARE_DISPLAY_ANGLE, a display that will render + everything in software will be returned." + +Issues + +Revision History + + Version 1, 2011/07/12 - first draft. diff --git a/gfx/angle/fix-angle-surface-assert.patch b/gfx/angle/fix-angle-surface-assert.patch deleted file mode 100644 index c06773eea857..000000000000 --- a/gfx/angle/fix-angle-surface-assert.patch +++ /dev/null @@ -1,42 +0,0 @@ -# HG changeset patch -# Parent 9869d707ee367a9a108b663c71388cdea4abb705 - -diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp ---- a/gfx/angle/src/libEGL/Surface.cpp -+++ b/gfx/angle/src/libEGL/Surface.cpp -@@ -210,33 +210,33 @@ bool Surface::resetSwapChain(int backbuf - } - - result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET, - presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); - } - - if (FAILED(result)) - { -- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); -+ ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); - - ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result); - release(); - return error(EGL_BAD_ALLOC, false); - } - - if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN) - { - result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, - presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType, - presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL); - } - - if (FAILED(result)) - { -- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); -+ ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); - - ERR("Could not create depthstencil surface for new swap chain: %08lX", result); - release(); - return error(EGL_BAD_ALLOC, false); - } - - if (mWindow) { - mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mRenderTarget); diff --git a/gfx/angle/include/EGL/eglext.h b/gfx/angle/include/EGL/eglext.h index b650a500c490..e2ac233fe0b1 100644 --- a/gfx/angle/include/EGL/eglext.h +++ b/gfx/angle/include/EGL/eglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2007-2009 The Khronos Group Inc. +** Copyright (c) 2007-2010 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -34,8 +34,8 @@ extern "C" { /* Header file version number */ /* Current version at http://www.khronos.org/registry/egl/ */ -/* $Revision: 10795 $ on $Date: 2010-03-19 17:04:17 -0700 (Fri, 19 Mar 2010) $ */ -#define EGL_EGLEXT_VERSION 5 +/* $Revision: 15052 $ on $Date: 2011-07-06 17:43:46 -0700 (Wed, 06 Jul 2011) $ */ +#define EGL_EGLEXT_VERSION 10 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 @@ -120,6 +120,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL #define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ #endif +#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ #ifndef EGL_KHR_reusable_sync #define EGL_KHR_reusable_sync 1 @@ -149,6 +150,7 @@ typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSy typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #endif +#endif #ifndef EGL_KHR_image_base #define EGL_KHR_image_base 1 @@ -169,6 +171,11 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #endif +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif + #ifndef EGL_NV_coverage_sample #define EGL_NV_coverage_sample 1 #define EGL_COVERAGE_BUFFERS_NV 0x30E0 @@ -182,6 +189,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG #define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 #endif +#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */ #ifndef EGL_NV_sync #define EGL_NV_sync 1 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 @@ -198,7 +206,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG #define EGL_SYNC_FENCE_NV 0x30EF #define EGL_NO_SYNC_NV ((EGLSyncNV)0) typedef void* EGLSyncNV; -typedef unsigned long long EGLTimeNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef EGL_EGLEXT_PROTOTYPES EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); EGLBoolean eglDestroySyncNV (EGLSyncNV sync); @@ -214,6 +222,76 @@ typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif +#endif + +#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */ +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */ +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +#endif +#endif + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 + +/* Surface Attribute */ +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +/* + * Structure representing a client pixmap + * (pixmap's data is in client-space memory). + */ +struct EGLClientPixmapHI +{ + void* pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; + +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +/* Config Attribute */ +#define EGL_COLOR_FORMAT_HI 0x8F70 +/* Color Formats */ +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */ +#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */ +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */ +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */ +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif #ifndef EGL_ANGLE_query_surface_pointer #define EGL_ANGLE_query_surface_pointer 1 @@ -224,8 +302,35 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay #endif #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif + +#ifndef EGL_ANGLE_software_display +#define EGL_ANGLE_software_display 1 +#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) +#endif + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 + +typedef khronos_utime_nanoseconds_t EGLuint64NV; + +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#endif #endif #ifdef __cplusplus diff --git a/gfx/angle/include/EGL/eglplatform.h b/gfx/angle/include/EGL/eglplatform.h index 22e855f56cad..299eac52bcd4 100644 --- a/gfx/angle/include/EGL/eglplatform.h +++ b/gfx/angle/include/EGL/eglplatform.h @@ -25,7 +25,7 @@ */ /* Platform-specific types and definitions for egl.h - * $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $ + * $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ * * Adopters may modify khrplatform.h and this file to suit their platform. * You are encouraged to submit all modifications to the Khronos group so that @@ -60,6 +60,11 @@ * Windows Device Context. They must be defined in platform-specific * code below. The EGL-prefixed versions of Native*Type are the same * types, renamed in EGL 1.3 so all types in the API start with "EGL". + * + * Khronos STRONGLY RECOMMENDS that you use the default definitions + * provided below, since these changes affect both binary and source + * portability of applications using EGL running on different EGL + * implementations. */ #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ @@ -78,6 +83,12 @@ typedef int EGLNativeDisplayType; typedef void *EGLNativeWindowType; typedef void *EGLNativePixmapType; +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + #elif defined(__unix__) /* X11 (tentative) */ diff --git a/gfx/angle/include/GLES2/gl2ext.h b/gfx/angle/include/GLES2/gl2ext.h index 01844de4b620..9371ad7d8f82 100644 --- a/gfx/angle/include/GLES2/gl2ext.h +++ b/gfx/angle/include/GLES2/gl2ext.h @@ -1,7 +1,7 @@ #ifndef __gl2ext_h_ #define __gl2ext_h_ -/* $Revision: 10798 $ on $Date:: 2010-03-19 17:34:30 -0700 #$ */ +/* $Revision: 15049 $ on $Date:: 2011-07-06 17:28:16 -0700 #$ */ #ifdef __cplusplus extern "C" { @@ -57,6 +57,15 @@ extern "C" { typedef void* GLeglImageOES; #endif +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +/* GLeglImageOES defined in GL_OES_EGL_image already. */ +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#endif + /* GL_OES_element_index_uint */ #ifndef GL_OES_element_index_uint #define GL_UNSIGNED_INT 0x1405 @@ -179,6 +188,79 @@ typedef void* GLeglImageOES; #define GL_Z400_BINARY_AMD 0x8740 #endif +/*------------------------------------------------------------------------* + * ANGLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif + +/*------------------------------------------------------------------------* + * ARM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif + +/* GL_ARM_rgba8 */ +/* No new tokens introduced by this extension. */ + /*------------------------------------------------------------------------* * EXT extension tokens *------------------------------------------------------------------------*/ @@ -206,6 +288,9 @@ typedef void* GLeglImageOES; #define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 #endif +/* GL_EXT_shader_texture_lod */ +/* No new tokens introduced by this extension. */ + /* GL_EXT_texture_filter_anisotropic */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE @@ -228,6 +313,22 @@ typedef void* GLeglImageOES; #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #endif +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#endif + +/*------------------------------------------------------------------------* + * DMP extension tokens + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_SHADER_BINARY_DMP 0x9250 +#endif + /*------------------------------------------------------------------------* * IMG extension tokens *------------------------------------------------------------------------*/ @@ -256,17 +357,18 @@ typedef void* GLeglImageOES; #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 #endif +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +#endif + /*------------------------------------------------------------------------* * NV extension tokens *------------------------------------------------------------------------*/ -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - /* GL_NV_coverage_sample */ #ifndef GL_NV_coverage_sample #define GL_COVERAGE_COMPONENT_NV 0x8ED0 @@ -285,10 +387,90 @@ typedef void* GLeglImageOES; #define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C #endif +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_READ_BUFFER_NV 0x0C02 +#endif + +/* GL_NV_read_buffer_front */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_compression_s3tc_update */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_npot_2D_mipmap */ +/* No new tokens introduced by this extension. */ + /*------------------------------------------------------------------------* * QCOM extension tokens *------------------------------------------------------------------------*/ +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +#endif + /* GL_QCOM_driver_control */ /* No new tokens introduced by this extension. */ @@ -357,22 +539,12 @@ typedef void* GLeglImageOES; #endif /*------------------------------------------------------------------------* - * ANGLE extension tokens + * VIV extension tokens *------------------------------------------------------------------------*/ -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 // alias GL_FRAMEBUFFER_BINDING -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_SHADER_BINARY_VIV 0x8FC4 #endif /*------------------------------------------------------------------------* @@ -419,6 +591,12 @@ typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); #endif +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ +#endif + /* GL_OES_element_index_uint */ #ifndef GL_OES_element_index_uint #define GL_OES_element_index_uint 1 @@ -600,6 +778,82 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito #define GL_AMD_program_binary_Z400 1 #endif +/*------------------------------------------------------------------------* + * ANGLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#endif + +/*------------------------------------------------------------------------* + * ARM extension functions + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#endif + +/* GL_ARM_rgba8 */ +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif + /*------------------------------------------------------------------------* * EXT extension functions *------------------------------------------------------------------------*/ @@ -633,6 +887,11 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL #define GL_EXT_read_format_bgra 1 #endif +/* GL_EXT_shader_texture_lod */ +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif + /* GL_EXT_texture_filter_anisotropic */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_EXT_texture_filter_anisotropic 1 @@ -653,6 +912,20 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL #define GL_EXT_texture_compression_dxt1 1 #endif +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#endif + +/*------------------------------------------------------------------------* + * DMP extension functions + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#endif + /*------------------------------------------------------------------------* * IMG extension functions *------------------------------------------------------------------------*/ @@ -677,10 +950,51 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL #define GL_IMG_texture_compression_pvrtc 1 #endif +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + /*------------------------------------------------------------------------* * NV extension functions *------------------------------------------------------------------------*/ +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#endif + /* GL_NV_fence */ #ifndef GL_NV_fence #define GL_NV_fence 1 @@ -702,26 +1016,58 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #endif -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 #ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); #endif -typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); -typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); #endif -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 +/* GL_NV_read_buffer_front */ +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif + +/* GL_NV_read_depth */ +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif + +/* GL_NV_read_depth_stencil */ +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif + +/* GL_NV_read_stencil */ +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif + +/* GL_NV_texture_compression_s3tc_update */ +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif + +/* GL_NV_texture_npot_2D_mipmap */ +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 #endif /*------------------------------------------------------------------------* * QCOM extension functions *------------------------------------------------------------------------*/ +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#endif + /* GL_QCOM_driver_control */ #ifndef GL_QCOM_driver_control #define GL_QCOM_driver_control 1 @@ -797,31 +1143,12 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); #endif /*------------------------------------------------------------------------* - * ANGLE extension functions + * VIV extension tokens *------------------------------------------------------------------------*/ -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, - GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, - GLsizei width, GLsizei height); +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 #endif #ifdef __cplusplus diff --git a/gfx/angle/include/GLSLANG/ShaderLang.h b/gfx/angle/include/GLSLANG/ShaderLang.h index 6795a87ee931..91af12af7e83 100644 --- a/gfx/angle/include/GLSLANG/ShaderLang.h +++ b/gfx/angle/include/GLSLANG/ShaderLang.h @@ -17,7 +17,7 @@ extern "C" { // Version number for shader translation API. // It is incremented everytime the API changes. -#define SH_VERSION 104 +#define SH_VERSION 105 // // The names of the following enums have been derived by replacing GL prefix @@ -35,6 +35,12 @@ typedef enum { SH_WEBGL_SPEC = 0x8B41 } ShShaderSpec; +typedef enum { + SH_ESSL_OUTPUT = 0x8B45, + SH_GLSL_OUTPUT = 0x8B46, + SH_HLSL_OUTPUT = 0x8B47 +} ShShaderOutput; + typedef enum { SH_NONE = 0, SH_INT = 0x1404, @@ -75,7 +81,11 @@ typedef enum { SH_ATTRIBUTES_UNIFORMS = 0x0008, SH_LINE_DIRECTIVES = 0x0010, SH_SOURCE_PATH = 0x0020, - SH_MAP_LONG_VARIABLE_NAMES = 0x0040 + SH_MAP_LONG_VARIABLE_NAMES = 0x0040, + SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0080, + + // This is needed only as a workaround for certain OpenGL driver bugs. + SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100 } ShCompileOptions; // @@ -109,6 +119,7 @@ typedef struct // Extensions. // Set to 1 to enable the extension, else 0. int OES_standard_derivatives; + int OES_EGL_image_external; } ShBuiltInResources; // @@ -128,13 +139,17 @@ typedef void* ShHandle; // // Driver calls these to create and destroy compiler objects. // -// Returns the handle of constructed compiler. +// Returns the handle of constructed compiler, null if the requested compiler is +// not supported. // Parameters: // type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER. // spec: Specifies the language spec the compiler must conform to - // SH_GLES2_SPEC or SH_WEBGL_SPEC. +// output: Specifies the output code type - SH_ESSL_OUTPUT, SH_GLSL_OUTPUT, +// or SH_HLSL_OUTPUT. // resources: Specifies the built-in resources. ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, + ShShaderOutput output, const ShBuiltInResources* resources); void ShDestruct(ShHandle handle); diff --git a/gfx/angle/samples/translator/translator.cpp b/gfx/angle/samples/translator/translator.cpp index fb1fb490a0ea..f22776019859 100644 --- a/gfx/angle/samples/translator/translator.cpp +++ b/gfx/angle/samples/translator/translator.cpp @@ -53,6 +53,7 @@ void GenerateResources(ShBuiltInResources* resources) resources->MaxDrawBuffers = 1; resources->OES_standard_derivatives = 0; + resources->OES_EGL_image_external = 0; } int main(int argc, char* argv[]) @@ -66,6 +67,7 @@ int main(int argc, char* argv[]) char* buffer = 0; int bufferLen = 0; int numAttribs = 0, numUniforms = 0; + ShShaderOutput output = SH_ESSL_OUTPUT; ShInitialize(); @@ -81,6 +83,21 @@ int main(int argc, char* argv[]) case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break; case 'o': compileOptions |= SH_OBJECT_CODE; break; case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break; + case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; break; + case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break; + case 'b': + if (argv[0][2] == '=') { + switch (argv[0][3]) { + case 'e': output = SH_ESSL_OUTPUT; break; + case 'g': output = SH_GLSL_OUTPUT; break; + case 'h': output = SH_HLSL_OUTPUT; break; + default: failCode = EFailUsage; + } + } else { + failCode = EFailUsage; + } + break; + case 'a': resources.OES_EGL_image_external = 1; break; default: failCode = EFailUsage; } } else { @@ -88,12 +105,14 @@ int main(int argc, char* argv[]) switch (FindShaderType(argv[0])) { case SH_VERTEX_SHADER: if (vertexCompiler == 0) - vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources); + vertexCompiler = ShConstructCompiler( + SH_VERTEX_SHADER, SH_GLES2_SPEC, output, &resources); compiler = vertexCompiler; break; case SH_FRAGMENT_SHADER: if (fragmentCompiler == 0) - fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources); + fragmentCompiler = ShConstructCompiler( + SH_FRAGMENT_SHADER, SH_GLES2_SPEC, output, &resources); compiler = fragmentCompiler; break; default: break; @@ -159,12 +178,18 @@ int main(int argc, char* argv[]) // void usage() { - printf("Usage: translate [-i -m -o -u] file1 file2 ...\n" - "Where: filename = filename ending in .frag or .vert\n" - " -i = print intermediate tree\n" - " -m = map long variable names\n" - " -o = print translated code\n" - " -u = print active attribs and uniforms\n"); + printf("Usage: translate [-i -m -o -u -l -e -b=e -b=g -b=h -a] file1 file2 ...\n" + "Where: filename : filename ending in .frag or .vert\n" + " -i : print intermediate tree\n" + " -m : map long variable names\n" + " -o : print translated code\n" + " -u : print active attribs and uniforms\n" + " -l : unroll for-loops with integer indices\n" + " -e : emulate certain built-in functions (workaround for driver bugs)\n" + " -b=e : output GLSL ES code (this is by default)\n" + " -b=g : output GLSL code\n" + " -b=h : output HLSL code\n" + " -a : enable GL_OES_EGL_image_external\n"); } // diff --git a/gfx/angle/src/ANGLE.sln b/gfx/angle/src/ANGLE.sln index d37d08df93ff..4807f6961b8b 100644 --- a/gfx/angle/src/ANGLE.sln +++ b/gfx/angle/src/ANGLE.sln @@ -21,25 +21,43 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.ActiveCfg = Debug|Win32 {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.Build.0 = Debug|Win32 + {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.ActiveCfg = Debug|x64 + {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.Build.0 = Debug|x64 {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.ActiveCfg = Release|Win32 {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.Build.0 = Release|Win32 + {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.ActiveCfg = Release|x64 + {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.Build.0 = Release|x64 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.ActiveCfg = Debug|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32 + {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.ActiveCfg = Debug|x64 + {B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.Build.0 = Debug|x64 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32 {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32 + {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.ActiveCfg = Release|x64 + {B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.Build.0 = Release|x64 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32 + {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.ActiveCfg = Debug|x64 + {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.Build.0 = Debug|x64 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32 {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32 + {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.ActiveCfg = Release|x64 + {5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.Build.0 = Release|x64 {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32 {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32 + {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.ActiveCfg = Debug|x64 + {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.Build.0 = Debug|x64 {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32 {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.Build.0 = Release|Win32 + {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.ActiveCfg = Release|x64 + {5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp index e94a9046ff7e..bd868003cd22 100644 --- a/gfx/angle/src/build_angle.gyp +++ b/gfx/angle/src/build_angle.gyp @@ -19,11 +19,17 @@ ], 'sources': [ 'compiler/BaseTypes.h', + 'compiler/BuiltInFunctionEmulator.cpp', + 'compiler/BuiltInFunctionEmulator.h', 'compiler/Common.h', 'compiler/Compiler.cpp', 'compiler/ConstantUnion.h', - 'compiler/compilerdebug.cpp', - 'compiler/compilerdebug.h', + 'compiler/debug.cpp', + 'compiler/debug.h', + 'compiler/DetectRecursion.cpp', + 'compiler/DetectRecursion.h', + 'compiler/ForLoopUnroll.cpp', + 'compiler/ForLoopUnroll.h', 'compiler/glslang.h', 'compiler/glslang_lex.cpp', 'compiler/glslang_tab.cpp', @@ -59,7 +65,6 @@ 'compiler/SymbolTable.cpp', 'compiler/SymbolTable.h', 'compiler/Types.h', - 'compiler/unistd.h', 'compiler/util.cpp', 'compiler/util.h', 'compiler/ValidateLimitations.cpp', @@ -102,10 +107,14 @@ ], 'sources': [ 'compiler/CodeGenGLSL.cpp', - 'compiler/ForLoopUnroll.cpp', - 'compiler/ForLoopUnroll.h', + 'compiler/OutputESSL.cpp', + 'compiler/OutputESSL.h', + 'compiler/OutputGLSLBase.cpp', + 'compiler/OutputGLSLBase.h', 'compiler/OutputGLSL.cpp', 'compiler/OutputGLSL.h', + 'compiler/TranslatorESSL.cpp', + 'compiler/TranslatorESSL.h', 'compiler/TranslatorGLSL.cpp', 'compiler/TranslatorGLSL.h', 'compiler/VersionGLSL.cpp', @@ -169,6 +178,7 @@ 'libGLESv2/HandleAllocator.h', 'libGLESv2/libGLESv2.cpp', 'libGLESv2/libGLESv2.def', + 'libGLESv2/libGLESv2.rc', 'libGLESv2/main.cpp', 'libGLESv2/main.h', 'libGLESv2/mathutil.h', @@ -217,6 +227,7 @@ 'libEGL/Display.h', 'libEGL/libEGL.cpp', 'libEGL/libEGL.def', + 'libEGL/libEGL.rc', 'libEGL/main.cpp', 'libEGL/main.h', 'libEGL/Surface.cpp', diff --git a/gfx/angle/src/common/version.h b/gfx/angle/src/common/version.h index 9462f0706321..03559ee55c28 100644 --- a/gfx/angle/src/common/version.h +++ b/gfx/angle/src/common/version.h @@ -1,7 +1,7 @@ #define MAJOR_VERSION 0 #define MINOR_VERSION 0 #define BUILD_VERSION 0 -#define BUILD_REVISION 686 +#define BUILD_REVISION 740 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/gfx/angle/src/compiler/BaseTypes.h b/gfx/angle/src/compiler/BaseTypes.h index 9f4a86020499..57e1d80a992d 100644 --- a/gfx/angle/src/compiler/BaseTypes.h +++ b/gfx/angle/src/compiler/BaseTypes.h @@ -42,6 +42,7 @@ enum TBasicType EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtSampler2D, EbtSamplerCube, + EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists. EbtGuardSamplerEnd, // non type: see implementation of IsSampler() EbtStruct, EbtAddress, // should be deprecated?? @@ -57,6 +58,7 @@ inline const char* getBasicString(TBasicType t) case EbtBool: return "bool"; break; case EbtSampler2D: return "sampler2D"; break; case EbtSamplerCube: return "samplerCube"; break; + case EbtSamplerExternalOES: return "samplerExternalOES"; break; case EbtStruct: return "structure"; break; default: return "unknown type"; } diff --git a/gfx/angle/src/compiler/BuiltInFunctionEmulator.cpp b/gfx/angle/src/compiler/BuiltInFunctionEmulator.cpp new file mode 100644 index 000000000000..86f67f4bcb57 --- /dev/null +++ b/gfx/angle/src/compiler/BuiltInFunctionEmulator.cpp @@ -0,0 +1,161 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/BuiltInFunctionEmulator.h" + +#include "compiler/SymbolTable.h" + +namespace { + +const char* kFunctionEmulationSource[] = { + "float webgl_normalize_emu(float a) { return normalize(a) * 1; }", + "vec2 webgl_normalize_emu(vec2 a) { return normalize(a) * 1; }", + "vec3 webgl_normalize_emu(vec3 a) { return normalize(a) * 1; }", + "vec4 webgl_normalize_emu(vec4 a) { return normalize(a) * 1; }", + "float webgl_abs_emu(float a) { float rt = abs(a); if (rt < 0.0) rt = 0.0; return rt; }", + "vec2 webgl_abs_emu(vec2 a) { vec2 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }", + "vec3 webgl_abs_emu(vec3 a) { vec3 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }", + "vec4 webgl_abs_emu(vec4 a) { vec4 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }", + "float webgl_sign_emu(float a) { float rt = sign(a); if (rt > 1.0) rt = 1.0; return rt; }", + "vec2 webgl_sign_emu(vec2 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }", + "vec3 webgl_sign_emu(vec3 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }", + "vec4 webgl_sign_emu(vec4 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }", +}; + +class BuiltInFunctionEmulationMarker : public TIntermTraverser { +public: + BuiltInFunctionEmulationMarker(BuiltInFunctionEmulator& emulator) + : mEmulator(emulator) + { + } + + virtual bool visitUnary(Visit visit, TIntermUnary* node) + { + if (visit == PreVisit) { + bool needToEmulate = mEmulator.SetFunctionCalled( + node->getOp(), node->getOperand()->getType()); + if (needToEmulate) + node->setUseEmulatedFunction(); + } + return true; + } + +private: + BuiltInFunctionEmulator& mEmulator; +}; + +} // anonymous namepsace + +BuiltInFunctionEmulator::BuiltInFunctionEmulator() + : mFunctionGroupMask(TFunctionGroupAll) +{ +} + +void BuiltInFunctionEmulator::SetFunctionGroupMask( + unsigned int functionGroupMask) +{ + mFunctionGroupMask = functionGroupMask; +} + +bool BuiltInFunctionEmulator::SetFunctionCalled( + TOperator op, const TType& returnType) +{ + TBuiltInFunction function = IdentifyFunction(op, returnType); + if (function == TFunctionUnknown) + return false; + for (size_t i = 0; i < mFunctions.size(); ++i) { + if (mFunctions[i] == function) + return true; + } + switch (function) { + case TFunctionNormalize1: + case TFunctionNormalize2: + case TFunctionNormalize3: + case TFunctionNormalize4: + if (mFunctionGroupMask & TFunctionGroupNormalize) { + mFunctions.push_back(function); + return true; + } + break; + case TFunctionAbs1: + case TFunctionAbs2: + case TFunctionAbs3: + case TFunctionAbs4: + if (mFunctionGroupMask & TFunctionGroupAbs) { + mFunctions.push_back(function); + return true; + } + break; + case TFunctionSign1: + case TFunctionSign2: + case TFunctionSign3: + case TFunctionSign4: + if (mFunctionGroupMask & TFunctionGroupSign) { + mFunctions.push_back(function); + return true; + } + break; + default: + UNREACHABLE(); + break; + } + return false; +} + +void BuiltInFunctionEmulator::OutputEmulatedFunctionDefinition( + TInfoSinkBase& out, bool withPrecision) const +{ + if (mFunctions.size() == 0) + return; + out << "// BEGIN: Generated code for built-in function emulation\n\n"; + if (withPrecision) { + out << "#if defined(GL_FRAGMENT_PRECISION_HIGH) && (GL_FRAGMENT_PRECISION_HIGH == 1)\n" + << "precision highp float;\n" + << "#else\n" + << "precision mediump float;\n" + << "#endif\n\n"; + } + for (size_t i = 0; i < mFunctions.size(); ++i) { + out << kFunctionEmulationSource[mFunctions[i]] << "\n\n"; + } + out << "// END: Generated code for built-in function emulation\n\n"; +} + +BuiltInFunctionEmulator::TBuiltInFunction +BuiltInFunctionEmulator::IdentifyFunction(TOperator op, const TType& returnType) +{ + unsigned int function = TFunctionUnknown; + if (op == EOpNormalize) + function = TFunctionNormalize1; + else if (op == EOpAbs) + function = TFunctionAbs1; + else if (op == EOpSign) + function = TFunctionSign1; + else + return static_cast(function); + + if (returnType.isVector()) + function += returnType.getNominalSize() - 1; + return static_cast(function); +} + +void BuiltInFunctionEmulator::MarkBuiltInFunctionsForEmulation( + TIntermNode* root) +{ + ASSERT(root); + + BuiltInFunctionEmulationMarker marker(*this); + root->traverse(&marker); +} + +//static +TString BuiltInFunctionEmulator::GetEmulatedFunctionName( + const TString& name) +{ + ASSERT(name[name.length() - 1] == '('); + return "webgl_" + name.substr(0, name.length() - 1) + "_emu("; +} + diff --git a/gfx/angle/src/compiler/BuiltInFunctionEmulator.h b/gfx/angle/src/compiler/BuiltInFunctionEmulator.h new file mode 100644 index 000000000000..3d90418bb003 --- /dev/null +++ b/gfx/angle/src/compiler/BuiltInFunctionEmulator.h @@ -0,0 +1,86 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_ +#define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_ + +#include "compiler/InfoSink.h" +#include "compiler/intermediate.h" + +// +// Built-in function groups. We only list the ones that might need to be +// emulated in certain os/drivers, assuming they are no more than 32. +// +enum TBuiltInFunctionGroup { + TFunctionGroupNormalize = 1 << 0, + TFunctionGroupAbs = 1 << 1, + TFunctionGroupSign = 1 << 2, + TFunctionGroupAll = + TFunctionGroupNormalize | TFunctionGroupAbs | TFunctionGroupSign +}; + +// +// This class decides which built-in functions need to be replaced with the +// emulated ones. +// It's only a workaround for OpenGL driver bugs, and isn't needed in general. +// +class BuiltInFunctionEmulator { +public: + BuiltInFunctionEmulator(); + + // functionGroupMask is a bitmap of TBuiltInFunctionGroup. + // We only emulate functions that are marked by this mask and are actually + // called in a given shader. + // By default the value is TFunctionGroupAll. + void SetFunctionGroupMask(unsigned int functionGroupMask); + + // Records that a function is called by the shader and might needs to be + // emulated. If the function's group is not in mFunctionGroupFilter, this + // becomes an no-op. + // Returns true if the function call needs to be replaced with an emulated + // one. + // TODO(zmo): for now, an operator and a return type is enough to identify + // the function we want to emulate. Should make this more flexible to + // handle any functions. + bool SetFunctionCalled(TOperator op, const TType& returnType); + + // Output function emulation definition. This should be before any other + // shader source. + void OutputEmulatedFunctionDefinition(TInfoSinkBase& out, bool withPrecision) const; + + void MarkBuiltInFunctionsForEmulation(TIntermNode* root); + + // "name(" becomes "webgl_name_emu(". + static TString GetEmulatedFunctionName(const TString& name); + +private: + // + // Built-in functions. + // + enum TBuiltInFunction { + TFunctionNormalize1 = 0, // float normalize(float); + TFunctionNormalize2, // vec2 normalize(vec2); + TFunctionNormalize3, // vec3 normalize(vec3); + TFunctionNormalize4, // fec4 normalize(vec4); + TFunctionAbs1, // float abs(float); + TFunctionAbs2, // vec2 abs(vec2); + TFunctionAbs3, // vec3 abs(vec3); + TFunctionAbs4, // vec4 abs(vec4); + TFunctionSign1, // float sign(float); + TFunctionSign2, // vec2 sign(vec2); + TFunctionSign3, // vec3 sign(vec3); + TFunctionSign4, // vec4 sign(vec4); + TFunctionUnknown + }; + + // Same TODO as SetFunctionCalled. + TBuiltInFunction IdentifyFunction(TOperator op, const TType& returnType); + + TVector mFunctions; + unsigned int mFunctionGroupMask; // a bitmap of TBuiltInFunctionGroup. +}; + +#endif // COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_ diff --git a/gfx/angle/src/compiler/CodeGenGLSL.cpp b/gfx/angle/src/compiler/CodeGenGLSL.cpp index d140b375f710..226bf8f0fc0e 100644 --- a/gfx/angle/src/compiler/CodeGenGLSL.cpp +++ b/gfx/angle/src/compiler/CodeGenGLSL.cpp @@ -5,15 +5,24 @@ // #include "compiler/TranslatorGLSL.h" +#include "compiler/TranslatorESSL.h" // // This function must be provided to create the actual // compile object used by higher level code. It returns // a subclass of TCompiler. // -TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec) +TCompiler* ConstructCompiler( + ShShaderType type, ShShaderSpec spec, ShShaderOutput output) { - return new TranslatorGLSL(type, spec); + switch (output) { + case SH_GLSL_OUTPUT: + return new TranslatorGLSL(type, spec); + case SH_ESSL_OUTPUT: + return new TranslatorESSL(type, spec); + default: + return NULL; + } } // diff --git a/gfx/angle/src/compiler/CodeGenHLSL.cpp b/gfx/angle/src/compiler/CodeGenHLSL.cpp index e04e78944159..f46ff66d40fb 100644 --- a/gfx/angle/src/compiler/CodeGenHLSL.cpp +++ b/gfx/angle/src/compiler/CodeGenHLSL.cpp @@ -11,9 +11,15 @@ // compile object used by higher level code. It returns // a subclass of TCompiler. // -TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec) +TCompiler* ConstructCompiler( + ShShaderType type, ShShaderSpec spec, ShShaderOutput output) { - return new TranslatorHLSL(type, spec); + switch (output) { + case SH_HLSL_OUTPUT: + return new TranslatorHLSL(type, spec); + default: + return NULL; + } } // diff --git a/gfx/angle/src/compiler/Compiler.cpp b/gfx/angle/src/compiler/Compiler.cpp index 1c0b2dbb9b61..554222543ce8 100644 --- a/gfx/angle/src/compiler/Compiler.cpp +++ b/gfx/angle/src/compiler/Compiler.cpp @@ -4,7 +4,9 @@ // found in the LICENSE file. // +#include "compiler/BuiltInFunctionEmulator.h" #include "compiler/DetectRecursion.h" +#include "compiler/ForLoopUnroll.h" #include "compiler/Initialize.h" #include "compiler/ParseHelper.h" #include "compiler/ShHandle.h" @@ -19,7 +21,10 @@ bool InitializeSymbolTable( { TIntermediate intermediate(infoSink); TExtensionBehavior extBehavior; - TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, NULL, infoSink); + InitExtensionBehavior(resources, extBehavior); + // The builtins deliberately don't specify precisions for the function + // arguments and return types. For that reason we don't try to check them. + TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink); GlobalParseContext = &parseContext; @@ -128,7 +133,7 @@ bool TCompiler::compile(const char* const shaderStrings[], TIntermediate intermediate(infoSink); TParseContext parseContext(symbolTable, extensionBehavior, intermediate, - shaderType, shaderSpec, compileOptions, + shaderType, shaderSpec, compileOptions, true, sourcePath, infoSink); GlobalParseContext = &parseContext; @@ -152,6 +157,14 @@ bool TCompiler::compile(const char* const shaderStrings[], if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING)) success = validateLimitations(root); + // Unroll for-loop markup needs to happen after validateLimitations pass. + if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX)) + ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(root); + + // Built-in function emulation needs to happen after validateLimitations pass. + if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS)) + builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root); + // Call mapLongVariableNames() before collectAttribsUniforms() so in // collectAttribsUniforms() we already have the mapped symbol names and // we could composite mapped and original variable names. @@ -238,3 +251,13 @@ int TCompiler::getMappedNameMaxLength() const { return MAX_IDENTIFIER_NAME_SIZE + 1; } + +const TExtensionBehavior& TCompiler::getExtensionBehavior() const +{ + return extensionBehavior; +} + +const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const +{ + return builtInFunctionEmulator; +} diff --git a/gfx/angle/src/compiler/DetectRecursion.cpp b/gfx/angle/src/compiler/DetectRecursion.cpp index 3d8a40de7ac2..b4354fc794be 100644 --- a/gfx/angle/src/compiler/DetectRecursion.cpp +++ b/gfx/angle/src/compiler/DetectRecursion.cpp @@ -64,29 +64,6 @@ DetectRecursion::~DetectRecursion() delete functions[i]; } -void DetectRecursion::visitSymbol(TIntermSymbol*) -{ -} - -void DetectRecursion::visitConstantUnion(TIntermConstantUnion*) -{ -} - -bool DetectRecursion::visitBinary(Visit, TIntermBinary*) -{ - return true; -} - -bool DetectRecursion::visitUnary(Visit, TIntermUnary*) -{ - return true; -} - -bool DetectRecursion::visitSelection(Visit, TIntermSelection*) -{ - return true; -} - bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node) { switch (node->getOp()) @@ -126,16 +103,6 @@ bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node) return true; } -bool DetectRecursion::visitLoop(Visit, TIntermLoop*) -{ - return true; -} - -bool DetectRecursion::visitBranch(Visit, TIntermBranch*) -{ - return true; -} - DetectRecursion::ErrorCode DetectRecursion::detectRecursion() { FunctionNode* main = findFunctionByName("main("); diff --git a/gfx/angle/src/compiler/DetectRecursion.h b/gfx/angle/src/compiler/DetectRecursion.h index 03dadfe4b262..bbac79dc9ce6 100644 --- a/gfx/angle/src/compiler/DetectRecursion.h +++ b/gfx/angle/src/compiler/DetectRecursion.h @@ -24,14 +24,7 @@ public: DetectRecursion(); ~DetectRecursion(); - virtual void visitSymbol(TIntermSymbol*); - virtual void visitConstantUnion(TIntermConstantUnion*); - virtual bool visitBinary(Visit, TIntermBinary*); - virtual bool visitUnary(Visit, TIntermUnary*); - virtual bool visitSelection(Visit, TIntermSelection*); virtual bool visitAggregate(Visit, TIntermAggregate*); - virtual bool visitLoop(Visit, TIntermLoop*); - virtual bool visitBranch(Visit, TIntermBranch*); ErrorCode detectRecursion(); diff --git a/gfx/angle/src/compiler/ExtensionBehavior.h b/gfx/angle/src/compiler/ExtensionBehavior.h index da96c2435ff4..e9bba4b23553 100644 --- a/gfx/angle/src/compiler/ExtensionBehavior.h +++ b/gfx/angle/src/compiler/ExtensionBehavior.h @@ -13,9 +13,26 @@ typedef enum { EBhRequire, EBhEnable, EBhWarn, - EBhDisable + EBhDisable, + EBhUndefined, } TBehavior; +inline const char* getBehaviorString(TBehavior b) +{ + switch(b) { + case EBhRequire: + return "require"; + case EBhEnable: + return "enable"; + case EBhWarn: + return "warn"; + case EBhDisable: + return "disable"; + default: + return NULL; + } +} + typedef TMap TExtensionBehavior; #endif // _EXTENSION_TABLE_INCLUDED_ diff --git a/gfx/angle/src/compiler/ForLoopUnroll.cpp b/gfx/angle/src/compiler/ForLoopUnroll.cpp index d631af44fc62..fdc3f44431e0 100644 --- a/gfx/angle/src/compiler/ForLoopUnroll.cpp +++ b/gfx/angle/src/compiler/ForLoopUnroll.cpp @@ -6,6 +6,39 @@ #include "compiler/ForLoopUnroll.h" +namespace { + +class IntegerForLoopUnrollMarker : public TIntermTraverser { +public: + + virtual bool visitLoop(Visit, TIntermLoop* node) + { + // This is called after ValidateLimitations pass, so all the ASSERT + // should never fail. + // See ValidateLimitations::validateForLoopInit(). + ASSERT(node); + ASSERT(node->getType() == ELoopFor); + ASSERT(node->getInit()); + TIntermAggregate* decl = node->getInit()->getAsAggregate(); + ASSERT(decl && decl->getOp() == EOpDeclaration); + TIntermSequence& declSeq = decl->getSequence(); + ASSERT(declSeq.size() == 1); + TIntermBinary* declInit = declSeq[0]->getAsBinaryNode(); + ASSERT(declInit && declInit->getOp() == EOpInitialize); + ASSERT(declInit->getLeft()); + TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode(); + ASSERT(symbol); + TBasicType type = symbol->getBasicType(); + ASSERT(type == EbtInt || type == EbtFloat); + if (type == EbtInt) + node->setUnrollFlag(true); + return true; + } + +}; + +} // anonymous namepsace + void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info) { ASSERT(node->getType() == ELoopFor); @@ -109,6 +142,16 @@ void ForLoopUnroll::Pop() mLoopIndexStack.pop_back(); } +// static +void ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling( + TIntermNode* root) +{ + ASSERT(root); + + IntegerForLoopUnrollMarker marker; + root->traverse(&marker); +} + int ForLoopUnroll::getLoopIncrement(TIntermLoop* node) { TIntermNode* expr = node->getExpression(); diff --git a/gfx/angle/src/compiler/ForLoopUnroll.h b/gfx/angle/src/compiler/ForLoopUnroll.h index b2b2b58c11c2..e800e25b1f0c 100644 --- a/gfx/angle/src/compiler/ForLoopUnroll.h +++ b/gfx/angle/src/compiler/ForLoopUnroll.h @@ -36,6 +36,8 @@ public: void Push(TLoopIndexInfo& info); void Pop(); + static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root); + private: int getLoopIncrement(TIntermLoop* node); diff --git a/gfx/angle/src/compiler/Initialize.cpp b/gfx/angle/src/compiler/Initialize.cpp index 74a2de36e663..e0e1db94eb8b 100644 --- a/gfx/angle/src/compiler/Initialize.cpp +++ b/gfx/angle/src/compiler/Initialize.cpp @@ -363,6 +363,12 @@ static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources) s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);")); s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);")); + if (resources.OES_EGL_image_external) { + s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);")); + s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);")); + s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);")); + } + return s; } @@ -388,6 +394,12 @@ static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources) s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);")); s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);")); + if (resources.OES_EGL_image_external) { + s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);")); + s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);")); + s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);")); + } + if (resources.OES_standard_derivatives) { s.append(TString("float dFdx(float p);")); s.append(TString("vec2 dFdx(vec2 p);")); @@ -625,5 +637,7 @@ void InitExtensionBehavior(const ShBuiltInResources& resources, TExtensionBehavior& extBehavior) { if (resources.OES_standard_derivatives) - extBehavior["GL_OES_standard_derivatives"] = EBhDisable; + extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; + if (resources.OES_EGL_image_external) + extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; } diff --git a/gfx/angle/src/compiler/MapLongVariableNames.cpp b/gfx/angle/src/compiler/MapLongVariableNames.cpp index 847e6e616346..22dfab13a3a4 100644 --- a/gfx/angle/src/compiler/MapLongVariableNames.cpp +++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp @@ -48,37 +48,10 @@ void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol) } } -void MapLongVariableNames::visitConstantUnion(TIntermConstantUnion*) -{ -} - -bool MapLongVariableNames::visitBinary(Visit, TIntermBinary*) -{ - return true; -} - -bool MapLongVariableNames::visitUnary(Visit, TIntermUnary*) -{ - return true; -} - -bool MapLongVariableNames::visitSelection(Visit, TIntermSelection*) -{ - return true; -} - -bool MapLongVariableNames::visitAggregate(Visit, TIntermAggregate* node) -{ - return true; -} - -bool MapLongVariableNames::visitLoop(Visit, TIntermLoop*) -{ - return true; -} - -bool MapLongVariableNames::visitBranch(Visit, TIntermBranch*) +bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node) { + if (node->getInit()) + node->getInit()->traverse(this); return true; } diff --git a/gfx/angle/src/compiler/MapLongVariableNames.h b/gfx/angle/src/compiler/MapLongVariableNames.h index 540909ea9abe..b8ab4493b8c5 100644 --- a/gfx/angle/src/compiler/MapLongVariableNames.h +++ b/gfx/angle/src/compiler/MapLongVariableNames.h @@ -22,13 +22,7 @@ public: MapLongVariableNames(TMap& varyingLongNameMap); virtual void visitSymbol(TIntermSymbol*); - virtual void visitConstantUnion(TIntermConstantUnion*); - virtual bool visitBinary(Visit, TIntermBinary*); - virtual bool visitUnary(Visit, TIntermUnary*); - virtual bool visitSelection(Visit, TIntermSelection*); - virtual bool visitAggregate(Visit, TIntermAggregate*); virtual bool visitLoop(Visit, TIntermLoop*); - virtual bool visitBranch(Visit, TIntermBranch*); private: TString mapVaryingLongName(const TString& name); diff --git a/gfx/angle/src/compiler/OutputESSL.cpp b/gfx/angle/src/compiler/OutputESSL.cpp new file mode 100644 index 000000000000..64ee92d44e15 --- /dev/null +++ b/gfx/angle/src/compiler/OutputESSL.cpp @@ -0,0 +1,22 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/OutputESSL.h" + +TOutputESSL::TOutputESSL(TInfoSinkBase& objSink) + : TOutputGLSLBase(objSink) +{ +} + +bool TOutputESSL::writeVariablePrecision(TPrecision precision) +{ + if (precision == EbpUndefined) + return false; + + TInfoSinkBase& out = objSink(); + out << getPrecisionString(precision); + return true; +} diff --git a/gfx/angle/src/compiler/OutputESSL.h b/gfx/angle/src/compiler/OutputESSL.h new file mode 100644 index 000000000000..4fa73c8047ab --- /dev/null +++ b/gfx/angle/src/compiler/OutputESSL.h @@ -0,0 +1,21 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef CROSSCOMPILERGLSL_OUTPUTESSL_H_ +#define CROSSCOMPILERGLSL_OUTPUTESSL_H_ + +#include "compiler/OutputGLSLBase.h" + +class TOutputESSL : public TOutputGLSLBase +{ +public: + TOutputESSL(TInfoSinkBase& objSink); + +protected: + virtual bool writeVariablePrecision(TPrecision precision); +}; + +#endif // CROSSCOMPILERGLSL_OUTPUTESSL_H_ diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/OutputGLSL.cpp index c21566bb2a6c..dd31b4b58bc0 100644 --- a/gfx/angle/src/compiler/OutputGLSL.cpp +++ b/gfx/angle/src/compiler/OutputGLSL.cpp @@ -5,706 +5,13 @@ // #include "compiler/OutputGLSL.h" -#include "compiler/compilerdebug.h" - -namespace -{ -TString getTypeName(const TType& type) -{ - TInfoSinkBase out; - if (type.isMatrix()) - { - out << "mat"; - out << type.getNominalSize(); - } - else if (type.isVector()) - { - switch (type.getBasicType()) - { - case EbtFloat: out << "vec"; break; - case EbtInt: out << "ivec"; break; - case EbtBool: out << "bvec"; break; - default: UNREACHABLE(); break; - } - out << type.getNominalSize(); - } - else - { - if (type.getBasicType() == EbtStruct) - out << type.getTypeName(); - else - out << type.getBasicString(); - } - return TString(out.c_str()); -} - -TString arrayBrackets(const TType& type) -{ - ASSERT(type.isArray()); - TInfoSinkBase out; - out << "[" << type.getArraySize() << "]"; - return TString(out.c_str()); -} - -bool isSingleStatement(TIntermNode* node) { - if (const TIntermAggregate* aggregate = node->getAsAggregate()) - { - return (aggregate->getOp() != EOpFunction) && - (aggregate->getOp() != EOpSequence); - } - else if (const TIntermSelection* selection = node->getAsSelectionNode()) - { - // Ternary operators are usually part of an assignment operator. - // This handles those rare cases in which they are all by themselves. - return selection->usesTernaryOperator(); - } - else if (node->getAsLoopNode()) - { - return false; - } - return true; -} -} // namespace TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink) - : TIntermTraverser(true, true, true), - mObjSink(objSink), - mDeclaringVariables(false) + : TOutputGLSLBase(objSink) { } -void TOutputGLSL::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr) +bool TOutputGLSL::writeVariablePrecision(TPrecision) { - TInfoSinkBase& out = objSink(); - if (visit == PreVisit && preStr) - { - out << preStr; - } - else if (visit == InVisit && inStr) - { - out << inStr; - } - else if (visit == PostVisit && postStr) - { - out << postStr; - } -} - -void TOutputGLSL::writeVariableType(const TType& type) -{ - TInfoSinkBase& out = objSink(); - TQualifier qualifier = type.getQualifier(); - // TODO(alokp): Validate qualifier for variable declarations. - if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal)) - out << type.getQualifierString() << " "; - - // Declare the struct if we have not done so already. - if ((type.getBasicType() == EbtStruct) && - (mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end())) - { - out << "struct " << type.getTypeName() << "{\n"; - const TTypeList* structure = type.getStruct(); - ASSERT(structure != NULL); - for (size_t i = 0; i < structure->size(); ++i) - { - const TType* fieldType = (*structure)[i].type; - ASSERT(fieldType != NULL); - out << getTypeName(*fieldType) << " " << fieldType->getFieldName(); - if (fieldType->isArray()) - out << arrayBrackets(*fieldType); - out << ";\n"; - } - out << "}"; - mDeclaredStructs.insert(type.getTypeName()); - } - else - { - out << getTypeName(type); - } -} - -void TOutputGLSL::writeFunctionParameters(const TIntermSequence& args) -{ - TInfoSinkBase& out = objSink(); - for (TIntermSequence::const_iterator iter = args.begin(); - iter != args.end(); ++iter) - { - const TIntermSymbol* arg = (*iter)->getAsSymbolNode(); - ASSERT(arg != NULL); - - const TType& type = arg->getType(); - TQualifier qualifier = type.getQualifier(); - // TODO(alokp): Validate qualifier for function arguments. - if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal)) - out << type.getQualifierString() << " "; - - out << getTypeName(type); - - const TString& name = arg->getSymbol(); - if (!name.empty()) - out << " " << name; - if (type.isArray()) - out << arrayBrackets(type); - - // Put a comma if this is not the last argument. - if (iter != args.end() - 1) - out << ", "; - } -} - -const ConstantUnion* TOutputGLSL::writeConstantUnion(const TType& type, - const ConstantUnion* pConstUnion) -{ - TInfoSinkBase& out = objSink(); - - if (type.getBasicType() == EbtStruct) - { - out << type.getTypeName() << "("; - const TTypeList* structure = type.getStruct(); - ASSERT(structure != NULL); - for (size_t i = 0; i < structure->size(); ++i) - { - const TType* fieldType = (*structure)[i].type; - ASSERT(fieldType != NULL); - pConstUnion = writeConstantUnion(*fieldType, pConstUnion); - if (i != structure->size() - 1) out << ", "; - } - out << ")"; - } - else - { - int size = type.getObjectSize(); - bool writeType = size > 1; - if (writeType) out << getTypeName(type) << "("; - for (int i = 0; i < size; ++i, ++pConstUnion) - { - switch (pConstUnion->getType()) - { - case EbtFloat: out << pConstUnion->getFConst(); break; - case EbtInt: out << pConstUnion->getIConst(); break; - case EbtBool: out << pConstUnion->getBConst(); break; - default: UNREACHABLE(); - } - if (i != size - 1) out << ", "; - } - if (writeType) out << ")"; - } - return pConstUnion; -} - -void TOutputGLSL::visitSymbol(TIntermSymbol* node) -{ - TInfoSinkBase& out = objSink(); - if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node)) - out << mLoopUnroll.GetLoopIndexValue(node); - else - out << node->getSymbol(); - - if (mDeclaringVariables && node->getType().isArray()) - out << arrayBrackets(node->getType()); -} - -void TOutputGLSL::visitConstantUnion(TIntermConstantUnion* node) -{ - writeConstantUnion(node->getType(), node->getUnionArrayPointer()); -} - -bool TOutputGLSL::visitBinary(Visit visit, TIntermBinary* node) -{ - bool visitChildren = true; - TInfoSinkBase& out = objSink(); - switch (node->getOp()) - { - case EOpInitialize: - if (visit == InVisit) - { - out << " = "; - // RHS of initialize is not being declared. - mDeclaringVariables = false; - } - break; - case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break; - case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break; - case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break; - case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break; - // Notice the fall-through. - case EOpMulAssign: - case EOpVectorTimesMatrixAssign: - case EOpVectorTimesScalarAssign: - case EOpMatrixTimesScalarAssign: - case EOpMatrixTimesMatrixAssign: - writeTriplet(visit, "(", " *= ", ")"); - break; - - case EOpIndexDirect: - case EOpIndexIndirect: - writeTriplet(visit, NULL, "[", "]"); - break; - case EOpIndexDirectStruct: - if (visit == InVisit) - { - out << "."; - // TODO(alokp): ASSERT - out << node->getType().getFieldName(); - visitChildren = false; - } - break; - case EOpVectorSwizzle: - if (visit == InVisit) - { - out << "."; - TIntermAggregate* rightChild = node->getRight()->getAsAggregate(); - TIntermSequence& sequence = rightChild->getSequence(); - for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit) - { - TIntermConstantUnion* element = (*sit)->getAsConstantUnion(); - ASSERT(element->getBasicType() == EbtInt); - ASSERT(element->getNominalSize() == 1); - const ConstantUnion& data = element->getUnionArrayPointer()[0]; - ASSERT(data.getType() == EbtInt); - switch (data.getIConst()) - { - case 0: out << "x"; break; - case 1: out << "y"; break; - case 2: out << "z"; break; - case 3: out << "w"; break; - default: UNREACHABLE(); break; - } - } - visitChildren = false; - } - break; - - case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break; - case EOpSub: writeTriplet(visit, "(", " - ", ")"); break; - case EOpMul: writeTriplet(visit, "(", " * ", ")"); break; - case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break; - case EOpMod: UNIMPLEMENTED(); break; - case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break; - case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break; - case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break; - case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break; - case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break; - case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break; - - // Notice the fall-through. - case EOpVectorTimesScalar: - case EOpVectorTimesMatrix: - case EOpMatrixTimesVector: - case EOpMatrixTimesScalar: - case EOpMatrixTimesMatrix: - writeTriplet(visit, "(", " * ", ")"); - break; - - case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break; - case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break; - case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break; - default: UNREACHABLE(); break; - } - - return visitChildren; -} - -bool TOutputGLSL::visitUnary(Visit visit, TIntermUnary* node) -{ - switch (node->getOp()) - { - case EOpNegative: writeTriplet(visit, "(-", NULL, ")"); break; - case EOpVectorLogicalNot: writeTriplet(visit, "not(", NULL, ")"); break; - case EOpLogicalNot: writeTriplet(visit, "(!", NULL, ")"); break; - - case EOpPostIncrement: writeTriplet(visit, "(", NULL, "++)"); break; - case EOpPostDecrement: writeTriplet(visit, "(", NULL, "--)"); break; - case EOpPreIncrement: writeTriplet(visit, "(++", NULL, ")"); break; - case EOpPreDecrement: writeTriplet(visit, "(--", NULL, ")"); break; - - case EOpConvIntToBool: - case EOpConvFloatToBool: - switch (node->getOperand()->getType().getNominalSize()) - { - case 1: writeTriplet(visit, "bool(", NULL, ")"); break; - case 2: writeTriplet(visit, "bvec2(", NULL, ")"); break; - case 3: writeTriplet(visit, "bvec3(", NULL, ")"); break; - case 4: writeTriplet(visit, "bvec4(", NULL, ")"); break; - default: UNREACHABLE(); - } - break; - case EOpConvBoolToFloat: - case EOpConvIntToFloat: - switch (node->getOperand()->getType().getNominalSize()) - { - case 1: writeTriplet(visit, "float(", NULL, ")"); break; - case 2: writeTriplet(visit, "vec2(", NULL, ")"); break; - case 3: writeTriplet(visit, "vec3(", NULL, ")"); break; - case 4: writeTriplet(visit, "vec4(", NULL, ")"); break; - default: UNREACHABLE(); - } - break; - case EOpConvFloatToInt: - case EOpConvBoolToInt: - switch (node->getOperand()->getType().getNominalSize()) - { - case 1: writeTriplet(visit, "int(", NULL, ")"); break; - case 2: writeTriplet(visit, "ivec2(", NULL, ")"); break; - case 3: writeTriplet(visit, "ivec3(", NULL, ")"); break; - case 4: writeTriplet(visit, "ivec4(", NULL, ")"); break; - default: UNREACHABLE(); - } - break; - - case EOpRadians: writeTriplet(visit, "radians(", NULL, ")"); break; - case EOpDegrees: writeTriplet(visit, "degrees(", NULL, ")"); break; - case EOpSin: writeTriplet(visit, "sin(", NULL, ")"); break; - case EOpCos: writeTriplet(visit, "cos(", NULL, ")"); break; - case EOpTan: writeTriplet(visit, "tan(", NULL, ")"); break; - case EOpAsin: writeTriplet(visit, "asin(", NULL, ")"); break; - case EOpAcos: writeTriplet(visit, "acos(", NULL, ")"); break; - case EOpAtan: writeTriplet(visit, "atan(", NULL, ")"); break; - - case EOpExp: writeTriplet(visit, "exp(", NULL, ")"); break; - case EOpLog: writeTriplet(visit, "log(", NULL, ")"); break; - case EOpExp2: writeTriplet(visit, "exp2(", NULL, ")"); break; - case EOpLog2: writeTriplet(visit, "log2(", NULL, ")"); break; - case EOpSqrt: writeTriplet(visit, "sqrt(", NULL, ")"); break; - case EOpInverseSqrt: writeTriplet(visit, "inversesqrt(", NULL, ")"); break; - - case EOpAbs: writeTriplet(visit, "abs(", NULL, ")"); break; - case EOpSign: writeTriplet(visit, "sign(", NULL, ")"); break; - case EOpFloor: writeTriplet(visit, "floor(", NULL, ")"); break; - case EOpCeil: writeTriplet(visit, "ceil(", NULL, ")"); break; - case EOpFract: writeTriplet(visit, "fract(", NULL, ")"); break; - - case EOpLength: writeTriplet(visit, "length(", NULL, ")"); break; - case EOpNormalize: writeTriplet(visit, "normalize(", NULL, ")"); break; - - case EOpDFdx: writeTriplet(visit, "dFdx(", NULL, ")"); break; - case EOpDFdy: writeTriplet(visit, "dFdy(", NULL, ")"); break; - case EOpFwidth: writeTriplet(visit, "fwidth(", NULL, ")"); break; - - case EOpAny: writeTriplet(visit, "any(", NULL, ")"); break; - case EOpAll: writeTriplet(visit, "all(", NULL, ")"); break; - - default: UNREACHABLE(); break; - } - - return true; -} - -bool TOutputGLSL::visitSelection(Visit visit, TIntermSelection* node) -{ - TInfoSinkBase& out = objSink(); - - if (node->usesTernaryOperator()) - { - // Notice two brackets at the beginning and end. The outer ones - // encapsulate the whole ternary expression. This preserves the - // order of precedence when ternary expressions are used in a - // compound expression, i.e., c = 2 * (a < b ? 1 : 2). - out << "(("; - node->getCondition()->traverse(this); - out << ") ? ("; - node->getTrueBlock()->traverse(this); - out << ") : ("; - node->getFalseBlock()->traverse(this); - out << "))"; - } - else - { - out << "if ("; - node->getCondition()->traverse(this); - out << ")\n"; - - incrementDepth(); - visitCodeBlock(node->getTrueBlock()); - - if (node->getFalseBlock()) - { - out << "else\n"; - visitCodeBlock(node->getFalseBlock()); - } - decrementDepth(); - } return false; } - -bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node) -{ - bool visitChildren = true; - TInfoSinkBase& out = objSink(); - switch (node->getOp()) - { - case EOpSequence: { - // Scope the sequences except when at the global scope. - if (depth > 0) out << "{\n"; - - incrementDepth(); - const TIntermSequence& sequence = node->getSequence(); - for (TIntermSequence::const_iterator iter = sequence.begin(); - iter != sequence.end(); ++iter) - { - TIntermNode* node = *iter; - ASSERT(node != NULL); - node->traverse(this); - - if (isSingleStatement(node)) - out << ";\n"; - } - decrementDepth(); - - // Scope the sequences except when at the global scope. - if (depth > 0) out << "}\n"; - visitChildren = false; - break; - } - case EOpPrototype: { - // Function declaration. - ASSERT(visit == PreVisit); - TString returnType = getTypeName(node->getType()); - out << returnType << " " << node->getName(); - - out << "("; - writeFunctionParameters(node->getSequence()); - out << ")"; - - visitChildren = false; - break; - } - case EOpFunction: { - // Function definition. - ASSERT(visit == PreVisit); - TString returnType = getTypeName(node->getType()); - TString functionName = TFunction::unmangleName(node->getName()); - out << returnType << " " << functionName; - - incrementDepth(); - // Function definition node contains one or two children nodes - // representing function parameters and function body. The latter - // is not present in case of empty function bodies. - const TIntermSequence& sequence = node->getSequence(); - ASSERT((sequence.size() == 1) || (sequence.size() == 2)); - TIntermSequence::const_iterator seqIter = sequence.begin(); - - // Traverse function parameters. - TIntermAggregate* params = (*seqIter)->getAsAggregate(); - ASSERT(params != NULL); - ASSERT(params->getOp() == EOpParameters); - params->traverse(this); - - // Traverse function body. - TIntermAggregate* body = ++seqIter != sequence.end() ? - (*seqIter)->getAsAggregate() : NULL; - visitCodeBlock(body); - decrementDepth(); - - // Fully processed; no need to visit children. - visitChildren = false; - break; - } - case EOpFunctionCall: - // Function call. - if (visit == PreVisit) - { - TString functionName = TFunction::unmangleName(node->getName()); - out << functionName << "("; - } - else if (visit == InVisit) - { - out << ", "; - } - else - { - out << ")"; - } - break; - case EOpParameters: { - // Function parameters. - ASSERT(visit == PreVisit); - out << "("; - writeFunctionParameters(node->getSequence()); - out << ")"; - visitChildren = false; - break; - } - case EOpDeclaration: { - // Variable declaration. - if (visit == PreVisit) - { - const TIntermSequence& sequence = node->getSequence(); - const TIntermTyped* variable = sequence.front()->getAsTyped(); - writeVariableType(variable->getType()); - out << " "; - mDeclaringVariables = true; - } - else if (visit == InVisit) - { - out << ", "; - mDeclaringVariables = true; - } - else - { - mDeclaringVariables = false; - } - break; - } - case EOpConstructFloat: writeTriplet(visit, "float(", NULL, ")"); break; - case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break; - case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break; - case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break; - case EOpConstructBool: writeTriplet(visit, "bool(", NULL, ")"); break; - case EOpConstructBVec2: writeTriplet(visit, "bvec2(", ", ", ")"); break; - case EOpConstructBVec3: writeTriplet(visit, "bvec3(", ", ", ")"); break; - case EOpConstructBVec4: writeTriplet(visit, "bvec4(", ", ", ")"); break; - case EOpConstructInt: writeTriplet(visit, "int(", NULL, ")"); break; - case EOpConstructIVec2: writeTriplet(visit, "ivec2(", ", ", ")"); break; - case EOpConstructIVec3: writeTriplet(visit, "ivec3(", ", ", ")"); break; - case EOpConstructIVec4: writeTriplet(visit, "ivec4(", ", ", ")"); break; - case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break; - case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break; - case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break; - case EOpConstructStruct: - if (visit == PreVisit) - { - const TType& type = node->getType(); - ASSERT(type.getBasicType() == EbtStruct); - out << type.getTypeName() << "("; - } - else if (visit == InVisit) - { - out << ", "; - } - else - { - out << ")"; - } - break; - - case EOpLessThan: writeTriplet(visit, "lessThan(", ", ", ")"); break; - case EOpGreaterThan: writeTriplet(visit, "greaterThan(", ", ", ")"); break; - case EOpLessThanEqual: writeTriplet(visit, "lessThanEqual(", ", ", ")"); break; - case EOpGreaterThanEqual: writeTriplet(visit, "greaterThanEqual(", ", ", ")"); break; - case EOpVectorEqual: writeTriplet(visit, "equal(", ", ", ")"); break; - case EOpVectorNotEqual: writeTriplet(visit, "notEqual(", ", ", ")"); break; - case EOpComma: writeTriplet(visit, NULL, ", ", NULL); break; - - case EOpMod: writeTriplet(visit, "mod(", ", ", ")"); break; - case EOpPow: writeTriplet(visit, "pow(", ", ", ")"); break; - case EOpAtan: writeTriplet(visit, "atan(", ", ", ")"); break; - case EOpMin: writeTriplet(visit, "min(", ", ", ")"); break; - case EOpMax: writeTriplet(visit, "max(", ", ", ")"); break; - case EOpClamp: writeTriplet(visit, "clamp(", ", ", ")"); break; - case EOpMix: writeTriplet(visit, "mix(", ", ", ")"); break; - case EOpStep: writeTriplet(visit, "step(", ", ", ")"); break; - case EOpSmoothStep: writeTriplet(visit, "smoothstep(", ", ", ")"); break; - - case EOpDistance: writeTriplet(visit, "distance(", ", ", ")"); break; - case EOpDot: writeTriplet(visit, "dot(", ", ", ")"); break; - case EOpCross: writeTriplet(visit, "cross(", ", ", ")"); break; - case EOpFaceForward: writeTriplet(visit, "faceforward(", ", ", ")"); break; - case EOpReflect: writeTriplet(visit, "reflect(", ", ", ")"); break; - case EOpRefract: writeTriplet(visit, "refract(", ", ", ")"); break; - case EOpMul: writeTriplet(visit, "matrixCompMult(", ", ", ")"); break; - - default: UNREACHABLE(); break; - } - return visitChildren; -} - -bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node) -{ - TInfoSinkBase& out = objSink(); - - incrementDepth(); - // Loop header. - TLoopType loopType = node->getType(); - if (loopType == ELoopFor) // for loop - { - if (!node->getUnrollFlag()) { - out << "for ("; - if (node->getInit()) - node->getInit()->traverse(this); - out << "; "; - - if (node->getCondition()) - node->getCondition()->traverse(this); - out << "; "; - - if (node->getExpression()) - node->getExpression()->traverse(this); - out << ")\n"; - } - } - else if (loopType == ELoopWhile) // while loop - { - out << "while ("; - ASSERT(node->getCondition() != NULL); - node->getCondition()->traverse(this); - out << ")\n"; - } - else // do-while loop - { - ASSERT(loopType == ELoopDoWhile); - out << "do\n"; - } - - // Loop body. - if (node->getUnrollFlag()) - { - TLoopIndexInfo indexInfo; - mLoopUnroll.FillLoopIndexInfo(node, indexInfo); - mLoopUnroll.Push(indexInfo); - while (mLoopUnroll.SatisfiesLoopCondition()) - { - visitCodeBlock(node->getBody()); - mLoopUnroll.Step(); - } - mLoopUnroll.Pop(); - } - else - { - visitCodeBlock(node->getBody()); - } - - // Loop footer. - if (loopType == ELoopDoWhile) // do-while loop - { - out << "while ("; - ASSERT(node->getCondition() != NULL); - node->getCondition()->traverse(this); - out << ");\n"; - } - decrementDepth(); - - // No need to visit children. They have been already processed in - // this function. - return false; -} - -bool TOutputGLSL::visitBranch(Visit visit, TIntermBranch* node) -{ - switch (node->getFlowOp()) - { - case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break; - case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break; - case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break; - case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break; - default: UNREACHABLE(); break; - } - - return true; -} - -void TOutputGLSL::visitCodeBlock(TIntermNode* node) { - TInfoSinkBase &out = objSink(); - if (node != NULL) - { - node->traverse(this); - // Single statements not part of a sequence need to be terminated - // with semi-colon. - if (isSingleStatement(node)) - out << ";\n"; - } - else - { - out << "{\n}\n"; // Empty code block. - } -} diff --git a/gfx/angle/src/compiler/OutputGLSL.h b/gfx/angle/src/compiler/OutputGLSL.h index ace110ac4a90..0fe2356eb734 100644 --- a/gfx/angle/src/compiler/OutputGLSL.h +++ b/gfx/angle/src/compiler/OutputGLSL.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -7,46 +7,15 @@ #ifndef CROSSCOMPILERGLSL_OUTPUTGLSL_H_ #define CROSSCOMPILERGLSL_OUTPUTGLSL_H_ -#include +#include "compiler/OutputGLSLBase.h" -#include "compiler/ForLoopUnroll.h" -#include "compiler/intermediate.h" -#include "compiler/ParseHelper.h" - -class TOutputGLSL : public TIntermTraverser +class TOutputGLSL : public TOutputGLSLBase { public: TOutputGLSL(TInfoSinkBase& objSink); protected: - TInfoSinkBase& objSink() { return mObjSink; } - void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr); - void writeVariableType(const TType& type); - void writeFunctionParameters(const TIntermSequence& args); - const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); - - virtual void visitSymbol(TIntermSymbol* node); - virtual void visitConstantUnion(TIntermConstantUnion* node); - virtual bool visitBinary(Visit visit, TIntermBinary* node); - virtual bool visitUnary(Visit visit, TIntermUnary* node); - virtual bool visitSelection(Visit visit, TIntermSelection* node); - virtual bool visitAggregate(Visit visit, TIntermAggregate* node); - virtual bool visitLoop(Visit visit, TIntermLoop* node); - virtual bool visitBranch(Visit visit, TIntermBranch* node); - - void visitCodeBlock(TIntermNode* node); - -private: - TInfoSinkBase& mObjSink; - bool mDeclaringVariables; - - // Structs are declared as the tree is traversed. This set contains all - // the structs already declared. It is maintained so that a struct is - // declared only once. - typedef std::set DeclaredStructs; - DeclaredStructs mDeclaredStructs; - - ForLoopUnroll mLoopUnroll; + virtual bool writeVariablePrecision(TPrecision); }; #endif // CROSSCOMPILERGLSL_OUTPUTGLSL_H_ diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/OutputGLSLBase.cpp new file mode 100644 index 000000000000..ba6f32066134 --- /dev/null +++ b/gfx/angle/src/compiler/OutputGLSLBase.cpp @@ -0,0 +1,714 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/OutputGLSLBase.h" +#include "compiler/compilerdebug.h" + +namespace +{ +TString getTypeName(const TType& type) +{ + TInfoSinkBase out; + if (type.isMatrix()) + { + out << "mat"; + out << type.getNominalSize(); + } + else if (type.isVector()) + { + switch (type.getBasicType()) + { + case EbtFloat: out << "vec"; break; + case EbtInt: out << "ivec"; break; + case EbtBool: out << "bvec"; break; + default: UNREACHABLE(); break; + } + out << type.getNominalSize(); + } + else + { + if (type.getBasicType() == EbtStruct) + out << type.getTypeName(); + else + out << type.getBasicString(); + } + return TString(out.c_str()); +} + +TString arrayBrackets(const TType& type) +{ + ASSERT(type.isArray()); + TInfoSinkBase out; + out << "[" << type.getArraySize() << "]"; + return TString(out.c_str()); +} + +bool isSingleStatement(TIntermNode* node) { + if (const TIntermAggregate* aggregate = node->getAsAggregate()) + { + return (aggregate->getOp() != EOpFunction) && + (aggregate->getOp() != EOpSequence); + } + else if (const TIntermSelection* selection = node->getAsSelectionNode()) + { + // Ternary operators are usually part of an assignment operator. + // This handles those rare cases in which they are all by themselves. + return selection->usesTernaryOperator(); + } + else if (node->getAsLoopNode()) + { + return false; + } + return true; +} +} // namespace + +TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink) + : TIntermTraverser(true, true, true), + mObjSink(objSink), + mDeclaringVariables(false) +{ +} + +void TOutputGLSLBase::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr) +{ + TInfoSinkBase& out = objSink(); + if (visit == PreVisit && preStr) + { + out << preStr; + } + else if (visit == InVisit && inStr) + { + out << inStr; + } + else if (visit == PostVisit && postStr) + { + out << postStr; + } +} + +void TOutputGLSLBase::writeVariableType(const TType& type) +{ + TInfoSinkBase& out = objSink(); + TQualifier qualifier = type.getQualifier(); + // TODO(alokp): Validate qualifier for variable declarations. + if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal)) + out << type.getQualifierString() << " "; + // Declare the struct if we have not done so already. + if ((type.getBasicType() == EbtStruct) && + (mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end())) + { + out << "struct " << type.getTypeName() << "{\n"; + const TTypeList* structure = type.getStruct(); + ASSERT(structure != NULL); + for (size_t i = 0; i < structure->size(); ++i) + { + const TType* fieldType = (*structure)[i].type; + ASSERT(fieldType != NULL); + if (writeVariablePrecision(fieldType->getPrecision())) + out << " "; + out << getTypeName(*fieldType) << " " << fieldType->getFieldName(); + if (fieldType->isArray()) + out << arrayBrackets(*fieldType); + out << ";\n"; + } + out << "}"; + mDeclaredStructs.insert(type.getTypeName()); + } + else + { + if (writeVariablePrecision(type.getPrecision())) + out << " "; + out << getTypeName(type); + } +} + +void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence& args) +{ + TInfoSinkBase& out = objSink(); + for (TIntermSequence::const_iterator iter = args.begin(); + iter != args.end(); ++iter) + { + const TIntermSymbol* arg = (*iter)->getAsSymbolNode(); + ASSERT(arg != NULL); + + const TType& type = arg->getType(); + writeVariableType(type); + + const TString& name = arg->getSymbol(); + if (!name.empty()) + out << " " << name; + if (type.isArray()) + out << arrayBrackets(type); + + // Put a comma if this is not the last argument. + if (iter != args.end() - 1) + out << ", "; + } +} + +const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type, + const ConstantUnion* pConstUnion) +{ + TInfoSinkBase& out = objSink(); + + if (type.getBasicType() == EbtStruct) + { + out << type.getTypeName() << "("; + const TTypeList* structure = type.getStruct(); + ASSERT(structure != NULL); + for (size_t i = 0; i < structure->size(); ++i) + { + const TType* fieldType = (*structure)[i].type; + ASSERT(fieldType != NULL); + pConstUnion = writeConstantUnion(*fieldType, pConstUnion); + if (i != structure->size() - 1) out << ", "; + } + out << ")"; + } + else + { + int size = type.getObjectSize(); + bool writeType = size > 1; + if (writeType) out << getTypeName(type) << "("; + for (int i = 0; i < size; ++i, ++pConstUnion) + { + switch (pConstUnion->getType()) + { + case EbtFloat: out << pConstUnion->getFConst(); break; + case EbtInt: out << pConstUnion->getIConst(); break; + case EbtBool: out << pConstUnion->getBConst(); break; + default: UNREACHABLE(); + } + if (i != size - 1) out << ", "; + } + if (writeType) out << ")"; + } + return pConstUnion; +} + +void TOutputGLSLBase::visitSymbol(TIntermSymbol* node) +{ + TInfoSinkBase& out = objSink(); + if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node)) + out << mLoopUnroll.GetLoopIndexValue(node); + else + out << node->getSymbol(); + + if (mDeclaringVariables && node->getType().isArray()) + out << arrayBrackets(node->getType()); +} + +void TOutputGLSLBase::visitConstantUnion(TIntermConstantUnion* node) +{ + writeConstantUnion(node->getType(), node->getUnionArrayPointer()); +} + +bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node) +{ + bool visitChildren = true; + TInfoSinkBase& out = objSink(); + switch (node->getOp()) + { + case EOpInitialize: + if (visit == InVisit) + { + out << " = "; + // RHS of initialize is not being declared. + mDeclaringVariables = false; + } + break; + case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break; + case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break; + case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break; + case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break; + // Notice the fall-through. + case EOpMulAssign: + case EOpVectorTimesMatrixAssign: + case EOpVectorTimesScalarAssign: + case EOpMatrixTimesScalarAssign: + case EOpMatrixTimesMatrixAssign: + writeTriplet(visit, "(", " *= ", ")"); + break; + + case EOpIndexDirect: + case EOpIndexIndirect: + writeTriplet(visit, NULL, "[", "]"); + break; + case EOpIndexDirectStruct: + if (visit == InVisit) + { + out << "."; + // TODO(alokp): ASSERT + out << node->getType().getFieldName(); + visitChildren = false; + } + break; + case EOpVectorSwizzle: + if (visit == InVisit) + { + out << "."; + TIntermAggregate* rightChild = node->getRight()->getAsAggregate(); + TIntermSequence& sequence = rightChild->getSequence(); + for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit) + { + TIntermConstantUnion* element = (*sit)->getAsConstantUnion(); + ASSERT(element->getBasicType() == EbtInt); + ASSERT(element->getNominalSize() == 1); + const ConstantUnion& data = element->getUnionArrayPointer()[0]; + ASSERT(data.getType() == EbtInt); + switch (data.getIConst()) + { + case 0: out << "x"; break; + case 1: out << "y"; break; + case 2: out << "z"; break; + case 3: out << "w"; break; + default: UNREACHABLE(); break; + } + } + visitChildren = false; + } + break; + + case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break; + case EOpSub: writeTriplet(visit, "(", " - ", ")"); break; + case EOpMul: writeTriplet(visit, "(", " * ", ")"); break; + case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break; + case EOpMod: UNIMPLEMENTED(); break; + case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break; + case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break; + case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break; + case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break; + case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break; + case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break; + + // Notice the fall-through. + case EOpVectorTimesScalar: + case EOpVectorTimesMatrix: + case EOpMatrixTimesVector: + case EOpMatrixTimesScalar: + case EOpMatrixTimesMatrix: + writeTriplet(visit, "(", " * ", ")"); + break; + + case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break; + case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break; + case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break; + default: UNREACHABLE(); break; + } + + return visitChildren; +} + +bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary* node) +{ + TString preString; + TString postString = ")"; + + switch (node->getOp()) + { + case EOpNegative: preString = "(-"; break; + case EOpVectorLogicalNot: preString = "not("; break; + case EOpLogicalNot: preString = "(!"; break; + + case EOpPostIncrement: preString = "("; postString = "++)"; break; + case EOpPostDecrement: preString = "("; postString = "--)"; break; + case EOpPreIncrement: preString = "(++"; break; + case EOpPreDecrement: preString = "(--"; break; + + case EOpConvIntToBool: + case EOpConvFloatToBool: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: preString = "bool("; break; + case 2: preString = "bvec2("; break; + case 3: preString = "bvec3("; break; + case 4: preString = "bvec4("; break; + default: UNREACHABLE(); + } + break; + case EOpConvBoolToFloat: + case EOpConvIntToFloat: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: preString = "float("; break; + case 2: preString = "vec2("; break; + case 3: preString = "vec3("; break; + case 4: preString = "vec4("; break; + default: UNREACHABLE(); + } + break; + case EOpConvFloatToInt: + case EOpConvBoolToInt: + switch (node->getOperand()->getType().getNominalSize()) + { + case 1: preString = "int("; break; + case 2: preString = "ivec2("; break; + case 3: preString = "ivec3("; break; + case 4: preString = "ivec4("; break; + default: UNREACHABLE(); + } + break; + + case EOpRadians: preString = "radians("; break; + case EOpDegrees: preString = "degrees("; break; + case EOpSin: preString = "sin("; break; + case EOpCos: preString = "cos("; break; + case EOpTan: preString = "tan("; break; + case EOpAsin: preString = "asin("; break; + case EOpAcos: preString = "acos("; break; + case EOpAtan: preString = "atan("; break; + + case EOpExp: preString = "exp("; break; + case EOpLog: preString = "log("; break; + case EOpExp2: preString = "exp2("; break; + case EOpLog2: preString = "log2("; break; + case EOpSqrt: preString = "sqrt("; break; + case EOpInverseSqrt: preString = "inversesqrt("; break; + + case EOpAbs: preString = "abs("; break; + case EOpSign: preString = "sign("; break; + case EOpFloor: preString = "floor("; break; + case EOpCeil: preString = "ceil("; break; + case EOpFract: preString = "fract("; break; + + case EOpLength: preString = "length("; break; + case EOpNormalize: preString = "normalize("; break; + + case EOpDFdx: preString = "dFdx("; break; + case EOpDFdy: preString = "dFdy("; break; + case EOpFwidth: preString = "fwidth("; break; + + case EOpAny: preString = "any("; break; + case EOpAll: preString = "all("; break; + + default: UNREACHABLE(); break; + } + + if (visit == PreVisit && node->getUseEmulatedFunction()) + preString = BuiltInFunctionEmulator::GetEmulatedFunctionName(preString); + writeTriplet(visit, preString.c_str(), NULL, postString.c_str()); + + return true; +} + +bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection* node) +{ + TInfoSinkBase& out = objSink(); + + if (node->usesTernaryOperator()) + { + // Notice two brackets at the beginning and end. The outer ones + // encapsulate the whole ternary expression. This preserves the + // order of precedence when ternary expressions are used in a + // compound expression, i.e., c = 2 * (a < b ? 1 : 2). + out << "(("; + node->getCondition()->traverse(this); + out << ") ? ("; + node->getTrueBlock()->traverse(this); + out << ") : ("; + node->getFalseBlock()->traverse(this); + out << "))"; + } + else + { + out << "if ("; + node->getCondition()->traverse(this); + out << ")\n"; + + incrementDepth(); + visitCodeBlock(node->getTrueBlock()); + + if (node->getFalseBlock()) + { + out << "else\n"; + visitCodeBlock(node->getFalseBlock()); + } + decrementDepth(); + } + return false; +} + +bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node) +{ + bool visitChildren = true; + TInfoSinkBase& out = objSink(); + switch (node->getOp()) + { + case EOpSequence: { + // Scope the sequences except when at the global scope. + if (depth > 0) out << "{\n"; + + incrementDepth(); + const TIntermSequence& sequence = node->getSequence(); + for (TIntermSequence::const_iterator iter = sequence.begin(); + iter != sequence.end(); ++iter) + { + TIntermNode* node = *iter; + ASSERT(node != NULL); + node->traverse(this); + + if (isSingleStatement(node)) + out << ";\n"; + } + decrementDepth(); + + // Scope the sequences except when at the global scope. + if (depth > 0) out << "}\n"; + visitChildren = false; + break; + } + case EOpPrototype: { + // Function declaration. + ASSERT(visit == PreVisit); + writeVariableType(node->getType()); + out << " " << node->getName(); + + out << "("; + writeFunctionParameters(node->getSequence()); + out << ")"; + + visitChildren = false; + break; + } + case EOpFunction: { + // Function definition. + ASSERT(visit == PreVisit); + writeVariableType(node->getType()); + out << " " << TFunction::unmangleName(node->getName()); + + incrementDepth(); + // Function definition node contains one or two children nodes + // representing function parameters and function body. The latter + // is not present in case of empty function bodies. + const TIntermSequence& sequence = node->getSequence(); + ASSERT((sequence.size() == 1) || (sequence.size() == 2)); + TIntermSequence::const_iterator seqIter = sequence.begin(); + + // Traverse function parameters. + TIntermAggregate* params = (*seqIter)->getAsAggregate(); + ASSERT(params != NULL); + ASSERT(params->getOp() == EOpParameters); + params->traverse(this); + + // Traverse function body. + TIntermAggregate* body = ++seqIter != sequence.end() ? + (*seqIter)->getAsAggregate() : NULL; + visitCodeBlock(body); + decrementDepth(); + + // Fully processed; no need to visit children. + visitChildren = false; + break; + } + case EOpFunctionCall: + // Function call. + if (visit == PreVisit) + { + TString functionName = TFunction::unmangleName(node->getName()); + out << functionName << "("; + } + else if (visit == InVisit) + { + out << ", "; + } + else + { + out << ")"; + } + break; + case EOpParameters: { + // Function parameters. + ASSERT(visit == PreVisit); + out << "("; + writeFunctionParameters(node->getSequence()); + out << ")"; + visitChildren = false; + break; + } + case EOpDeclaration: { + // Variable declaration. + if (visit == PreVisit) + { + const TIntermSequence& sequence = node->getSequence(); + const TIntermTyped* variable = sequence.front()->getAsTyped(); + writeVariableType(variable->getType()); + out << " "; + mDeclaringVariables = true; + } + else if (visit == InVisit) + { + out << ", "; + mDeclaringVariables = true; + } + else + { + mDeclaringVariables = false; + } + break; + } + case EOpConstructFloat: writeTriplet(visit, "float(", NULL, ")"); break; + case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break; + case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break; + case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break; + case EOpConstructBool: writeTriplet(visit, "bool(", NULL, ")"); break; + case EOpConstructBVec2: writeTriplet(visit, "bvec2(", ", ", ")"); break; + case EOpConstructBVec3: writeTriplet(visit, "bvec3(", ", ", ")"); break; + case EOpConstructBVec4: writeTriplet(visit, "bvec4(", ", ", ")"); break; + case EOpConstructInt: writeTriplet(visit, "int(", NULL, ")"); break; + case EOpConstructIVec2: writeTriplet(visit, "ivec2(", ", ", ")"); break; + case EOpConstructIVec3: writeTriplet(visit, "ivec3(", ", ", ")"); break; + case EOpConstructIVec4: writeTriplet(visit, "ivec4(", ", ", ")"); break; + case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break; + case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break; + case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break; + case EOpConstructStruct: + if (visit == PreVisit) + { + const TType& type = node->getType(); + ASSERT(type.getBasicType() == EbtStruct); + out << type.getTypeName() << "("; + } + else if (visit == InVisit) + { + out << ", "; + } + else + { + out << ")"; + } + break; + + case EOpLessThan: writeTriplet(visit, "lessThan(", ", ", ")"); break; + case EOpGreaterThan: writeTriplet(visit, "greaterThan(", ", ", ")"); break; + case EOpLessThanEqual: writeTriplet(visit, "lessThanEqual(", ", ", ")"); break; + case EOpGreaterThanEqual: writeTriplet(visit, "greaterThanEqual(", ", ", ")"); break; + case EOpVectorEqual: writeTriplet(visit, "equal(", ", ", ")"); break; + case EOpVectorNotEqual: writeTriplet(visit, "notEqual(", ", ", ")"); break; + case EOpComma: writeTriplet(visit, NULL, ", ", NULL); break; + + case EOpMod: writeTriplet(visit, "mod(", ", ", ")"); break; + case EOpPow: writeTriplet(visit, "pow(", ", ", ")"); break; + case EOpAtan: writeTriplet(visit, "atan(", ", ", ")"); break; + case EOpMin: writeTriplet(visit, "min(", ", ", ")"); break; + case EOpMax: writeTriplet(visit, "max(", ", ", ")"); break; + case EOpClamp: writeTriplet(visit, "clamp(", ", ", ")"); break; + case EOpMix: writeTriplet(visit, "mix(", ", ", ")"); break; + case EOpStep: writeTriplet(visit, "step(", ", ", ")"); break; + case EOpSmoothStep: writeTriplet(visit, "smoothstep(", ", ", ")"); break; + + case EOpDistance: writeTriplet(visit, "distance(", ", ", ")"); break; + case EOpDot: writeTriplet(visit, "dot(", ", ", ")"); break; + case EOpCross: writeTriplet(visit, "cross(", ", ", ")"); break; + case EOpFaceForward: writeTriplet(visit, "faceforward(", ", ", ")"); break; + case EOpReflect: writeTriplet(visit, "reflect(", ", ", ")"); break; + case EOpRefract: writeTriplet(visit, "refract(", ", ", ")"); break; + case EOpMul: writeTriplet(visit, "matrixCompMult(", ", ", ")"); break; + + default: UNREACHABLE(); break; + } + return visitChildren; +} + +bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node) +{ + TInfoSinkBase& out = objSink(); + + incrementDepth(); + // Loop header. + TLoopType loopType = node->getType(); + if (loopType == ELoopFor) // for loop + { + if (!node->getUnrollFlag()) { + out << "for ("; + if (node->getInit()) + node->getInit()->traverse(this); + out << "; "; + + if (node->getCondition()) + node->getCondition()->traverse(this); + out << "; "; + + if (node->getExpression()) + node->getExpression()->traverse(this); + out << ")\n"; + } + } + else if (loopType == ELoopWhile) // while loop + { + out << "while ("; + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); + out << ")\n"; + } + else // do-while loop + { + ASSERT(loopType == ELoopDoWhile); + out << "do\n"; + } + + // Loop body. + if (node->getUnrollFlag()) + { + TLoopIndexInfo indexInfo; + mLoopUnroll.FillLoopIndexInfo(node, indexInfo); + mLoopUnroll.Push(indexInfo); + while (mLoopUnroll.SatisfiesLoopCondition()) + { + visitCodeBlock(node->getBody()); + mLoopUnroll.Step(); + } + mLoopUnroll.Pop(); + } + else + { + visitCodeBlock(node->getBody()); + } + + // Loop footer. + if (loopType == ELoopDoWhile) // do-while loop + { + out << "while ("; + ASSERT(node->getCondition() != NULL); + node->getCondition()->traverse(this); + out << ");\n"; + } + decrementDepth(); + + // No need to visit children. They have been already processed in + // this function. + return false; +} + +bool TOutputGLSLBase::visitBranch(Visit visit, TIntermBranch* node) +{ + switch (node->getFlowOp()) + { + case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break; + case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break; + case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break; + case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break; + default: UNREACHABLE(); break; + } + + return true; +} + +void TOutputGLSLBase::visitCodeBlock(TIntermNode* node) { + TInfoSinkBase &out = objSink(); + if (node != NULL) + { + node->traverse(this); + // Single statements not part of a sequence need to be terminated + // with semi-colon. + if (isSingleStatement(node)) + out << ";\n"; + } + else + { + out << "{\n}\n"; // Empty code block. + } +} diff --git a/gfx/angle/src/compiler/OutputGLSLBase.h b/gfx/angle/src/compiler/OutputGLSLBase.h new file mode 100644 index 000000000000..efd0b5fc2d8f --- /dev/null +++ b/gfx/angle/src/compiler/OutputGLSLBase.h @@ -0,0 +1,53 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ +#define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ + +#include + +#include "compiler/ForLoopUnroll.h" +#include "compiler/intermediate.h" +#include "compiler/ParseHelper.h" + +class TOutputGLSLBase : public TIntermTraverser +{ +public: + TOutputGLSLBase(TInfoSinkBase& objSink); + +protected: + TInfoSinkBase& objSink() { return mObjSink; } + void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr); + void writeVariableType(const TType& type); + virtual bool writeVariablePrecision(TPrecision precision) = 0; + void writeFunctionParameters(const TIntermSequence& args); + const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); + + virtual void visitSymbol(TIntermSymbol* node); + virtual void visitConstantUnion(TIntermConstantUnion* node); + virtual bool visitBinary(Visit visit, TIntermBinary* node); + virtual bool visitUnary(Visit visit, TIntermUnary* node); + virtual bool visitSelection(Visit visit, TIntermSelection* node); + virtual bool visitAggregate(Visit visit, TIntermAggregate* node); + virtual bool visitLoop(Visit visit, TIntermLoop* node); + virtual bool visitBranch(Visit visit, TIntermBranch* node); + + void visitCodeBlock(TIntermNode* node); + +private: + TInfoSinkBase& mObjSink; + bool mDeclaringVariables; + + // Structs are declared as the tree is traversed. This set contains all + // the structs already declared. It is maintained so that a struct is + // declared only once. + typedef std::set DeclaredStructs; + DeclaredStructs mDeclaredStructs; + + ForLoopUnroll mLoopUnroll; +}; + +#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ diff --git a/gfx/angle/src/compiler/ParseHelper.cpp b/gfx/angle/src/compiler/ParseHelper.cpp index 387484391361..dd997fc620ff 100644 --- a/gfx/angle/src/compiler/ParseHelper.cpp +++ b/gfx/angle/src/compiler/ParseHelper.cpp @@ -196,7 +196,6 @@ bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TM // void TParseContext::recover() { - recoveredFromError = true; } // @@ -261,6 +260,8 @@ void TParseContext::binaryOpError(int line, const char* op, TString left, TStrin } bool TParseContext::precisionErrorCheck(int line, TPrecision precision, TBasicType type){ + if (!checksPrecisionErrors) + return false; switch( type ){ case EbtFloat: if( precision == EbpUndefined ){ @@ -941,6 +942,12 @@ bool TParseContext::extensionErrorCheck(int line, const TString& extension) return false; } +bool TParseContext::supportsExtension(const char* extension) +{ + TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension); + return (iter != extensionBehavior.end()); +} + ///////////////////////////////////////////////////////////////////////////////// // // Non-Errors. diff --git a/gfx/angle/src/compiler/ParseHelper.h b/gfx/angle/src/compiler/ParseHelper.h index f5a6c572eb62..b85eb819e4bb 100644 --- a/gfx/angle/src/compiler/ParseHelper.h +++ b/gfx/angle/src/compiler/ParseHelper.h @@ -30,36 +30,41 @@ struct TPragma { // they can be passed to the parser without needing a global. // struct TParseContext { - TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, const char* sourcePath, TInfoSink& is) : - intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), sourcePath(sourcePath), treeRoot(0), - recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), - inTypeParen(false), scanner(NULL), contextPragma(true, false) { } + TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) : + intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), checksPrecisionErrors(checksPrecErrors), sourcePath(sourcePath), treeRoot(0), + numErrors(0), lexAfterType(false), loopNestingLevel(0), + inTypeParen(false), contextPragma(true, false), scanner(NULL) { } TIntermediate& intermediate; // to hold and build a parse tree TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed - TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior. + TExtensionBehavior& extensionBehavior; // mapping between supported extensions and current behavior. TInfoSink& infoSink; ShShaderType shaderType; // vertex or fragment language (future: pack or unpack) ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. int compileOptions; const char* sourcePath; // Path of source file or NULL. TIntermNode* treeRoot; // root of parse tree being created - bool recoveredFromError; // true if a parse error has occurred, but we continue to parse int numErrors; bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier int loopNestingLevel; // 0 if outside all loops bool inTypeParen; // true if in parentheses, looking only for an identifier const TType* currentFunctionType; // the return type of the function that's currently being parsed bool functionReturnsValue; // true if a non-void function has a return + bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit. + struct TPragma contextPragma; + TString HashErrMsg; + bool AfterEOF; + void* scanner; void error(TSourceLoc loc, const char *reason, const char* token, const char* extraInfoFormat, ...); void warning(TSourceLoc loc, const char* reason, const char* token, const char* extraInfoFormat, ...); - bool reservedErrorCheck(int line, const TString& identifier); void recover(); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line); bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line); + + bool reservedErrorCheck(int line, const TString& identifier); void assignError(int line, const char* op, TString left, TString right); void unaryOpError(int line, const char* op, TString operand); void binaryOpError(int line, const char* op, TString left, TString right); @@ -79,15 +84,19 @@ struct TParseContext { bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason); bool structQualifierErrorCheck(int line, const TPublicType& pType); bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type); - bool containsSampler(TType& type); bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type); bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable); bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type); bool extensionErrorCheck(int line, const TString&); + bool supportsExtension(const char* extension); + + bool containsSampler(TType& type); + bool areAllChildConst(TIntermAggregate* aggrNode); const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0); bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); - bool areAllChildConst(TIntermAggregate* aggrNode); + bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); + TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc); TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset); @@ -96,11 +105,6 @@ struct TParseContext { TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); - bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); - void* scanner; - struct TPragma contextPragma; - TString HashErrMsg; - bool AfterEOF; }; int PaParseStrings(int count, const char* const string[], const int length[], diff --git a/gfx/angle/src/compiler/ShHandle.h b/gfx/angle/src/compiler/ShHandle.h index 109fd7523da5..759d50a5a778 100644 --- a/gfx/angle/src/compiler/ShHandle.h +++ b/gfx/angle/src/compiler/ShHandle.h @@ -16,6 +16,7 @@ #include "GLSLANG/ShaderLang.h" +#include "compiler/BuiltInFunctionEmulator.h" #include "compiler/ExtensionBehavior.h" #include "compiler/InfoSink.h" #include "compiler/SymbolTable.h" @@ -77,6 +78,10 @@ protected: void mapLongVariableNames(TIntermNode* root); // Translate to object code. virtual void translate(TIntermNode* root) = 0; + // Get built-in extensions with default behavior. + const TExtensionBehavior& getExtensionBehavior() const; + + const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const; private: ShShaderType shaderType; @@ -88,6 +93,8 @@ private: // Built-in extensions with default behavior. TExtensionBehavior extensionBehavior; + BuiltInFunctionEmulator builtInFunctionEmulator; + // Results of compilation. TInfoSink infoSink; // Output sink. TVariableInfoList attribs; // Active attributes in the compiled shader. @@ -106,7 +113,8 @@ private: // destroy the machine dependent objects, which contain the // above machine independent information. // -TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec); +TCompiler* ConstructCompiler( + ShShaderType type, ShShaderSpec spec, ShShaderOutput output); void DeleteCompiler(TCompiler*); #endif // _SHHANDLE_INCLUDED_ diff --git a/gfx/angle/src/compiler/ShaderLang.cpp b/gfx/angle/src/compiler/ShaderLang.cpp index 051e4ec92c78..65a4d9b870c4 100644 --- a/gfx/angle/src/compiler/ShaderLang.cpp +++ b/gfx/angle/src/compiler/ShaderLang.cpp @@ -104,18 +104,20 @@ void ShInitBuiltInResources(ShBuiltInResources* resources) // Extensions. resources->OES_standard_derivatives = 0; + resources->OES_EGL_image_external = 0; } // // Driver calls these to create and destroy compiler objects. // ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, + ShShaderOutput output, const ShBuiltInResources* resources) { if (!InitThread()) return 0; - TShHandleBase* base = static_cast(ConstructCompiler(type, spec)); + TShHandleBase* base = static_cast(ConstructCompiler(type, spec, output)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) return 0; diff --git a/gfx/angle/src/compiler/TranslatorESSL.cpp b/gfx/angle/src/compiler/TranslatorESSL.cpp new file mode 100644 index 000000000000..e3a2c2a80240 --- /dev/null +++ b/gfx/angle/src/compiler/TranslatorESSL.cpp @@ -0,0 +1,40 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "compiler/TranslatorESSL.h" + +#include "compiler/OutputESSL.h" + +TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec) + : TCompiler(type, spec) { +} + +void TranslatorESSL::translate(TIntermNode* root) { + TInfoSinkBase& sink = getInfoSink().obj; + + // Write built-in extension behaviors. + writeExtensionBehavior(); + + // Write emulated built-in functions if needed. + getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( + sink, getShaderType() == SH_FRAGMENT_SHADER); + + // Write translated shader. + TOutputESSL outputESSL(sink); + root->traverse(&outputESSL); +} + +void TranslatorESSL::writeExtensionBehavior() { + TInfoSinkBase& sink = getInfoSink().obj; + const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); + for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); + iter != extensionBehavior.end(); ++iter) { + if (iter->second != EBhUndefined) { + sink << "#extension " << iter->first << " : " + << getBehaviorString(iter->second) << "\n"; + } + } +} diff --git a/gfx/angle/src/compiler/TranslatorESSL.h b/gfx/angle/src/compiler/TranslatorESSL.h new file mode 100644 index 000000000000..a1196bd0013a --- /dev/null +++ b/gfx/angle/src/compiler/TranslatorESSL.h @@ -0,0 +1,23 @@ +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_TRANSLATORESSL_H_ +#define COMPILER_TRANSLATORESSL_H_ + +#include "compiler/ShHandle.h" + +class TranslatorESSL : public TCompiler { +public: + TranslatorESSL(ShShaderType type, ShShaderSpec spec); + +protected: + virtual void translate(TIntermNode* root); + +private: + void writeExtensionBehavior(); +}; + +#endif // COMPILER_TRANSLATORESSL_H_ diff --git a/gfx/angle/src/compiler/TranslatorGLSL.cpp b/gfx/angle/src/compiler/TranslatorGLSL.cpp index 7a63ae1f057b..bb07a1eb4e8f 100644 --- a/gfx/angle/src/compiler/TranslatorGLSL.cpp +++ b/gfx/angle/src/compiler/TranslatorGLSL.cpp @@ -31,6 +31,10 @@ void TranslatorGLSL::translate(TIntermNode* root) { // Write GLSL version. writeVersion(getShaderType(), root, sink); + // Write emulated built-in functions if needed. + getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( + sink, false); + // Write translated shader. TOutputGLSL outputGLSL(sink); root->traverse(&outputGLSL); diff --git a/gfx/angle/src/compiler/ValidateLimitations.cpp b/gfx/angle/src/compiler/ValidateLimitations.cpp index b46e4b91b27c..767d0bf38487 100644 --- a/gfx/angle/src/compiler/ValidateLimitations.cpp +++ b/gfx/angle/src/compiler/ValidateLimitations.cpp @@ -53,13 +53,6 @@ public: IsLoopIndex(symbol, mLoopStack); } } - virtual void visitConstantUnion(TIntermConstantUnion*) {} - virtual bool visitBinary(Visit, TIntermBinary*) { return true; } - virtual bool visitUnary(Visit, TIntermUnary*) { return true; } - virtual bool visitSelection(Visit, TIntermSelection*) { return true; } - virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; } - virtual bool visitLoop(Visit, TIntermLoop*) { return true; } - virtual bool visitBranch(Visit, TIntermBranch*) { return true; } private: bool mValid; @@ -94,13 +87,6 @@ public: } } } - virtual void visitConstantUnion(TIntermConstantUnion*) {} - virtual bool visitBinary(Visit, TIntermBinary*) { return true; } - virtual bool visitUnary(Visit, TIntermUnary*) { return true; } - virtual bool visitSelection(Visit, TIntermSelection*) { return true; } - virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; } - virtual bool visitLoop(Visit, TIntermLoop*) { return true; } - virtual bool visitBranch(Visit, TIntermBranch*) { return true; } private: bool mUsesFloatLoopIndex; @@ -117,14 +103,6 @@ ValidateLimitations::ValidateLimitations(ShShaderType shaderType, { } -void ValidateLimitations::visitSymbol(TIntermSymbol*) -{ -} - -void ValidateLimitations::visitConstantUnion(TIntermConstantUnion*) -{ -} - bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node) { // Check if loop index is modified in the loop body. @@ -170,11 +148,6 @@ bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node) return true; } -bool ValidateLimitations::visitSelection(Visit, TIntermSelection*) -{ - return true; -} - bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node) { switch (node->getOp()) { @@ -209,11 +182,6 @@ bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node) return false; } -bool ValidateLimitations::visitBranch(Visit, TIntermBranch*) -{ - return true; -} - void ValidateLimitations::error(TSourceLoc loc, const char *reason, const char* token) { diff --git a/gfx/angle/src/compiler/ValidateLimitations.h b/gfx/angle/src/compiler/ValidateLimitations.h index dd2e5bf09a22..a835cb3c226e 100644 --- a/gfx/angle/src/compiler/ValidateLimitations.h +++ b/gfx/angle/src/compiler/ValidateLimitations.h @@ -25,14 +25,10 @@ public: int numErrors() const { return mNumErrors; } - virtual void visitSymbol(TIntermSymbol*); - virtual void visitConstantUnion(TIntermConstantUnion*); virtual bool visitBinary(Visit, TIntermBinary*); virtual bool visitUnary(Visit, TIntermUnary*); - virtual bool visitSelection(Visit, TIntermSelection*); virtual bool visitAggregate(Visit, TIntermAggregate*); virtual bool visitLoop(Visit, TIntermLoop*); - virtual bool visitBranch(Visit, TIntermBranch*); private: void error(TSourceLoc loc, const char *reason, const char* token); diff --git a/gfx/angle/src/compiler/generate_glslang_lexer.sh b/gfx/angle/src/compiler/generate_glslang_lexer.sh index 268479dadb56..e69de29bb2d1 100644 --- a/gfx/angle/src/compiler/generate_glslang_lexer.sh +++ b/gfx/angle/src/compiler/generate_glslang_lexer.sh @@ -1,11 +0,0 @@ -#!/bin/bash -# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Generates GLSL ES lexer - glslang_lex.cpp - -script_dir=$(dirname $0) -input_file=$script_dir/glslang.l -output_file=$script_dir/glslang_lex.cpp -flex --noline --nounistd --outfile=$output_file $input_file diff --git a/gfx/angle/src/compiler/generate_glslang_parser.sh b/gfx/angle/src/compiler/generate_glslang_parser.sh index 889f5c0dbd41..e69de29bb2d1 100644 --- a/gfx/angle/src/compiler/generate_glslang_parser.sh +++ b/gfx/angle/src/compiler/generate_glslang_parser.sh @@ -1,12 +0,0 @@ -#!/bin/bash -# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp - -script_dir=$(dirname $0) -input_file=$script_dir/glslang.y -output_header=$script_dir/glslang_tab.h -output_source=$script_dir/glslang_tab.cpp -bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file diff --git a/gfx/angle/src/compiler/generate_parser.sh b/gfx/angle/src/compiler/generate_parser.sh new file mode 100644 index 000000000000..e4721915e3cf --- /dev/null +++ b/gfx/angle/src/compiler/generate_parser.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Generates GLSL ES parser - glslang_lex.cpp, glslang_tab.h, and glslang_tab.cpp + +run_flex() +{ +input_file=$script_dir/$1.l +output_source=$script_dir/$1_lex.cpp +flex --noline --nounistd --outfile=$output_source $input_file +} + +run_bison() +{ +input_file=$script_dir/$1.y +output_header=$script_dir/$1_tab.h +output_source=$script_dir/$1_tab.cpp +bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file +} + +script_dir=$(dirname $0) + +# Generate Parser +run_flex glslang +run_bison glslang diff --git a/gfx/angle/src/compiler/glslang.l b/gfx/angle/src/compiler/glslang.l index 5a7c5d52a50f..1eaa30c1c373 100644 --- a/gfx/angle/src/compiler/glslang.l +++ b/gfx/angle/src/compiler/glslang.l @@ -9,7 +9,7 @@ This file contains the Lex specification for GLSL ES. Based on ANSI C grammar, Lex specification: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh, +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). */ @@ -20,7 +20,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). // found in the LICENSE file. // -// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT! +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! } %{ @@ -120,6 +120,7 @@ O [0-7] "sampler2D" { context->lexAfterType = true; return SAMPLER2D; } "samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; } +"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; } "struct" { context->lexAfterType = true; return(STRUCT); } diff --git a/gfx/angle/src/compiler/glslang.y b/gfx/angle/src/compiler/glslang.y index b6fa1638ccad..f0734527b17c 100644 --- a/gfx/angle/src/compiler/glslang.y +++ b/gfx/angle/src/compiler/glslang.y @@ -9,7 +9,7 @@ This file contains the Yacc grammar for GLSL ES. Based on ANSI C Yacc grammar: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html -IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh, +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). */ @@ -20,7 +20,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). // found in the LICENSE file. // -// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! #include "compiler/SymbolTable.h" #include "compiler/ParseHelper.h" @@ -98,7 +98,7 @@ extern void yyerror(TParseContext* context, const char* reason); %token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 %token MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING %token STRUCT VOID_TYPE WHILE -%token SAMPLER2D SAMPLERCUBE +%token SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES %token IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT %token FIELD_SELECTION @@ -591,17 +591,10 @@ function_call_header // Grammar Note: Constructors look like functions, but are recognized as types. function_identifier - : type_specifier { + : type_specifier_nonarray { // // Constructor // - if ($1.array) { - // Constructors for arrays are not allowed. - context->error($1.line, "cannot construct this type", "array", ""); - context->recover(); - $1.setArray(false); - } - TOperator op = EOpNull; if ($1.userDef) { op = EOpConstructStruct; @@ -1176,13 +1169,6 @@ parameter_type_specifier init_declarator_list : single_declaration { $$ = $1; - - if ($$.type.precision == EbpUndefined) { - $$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type); - if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) { - context->recover(); - } - } } | init_declarator_list COMMA IDENTIFIER { TIntermSymbol* symbol = context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line); @@ -1490,6 +1476,13 @@ type_qualifier type_specifier : type_specifier_no_prec { $$ = $1; + + if ($$.precision == EbpUndefined) { + $$.precision = context->symbolTable.getDefaultPrecision($1.type); + if (context->precisionErrorCheck($1.line, $$.precision, $1.type)) { + context->recover(); + } + } } | precision_qualifier type_specifier_no_prec { $$ = $2; @@ -1622,6 +1615,15 @@ type_specifier_nonarray TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; $$.setBasic(EbtSamplerCube, qual, $1.line); } + | SAMPLER_EXTERNAL_OES { + if (!context->supportsExtension("GL_OES_EGL_image_external")) { + context->error($1.line, "unsupported type", "samplerExternalOES", ""); + context->recover(); + } + FRAG_VERT_ONLY("samplerExternalOES", $1.line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + $$.setBasic(EbtSamplerExternalOES, qual, $1.line); + } | struct_specifier { FRAG_VERT_ONLY("struct", $1.line); $$ = $1; @@ -1693,6 +1695,7 @@ struct_declaration type->setBasicType($1.type); type->setNominalSize($1.size); type->setMatrix($1.matrix); + type->setPrecision($1.precision); // don't allow arrays of arrays if (type->isArray()) { diff --git a/gfx/angle/src/compiler/glslang_lex.cpp b/gfx/angle/src/compiler/glslang_lex.cpp index 9d5f53f8fb45..78660563cccb 100644 --- a/gfx/angle/src/compiler/glslang_lex.cpp +++ b/gfx/angle/src/compiler/glslang_lex.cpp @@ -5,7 +5,7 @@ // found in the LICENSE file. // -// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT! +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! @@ -371,8 +371,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 145 -#define YY_END_OF_BUFFER 146 +#define YY_NUM_RULES 146 +#define YY_END_OF_BUFFER 147 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -380,53 +380,55 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[411] = +static yyconst flex_int16_t yy_accept[422] = { 0, - 0, 0, 0, 0, 0, 0, 146, 144, 143, 143, - 128, 134, 139, 123, 124, 132, 131, 120, 129, 127, - 133, 92, 92, 121, 117, 135, 122, 136, 140, 88, - 125, 126, 138, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 118, 137, 119, 130, 3, 4, 3, - 142, 145, 141, 114, 100, 119, 108, 103, 98, 106, - 96, 107, 97, 95, 2, 1, 99, 94, 90, 91, - 0, 0, 92, 126, 118, 125, 115, 111, 113, 112, - 116, 88, 104, 110, 88, 88, 88, 88, 88, 88, + 0, 0, 0, 0, 0, 0, 147, 145, 144, 144, + 129, 135, 140, 124, 125, 133, 132, 121, 130, 128, + 134, 93, 93, 122, 118, 136, 123, 137, 141, 89, + 126, 127, 139, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 119, 138, 120, 131, 3, 4, 3, + 143, 146, 142, 115, 101, 120, 109, 104, 99, 107, + 97, 108, 98, 96, 2, 1, 100, 95, 91, 92, + 0, 0, 93, 127, 119, 126, 116, 112, 114, 113, + 117, 89, 105, 111, 89, 89, 89, 89, 89, 89, - 88, 88, 88, 88, 17, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 20, 22, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 105, 109, 5, 141, - 0, 1, 94, 0, 0, 93, 89, 101, 102, 48, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 18, 88, 88, - 88, 88, 88, 88, 88, 88, 26, 88, 88, 88, - 88, 88, 88, 88, 88, 23, 88, 88, 88, 88, + 89, 89, 89, 89, 17, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 20, 22, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 106, 110, 5, 142, + 0, 1, 95, 0, 0, 94, 90, 102, 103, 49, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 18, 89, 89, + 89, 89, 89, 89, 89, 89, 26, 89, 89, 89, + 89, 89, 89, 89, 89, 23, 89, 89, 89, 89, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 0, 95, - 0, 94, 88, 28, 88, 88, 85, 88, 88, 88, - 88, 88, 88, 88, 21, 51, 88, 88, 88, 88, - 88, 56, 70, 88, 88, 88, 88, 88, 88, 88, - 88, 67, 9, 33, 34, 35, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, - 88, 54, 29, 88, 88, 88, 88, 88, 88, 36, - 37, 38, 27, 88, 88, 88, 15, 42, 43, 44, - 49, 12, 88, 88, 88, 88, 81, 82, 83, 88, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 0, 96, + 0, 95, 89, 28, 89, 89, 86, 89, 89, 89, + 89, 89, 89, 89, 21, 52, 89, 89, 89, 89, + 89, 57, 71, 89, 89, 89, 89, 89, 89, 89, + 89, 68, 9, 33, 34, 35, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, + 89, 55, 29, 89, 89, 89, 89, 89, 89, 36, + 37, 38, 27, 89, 89, 89, 15, 42, 43, 44, + 50, 12, 89, 89, 89, 89, 82, 83, 84, 89, - 30, 71, 25, 78, 79, 80, 7, 75, 76, 77, - 88, 24, 73, 88, 88, 39, 40, 41, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 68, 88, 88, - 88, 88, 88, 88, 88, 50, 88, 87, 88, 88, - 19, 88, 88, 88, 88, 69, 64, 59, 88, 88, - 88, 88, 88, 74, 55, 88, 62, 32, 88, 84, - 63, 47, 57, 88, 88, 88, 88, 88, 88, 88, - 88, 58, 31, 88, 88, 88, 8, 88, 88, 88, - 88, 88, 52, 13, 88, 14, 88, 88, 16, 65, - 88, 88, 88, 60, 88, 88, 88, 53, 72, 61, + 30, 72, 25, 79, 80, 81, 7, 76, 77, 78, + 89, 24, 74, 89, 89, 39, 40, 41, 89, 89, + 89, 89, 89, 89, 89, 89, 89, 69, 89, 89, + 89, 89, 89, 89, 89, 51, 89, 88, 89, 89, + 19, 89, 89, 89, 89, 70, 65, 60, 89, 89, + 89, 89, 89, 75, 56, 89, 63, 32, 89, 85, + 64, 48, 58, 89, 89, 89, 89, 89, 89, 89, + 89, 59, 31, 89, 89, 89, 8, 89, 89, 89, + 89, 89, 53, 13, 89, 14, 89, 89, 16, 66, + 89, 89, 89, 61, 89, 89, 89, 89, 54, 73, - 11, 66, 6, 86, 10, 45, 88, 88, 46, 0 + 62, 11, 67, 6, 87, 10, 45, 89, 89, 89, + 89, 46, 89, 89, 89, 89, 89, 89, 89, 47, + 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -438,13 +440,13 @@ static yyconst flex_int32_t yy_ec[256] = 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 16, 16, 16, 20, 20, 21, 22, 23, 24, 25, 26, 1, 27, 27, 28, 29, 30, 27, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, - 33, 1, 34, 35, 31, 1, 36, 37, 38, 39, + 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, + 31, 31, 33, 31, 31, 31, 31, 34, 31, 31, + 35, 1, 36, 37, 31, 1, 38, 39, 40, 41, - 40, 41, 42, 43, 44, 31, 45, 46, 47, 48, - 49, 50, 31, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 1, 1, 1, 1, + 42, 43, 44, 45, 46, 31, 47, 48, 49, 50, + 51, 52, 31, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -461,195 +463,199 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[64] = +static yyconst flex_int32_t yy_meta[66] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, - 4, 4, 1, 1, 1, 3, 3, 3, 3, 3, - 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, - 1, 1, 1 + 4, 4, 4, 4, 1, 1, 1, 3, 3, 3, + 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[416] = +static yyconst flex_int16_t yy_base[427] = { 0, - 0, 0, 61, 62, 71, 0, 606, 607, 607, 607, - 581, 42, 129, 607, 607, 580, 126, 607, 125, 123, - 137, 149, 157, 578, 607, 175, 578, 44, 607, 0, - 607, 607, 120, 95, 103, 142, 146, 136, 156, 552, - 168, 162, 551, 120, 158, 545, 173, 558, 172, 178, - 111, 186, 554, 607, 159, 607, 607, 607, 607, 582, - 607, 607, 0, 607, 607, 607, 607, 607, 607, 607, - 607, 607, 607, 222, 607, 0, 607, 228, 254, 262, - 281, 0, 290, 607, 607, 607, 571, 607, 607, 607, - 570, 0, 607, 607, 546, 539, 542, 550, 549, 536, + 0, 0, 63, 64, 73, 0, 621, 622, 622, 622, + 596, 44, 133, 622, 622, 595, 130, 622, 129, 127, + 141, 153, 161, 593, 622, 177, 593, 46, 622, 0, + 622, 622, 124, 97, 105, 137, 148, 154, 168, 565, + 151, 167, 564, 121, 158, 558, 111, 571, 177, 176, + 157, 188, 567, 622, 168, 622, 622, 622, 622, 597, + 622, 622, 0, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 225, 622, 0, 622, 231, 259, 267, + 288, 0, 297, 622, 622, 622, 586, 622, 622, 622, + 585, 0, 622, 622, 559, 552, 555, 563, 562, 549, - 551, 538, 544, 532, 529, 542, 529, 526, 526, 532, - 520, 527, 524, 534, 520, 526, 529, 530, 0, 204, - 529, 207, 515, 528, 519, 521, 511, 525, 522, 524, - 507, 512, 509, 498, 183, 512, 508, 510, 499, 502, - 212, 507, 499, 511, 186, 504, 607, 607, 607, 0, - 306, 0, 316, 332, 270, 342, 0, 607, 607, 0, - 496, 500, 509, 506, 490, 490, 161, 505, 502, 502, - 500, 497, 489, 495, 482, 493, 496, 0, 493, 481, - 488, 485, 489, 482, 471, 470, 483, 486, 483, 478, - 469, 294, 474, 477, 468, 465, 469, 475, 466, 457, + 564, 551, 557, 545, 542, 555, 542, 539, 539, 545, + 533, 540, 537, 547, 533, 539, 542, 543, 0, 205, + 542, 170, 528, 541, 532, 534, 524, 538, 535, 537, + 520, 525, 522, 511, 199, 525, 521, 523, 512, 515, + 212, 520, 512, 524, 138, 517, 622, 622, 622, 0, + 313, 0, 325, 341, 275, 353, 0, 622, 622, 0, + 509, 513, 522, 519, 503, 503, 179, 518, 515, 515, + 513, 510, 502, 508, 495, 506, 509, 0, 506, 494, + 501, 498, 502, 495, 484, 483, 496, 499, 496, 491, + 482, 246, 487, 490, 481, 478, 482, 488, 479, 470, - 460, 458, 468, 454, 452, 452, 454, 451, 462, 461, - 278, 456, 451, 440, 320, 458, 460, 449, 348, 354, - 360, 366, 450, 0, 448, 336, 0, 440, 438, 446, - 435, 452, 441, 370, 0, 0, 435, 445, 445, 430, - 373, 0, 0, 432, 376, 433, 427, 426, 427, 426, - 379, 0, 0, 0, 0, 0, 422, 423, 428, 419, - 432, 427, 426, 418, 422, 414, 417, 421, 426, 425, - 416, 0, 0, 422, 411, 411, 416, 415, 412, 0, - 0, 0, 0, 402, 414, 416, 0, 0, 0, 0, - 0, 0, 404, 405, 399, 409, 0, 0, 0, 400, + 473, 471, 481, 467, 465, 465, 467, 464, 475, 474, + 245, 469, 464, 453, 251, 471, 473, 462, 359, 365, + 371, 377, 463, 0, 461, 301, 0, 453, 451, 459, + 448, 465, 454, 317, 0, 0, 448, 458, 458, 443, + 329, 0, 0, 445, 345, 446, 440, 439, 440, 439, + 381, 0, 0, 0, 0, 0, 435, 436, 441, 432, + 445, 440, 439, 431, 435, 427, 430, 434, 439, 438, + 429, 0, 0, 435, 424, 424, 429, 428, 425, 0, + 0, 0, 0, 415, 427, 429, 0, 0, 0, 0, + 0, 0, 417, 418, 412, 422, 0, 0, 0, 413, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 407, 0, 0, 405, 401, 0, 0, 0, 397, 393, - 398, 388, 401, 387, 400, 389, 396, 0, 394, 396, - 380, 389, 395, 390, 378, 0, 380, 0, 379, 382, - 0, 371, 370, 370, 383, 0, 385, 0, 384, 383, - 368, 381, 368, 0, 0, 371, 0, 0, 363, 0, - 0, 0, 0, 360, 371, 364, 368, 303, 297, 288, - 300, 0, 0, 283, 290, 269, 0, 277, 274, 255, - 232, 255, 0, 0, 244, 0, 236, 226, 0, 0, - 225, 208, 211, 0, 185, 202, 131, 0, 0, 0, + 420, 0, 0, 418, 414, 0, 0, 0, 410, 406, + 411, 401, 414, 400, 413, 402, 409, 0, 407, 409, + 393, 402, 408, 403, 391, 0, 393, 0, 392, 395, + 0, 384, 383, 383, 396, 0, 398, 0, 397, 396, + 381, 394, 381, 0, 0, 384, 0, 0, 376, 0, + 0, 0, 0, 373, 384, 377, 383, 380, 375, 367, + 379, 0, 0, 372, 379, 368, 0, 377, 374, 364, + 294, 372, 0, 0, 372, 0, 368, 324, 0, 0, + 323, 299, 310, 0, 300, 320, 282, 278, 0, 0, - 0, 0, 0, 0, 0, 0, 134, 117, 0, 607, - 398, 400, 402, 406, 142 + 0, 0, 0, 0, 0, 0, 0, 287, 266, 260, + 257, 0, 228, 221, 221, 206, 206, 197, 160, 0, + 622, 400, 402, 404, 408, 157 } ; -static yyconst flex_int16_t yy_def[416] = +static yyconst flex_int16_t yy_def[427] = { 0, - 410, 1, 411, 411, 410, 5, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 412, - 410, 410, 410, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 413, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 414, 410, 410, 410, 410, - 410, 415, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 412, 410, 410, 412, 412, 412, 412, 412, 412, + 421, 1, 422, 422, 421, 5, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 423, + 421, 421, 421, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 424, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 425, 421, 421, 421, 421, + 421, 426, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 423, 421, 421, 423, 423, 423, 423, 423, 423, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 410, 410, 410, 413, - 410, 414, 410, 410, 410, 410, 415, 410, 410, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 421, 421, 421, 424, + 421, 425, 421, 421, 421, 421, 426, 421, 421, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 410, 410, - 410, 410, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 421, 421, + 421, 421, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, - 412, 412, 412, 412, 412, 412, 412, 412, 412, 0, - 410, 410, 410, 410, 410 + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 423, 423, 423, 423, 423, 423, 423, 423, 423, 423, + 0, 421, 421, 421, 421, 421 } ; -static yyconst flex_int16_t yy_nxt[671] = +static yyconst flex_int16_t yy_nxt[688] = { 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 23, 23, 23, 24, 25, 26, 27, 28, 29, 30, 30, 30, 30, - 30, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 30, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 30, 30, 30, 54, - 55, 56, 57, 59, 59, 65, 66, 90, 91, 60, - 60, 8, 61, 62, 8, 8, 8, 8, 8, 8, + 30, 30, 30, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 30, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 30, 30, + 30, 54, 55, 56, 57, 59, 59, 65, 66, 90, + 91, 60, 60, 8, 61, 62, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 63, 63, 63, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 63, - 63, 63, 63, 8, 8, 8, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 8, 8, 8, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 8, 8, 8, 8, 67, 70, 72, 74, 74, 74, - 74, 74, 74, 93, 157, 75, 95, 96, 73, 71, - 76, 97, 68, 98, 94, 123, 409, 99, 141, 124, - 77, 78, 142, 79, 79, 79, 79, 79, 80, 78, - 408, 83, 83, 83, 83, 83, 83, 100, 81, 85, - 82, 107, 147, 108, 407, 103, 81, 101, 81, 104, - 102, 110, 109, 125, 105, 86, 81, 87, 88, 111, + 63, 63, 63, 63, 8, 8, 8, 8, 67, 70, + 72, 74, 74, 74, 74, 74, 74, 93, 128, 75, + 95, 96, 73, 71, 76, 97, 68, 98, 123, 157, + 94, 99, 124, 129, 77, 78, 130, 79, 79, 79, + 79, 79, 80, 78, 100, 83, 83, 83, 83, 83, + 83, 85, 81, 216, 101, 217, 82, 102, 116, 103, + 81, 147, 420, 104, 81, 125, 117, 86, 105, 87, - 106, 112, 119, 116, 113, 82, 126, 132, 128, 120, - 114, 117, 229, 230, 133, 134, 121, 137, 204, 148, - 138, 143, 118, 129, 135, 144, 130, 136, 139, 216, - 406, 217, 405, 205, 145, 140, 74, 74, 74, 74, - 74, 74, 153, 153, 153, 153, 153, 153, 396, 184, - 404, 151, 185, 186, 190, 211, 187, 154, 188, 397, - 403, 151, 191, 212, 402, 401, 78, 154, 79, 79, - 79, 79, 79, 80, 78, 400, 80, 80, 80, 80, - 80, 80, 399, 81, 156, 156, 156, 156, 156, 156, - 155, 81, 155, 81, 398, 156, 156, 156, 156, 156, + 88, 107, 81, 108, 106, 110, 141, 118, 126, 119, + 142, 82, 109, 111, 132, 112, 120, 137, 113, 190, + 138, 133, 134, 121, 114, 143, 419, 191, 139, 144, + 148, 135, 229, 230, 136, 140, 204, 418, 145, 74, + 74, 74, 74, 74, 74, 153, 153, 153, 153, 153, + 153, 205, 184, 417, 151, 185, 186, 211, 416, 187, + 154, 188, 254, 255, 256, 212, 151, 280, 281, 282, + 415, 78, 154, 79, 79, 79, 79, 79, 80, 78, + 414, 80, 80, 80, 80, 80, 80, 275, 81, 156, + 156, 156, 156, 156, 156, 276, 81, 155, 413, 155, - 156, 81, 78, 395, 83, 83, 83, 83, 83, 83, - 254, 255, 256, 394, 393, 219, 392, 219, 275, 81, - 220, 220, 220, 220, 220, 220, 276, 391, 390, 81, - 153, 153, 153, 153, 153, 153, 280, 281, 282, 389, - 388, 221, 387, 221, 386, 154, 222, 222, 222, 222, - 222, 222, 288, 289, 290, 154, 156, 156, 156, 156, - 156, 156, 220, 220, 220, 220, 220, 220, 220, 220, - 220, 220, 220, 220, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 297, 298, 299, 304, - 305, 306, 308, 309, 310, 316, 317, 318, 58, 58, + 81, 412, 156, 156, 156, 156, 156, 156, 81, 78, + 396, 83, 83, 83, 83, 83, 83, 288, 289, 290, + 411, 397, 219, 398, 219, 410, 81, 220, 220, 220, + 220, 220, 220, 297, 298, 299, 409, 408, 81, 153, + 153, 153, 153, 153, 153, 304, 305, 306, 407, 406, + 221, 405, 221, 404, 154, 222, 222, 222, 222, 222, + 222, 308, 309, 310, 403, 402, 154, 156, 156, 156, + 156, 156, 156, 220, 220, 220, 220, 220, 220, 220, + 220, 220, 220, 220, 220, 222, 222, 222, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 316, 317, 318, - 58, 58, 92, 92, 150, 150, 152, 385, 152, 152, - 384, 383, 382, 381, 380, 379, 378, 377, 376, 375, - 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, - 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, - 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, - 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, - 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, - 324, 323, 322, 321, 320, 319, 315, 314, 313, 312, - 311, 307, 303, 302, 301, 300, 296, 295, 294, 293, - 292, 291, 287, 286, 285, 284, 283, 279, 278, 277, + 58, 58, 58, 58, 92, 92, 150, 150, 152, 401, + 152, 152, 400, 399, 395, 394, 393, 392, 391, 390, + 389, 388, 387, 386, 385, 384, 383, 382, 381, 380, + 379, 378, 377, 376, 375, 374, 373, 372, 371, 370, + 369, 368, 367, 366, 365, 364, 363, 362, 361, 360, + 359, 358, 357, 356, 355, 354, 353, 352, 351, 350, + 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, + 339, 338, 337, 336, 335, 334, 333, 332, 331, 330, + 329, 328, 327, 326, 325, 324, 323, 322, 321, 320, + 319, 315, 314, 313, 312, 311, 307, 303, 302, 301, - 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, - 264, 263, 262, 261, 260, 259, 258, 257, 253, 252, - 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, - 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, - 231, 228, 227, 226, 225, 224, 223, 218, 215, 214, - 213, 210, 209, 208, 207, 206, 203, 202, 201, 200, - 199, 198, 197, 196, 195, 194, 193, 192, 189, 183, - 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, - 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, - 162, 161, 160, 159, 158, 149, 146, 131, 127, 122, + 300, 296, 295, 294, 293, 292, 291, 287, 286, 285, + 284, 283, 279, 278, 277, 274, 273, 272, 271, 270, + 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, + 259, 258, 257, 253, 252, 251, 250, 249, 248, 247, + 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, + 236, 235, 234, 233, 232, 231, 228, 227, 226, 225, + 224, 223, 218, 215, 214, 213, 210, 209, 208, 207, + 206, 203, 202, 201, 200, 199, 198, 197, 196, 195, + 194, 193, 192, 189, 183, 182, 181, 180, 179, 178, + 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, - 115, 89, 84, 69, 64, 410, 7, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410 + 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, + 149, 146, 131, 127, 122, 115, 89, 84, 69, 64, + 421, 7, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421 } ; -static yyconst flex_int16_t yy_chk[671] = +static yyconst flex_int16_t yy_chk[688] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -657,77 +663,79 @@ static yyconst flex_int16_t yy_chk[671] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 12, 12, 28, 28, 3, - 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 1, 1, 1, 1, 1, 3, 4, 12, 12, 28, + 28, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 13, 17, 19, 20, 20, 20, - 20, 20, 20, 33, 415, 21, 34, 34, 19, 17, - 21, 35, 13, 35, 33, 44, 408, 35, 51, 44, - 21, 22, 51, 22, 22, 22, 22, 22, 22, 23, - 407, 23, 23, 23, 23, 23, 23, 36, 22, 26, - 22, 38, 55, 38, 397, 37, 23, 36, 22, 37, - 36, 39, 38, 45, 37, 26, 23, 26, 26, 39, + 5, 5, 5, 5, 5, 5, 5, 5, 13, 17, + 19, 20, 20, 20, 20, 20, 20, 33, 47, 21, + 34, 34, 19, 17, 21, 35, 13, 35, 44, 426, + 33, 35, 44, 47, 21, 22, 47, 22, 22, 22, + 22, 22, 22, 23, 36, 23, 23, 23, 23, 23, + 23, 26, 22, 145, 36, 145, 22, 36, 41, 37, + 23, 55, 419, 37, 22, 45, 41, 26, 37, 26, - 37, 39, 42, 41, 39, 22, 45, 49, 47, 42, - 39, 41, 167, 167, 49, 49, 42, 50, 135, 55, - 50, 52, 41, 47, 49, 52, 47, 49, 50, 145, - 396, 145, 395, 135, 52, 50, 74, 74, 74, 74, - 74, 74, 78, 78, 78, 78, 78, 78, 381, 120, - 393, 74, 120, 120, 122, 141, 120, 78, 120, 381, - 392, 74, 122, 141, 391, 388, 79, 78, 79, 79, - 79, 79, 79, 79, 80, 387, 80, 80, 80, 80, - 80, 80, 385, 79, 155, 155, 155, 155, 155, 155, - 81, 80, 81, 79, 382, 81, 81, 81, 81, 81, + 26, 38, 23, 38, 37, 39, 51, 41, 45, 42, + 51, 22, 38, 39, 49, 39, 42, 50, 39, 122, + 50, 49, 49, 42, 39, 52, 418, 122, 50, 52, + 55, 49, 167, 167, 49, 50, 135, 417, 52, 74, + 74, 74, 74, 74, 74, 78, 78, 78, 78, 78, + 78, 135, 120, 416, 74, 120, 120, 141, 415, 120, + 78, 120, 192, 192, 192, 141, 74, 215, 215, 215, + 414, 79, 78, 79, 79, 79, 79, 79, 79, 80, + 413, 80, 80, 80, 80, 80, 80, 211, 79, 155, + 155, 155, 155, 155, 155, 211, 80, 81, 411, 81, - 81, 80, 83, 380, 83, 83, 83, 83, 83, 83, - 192, 192, 192, 379, 378, 151, 376, 151, 211, 83, - 151, 151, 151, 151, 151, 151, 211, 375, 374, 83, - 153, 153, 153, 153, 153, 153, 215, 215, 215, 371, - 370, 154, 369, 154, 368, 153, 154, 154, 154, 154, - 154, 154, 226, 226, 226, 153, 156, 156, 156, 156, - 156, 156, 219, 219, 219, 219, 219, 219, 220, 220, - 220, 220, 220, 220, 221, 221, 221, 221, 221, 221, - 222, 222, 222, 222, 222, 222, 234, 234, 234, 241, - 241, 241, 245, 245, 245, 251, 251, 251, 411, 411, + 79, 410, 81, 81, 81, 81, 81, 81, 80, 83, + 381, 83, 83, 83, 83, 83, 83, 226, 226, 226, + 409, 381, 151, 381, 151, 408, 83, 151, 151, 151, + 151, 151, 151, 234, 234, 234, 398, 397, 83, 153, + 153, 153, 153, 153, 153, 241, 241, 241, 396, 395, + 154, 393, 154, 392, 153, 154, 154, 154, 154, 154, + 154, 245, 245, 245, 391, 388, 153, 156, 156, 156, + 156, 156, 156, 219, 219, 219, 219, 219, 219, 220, + 220, 220, 220, 220, 220, 221, 221, 221, 221, 221, + 221, 222, 222, 222, 222, 222, 222, 251, 251, 251, - 411, 411, 412, 412, 413, 413, 414, 367, 414, 414, - 366, 365, 364, 359, 356, 353, 352, 351, 350, 349, - 347, 345, 344, 343, 342, 340, 339, 337, 335, 334, - 333, 332, 331, 330, 329, 327, 326, 325, 324, 323, - 322, 321, 320, 319, 315, 314, 311, 300, 296, 295, - 294, 293, 286, 285, 284, 279, 278, 277, 276, 275, - 274, 271, 270, 269, 268, 267, 266, 265, 264, 263, - 262, 261, 260, 259, 258, 257, 250, 249, 248, 247, - 246, 244, 240, 239, 238, 237, 233, 232, 231, 230, - 229, 228, 225, 223, 218, 217, 216, 214, 213, 212, + 422, 422, 422, 422, 423, 423, 424, 424, 425, 387, + 425, 425, 385, 382, 380, 379, 378, 376, 375, 374, + 371, 370, 369, 368, 367, 366, 365, 364, 359, 356, + 353, 352, 351, 350, 349, 347, 345, 344, 343, 342, + 340, 339, 337, 335, 334, 333, 332, 331, 330, 329, + 327, 326, 325, 324, 323, 322, 321, 320, 319, 315, + 314, 311, 300, 296, 295, 294, 293, 286, 285, 284, + 279, 278, 277, 276, 275, 274, 271, 270, 269, 268, + 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, + 257, 250, 249, 248, 247, 246, 244, 240, 239, 238, - 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, - 200, 199, 198, 197, 196, 195, 194, 193, 191, 190, - 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, - 179, 177, 176, 175, 174, 173, 172, 171, 170, 169, - 168, 166, 165, 164, 163, 162, 161, 146, 144, 143, - 142, 140, 139, 138, 137, 136, 134, 133, 132, 131, - 130, 129, 128, 127, 126, 125, 124, 123, 121, 118, - 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, - 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, - 97, 96, 95, 91, 87, 60, 53, 48, 46, 43, + 237, 233, 232, 231, 230, 229, 228, 225, 223, 218, + 217, 216, 214, 213, 212, 210, 209, 208, 207, 206, + 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, + 195, 194, 193, 191, 190, 189, 188, 187, 186, 185, + 184, 183, 182, 181, 180, 179, 177, 176, 175, 174, + 173, 172, 171, 170, 169, 168, 166, 165, 164, 163, + 162, 161, 146, 144, 143, 142, 140, 139, 138, 137, + 136, 134, 133, 132, 131, 130, 129, 128, 127, 126, + 125, 124, 123, 121, 118, 117, 116, 115, 114, 113, + 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, - 40, 27, 24, 16, 11, 7, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410 + 102, 101, 100, 99, 98, 97, 96, 95, 91, 87, + 60, 53, 48, 46, 43, 40, 27, 24, 16, 11, + 7, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, + 421, 421, 421, 421, 421, 421, 421 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[146] = +static yyconst flex_int32_t yy_rule_can_match_eol[147] = { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -736,7 +744,7 @@ static yyconst flex_int32_t yy_rule_can_match_eol[146] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, }; + 0, 0, 0, 0, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -756,7 +764,7 @@ This file contains the Lex specification for GLSL ES. Based on ANSI C grammar, Lex specification: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh, +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh, WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). */ @@ -1062,13 +1070,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 411 ) + if ( yy_current_state >= 422 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 410 ); + while ( yy_current_state != 421 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1285,11 +1293,11 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -{ context->lexAfterType = true; return(STRUCT); } +{ context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; } YY_BREAK case 48: YY_RULE_SETUP -{ return reserved_word(yyscanner); } +{ context->lexAfterType = true; return(STRUCT); } YY_BREAK case 49: YY_RULE_SETUP @@ -1449,30 +1457,30 @@ YY_RULE_SETUP YY_BREAK case 88: YY_RULE_SETUP +{ return reserved_word(yyscanner); } + YY_BREAK +case 89: +YY_RULE_SETUP { yylval->lex.string = NewPoolTString(yytext); return check_type(yyscanner); } YY_BREAK -case 89: -YY_RULE_SETUP -{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } - YY_BREAK case 90: YY_RULE_SETUP { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } YY_BREAK case 91: YY_RULE_SETUP -{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;} +{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } YY_BREAK case 92: YY_RULE_SETUP -{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } +{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;} YY_BREAK case 93: YY_RULE_SETUP -{ yylval->lex.f = static_cast(atof_dot(yytext)); return(FLOATCONSTANT); } +{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } YY_BREAK case 94: YY_RULE_SETUP @@ -1484,198 +1492,202 @@ YY_RULE_SETUP YY_BREAK case 96: YY_RULE_SETUP -{ return(ADD_ASSIGN); } +{ yylval->lex.f = static_cast(atof_dot(yytext)); return(FLOATCONSTANT); } YY_BREAK case 97: YY_RULE_SETUP -{ return(SUB_ASSIGN); } +{ return(ADD_ASSIGN); } YY_BREAK case 98: YY_RULE_SETUP -{ return(MUL_ASSIGN); } +{ return(SUB_ASSIGN); } YY_BREAK case 99: YY_RULE_SETUP -{ return(DIV_ASSIGN); } +{ return(MUL_ASSIGN); } YY_BREAK case 100: YY_RULE_SETUP -{ return(MOD_ASSIGN); } +{ return(DIV_ASSIGN); } YY_BREAK case 101: YY_RULE_SETUP -{ return(LEFT_ASSIGN); } +{ return(MOD_ASSIGN); } YY_BREAK case 102: YY_RULE_SETUP -{ return(RIGHT_ASSIGN); } +{ return(LEFT_ASSIGN); } YY_BREAK case 103: YY_RULE_SETUP -{ return(AND_ASSIGN); } +{ return(RIGHT_ASSIGN); } YY_BREAK case 104: YY_RULE_SETUP -{ return(XOR_ASSIGN); } +{ return(AND_ASSIGN); } YY_BREAK case 105: YY_RULE_SETUP -{ return(OR_ASSIGN); } +{ return(XOR_ASSIGN); } YY_BREAK case 106: YY_RULE_SETUP -{ return(INC_OP); } +{ return(OR_ASSIGN); } YY_BREAK case 107: YY_RULE_SETUP -{ return(DEC_OP); } +{ return(INC_OP); } YY_BREAK case 108: YY_RULE_SETUP -{ return(AND_OP); } +{ return(DEC_OP); } YY_BREAK case 109: YY_RULE_SETUP -{ return(OR_OP); } +{ return(AND_OP); } YY_BREAK case 110: YY_RULE_SETUP -{ return(XOR_OP); } +{ return(OR_OP); } YY_BREAK case 111: YY_RULE_SETUP -{ return(LE_OP); } +{ return(XOR_OP); } YY_BREAK case 112: YY_RULE_SETUP -{ return(GE_OP); } +{ return(LE_OP); } YY_BREAK case 113: YY_RULE_SETUP -{ return(EQ_OP); } +{ return(GE_OP); } YY_BREAK case 114: YY_RULE_SETUP -{ return(NE_OP); } +{ return(EQ_OP); } YY_BREAK case 115: YY_RULE_SETUP -{ return(LEFT_OP); } +{ return(NE_OP); } YY_BREAK case 116: YY_RULE_SETUP -{ return(RIGHT_OP); } +{ return(LEFT_OP); } YY_BREAK case 117: YY_RULE_SETUP -{ context->lexAfterType = false; return(SEMICOLON); } +{ return(RIGHT_OP); } YY_BREAK case 118: YY_RULE_SETUP -{ context->lexAfterType = false; return(LEFT_BRACE); } +{ context->lexAfterType = false; return(SEMICOLON); } YY_BREAK case 119: YY_RULE_SETUP -{ return(RIGHT_BRACE); } +{ context->lexAfterType = false; return(LEFT_BRACE); } YY_BREAK case 120: YY_RULE_SETUP -{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); } +{ return(RIGHT_BRACE); } YY_BREAK case 121: YY_RULE_SETUP -{ return(COLON); } +{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); } YY_BREAK case 122: YY_RULE_SETUP -{ context->lexAfterType = false; return(EQUAL); } +{ return(COLON); } YY_BREAK case 123: YY_RULE_SETUP -{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); } +{ context->lexAfterType = false; return(EQUAL); } YY_BREAK case 124: YY_RULE_SETUP -{ context->inTypeParen = false; return(RIGHT_PAREN); } +{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); } YY_BREAK case 125: YY_RULE_SETUP -{ return(LEFT_BRACKET); } +{ context->inTypeParen = false; return(RIGHT_PAREN); } YY_BREAK case 126: YY_RULE_SETUP -{ return(RIGHT_BRACKET); } +{ return(LEFT_BRACKET); } YY_BREAK case 127: YY_RULE_SETUP -{ BEGIN(FIELDS); return(DOT); } +{ return(RIGHT_BRACKET); } YY_BREAK case 128: YY_RULE_SETUP -{ return(BANG); } +{ BEGIN(FIELDS); return(DOT); } YY_BREAK case 129: YY_RULE_SETUP -{ return(DASH); } +{ return(BANG); } YY_BREAK case 130: YY_RULE_SETUP -{ return(TILDE); } +{ return(DASH); } YY_BREAK case 131: YY_RULE_SETUP -{ return(PLUS); } +{ return(TILDE); } YY_BREAK case 132: YY_RULE_SETUP -{ return(STAR); } +{ return(PLUS); } YY_BREAK case 133: YY_RULE_SETUP -{ return(SLASH); } +{ return(STAR); } YY_BREAK case 134: YY_RULE_SETUP -{ return(PERCENT); } +{ return(SLASH); } YY_BREAK case 135: YY_RULE_SETUP -{ return(LEFT_ANGLE); } +{ return(PERCENT); } YY_BREAK case 136: YY_RULE_SETUP -{ return(RIGHT_ANGLE); } +{ return(LEFT_ANGLE); } YY_BREAK case 137: YY_RULE_SETUP -{ return(VERTICAL_BAR); } +{ return(RIGHT_ANGLE); } YY_BREAK case 138: YY_RULE_SETUP -{ return(CARET); } +{ return(VERTICAL_BAR); } YY_BREAK case 139: YY_RULE_SETUP -{ return(AMPERSAND); } +{ return(CARET); } YY_BREAK case 140: YY_RULE_SETUP -{ return(QUESTION); } +{ return(AMPERSAND); } YY_BREAK case 141: YY_RULE_SETUP +{ return(QUESTION); } + YY_BREAK +case 142: +YY_RULE_SETUP { BEGIN(INITIAL); yylval->lex.string = NewPoolTString(yytext); return FIELD_SELECTION; } YY_BREAK -case 142: +case 143: YY_RULE_SETUP {} YY_BREAK -case 143: -/* rule 143 can match eol */ +case 144: +/* rule 144 can match eol */ YY_RULE_SETUP { } YY_BREAK @@ -1684,11 +1696,11 @@ case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(FIELDS): { context->AfterEOF = true; yyterminate(); } YY_BREAK -case 144: +case 145: YY_RULE_SETUP { context->warning(yylineno, "Unknown char", yytext, ""); return 0; } YY_BREAK -case 145: +case 146: YY_RULE_SETUP ECHO; YY_BREAK @@ -1984,7 +1996,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 411 ) + if ( yy_current_state >= 422 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2013,11 +2025,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 411 ) + if ( yy_current_state >= 422 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 410); + yy_is_jam = (yy_current_state == 421); return yy_is_jam ? 0 : yy_current_state; } diff --git a/gfx/angle/src/compiler/glslang_tab.cpp b/gfx/angle/src/compiler/glslang_tab.cpp index 83ac52493ad8..6e54e96be4c7 100644 --- a/gfx/angle/src/compiler/glslang_tab.cpp +++ b/gfx/angle/src/compiler/glslang_tab.cpp @@ -106,57 +106,58 @@ WHILE = 295, SAMPLER2D = 296, SAMPLERCUBE = 297, - IDENTIFIER = 298, - TYPE_NAME = 299, - FLOATCONSTANT = 300, - INTCONSTANT = 301, - BOOLCONSTANT = 302, - FIELD_SELECTION = 303, - LEFT_OP = 304, - RIGHT_OP = 305, - INC_OP = 306, - DEC_OP = 307, - LE_OP = 308, - GE_OP = 309, - EQ_OP = 310, - NE_OP = 311, - AND_OP = 312, - OR_OP = 313, - XOR_OP = 314, - MUL_ASSIGN = 315, - DIV_ASSIGN = 316, - ADD_ASSIGN = 317, - MOD_ASSIGN = 318, - LEFT_ASSIGN = 319, - RIGHT_ASSIGN = 320, - AND_ASSIGN = 321, - XOR_ASSIGN = 322, - OR_ASSIGN = 323, - SUB_ASSIGN = 324, - LEFT_PAREN = 325, - RIGHT_PAREN = 326, - LEFT_BRACKET = 327, - RIGHT_BRACKET = 328, - LEFT_BRACE = 329, - RIGHT_BRACE = 330, - DOT = 331, - COMMA = 332, - COLON = 333, - EQUAL = 334, - SEMICOLON = 335, - BANG = 336, - DASH = 337, - TILDE = 338, - PLUS = 339, - STAR = 340, - SLASH = 341, - PERCENT = 342, - LEFT_ANGLE = 343, - RIGHT_ANGLE = 344, - VERTICAL_BAR = 345, - CARET = 346, - AMPERSAND = 347, - QUESTION = 348 + SAMPLER_EXTERNAL_OES = 298, + IDENTIFIER = 299, + TYPE_NAME = 300, + FLOATCONSTANT = 301, + INTCONSTANT = 302, + BOOLCONSTANT = 303, + FIELD_SELECTION = 304, + LEFT_OP = 305, + RIGHT_OP = 306, + INC_OP = 307, + DEC_OP = 308, + LE_OP = 309, + GE_OP = 310, + EQ_OP = 311, + NE_OP = 312, + AND_OP = 313, + OR_OP = 314, + XOR_OP = 315, + MUL_ASSIGN = 316, + DIV_ASSIGN = 317, + ADD_ASSIGN = 318, + MOD_ASSIGN = 319, + LEFT_ASSIGN = 320, + RIGHT_ASSIGN = 321, + AND_ASSIGN = 322, + XOR_ASSIGN = 323, + OR_ASSIGN = 324, + SUB_ASSIGN = 325, + LEFT_PAREN = 326, + RIGHT_PAREN = 327, + LEFT_BRACKET = 328, + RIGHT_BRACKET = 329, + LEFT_BRACE = 330, + RIGHT_BRACE = 331, + DOT = 332, + COMMA = 333, + COLON = 334, + EQUAL = 335, + SEMICOLON = 336, + BANG = 337, + DASH = 338, + TILDE = 339, + PLUS = 340, + STAR = 341, + SLASH = 342, + PERCENT = 343, + LEFT_ANGLE = 344, + RIGHT_ANGLE = 345, + VERTICAL_BAR = 346, + CARET = 347, + AMPERSAND = 348, + QUESTION = 349 }; #endif /* Tokens. */ @@ -200,57 +201,58 @@ #define WHILE 295 #define SAMPLER2D 296 #define SAMPLERCUBE 297 -#define IDENTIFIER 298 -#define TYPE_NAME 299 -#define FLOATCONSTANT 300 -#define INTCONSTANT 301 -#define BOOLCONSTANT 302 -#define FIELD_SELECTION 303 -#define LEFT_OP 304 -#define RIGHT_OP 305 -#define INC_OP 306 -#define DEC_OP 307 -#define LE_OP 308 -#define GE_OP 309 -#define EQ_OP 310 -#define NE_OP 311 -#define AND_OP 312 -#define OR_OP 313 -#define XOR_OP 314 -#define MUL_ASSIGN 315 -#define DIV_ASSIGN 316 -#define ADD_ASSIGN 317 -#define MOD_ASSIGN 318 -#define LEFT_ASSIGN 319 -#define RIGHT_ASSIGN 320 -#define AND_ASSIGN 321 -#define XOR_ASSIGN 322 -#define OR_ASSIGN 323 -#define SUB_ASSIGN 324 -#define LEFT_PAREN 325 -#define RIGHT_PAREN 326 -#define LEFT_BRACKET 327 -#define RIGHT_BRACKET 328 -#define LEFT_BRACE 329 -#define RIGHT_BRACE 330 -#define DOT 331 -#define COMMA 332 -#define COLON 333 -#define EQUAL 334 -#define SEMICOLON 335 -#define BANG 336 -#define DASH 337 -#define TILDE 338 -#define PLUS 339 -#define STAR 340 -#define SLASH 341 -#define PERCENT 342 -#define LEFT_ANGLE 343 -#define RIGHT_ANGLE 344 -#define VERTICAL_BAR 345 -#define CARET 346 -#define AMPERSAND 347 -#define QUESTION 348 +#define SAMPLER_EXTERNAL_OES 298 +#define IDENTIFIER 299 +#define TYPE_NAME 300 +#define FLOATCONSTANT 301 +#define INTCONSTANT 302 +#define BOOLCONSTANT 303 +#define FIELD_SELECTION 304 +#define LEFT_OP 305 +#define RIGHT_OP 306 +#define INC_OP 307 +#define DEC_OP 308 +#define LE_OP 309 +#define GE_OP 310 +#define EQ_OP 311 +#define NE_OP 312 +#define AND_OP 313 +#define OR_OP 314 +#define XOR_OP 315 +#define MUL_ASSIGN 316 +#define DIV_ASSIGN 317 +#define ADD_ASSIGN 318 +#define MOD_ASSIGN 319 +#define LEFT_ASSIGN 320 +#define RIGHT_ASSIGN 321 +#define AND_ASSIGN 322 +#define XOR_ASSIGN 323 +#define OR_ASSIGN 324 +#define SUB_ASSIGN 325 +#define LEFT_PAREN 326 +#define RIGHT_PAREN 327 +#define LEFT_BRACKET 328 +#define RIGHT_BRACKET 329 +#define LEFT_BRACE 330 +#define RIGHT_BRACE 331 +#define DOT 332 +#define COMMA 333 +#define COLON 334 +#define EQUAL 335 +#define SEMICOLON 336 +#define BANG 337 +#define DASH 338 +#define TILDE 339 +#define PLUS 340 +#define STAR 341 +#define SLASH 342 +#define PERCENT 343 +#define LEFT_ANGLE 344 +#define RIGHT_ANGLE 345 +#define VERTICAL_BAR 346 +#define CARET 347 +#define AMPERSAND 348 +#define QUESTION 349 @@ -264,7 +266,7 @@ // found in the LICENSE file. // -// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! #include "compiler/SymbolTable.h" #include "compiler/ParseHelper.h" @@ -325,7 +327,7 @@ typedef union YYSTYPE }; } interm; } -/* Line 193 of yacc.c. */ +/* Line 187 of yacc.c. */ YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -415,7 +417,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -578,22 +580,22 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 69 +#define YYFINAL 70 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1334 +#define YYLAST 1381 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 94 +#define YYNTOKENS 95 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 78 /* YYNRULES -- Number of rules. */ -#define YYNRULES 193 +#define YYNRULES 194 /* YYNRULES -- Number of states. */ -#define YYNSTATES 296 +#define YYNSTATES 297 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 348 +#define YYMAXUTOK 349 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -635,7 +637,7 @@ static const yytype_uint8 yytranslate[] = 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93 + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94 }; #if YYDEBUG @@ -656,74 +658,74 @@ static const yytype_uint16 yyprhs[] = 298, 303, 306, 308, 311, 313, 315, 317, 320, 322, 324, 327, 329, 331, 333, 335, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, - 368, 370, 372, 374, 376, 378, 380, 386, 391, 393, - 396, 400, 402, 406, 408, 413, 415, 417, 419, 421, - 423, 425, 427, 429, 431, 434, 435, 436, 442, 444, - 446, 449, 453, 455, 458, 460, 463, 469, 473, 475, - 477, 482, 483, 490, 491, 500, 501, 509, 511, 513, - 515, 516, 519, 523, 526, 529, 532, 536, 539, 541, - 544, 546, 548, 549 + 368, 370, 372, 374, 376, 378, 380, 382, 388, 393, + 395, 398, 402, 404, 408, 410, 415, 417, 419, 421, + 423, 425, 427, 429, 431, 433, 436, 437, 438, 444, + 446, 448, 451, 455, 457, 460, 462, 465, 471, 475, + 477, 479, 484, 485, 492, 493, 502, 503, 511, 513, + 515, 517, 518, 521, 525, 528, 531, 534, 538, 541, + 543, 546, 548, 550, 551 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 168, 0, -1, 43, -1, 95, -1, 46, -1, 45, - -1, 47, -1, 70, 122, 71, -1, 96, -1, 97, - 72, 98, 73, -1, 99, -1, 97, 76, 48, -1, - 97, 51, -1, 97, 52, -1, 122, -1, 100, -1, - 101, -1, 97, 76, 101, -1, 103, 71, -1, 102, - 71, -1, 104, 39, -1, 104, -1, 104, 120, -1, - 103, 77, 120, -1, 105, 70, -1, 137, -1, 43, - -1, 48, -1, 97, -1, 51, 106, -1, 52, 106, - -1, 107, 106, -1, 84, -1, 82, -1, 81, -1, - 106, -1, 108, 85, 106, -1, 108, 86, 106, -1, - 108, -1, 109, 84, 108, -1, 109, 82, 108, -1, - 109, -1, 110, -1, 111, 88, 110, -1, 111, 89, - 110, -1, 111, 53, 110, -1, 111, 54, 110, -1, - 111, -1, 112, 55, 111, -1, 112, 56, 111, -1, - 112, -1, 113, -1, 114, -1, 115, -1, 116, 57, - 115, -1, 116, -1, 117, 59, 116, -1, 117, -1, - 118, 58, 117, -1, 118, -1, 118, 93, 122, 78, - 120, -1, 119, -1, 106, 121, 120, -1, 79, -1, - 60, -1, 61, -1, 62, -1, 69, -1, 120, -1, - 122, 77, 120, -1, 119, -1, 125, 80, -1, 133, - 80, -1, 7, 138, 139, 80, -1, 126, 71, -1, - 128, -1, 127, -1, 128, 130, -1, 127, 77, 130, - -1, 135, 43, 70, -1, 137, 43, -1, 137, 43, - 72, 123, 73, -1, 136, 131, 129, -1, 131, 129, - -1, 136, 131, 132, -1, 131, 132, -1, -1, 33, - -1, 34, -1, 35, -1, 137, -1, 134, -1, 133, - 77, 43, -1, 133, 77, 43, 72, 73, -1, 133, - 77, 43, 72, 123, 73, -1, 133, 77, 43, 79, - 146, -1, 135, -1, 135, 43, -1, 135, 43, 72, - 73, -1, 135, 43, 72, 123, 73, -1, 135, 43, - 79, 146, -1, 3, 43, -1, 137, -1, 136, 137, + 169, 0, -1, 44, -1, 96, -1, 47, -1, 46, + -1, 48, -1, 71, 123, 72, -1, 97, -1, 98, + 73, 99, 74, -1, 100, -1, 98, 77, 49, -1, + 98, 52, -1, 98, 53, -1, 123, -1, 101, -1, + 102, -1, 98, 77, 102, -1, 104, 72, -1, 103, + 72, -1, 105, 39, -1, 105, -1, 105, 121, -1, + 104, 78, 121, -1, 106, 71, -1, 141, -1, 44, + -1, 49, -1, 98, -1, 52, 107, -1, 53, 107, + -1, 108, 107, -1, 85, -1, 83, -1, 82, -1, + 107, -1, 109, 86, 107, -1, 109, 87, 107, -1, + 109, -1, 110, 85, 109, -1, 110, 83, 109, -1, + 110, -1, 111, -1, 112, 89, 111, -1, 112, 90, + 111, -1, 112, 54, 111, -1, 112, 55, 111, -1, + 112, -1, 113, 56, 112, -1, 113, 57, 112, -1, + 113, -1, 114, -1, 115, -1, 116, -1, 117, 58, + 116, -1, 117, -1, 118, 60, 117, -1, 118, -1, + 119, 59, 118, -1, 119, -1, 119, 94, 123, 79, + 121, -1, 120, -1, 107, 122, 121, -1, 80, -1, + 61, -1, 62, -1, 63, -1, 70, -1, 121, -1, + 123, 78, 121, -1, 120, -1, 126, 81, -1, 134, + 81, -1, 7, 139, 140, 81, -1, 127, 72, -1, + 129, -1, 128, -1, 129, 131, -1, 128, 78, 131, + -1, 136, 44, 71, -1, 138, 44, -1, 138, 44, + 73, 124, 74, -1, 137, 132, 130, -1, 132, 130, + -1, 137, 132, 133, -1, 132, 133, -1, -1, 33, + -1, 34, -1, 35, -1, 138, -1, 135, -1, 134, + 78, 44, -1, 134, 78, 44, 73, 74, -1, 134, + 78, 44, 73, 124, 74, -1, 134, 78, 44, 80, + 147, -1, 136, -1, 136, 44, -1, 136, 44, 73, + 74, -1, 136, 44, 73, 124, 74, -1, 136, 44, + 80, 147, -1, 3, 44, -1, 138, -1, 137, 138, -1, 9, -1, 8, -1, 37, -1, 3, 37, -1, - 36, -1, 139, -1, 138, 139, -1, 4, -1, 5, - -1, 6, -1, 140, -1, 140, 72, 123, 73, -1, + 36, -1, 140, -1, 139, 140, -1, 4, -1, 5, + -1, 6, -1, 141, -1, 141, 73, 124, 74, -1, 39, -1, 11, -1, 12, -1, 10, -1, 27, -1, 28, -1, 29, -1, 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, 30, -1, 31, -1, - 32, -1, 41, -1, 42, -1, 141, -1, 44, -1, - 38, 43, 74, 142, 75, -1, 38, 74, 142, 75, - -1, 143, -1, 142, 143, -1, 137, 144, 80, -1, - 145, -1, 144, 77, 145, -1, 43, -1, 43, 72, - 123, 73, -1, 120, -1, 124, -1, 150, -1, 149, - -1, 147, -1, 156, -1, 157, -1, 160, -1, 167, - -1, 74, 75, -1, -1, -1, 74, 151, 155, 152, - 75, -1, 154, -1, 149, -1, 74, 75, -1, 74, - 155, 75, -1, 148, -1, 155, 148, -1, 80, -1, - 122, 80, -1, 18, 70, 122, 71, 158, -1, 148, - 16, 148, -1, 148, -1, 122, -1, 135, 43, 79, - 146, -1, -1, 40, 70, 161, 159, 71, 153, -1, - -1, 15, 162, 148, 40, 70, 122, 71, 80, -1, - -1, 17, 70, 163, 164, 166, 71, 153, -1, 156, - -1, 147, -1, 159, -1, -1, 165, 80, -1, 165, - 80, 122, -1, 14, 80, -1, 13, 80, -1, 20, - 80, -1, 20, 122, 80, -1, 19, 80, -1, 169, - -1, 168, 169, -1, 170, -1, 124, -1, -1, 125, - 171, 154, -1 + 32, -1, 41, -1, 42, -1, 43, -1, 142, -1, + 45, -1, 38, 44, 75, 143, 76, -1, 38, 75, + 143, 76, -1, 144, -1, 143, 144, -1, 138, 145, + 81, -1, 146, -1, 145, 78, 146, -1, 44, -1, + 44, 73, 124, 74, -1, 121, -1, 125, -1, 151, + -1, 150, -1, 148, -1, 157, -1, 158, -1, 161, + -1, 168, -1, 75, 76, -1, -1, -1, 75, 152, + 156, 153, 76, -1, 155, -1, 150, -1, 75, 76, + -1, 75, 156, 76, -1, 149, -1, 156, 149, -1, + 81, -1, 123, 81, -1, 18, 71, 123, 72, 159, + -1, 149, 16, 149, -1, 149, -1, 123, -1, 136, + 44, 80, 147, -1, -1, 40, 71, 162, 160, 72, + 154, -1, -1, 15, 163, 149, 40, 71, 123, 72, + 81, -1, -1, 17, 71, 164, 165, 167, 72, 154, + -1, 157, -1, 148, -1, 160, -1, -1, 166, 81, + -1, 166, 81, 123, -1, 14, 81, -1, 13, 81, + -1, 20, 81, -1, 20, 123, 81, -1, 19, 81, + -1, 170, -1, 169, 170, -1, 171, -1, 125, -1, + -1, 126, 172, 155, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -731,24 +733,24 @@ static const yytype_uint16 yyrline[] = { 0, 153, 153, 188, 191, 204, 209, 214, 220, 223, 296, 299, 408, 418, 431, 439, 538, 541, 549, 553, - 560, 564, 571, 577, 586, 594, 656, 663, 673, 676, - 686, 696, 717, 718, 719, 724, 725, 734, 746, 747, - 755, 766, 770, 771, 781, 791, 801, 814, 815, 825, - 838, 842, 846, 850, 851, 864, 865, 878, 879, 892, - 893, 910, 911, 924, 925, 926, 927, 928, 932, 935, - 946, 954, 979, 984, 991, 1027, 1030, 1037, 1045, 1066, - 1085, 1096, 1125, 1130, 1140, 1145, 1155, 1158, 1161, 1164, - 1170, 1177, 1187, 1203, 1221, 1245, 1268, 1272, 1290, 1298, - 1330, 1350, 1426, 1435, 1458, 1461, 1467, 1475, 1483, 1491, - 1494, 1501, 1504, 1507, 1513, 1516, 1531, 1535, 1539, 1543, - 1552, 1557, 1562, 1567, 1572, 1577, 1582, 1587, 1592, 1597, - 1603, 1609, 1615, 1620, 1625, 1630, 1643, 1656, 1664, 1667, - 1682, 1713, 1717, 1723, 1731, 1747, 1751, 1755, 1756, 1762, - 1763, 1764, 1765, 1766, 1770, 1771, 1771, 1771, 1781, 1782, - 1787, 1790, 1800, 1803, 1809, 1810, 1814, 1822, 1826, 1836, - 1841, 1858, 1858, 1863, 1863, 1870, 1870, 1878, 1881, 1887, - 1890, 1896, 1900, 1907, 1914, 1921, 1928, 1939, 1948, 1952, - 1959, 1962, 1968, 1968 + 560, 564, 571, 577, 586, 594, 649, 656, 666, 669, + 679, 689, 710, 711, 712, 717, 718, 727, 739, 740, + 748, 759, 763, 764, 774, 784, 794, 807, 808, 818, + 831, 835, 839, 843, 844, 857, 858, 871, 872, 885, + 886, 903, 904, 917, 918, 919, 920, 921, 925, 928, + 939, 947, 972, 977, 984, 1020, 1023, 1030, 1038, 1059, + 1078, 1089, 1118, 1123, 1133, 1138, 1148, 1151, 1154, 1157, + 1163, 1170, 1173, 1189, 1207, 1231, 1254, 1258, 1276, 1284, + 1316, 1336, 1412, 1421, 1444, 1447, 1453, 1461, 1469, 1477, + 1487, 1494, 1497, 1500, 1506, 1509, 1524, 1528, 1532, 1536, + 1545, 1550, 1555, 1560, 1565, 1570, 1575, 1580, 1585, 1590, + 1596, 1602, 1608, 1613, 1618, 1627, 1632, 1645, 1658, 1666, + 1669, 1684, 1716, 1720, 1726, 1734, 1750, 1754, 1758, 1759, + 1765, 1766, 1767, 1768, 1769, 1773, 1774, 1774, 1774, 1784, + 1785, 1790, 1793, 1803, 1806, 1812, 1813, 1817, 1825, 1829, + 1839, 1844, 1861, 1861, 1866, 1866, 1873, 1873, 1881, 1884, + 1890, 1893, 1899, 1903, 1910, 1917, 1924, 1931, 1942, 1951, + 1955, 1962, 1965, 1971, 1971 }; #endif @@ -764,12 +766,12 @@ static const char *const yytname[] = "BVEC4", "IVEC2", "IVEC3", "IVEC4", "VEC2", "VEC3", "VEC4", "MATRIX2", "MATRIX3", "MATRIX4", "IN_QUAL", "OUT_QUAL", "INOUT_QUAL", "UNIFORM", "VARYING", "STRUCT", "VOID_TYPE", "WHILE", "SAMPLER2D", "SAMPLERCUBE", - "IDENTIFIER", "TYPE_NAME", "FLOATCONSTANT", "INTCONSTANT", - "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", - "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", - "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", - "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", - "SUB_ASSIGN", "LEFT_PAREN", "RIGHT_PAREN", "LEFT_BRACKET", + "SAMPLER_EXTERNAL_OES", "IDENTIFIER", "TYPE_NAME", "FLOATCONSTANT", + "INTCONSTANT", "BOOLCONSTANT", "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", + "INC_OP", "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", "NE_OP", "AND_OP", + "OR_OP", "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", "ADD_ASSIGN", + "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", + "OR_ASSIGN", "SUB_ASSIGN", "LEFT_PAREN", "RIGHT_PAREN", "LEFT_BRACKET", "RIGHT_BRACKET", "LEFT_BRACE", "RIGHT_BRACE", "DOT", "COMMA", "COLON", "EQUAL", "SEMICOLON", "BANG", "DASH", "TILDE", "PLUS", "STAR", "SLASH", "PERCENT", "LEFT_ANGLE", "RIGHT_ANGLE", "VERTICAL_BAR", "CARET", @@ -819,33 +821,33 @@ static const yytype_uint16 yytoknum[] = 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348 + 345, 346, 347, 348, 349 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 94, 95, 96, 96, 96, 96, 96, 97, 97, - 97, 97, 97, 97, 98, 99, 100, 100, 101, 101, - 102, 102, 103, 103, 104, 105, 105, 105, 106, 106, - 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, - 109, 110, 111, 111, 111, 111, 111, 112, 112, 112, - 113, 114, 115, 116, 116, 117, 117, 118, 118, 119, - 119, 120, 120, 121, 121, 121, 121, 121, 122, 122, - 123, 124, 124, 124, 125, 126, 126, 127, 127, 128, - 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, - 132, 133, 133, 133, 133, 133, 134, 134, 134, 134, - 134, 134, 135, 135, 136, 136, 136, 136, 136, 137, - 137, 138, 138, 138, 139, 139, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 141, 141, 142, 142, - 143, 144, 144, 145, 145, 146, 147, 148, 148, 149, - 149, 149, 149, 149, 150, 151, 152, 150, 153, 153, - 154, 154, 155, 155, 156, 156, 157, 158, 158, 159, - 159, 161, 160, 162, 160, 163, 160, 164, 164, 165, - 165, 166, 166, 167, 167, 167, 167, 167, 168, 168, - 169, 169, 171, 170 + 0, 95, 96, 97, 97, 97, 97, 97, 98, 98, + 98, 98, 98, 98, 99, 100, 101, 101, 102, 102, + 103, 103, 104, 104, 105, 106, 106, 106, 107, 107, + 107, 107, 108, 108, 108, 109, 109, 109, 110, 110, + 110, 111, 112, 112, 112, 112, 112, 113, 113, 113, + 114, 115, 116, 117, 117, 118, 118, 119, 119, 120, + 120, 121, 121, 122, 122, 122, 122, 122, 123, 123, + 124, 125, 125, 125, 126, 127, 127, 128, 128, 129, + 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, + 133, 134, 134, 134, 134, 134, 135, 135, 135, 135, + 135, 135, 136, 136, 137, 137, 137, 137, 137, 138, + 138, 139, 139, 139, 140, 140, 141, 141, 141, 141, + 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 141, 141, 141, 141, 141, 141, 141, 142, 142, 143, + 143, 144, 145, 145, 146, 146, 147, 148, 149, 149, + 150, 150, 150, 150, 150, 151, 152, 153, 151, 154, + 154, 155, 155, 156, 156, 157, 157, 158, 159, 159, + 160, 160, 162, 161, 163, 161, 164, 161, 165, 165, + 166, 166, 167, 167, 168, 168, 168, 168, 168, 169, + 169, 170, 170, 172, 171 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -864,13 +866,13 @@ static const yytype_uint8 yyr2[] = 4, 2, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 5, 4, 1, 2, - 3, 1, 3, 1, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 0, 0, 5, 1, 1, - 2, 3, 1, 2, 1, 2, 5, 3, 1, 1, - 4, 0, 6, 0, 8, 0, 7, 1, 1, 1, - 0, 2, 3, 2, 2, 2, 3, 2, 1, 2, - 1, 1, 0, 3 + 1, 1, 1, 1, 1, 1, 1, 5, 4, 1, + 2, 3, 1, 3, 1, 4, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 0, 0, 5, 1, + 1, 2, 3, 1, 2, 1, 2, 5, 3, 1, + 1, 4, 0, 6, 0, 8, 0, 7, 1, 1, + 1, 0, 2, 3, 2, 2, 2, 3, 2, 1, + 2, 1, 1, 0, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -880,378 +882,388 @@ static const yytype_uint8 yydefact[] = { 0, 0, 111, 112, 113, 0, 105, 104, 119, 117, 118, 123, 124, 125, 126, 127, 128, 120, 121, 122, - 129, 130, 131, 108, 106, 0, 116, 132, 133, 135, - 191, 192, 0, 76, 86, 0, 91, 96, 0, 102, - 0, 109, 114, 134, 0, 188, 190, 107, 101, 0, - 0, 0, 71, 0, 74, 86, 0, 87, 88, 89, - 77, 0, 86, 0, 72, 97, 103, 110, 0, 1, - 189, 0, 0, 0, 0, 138, 0, 193, 78, 83, - 85, 90, 0, 92, 79, 0, 0, 2, 5, 4, - 6, 27, 0, 0, 0, 34, 33, 32, 3, 8, - 28, 10, 15, 16, 0, 0, 21, 0, 35, 0, - 38, 41, 42, 47, 50, 51, 52, 53, 55, 57, - 59, 70, 0, 25, 73, 0, 143, 0, 141, 137, - 139, 0, 0, 173, 0, 0, 0, 0, 0, 155, - 160, 164, 35, 61, 68, 0, 146, 0, 102, 149, - 162, 148, 147, 0, 150, 151, 152, 153, 80, 82, - 84, 0, 0, 98, 0, 145, 100, 29, 30, 0, - 12, 13, 0, 0, 19, 18, 0, 116, 22, 24, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 115, 136, 0, 0, 140, - 184, 183, 0, 175, 0, 187, 185, 0, 171, 154, - 0, 64, 65, 66, 67, 63, 0, 0, 165, 161, - 163, 0, 93, 0, 95, 99, 7, 0, 14, 26, - 11, 17, 23, 36, 37, 40, 39, 45, 46, 43, - 44, 48, 49, 54, 56, 58, 0, 0, 142, 0, - 0, 0, 186, 0, 156, 62, 69, 0, 94, 9, - 0, 144, 0, 178, 177, 180, 0, 169, 0, 0, - 0, 81, 60, 0, 179, 0, 0, 168, 166, 0, - 0, 157, 0, 181, 0, 0, 0, 159, 172, 158, - 0, 182, 176, 167, 170, 174 + 129, 130, 131, 108, 106, 0, 116, 132, 133, 134, + 136, 192, 193, 0, 76, 86, 0, 91, 96, 0, + 102, 0, 109, 114, 135, 0, 189, 191, 107, 101, + 0, 0, 0, 71, 0, 74, 86, 0, 87, 88, + 89, 77, 0, 86, 0, 72, 97, 103, 110, 0, + 1, 190, 0, 0, 0, 0, 139, 0, 194, 78, + 83, 85, 90, 0, 92, 79, 0, 0, 2, 5, + 4, 6, 27, 0, 0, 0, 34, 33, 32, 3, + 8, 28, 10, 15, 16, 0, 0, 21, 0, 35, + 0, 38, 41, 42, 47, 50, 51, 52, 53, 55, + 57, 59, 70, 0, 25, 73, 0, 144, 0, 142, + 138, 140, 0, 0, 174, 0, 0, 0, 0, 0, + 156, 161, 165, 35, 61, 68, 0, 147, 0, 114, + 150, 163, 149, 148, 0, 151, 152, 153, 154, 80, + 82, 84, 0, 0, 98, 0, 146, 100, 29, 30, + 0, 12, 13, 0, 0, 19, 18, 0, 20, 22, + 24, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 115, 137, 0, 0, + 141, 185, 184, 0, 176, 0, 188, 186, 0, 172, + 155, 0, 64, 65, 66, 67, 63, 0, 0, 166, + 162, 164, 0, 93, 0, 95, 99, 7, 0, 14, + 26, 11, 17, 23, 36, 37, 40, 39, 45, 46, + 43, 44, 48, 49, 54, 56, 58, 0, 0, 143, + 0, 0, 0, 187, 0, 157, 62, 69, 0, 94, + 9, 0, 145, 0, 179, 178, 181, 0, 170, 0, + 0, 0, 81, 60, 0, 180, 0, 0, 169, 167, + 0, 0, 158, 0, 182, 0, 0, 0, 160, 173, + 159, 0, 183, 177, 168, 171, 175 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 98, 99, 100, 227, 101, 102, 103, 104, 105, - 106, 107, 142, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 143, 144, 216, 145, 122, - 146, 147, 32, 33, 34, 79, 60, 61, 80, 35, - 36, 37, 38, 123, 40, 41, 42, 43, 74, 75, - 127, 128, 166, 149, 150, 151, 152, 210, 270, 288, - 289, 153, 154, 155, 278, 269, 156, 253, 202, 250, - 265, 275, 276, 157, 44, 45, 46, 53 + -1, 99, 100, 101, 228, 102, 103, 104, 105, 106, + 107, 108, 143, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 144, 145, 217, 146, 123, + 147, 148, 33, 34, 35, 80, 61, 62, 81, 36, + 37, 38, 39, 40, 41, 42, 124, 44, 75, 76, + 128, 129, 167, 150, 151, 152, 153, 211, 271, 289, + 290, 154, 155, 156, 279, 270, 157, 254, 203, 251, + 266, 276, 277, 158, 45, 46, 47, 54 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -250 +#define YYPACT_NINF -251 static const yytype_int16 yypact[] = { - 1225, 36, -250, -250, -250, 150, -250, -250, -250, -250, - -250, -250, -250, -250, -250, -250, -250, -250, -250, -250, - -250, -250, -250, -250, -250, -33, -250, -250, -250, -250, - -250, -60, -22, -17, 21, -62, -250, 22, 1266, -250, - 1290, -250, 11, -250, 1138, -250, -250, -250, -250, 1290, - 14, 1266, -250, 27, -250, 34, 41, -250, -250, -250, - -250, 1266, 129, 61, -250, 17, -250, -250, 908, -250, - -250, 31, 1266, 72, 1042, -250, 283, -250, -250, -250, - -250, 90, 1266, -46, -250, 194, 908, 65, -250, -250, - -250, -250, 908, 908, 908, -250, -250, -250, -250, -250, - -40, -250, -250, -250, 80, -25, 975, 87, -250, 908, - 35, 13, -250, -26, 68, -250, -250, -250, 110, 109, - -54, -250, 96, -250, -250, 1083, 98, 33, -250, -250, - -250, 91, 92, -250, 104, 107, 99, 760, 108, 105, - -250, -250, 24, -250, -250, 37, -250, -60, 112, -250, - -250, -250, -250, 365, -250, -250, -250, -250, 111, -250, - -250, 827, 908, -250, 113, -250, -250, -250, -250, 4, - -250, -250, 908, 1179, -250, -250, 908, 114, -250, -250, - -250, 908, 908, 908, 908, 908, 908, 908, 908, 908, - 908, 908, 908, 908, 908, -250, -250, 908, 72, -250, - -250, -250, 447, -250, 908, -250, -250, 42, -250, -250, - 447, -250, -250, -250, -250, -250, 908, 908, -250, -250, - -250, 908, -250, 115, -250, -250, -250, 116, 117, -250, - 120, -250, -250, -250, -250, 35, 35, -250, -250, -250, - -250, -26, -26, -250, 110, 109, 51, 119, -250, 144, - 611, 23, -250, 693, 447, -250, -250, 122, -250, -250, - 908, -250, 123, -250, -250, 693, 447, 117, 153, 126, - 128, -250, -250, 908, -250, 127, 137, 171, -250, 130, - 529, -250, 28, 908, 529, 447, 908, -250, -250, -250, - 131, 117, -250, -250, -250, -250 + 1233, -19, -251, -251, -251, 130, -251, -251, -251, -251, + -251, -251, -251, -251, -251, -251, -251, -251, -251, -251, + -251, -251, -251, -251, -251, -24, -251, -251, -251, -251, + -251, -251, -62, -6, 17, 34, -20, -251, 36, 1275, + -251, 1336, -251, 32, -251, 1190, -251, -251, -251, -251, + 1336, 44, 1275, -251, 47, -251, 51, 78, -251, -251, + -251, -251, 1275, 109, 81, -251, -50, -251, -251, 959, + -251, -251, 56, 1275, 102, 1092, -251, 284, -251, -251, + -251, -251, 111, 1275, -44, -251, 764, 959, 87, -251, + -251, -251, -251, 959, 959, 959, -251, -251, -251, -251, + -251, 37, -251, -251, -251, 89, 22, 1024, 88, -251, + 959, -54, -9, -251, -43, 92, -251, -251, -251, 105, + 104, -45, -251, 91, -251, -251, 1134, 93, 15, -251, + -251, -251, 86, 90, -251, 97, 98, 94, 829, 99, + 101, -251, -251, 2, -251, -251, 31, -251, -62, 74, + -251, -251, -251, -251, 367, -251, -251, -251, -251, 100, + -251, -251, 894, 959, -251, 107, -251, -251, -251, -251, + 25, -251, -251, 959, 1300, -251, -251, 959, 103, -251, + -251, -251, 959, 959, 959, 959, 959, 959, 959, 959, + 959, 959, 959, 959, 959, 959, -251, -251, 959, 102, + -251, -251, -251, 450, -251, 959, -251, -251, 40, -251, + -251, 450, -251, -251, -251, -251, -251, 959, 959, -251, + -251, -251, 959, -251, 108, -251, -251, -251, 110, 113, + -251, 112, -251, -251, -251, -251, -54, -54, -251, -251, + -251, -251, -43, -43, -251, 105, 104, 72, 114, -251, + 138, 616, 26, -251, 699, 450, -251, -251, 115, -251, + -251, 959, -251, 116, -251, -251, 699, 450, 113, 135, + 121, 118, -251, -251, 959, -251, 117, 123, 169, -251, + 106, 533, -251, 35, 959, 533, 450, 959, -251, -251, + -251, 119, 113, -251, -251, -251, -251 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -250, -250, -250, -250, -250, -250, -250, 39, -250, -250, - -250, -250, -45, -250, -18, -250, -79, -30, -250, -250, - -250, 38, 52, 20, -250, -63, -85, -250, -92, -71, - 6, 9, -250, -250, -250, 132, 172, 166, 148, -250, - -250, -246, -21, 0, 226, -24, -250, -250, 162, -66, - -250, 45, -159, -3, -136, -249, -250, -250, -250, -36, - 196, 46, 1, -250, -250, -13, -250, -250, -250, -250, - -250, -250, -250, -250, -250, 211, -250, -250 + -251, -251, -251, -251, -251, -251, -251, 23, -251, -251, + -251, -251, 30, -251, -32, -251, -58, -34, -251, -251, + -251, 4, 6, 7, -251, -60, -85, -251, -94, -81, + 8, 10, -251, -251, -251, 122, 148, 143, 124, -251, + -251, -238, -22, -35, 203, -26, 0, -251, 136, -69, + -251, 11, -160, -25, -147, -250, -251, -251, -251, -56, + 171, 16, -21, -251, -251, -33, -251, -251, -251, -251, + -251, -251, -251, -251, -251, 186, -251, -251 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -76 +#define YYTABLE_NINF -117 static const yytype_int16 yytable[] = { - 39, 165, 169, 224, 193, 121, 30, 268, 130, 31, - 50, 170, 171, 62, 164, 63, 67, 220, 64, 268, - 52, 178, 121, 108, 56, 71, 161, 185, 186, 6, - 7, 287, 172, 162, 62, 287, 173, 56, 66, 194, - 108, 51, 6, 7, 39, 207, 175, 167, 168, 54, - 30, 73, 176, 31, 57, 58, 59, 23, 24, 130, - 55, 81, 187, 188, 180, 65, 249, 57, 58, 59, - 23, 24, 73, 47, 73, 226, 148, 165, 47, 48, - 228, 217, 81, 68, 211, 212, 213, 84, 72, 85, - 223, 232, -75, 214, 266, 183, 86, 184, 121, 290, - 217, 76, 246, 215, 83, 217, 237, 238, 239, 240, - 198, 124, 251, 199, 217, 126, 108, 218, 220, 217, - 181, 182, 252, 189, 190, 73, 247, 294, 217, 260, - 277, 255, 256, 158, 121, -26, 233, 234, 108, 108, - 108, 108, 108, 108, 108, 108, 108, 108, 108, 293, - 257, 174, 108, 148, 2, 3, 4, 179, 121, 241, - 242, 267, 57, 58, 59, 235, 236, 191, 192, 195, - 197, 200, 201, 267, 203, 272, 108, 204, 208, 205, - 209, 282, -25, 221, 262, -20, 225, 285, 258, 259, - -27, 291, 261, 273, 217, 271, 279, 280, 2, 3, - 4, 165, 148, 281, 8, 9, 10, 283, 284, 286, - 148, 295, 231, 245, 159, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 78, 82, 243, - 160, 49, 25, 26, 125, 27, 28, 87, 29, 88, - 89, 90, 91, 248, 244, 92, 93, 263, 292, 77, - 148, 264, 274, 148, 148, 70, 254, 0, 0, 0, - 0, 0, 0, 0, 94, 148, 148, 163, 0, 0, - 0, 0, 0, 0, 0, 95, 96, 0, 97, 0, - 148, 0, 0, 0, 148, 148, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 131, 132, 133, 0, - 134, 135, 136, 137, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, - 24, 25, 26, 138, 27, 28, 87, 29, 88, 89, - 90, 91, 0, 0, 92, 93, 0, 0, 0, 0, + 43, 170, 166, 225, 67, 165, 131, 221, 31, 122, + 32, 186, 187, 63, 194, 68, 269, 74, 48, 53, + 51, 85, 179, 86, 72, 49, 122, 82, 269, 162, + 87, 288, 182, 183, 63, 288, 163, 57, 74, 43, + 74, 43, 6, 7, 208, 43, 188, 189, 82, 195, + 43, 52, 43, 31, 57, 32, 250, 131, 64, 6, + 7, 65, 43, 212, 213, 214, 55, 58, 59, 60, + 23, 24, 215, 43, 184, 43, 185, 149, 166, 229, + 66, 224, 216, 43, 58, 59, 60, 23, 24, 171, + 172, 74, 233, 199, 176, 56, 200, 227, 267, 109, + 177, 247, 122, 218, 218, 69, -75, 291, 221, 218, + 173, 252, 219, 218, 174, 48, 109, 248, 218, 73, + 278, 253, 77, 168, 169, 84, 43, 295, 238, 239, + 240, 241, 256, 257, 2, 3, 4, 125, 122, 294, + 181, 258, 58, 59, 60, -25, 127, 69, 190, 191, + 218, 261, 236, 237, 149, 159, 242, 243, -26, 180, + 268, 175, 122, 192, 193, 196, 198, 201, 204, 205, + 209, 202, 268, 222, -116, 206, 273, 210, 263, 280, + 283, 226, 259, -27, 260, 286, 287, 274, 262, 272, + 292, 218, 109, 281, 282, 285, 244, 232, 284, 245, + 296, 246, 166, 149, 79, 160, 83, 161, 50, 126, + 249, 149, 234, 235, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 78, 264, 255, 109, 293, + 265, 71, 0, 275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 94, 0, 0, 0, 139, 140, 0, - 0, 0, 0, 141, 95, 96, 0, 97, 1, 2, - 3, 4, 5, 6, 7, 8, 9, 10, 131, 132, - 133, 0, 134, 135, 136, 137, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, - 0, 23, 24, 25, 26, 138, 27, 28, 87, 29, - 88, 89, 90, 91, 0, 0, 92, 93, 0, 0, + 0, 149, 109, 0, 149, 149, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 149, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 94, 0, 0, 0, 139, - 219, 0, 0, 0, 0, 141, 95, 96, 0, 97, + 0, 149, 0, 0, 0, 149, 149, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 132, 133, 134, + 0, 135, 136, 137, 138, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 23, 24, 25, 26, 139, 27, 28, 29, 88, 30, + 89, 90, 91, 92, 0, 0, 93, 94, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 95, 0, 0, 0, 140, + 141, 0, 0, 0, 0, 142, 96, 97, 0, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 131, 132, 133, 0, 134, 135, 136, 137, 11, 12, + 132, 133, 134, 0, 135, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 0, 23, 24, 25, 26, 138, 27, 28, - 87, 29, 88, 89, 90, 91, 0, 0, 92, 93, + 0, 0, 0, 23, 24, 25, 26, 139, 27, 28, + 29, 88, 30, 89, 90, 91, 92, 0, 0, 93, + 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, + 0, 0, 140, 220, 0, 0, 0, 0, 142, 96, + 97, 0, 98, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 132, 133, 134, 0, 135, 136, 137, + 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 0, 0, 0, 23, 24, 25, 26, + 139, 27, 28, 29, 88, 30, 89, 90, 91, 92, + 0, 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, - 0, 139, 0, 0, 0, 0, 0, 141, 95, 96, - 0, 97, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 131, 132, 133, 0, 134, 135, 136, 137, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 0, 0, 0, 23, 24, 25, 26, 138, - 27, 28, 87, 29, 88, 89, 90, 91, 0, 0, - 92, 93, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, - 0, 0, 0, 76, 0, 0, 0, 0, 0, 141, - 95, 96, 0, 97, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, - 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 0, 0, 23, 24, 25, - 26, 0, 27, 28, 87, 29, 88, 89, 90, 91, - 0, 0, 92, 93, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 94, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 141, 95, 96, 0, 97, 56, 2, 3, 4, - 0, 6, 7, 8, 9, 10, 0, 0, 0, 0, - 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, + 0, 95, 0, 0, 0, 140, 0, 0, 0, 0, + 0, 142, 96, 97, 0, 98, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 132, 133, 134, 0, + 135, 136, 137, 138, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, - 24, 25, 26, 0, 27, 28, 87, 29, 88, 89, - 90, 91, 0, 0, 92, 93, 0, 0, 0, 0, + 24, 25, 26, 139, 27, 28, 29, 88, 30, 89, + 90, 91, 92, 0, 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 94, 2, 3, 4, 0, 0, 0, - 8, 9, 10, 0, 95, 96, 0, 97, 0, 0, - 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 0, 0, 0, 0, 0, 25, 26, - 0, 27, 28, 87, 29, 88, 89, 90, 91, 0, - 0, 92, 93, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 94, 2, 3, 4, 0, 0, 0, 8, 9, 10, - 206, 95, 96, 0, 97, 0, 0, 0, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 0, 0, 0, 25, 26, 0, 27, 28, - 87, 29, 88, 89, 90, 91, 0, 0, 92, 93, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, - 222, 0, 0, 0, 0, 0, 0, 0, 95, 96, - 0, 97, 2, 3, 4, 0, 0, 0, 8, 9, - 10, 0, 0, 0, 0, 0, 0, 0, 0, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 0, 0, 0, 0, 25, 26, 0, 27, - 28, 87, 29, 88, 89, 90, 91, 0, 0, 92, - 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 94, 2, - 3, 4, 0, 0, 0, 8, 9, 10, 0, 95, - 96, 0, 97, 0, 0, 0, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, - 0, 0, 0, 25, 177, 0, 27, 28, 87, 29, - 88, 89, 90, 91, 0, 0, 92, 93, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 94, 2, 3, 4, 0, - 0, 0, 8, 9, 10, 0, 95, 96, 0, 97, - 0, 0, 0, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, - 25, 26, 0, 27, 28, 0, 29, 2, 3, 4, - 0, 0, 0, 8, 9, 10, 0, 0, 0, 0, - 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 129, 0, 0, - 0, 25, 26, 0, 27, 28, 0, 29, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 0, 0, 0, 0, 0, 0, 0, 196, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 0, 0, 23, 24, 25, 26, 0, 27, - 28, 0, 29, 2, 3, 4, 0, 0, 0, 8, - 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 0, 0, 0, 0, 0, 25, 26, 0, - 27, 28, 229, 29, 0, 0, 0, 230, 1, 2, - 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, - 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, - 0, 23, 24, 25, 26, 0, 27, 28, 0, 29, - 2, 3, 4, 0, 0, 0, 8, 9, 10, 0, + 0, 0, 0, 0, 95, 0, 0, 0, 77, 0, + 0, 0, 0, 0, 142, 96, 97, 0, 98, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, - 8, 9, 10, 0, 25, 26, 0, 27, 28, 0, - 29, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 0, 0, 23, 24, 25, 26, 0, 27, 28, 29, + 88, 30, 89, 90, 91, 92, 0, 0, 93, 94, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 142, 96, 97, + 0, 98, 57, 2, 3, 4, 0, 6, 7, 8, + 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 23, 24, 25, 26, 0, + 27, 28, 29, 88, 30, 89, 90, 91, 92, 0, + 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 95, 0, 0, 0, 8, 9, 10, 0, 0, 0, + 0, 96, 97, 0, 98, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 0, 0, 25, 26, 0, 27, 28, 29, 88, 30, + 89, 90, 91, 92, 0, 0, 93, 94, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 95, 0, 0, 164, 8, + 9, 10, 0, 0, 0, 0, 96, 97, 0, 98, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 0, 0, 25, 26, 0, + 27, 28, 29, 88, 30, 89, 90, 91, 92, 0, + 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 95, 0, 0, 0, 8, 9, 10, 0, 0, 0, + 207, 96, 97, 0, 98, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 0, 0, 25, 26, 0, 27, 28, 29, 88, 30, + 89, 90, 91, 92, 0, 0, 93, 94, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 95, 0, 0, 223, 8, + 9, 10, 0, 0, 0, 0, 96, 97, 0, 98, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 0, 0, 25, 26, 0, + 27, 28, 29, 88, 30, 89, 90, 91, 92, 0, + 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 95, 0, 0, 0, 8, 9, 10, 0, 0, 0, + 0, 96, 97, 0, 98, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 0, 0, 25, 178, 0, 27, 28, 29, 88, 30, + 89, 90, 91, 92, 0, 0, 93, 94, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 95, 2, 3, 4, 0, + 0, 0, 8, 9, 10, 0, 96, 97, 0, 98, + 0, 0, 0, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, + 25, 26, 0, 27, 28, 29, 0, 30, 2, 3, + 4, 0, 0, 0, 8, 9, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 130, 0, + 0, 0, 25, 26, 0, 27, 28, 29, 0, 30, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 70, 0, 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, + 197, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 0, 0, 0, 23, 24, 25, 26, + 0, 27, 28, 29, 0, 30, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 0, 0, 23, + 24, 25, 26, 0, 27, 28, 29, 0, 30, 2, + 3, 4, 0, 0, 0, 8, 9, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, + 8, 9, 10, 25, 26, 0, 27, 28, 29, 0, + 30, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, 25, 26, - 0, 27, 28, 0, 29 + 0, 27, 28, 29, 230, 30, 8, 9, 10, 231, + 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, + 0, 0, 0, 0, 25, 26, 0, 27, 28, 29, + 0, 30 }; static const yytype_int16 yycheck[] = { - 0, 86, 94, 162, 58, 68, 0, 253, 74, 0, - 43, 51, 52, 34, 85, 77, 40, 153, 80, 265, - 80, 106, 85, 68, 3, 49, 72, 53, 54, 8, - 9, 280, 72, 79, 55, 284, 76, 3, 38, 93, - 85, 74, 8, 9, 44, 137, 71, 92, 93, 71, - 44, 51, 77, 44, 33, 34, 35, 36, 37, 125, - 77, 61, 88, 89, 109, 43, 202, 33, 34, 35, - 36, 37, 72, 37, 74, 71, 76, 162, 37, 43, - 172, 77, 82, 72, 60, 61, 62, 70, 74, 72, - 161, 176, 71, 69, 71, 82, 79, 84, 161, 71, - 77, 74, 194, 79, 43, 77, 185, 186, 187, 188, - 77, 80, 204, 80, 77, 43, 161, 80, 254, 77, - 85, 86, 80, 55, 56, 125, 197, 286, 77, 78, - 266, 216, 217, 43, 197, 70, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 285, - 221, 71, 197, 153, 4, 5, 6, 70, 221, 189, - 190, 253, 33, 34, 35, 183, 184, 57, 59, 73, - 72, 80, 80, 265, 70, 260, 221, 70, 70, 80, - 75, 273, 70, 72, 40, 71, 73, 16, 73, 73, - 70, 283, 73, 70, 77, 73, 43, 71, 4, 5, - 6, 286, 202, 75, 10, 11, 12, 80, 71, 79, - 210, 80, 173, 193, 82, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 55, 62, 191, - 82, 5, 38, 39, 72, 41, 42, 43, 44, 45, - 46, 47, 48, 198, 192, 51, 52, 250, 284, 53, - 250, 250, 265, 253, 254, 44, 210, -1, -1, -1, - -1, -1, -1, -1, 70, 265, 266, 73, -1, -1, - -1, -1, -1, -1, -1, 81, 82, -1, 84, -1, - 280, -1, -1, -1, 284, 285, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, + 0, 95, 87, 163, 39, 86, 75, 154, 0, 69, + 0, 54, 55, 35, 59, 41, 254, 52, 37, 81, + 44, 71, 107, 73, 50, 44, 86, 62, 266, 73, + 80, 281, 86, 87, 56, 285, 80, 3, 73, 39, + 75, 41, 8, 9, 138, 45, 89, 90, 83, 94, + 50, 75, 52, 45, 3, 45, 203, 126, 78, 8, + 9, 81, 62, 61, 62, 63, 72, 33, 34, 35, + 36, 37, 70, 73, 83, 75, 85, 77, 163, 173, + 44, 162, 80, 83, 33, 34, 35, 36, 37, 52, + 53, 126, 177, 78, 72, 78, 81, 72, 72, 69, + 78, 195, 162, 78, 78, 73, 72, 72, 255, 78, + 73, 205, 81, 78, 77, 37, 86, 198, 78, 75, + 267, 81, 75, 93, 94, 44, 126, 287, 186, 187, + 188, 189, 217, 218, 4, 5, 6, 81, 198, 286, + 110, 222, 33, 34, 35, 71, 44, 73, 56, 57, + 78, 79, 184, 185, 154, 44, 190, 191, 71, 71, + 254, 72, 222, 58, 60, 74, 73, 81, 71, 71, + 71, 81, 266, 73, 71, 81, 261, 76, 40, 44, + 274, 74, 74, 71, 74, 16, 80, 71, 74, 74, + 284, 78, 162, 72, 76, 72, 192, 174, 81, 193, + 81, 194, 287, 203, 56, 83, 63, 83, 5, 73, + 199, 211, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 54, 251, 211, 198, 285, + 251, 45, -1, 266, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 70, -1, -1, -1, 74, 75, -1, - -1, -1, -1, 80, 81, 82, -1, 84, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, -1, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, - -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, + -1, 251, 222, -1, 254, 255, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 266, 267, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 70, -1, -1, -1, 74, - 75, -1, -1, -1, -1, 80, 81, 82, -1, 84, + -1, 281, -1, -1, -1, 285, 286, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, -1, -1, 52, 53, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 71, -1, -1, -1, 75, + 76, -1, -1, -1, -1, 81, 82, 83, -1, 85, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, -1, -1, 51, 52, + 43, 44, 45, 46, 47, 48, 49, -1, -1, 52, + 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 71, -1, + -1, -1, 75, 76, -1, -1, -1, -1, 81, 82, + 83, -1, 85, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, -1, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + -1, -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, - -1, 74, -1, -1, -1, -1, -1, 80, 81, 82, - -1, 84, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, -1, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, -1, -1, -1, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, -1, -1, - 51, 52, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, - -1, -1, -1, 74, -1, -1, -1, -1, -1, 80, - 81, 82, -1, 84, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, -1, -1, -1, -1, -1, -1, - -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, -1, -1, -1, 36, 37, 38, - 39, -1, 41, 42, 43, 44, 45, 46, 47, 48, - -1, -1, 51, 52, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 80, 81, 82, -1, 84, 3, 4, 5, 6, - -1, 8, 9, 10, 11, 12, -1, -1, -1, -1, - -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, + -1, 71, -1, -1, -1, 75, -1, -1, -1, -1, + -1, 81, 82, 83, -1, 85, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, - 37, 38, 39, -1, 41, 42, 43, 44, 45, 46, - 47, 48, -1, -1, 51, 52, -1, -1, -1, -1, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, -1, -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 70, 4, 5, 6, -1, -1, -1, - 10, 11, 12, -1, 81, 82, -1, 84, -1, -1, - -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, -1, -1, -1, -1, -1, 38, 39, - -1, 41, 42, 43, 44, 45, 46, 47, 48, -1, - -1, 51, 52, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 70, 4, 5, 6, -1, -1, -1, 10, 11, 12, - 80, 81, 82, -1, 84, -1, -1, -1, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - -1, -1, -1, -1, -1, 38, 39, -1, 41, 42, - 43, 44, 45, 46, 47, 48, -1, -1, 51, 52, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, - 73, -1, -1, -1, -1, -1, -1, -1, 81, 82, - -1, 84, 4, 5, 6, -1, -1, -1, 10, 11, - 12, -1, -1, -1, -1, -1, -1, -1, -1, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, -1, -1, -1, -1, -1, 38, 39, -1, 41, - 42, 43, 44, 45, 46, 47, 48, -1, -1, 51, - 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 70, 4, - 5, 6, -1, -1, -1, 10, 11, 12, -1, 81, - 82, -1, 84, -1, -1, -1, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, - -1, -1, -1, 38, 39, -1, 41, 42, 43, 44, - 45, 46, 47, 48, -1, -1, 51, 52, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 70, 4, 5, 6, -1, - -1, -1, 10, 11, 12, -1, 81, 82, -1, 84, - -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, - 38, 39, -1, 41, 42, -1, 44, 4, 5, 6, - -1, -1, -1, 10, 11, 12, -1, -1, -1, -1, - -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, -1, 75, -1, -1, - -1, 38, 39, -1, 41, 42, -1, 44, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, -1, -1, -1, -1, -1, -1, -1, 75, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, -1, -1, -1, 36, 37, 38, 39, -1, 41, - 42, -1, 44, 4, 5, 6, -1, -1, -1, 10, - 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, -1, -1, -1, -1, -1, 38, 39, -1, - 41, 42, 43, 44, -1, -1, -1, 48, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, - -1, -1, -1, -1, -1, -1, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, - -1, 36, 37, 38, 39, -1, 41, 42, -1, 44, - 4, 5, 6, -1, -1, -1, 10, 11, 12, -1, + -1, -1, -1, -1, 71, -1, -1, -1, 75, -1, + -1, -1, -1, -1, 81, 82, 83, -1, 85, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, - 10, 11, 12, -1, 38, 39, -1, 41, 42, -1, - 44, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 36, 37, 38, 39, -1, 41, 42, 43, + 44, 45, 46, 47, 48, 49, -1, -1, 52, 53, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 71, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 81, 82, 83, + -1, 85, 3, 4, 5, 6, -1, 8, 9, 10, + 11, 12, -1, -1, -1, -1, -1, -1, -1, -1, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, 36, 37, 38, 39, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, -1, + -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 71, -1, -1, -1, 10, 11, 12, -1, -1, -1, + -1, 82, 83, -1, 85, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, + -1, -1, 38, 39, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, -1, -1, 52, 53, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 71, -1, -1, 74, 10, + 11, 12, -1, -1, -1, -1, 82, 83, -1, 85, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, -1, -1, 38, 39, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, -1, + -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 71, -1, -1, -1, 10, 11, 12, -1, -1, -1, + 81, 82, 83, -1, 85, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, + -1, -1, 38, 39, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, -1, -1, 52, 53, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 71, -1, -1, 74, 10, + 11, 12, -1, -1, -1, -1, 82, 83, -1, 85, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, -1, -1, 38, 39, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, -1, + -1, 52, 53, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 71, -1, -1, -1, 10, 11, 12, -1, -1, -1, + -1, 82, 83, -1, 85, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, + -1, -1, 38, 39, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, -1, -1, 52, 53, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 71, 4, 5, 6, -1, + -1, -1, 10, 11, 12, -1, 82, 83, -1, 85, + -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, + 38, 39, -1, 41, 42, 43, -1, 45, 4, 5, + 6, -1, -1, -1, 10, 11, 12, -1, -1, -1, + -1, -1, -1, -1, -1, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, -1, 76, -1, + -1, -1, 38, 39, -1, 41, 42, 43, -1, 45, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, -1, -1, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, -1, -1, -1, -1, -1, -1, -1, + 76, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, 36, 37, 38, 39, + -1, 41, 42, 43, -1, 45, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, -1, -1, -1, -1, + -1, -1, -1, -1, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, -1, -1, -1, 36, + 37, 38, 39, -1, 41, 42, 43, -1, 45, 4, + 5, 6, -1, -1, -1, 10, 11, 12, -1, -1, + -1, -1, -1, -1, -1, -1, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, + 10, 11, 12, 38, 39, -1, 41, 42, 43, -1, + 45, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, 38, 39, - -1, 41, 42, -1, 44 + -1, 41, 42, 43, 44, 45, 10, 11, 12, 49, + -1, -1, -1, -1, -1, -1, -1, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, + -1, -1, -1, -1, 38, 39, -1, 41, 42, 43, + -1, 45 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -1260,34 +1272,34 @@ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 36, 37, 38, 39, 41, 42, 44, - 124, 125, 126, 127, 128, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 168, 169, 170, 37, 43, 138, - 43, 74, 80, 171, 71, 77, 3, 33, 34, 35, - 130, 131, 136, 77, 80, 43, 137, 139, 72, 0, - 169, 139, 74, 137, 142, 143, 74, 154, 130, 129, - 132, 137, 131, 43, 70, 72, 79, 43, 45, 46, - 47, 48, 51, 52, 70, 81, 82, 84, 95, 96, - 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 30, 31, 32, 36, 37, 38, 39, 41, 42, 43, + 45, 125, 126, 127, 128, 129, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 169, 170, 171, 37, 44, + 139, 44, 75, 81, 172, 72, 78, 3, 33, 34, + 35, 131, 132, 137, 78, 81, 44, 138, 140, 73, + 0, 170, 140, 75, 138, 143, 144, 75, 155, 131, + 130, 133, 138, 132, 44, 71, 73, 80, 44, 46, + 47, 48, 49, 52, 53, 71, 82, 83, 85, 96, + 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 123, 137, 80, 142, 43, 144, 145, 75, - 143, 13, 14, 15, 17, 18, 19, 20, 40, 74, - 75, 80, 106, 119, 120, 122, 124, 125, 137, 147, - 148, 149, 150, 155, 156, 157, 160, 167, 43, 129, - 132, 72, 79, 73, 123, 120, 146, 106, 106, 122, - 51, 52, 72, 76, 71, 71, 77, 39, 120, 70, - 106, 85, 86, 82, 84, 53, 54, 88, 89, 55, - 56, 57, 59, 58, 93, 73, 75, 72, 77, 80, - 80, 80, 162, 70, 70, 80, 80, 122, 70, 75, - 151, 60, 61, 62, 69, 79, 121, 77, 80, 75, - 148, 72, 73, 123, 146, 73, 71, 98, 122, 43, - 48, 101, 120, 106, 106, 108, 108, 110, 110, 110, - 110, 111, 111, 115, 116, 117, 122, 123, 145, 148, - 163, 122, 80, 161, 155, 120, 120, 123, 73, 73, - 78, 73, 40, 147, 156, 164, 71, 122, 135, 159, - 152, 73, 120, 70, 159, 165, 166, 148, 158, 43, - 71, 75, 122, 80, 71, 16, 79, 149, 153, 154, - 71, 122, 153, 148, 146, 80 + 118, 119, 120, 124, 141, 81, 143, 44, 145, 146, + 76, 144, 13, 14, 15, 17, 18, 19, 20, 40, + 75, 76, 81, 107, 120, 121, 123, 125, 126, 141, + 148, 149, 150, 151, 156, 157, 158, 161, 168, 44, + 130, 133, 73, 80, 74, 124, 121, 147, 107, 107, + 123, 52, 53, 73, 77, 72, 72, 78, 39, 121, + 71, 107, 86, 87, 83, 85, 54, 55, 89, 90, + 56, 57, 58, 60, 59, 94, 74, 76, 73, 78, + 81, 81, 81, 163, 71, 71, 81, 81, 123, 71, + 76, 152, 61, 62, 63, 70, 80, 122, 78, 81, + 76, 149, 73, 74, 124, 147, 74, 72, 99, 123, + 44, 49, 102, 121, 107, 107, 109, 109, 111, 111, + 111, 111, 112, 112, 116, 117, 118, 123, 124, 146, + 149, 164, 123, 81, 162, 156, 121, 121, 124, 74, + 74, 79, 74, 40, 148, 157, 165, 72, 123, 136, + 160, 153, 74, 121, 71, 160, 166, 167, 149, 159, + 44, 72, 76, 123, 81, 72, 16, 80, 150, 154, + 155, 72, 123, 154, 149, 147, 81 }; #define yyerrok (yyerrstatus = 0) @@ -1361,7 +1373,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -2614,13 +2626,6 @@ yyreduce: // // Constructor // - if ((yyvsp[(1) - (1)].interm.type).array) { - // Constructors for arrays are not allowed. - context->error((yyvsp[(1) - (1)].interm.type).line, "cannot construct this type", "array", ""); - context->recover(); - (yyvsp[(1) - (1)].interm.type).setArray(false); - } - TOperator op = EOpNull; if ((yyvsp[(1) - (1)].interm.type).userDef) { op = EOpConstructStruct; @@ -3360,13 +3365,6 @@ yyreduce: { (yyval.interm) = (yyvsp[(1) - (1)].interm); - - if ((yyval.interm).type.precision == EbpUndefined) { - (yyval.interm).type.precision = context->symbolTable.getDefaultPrecision((yyvsp[(1) - (1)].interm).type.type); - if (context->precisionErrorCheck((yyvsp[(1) - (1)].interm).line, (yyval.interm).type.precision, (yyvsp[(1) - (1)].interm).type.type)) { - context->recover(); - } - } ;} break; @@ -3666,6 +3664,13 @@ yyreduce: { (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); + + if ((yyval.interm.type).precision == EbpUndefined) { + (yyval.interm.type).precision = context->symbolTable.getDefaultPrecision((yyvsp[(1) - (1)].interm.type).type); + if (context->precisionErrorCheck((yyvsp[(1) - (1)].interm.type).line, (yyval.interm.type).precision, (yyvsp[(1) - (1)].interm.type).type)) { + context->recover(); + } + } ;} break; @@ -3884,6 +3889,19 @@ yyreduce: case 134: + { + if (!context->supportsExtension("GL_OES_EGL_image_external")) { + context->error((yyvsp[(1) - (1)].lex).line, "unsupported type", "samplerExternalOES", ""); + context->recover(); + } + FRAG_VERT_ONLY("samplerExternalOES", (yyvsp[(1) - (1)].lex).line); + TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary; + (yyval.interm.type).setBasic(EbtSamplerExternalOES, qual, (yyvsp[(1) - (1)].lex).line); + ;} + break; + + case 135: + { FRAG_VERT_ONLY("struct", (yyvsp[(1) - (1)].interm.type).line); (yyval.interm.type) = (yyvsp[(1) - (1)].interm.type); @@ -3891,7 +3909,7 @@ yyreduce: ;} break; - case 135: + case 136: { // @@ -3905,7 +3923,7 @@ yyreduce: ;} break; - case 136: + case 137: { if (context->reservedErrorCheck((yyvsp[(2) - (5)].lex).line, *(yyvsp[(2) - (5)].lex).string)) @@ -3922,7 +3940,7 @@ yyreduce: ;} break; - case 137: + case 138: { TType* structure = new TType((yyvsp[(3) - (4)].interm.typeList), TString("")); @@ -3931,14 +3949,14 @@ yyreduce: ;} break; - case 138: + case 139: { (yyval.interm.typeList) = (yyvsp[(1) - (1)].interm.typeList); ;} break; - case 139: + case 140: { (yyval.interm.typeList) = (yyvsp[(1) - (2)].interm.typeList); @@ -3954,7 +3972,7 @@ yyreduce: ;} break; - case 140: + case 141: { (yyval.interm.typeList) = (yyvsp[(2) - (3)].interm.typeList); @@ -3970,6 +3988,7 @@ yyreduce: type->setBasicType((yyvsp[(1) - (3)].interm.type).type); type->setNominalSize((yyvsp[(1) - (3)].interm.type).size); type->setMatrix((yyvsp[(1) - (3)].interm.type).matrix); + type->setPrecision((yyvsp[(1) - (3)].interm.type).precision); // don't allow arrays of arrays if (type->isArray()) { @@ -3986,7 +4005,7 @@ yyreduce: ;} break; - case 141: + case 142: { (yyval.interm.typeList) = NewPoolTTypeList(); @@ -3994,14 +4013,14 @@ yyreduce: ;} break; - case 142: + case 143: { (yyval.interm.typeList)->push_back((yyvsp[(3) - (3)].interm.typeLine)); ;} break; - case 143: + case 144: { if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string)) @@ -4013,7 +4032,7 @@ yyreduce: ;} break; - case 144: + case 145: { if (context->reservedErrorCheck((yyvsp[(1) - (4)].lex).line, *(yyvsp[(1) - (4)].lex).string)) @@ -4030,24 +4049,19 @@ yyreduce: ;} break; - case 145: + case 146: { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} break; - case 146: - - { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} - break; - case 147: - { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); ;} + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} break; case 148: - { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); ;} break; case 149: @@ -4077,21 +4091,26 @@ yyreduce: case 154: - { (yyval.interm.intermAggregate) = 0; ;} + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} break; case 155: - { context->symbolTable.push(); ;} + { (yyval.interm.intermAggregate) = 0; ;} break; case 156: - { context->symbolTable.pop(); ;} + { context->symbolTable.push(); ;} break; case 157: + { context->symbolTable.pop(); ;} + break; + + case 158: + { if ((yyvsp[(3) - (5)].interm.intermAggregate) != 0) { (yyvsp[(3) - (5)].interm.intermAggregate)->setOp(EOpSequence); @@ -4101,11 +4120,6 @@ yyreduce: ;} break; - case 158: - - { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} - break; - case 159: { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} @@ -4113,12 +4127,17 @@ yyreduce: case 160: + { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} + break; + + case 161: + { (yyval.interm.intermNode) = 0; ;} break; - case 161: + case 162: { if ((yyvsp[(2) - (3)].interm.intermAggregate)) { @@ -4129,31 +4148,31 @@ yyreduce: ;} break; - case 162: + case 163: { (yyval.interm.intermAggregate) = context->intermediate.makeAggregate((yyvsp[(1) - (1)].interm.intermNode), 0); ;} break; - case 163: + case 164: { (yyval.interm.intermAggregate) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermAggregate), (yyvsp[(2) - (2)].interm.intermNode), 0); ;} break; - case 164: + case 165: { (yyval.interm.intermNode) = 0; ;} break; - case 165: + case 166: { (yyval.interm.intermNode) = static_cast((yyvsp[(1) - (2)].interm.intermTypedNode)); ;} break; - case 166: + case 167: { if (context->boolErrorCheck((yyvsp[(1) - (5)].lex).line, (yyvsp[(3) - (5)].interm.intermTypedNode))) @@ -4162,7 +4181,7 @@ yyreduce: ;} break; - case 167: + case 168: { (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermNode); @@ -4170,7 +4189,7 @@ yyreduce: ;} break; - case 168: + case 169: { (yyval.interm.nodePair).node1 = (yyvsp[(1) - (1)].interm.intermNode); @@ -4178,7 +4197,7 @@ yyreduce: ;} break; - case 169: + case 170: { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); @@ -4187,7 +4206,7 @@ yyreduce: ;} break; - case 170: + case 171: { TIntermNode* intermNode; @@ -4205,12 +4224,12 @@ yyreduce: ;} break; - case 171: + case 172: { context->symbolTable.push(); ++context->loopNestingLevel; ;} break; - case 172: + case 173: { context->symbolTable.pop(); @@ -4219,12 +4238,12 @@ yyreduce: ;} break; - case 173: + case 174: { ++context->loopNestingLevel; ;} break; - case 174: + case 175: { if (context->boolErrorCheck((yyvsp[(8) - (8)].lex).line, (yyvsp[(6) - (8)].interm.intermTypedNode))) @@ -4235,24 +4254,17 @@ yyreduce: ;} break; - case 175: - - { context->symbolTable.push(); ++context->loopNestingLevel; ;} - break; - case 176: - { - context->symbolTable.pop(); - (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yyvsp[(1) - (7)].lex).line); - --context->loopNestingLevel; - ;} + { context->symbolTable.push(); ++context->loopNestingLevel; ;} break; case 177: { - (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + context->symbolTable.pop(); + (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yyvsp[(1) - (7)].lex).line); + --context->loopNestingLevel; ;} break; @@ -4266,26 +4278,33 @@ yyreduce: case 179: { - (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); ;} break; case 180: { - (yyval.interm.intermTypedNode) = 0; + (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); ;} break; case 181: + { + (yyval.interm.intermTypedNode) = 0; + ;} + break; + + case 182: + { (yyval.interm.nodePair).node1 = (yyvsp[(1) - (2)].interm.intermTypedNode); (yyval.interm.nodePair).node2 = 0; ;} break; - case 182: + case 183: { (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermTypedNode); @@ -4293,7 +4312,7 @@ yyreduce: ;} break; - case 183: + case 184: { if (context->loopNestingLevel <= 0) { @@ -4304,7 +4323,7 @@ yyreduce: ;} break; - case 184: + case 185: { if (context->loopNestingLevel <= 0) { @@ -4315,7 +4334,7 @@ yyreduce: ;} break; - case 185: + case 186: { (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(1) - (2)].lex).line); @@ -4326,7 +4345,7 @@ yyreduce: ;} break; - case 186: + case 187: { (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(2) - (3)].interm.intermTypedNode), (yyvsp[(1) - (3)].lex).line); @@ -4341,7 +4360,7 @@ yyreduce: ;} break; - case 187: + case 188: { FRAG_ONLY("discard", (yyvsp[(1) - (2)].lex).line); @@ -4349,18 +4368,10 @@ yyreduce: ;} break; - case 188: - - { - (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); - context->treeRoot = (yyval.interm.intermNode); - ;} - break; - case 189: { - (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0); + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); context->treeRoot = (yyval.interm.intermNode); ;} break; @@ -4368,7 +4379,8 @@ yyreduce: case 190: { - (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0); + context->treeRoot = (yyval.interm.intermNode); ;} break; @@ -4381,6 +4393,13 @@ yyreduce: case 192: + { + (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); + ;} + break; + + case 193: + { TFunction* function = (yyvsp[(1) - (1)].interm).function; TFunction* prevDec = static_cast(context->symbolTable.find(function->getMangledName())); @@ -4464,7 +4483,7 @@ yyreduce: ;} break; - case 193: + case 194: { //?? Check that all paths return a value if return type != void ? diff --git a/gfx/angle/src/compiler/glslang_tab.h b/gfx/angle/src/compiler/glslang_tab.h index fa8480d3ad11..55c271c811f4 100644 --- a/gfx/angle/src/compiler/glslang_tab.h +++ b/gfx/angle/src/compiler/glslang_tab.h @@ -79,57 +79,58 @@ WHILE = 295, SAMPLER2D = 296, SAMPLERCUBE = 297, - IDENTIFIER = 298, - TYPE_NAME = 299, - FLOATCONSTANT = 300, - INTCONSTANT = 301, - BOOLCONSTANT = 302, - FIELD_SELECTION = 303, - LEFT_OP = 304, - RIGHT_OP = 305, - INC_OP = 306, - DEC_OP = 307, - LE_OP = 308, - GE_OP = 309, - EQ_OP = 310, - NE_OP = 311, - AND_OP = 312, - OR_OP = 313, - XOR_OP = 314, - MUL_ASSIGN = 315, - DIV_ASSIGN = 316, - ADD_ASSIGN = 317, - MOD_ASSIGN = 318, - LEFT_ASSIGN = 319, - RIGHT_ASSIGN = 320, - AND_ASSIGN = 321, - XOR_ASSIGN = 322, - OR_ASSIGN = 323, - SUB_ASSIGN = 324, - LEFT_PAREN = 325, - RIGHT_PAREN = 326, - LEFT_BRACKET = 327, - RIGHT_BRACKET = 328, - LEFT_BRACE = 329, - RIGHT_BRACE = 330, - DOT = 331, - COMMA = 332, - COLON = 333, - EQUAL = 334, - SEMICOLON = 335, - BANG = 336, - DASH = 337, - TILDE = 338, - PLUS = 339, - STAR = 340, - SLASH = 341, - PERCENT = 342, - LEFT_ANGLE = 343, - RIGHT_ANGLE = 344, - VERTICAL_BAR = 345, - CARET = 346, - AMPERSAND = 347, - QUESTION = 348 + SAMPLER_EXTERNAL_OES = 298, + IDENTIFIER = 299, + TYPE_NAME = 300, + FLOATCONSTANT = 301, + INTCONSTANT = 302, + BOOLCONSTANT = 303, + FIELD_SELECTION = 304, + LEFT_OP = 305, + RIGHT_OP = 306, + INC_OP = 307, + DEC_OP = 308, + LE_OP = 309, + GE_OP = 310, + EQ_OP = 311, + NE_OP = 312, + AND_OP = 313, + OR_OP = 314, + XOR_OP = 315, + MUL_ASSIGN = 316, + DIV_ASSIGN = 317, + ADD_ASSIGN = 318, + MOD_ASSIGN = 319, + LEFT_ASSIGN = 320, + RIGHT_ASSIGN = 321, + AND_ASSIGN = 322, + XOR_ASSIGN = 323, + OR_ASSIGN = 324, + SUB_ASSIGN = 325, + LEFT_PAREN = 326, + RIGHT_PAREN = 327, + LEFT_BRACKET = 328, + RIGHT_BRACKET = 329, + LEFT_BRACE = 330, + RIGHT_BRACE = 331, + DOT = 332, + COMMA = 333, + COLON = 334, + EQUAL = 335, + SEMICOLON = 336, + BANG = 337, + DASH = 338, + TILDE = 339, + PLUS = 340, + STAR = 341, + SLASH = 342, + PERCENT = 343, + LEFT_ANGLE = 344, + RIGHT_ANGLE = 345, + VERTICAL_BAR = 346, + CARET = 347, + AMPERSAND = 348, + QUESTION = 349 }; #endif /* Tokens. */ @@ -173,57 +174,58 @@ #define WHILE 295 #define SAMPLER2D 296 #define SAMPLERCUBE 297 -#define IDENTIFIER 298 -#define TYPE_NAME 299 -#define FLOATCONSTANT 300 -#define INTCONSTANT 301 -#define BOOLCONSTANT 302 -#define FIELD_SELECTION 303 -#define LEFT_OP 304 -#define RIGHT_OP 305 -#define INC_OP 306 -#define DEC_OP 307 -#define LE_OP 308 -#define GE_OP 309 -#define EQ_OP 310 -#define NE_OP 311 -#define AND_OP 312 -#define OR_OP 313 -#define XOR_OP 314 -#define MUL_ASSIGN 315 -#define DIV_ASSIGN 316 -#define ADD_ASSIGN 317 -#define MOD_ASSIGN 318 -#define LEFT_ASSIGN 319 -#define RIGHT_ASSIGN 320 -#define AND_ASSIGN 321 -#define XOR_ASSIGN 322 -#define OR_ASSIGN 323 -#define SUB_ASSIGN 324 -#define LEFT_PAREN 325 -#define RIGHT_PAREN 326 -#define LEFT_BRACKET 327 -#define RIGHT_BRACKET 328 -#define LEFT_BRACE 329 -#define RIGHT_BRACE 330 -#define DOT 331 -#define COMMA 332 -#define COLON 333 -#define EQUAL 334 -#define SEMICOLON 335 -#define BANG 336 -#define DASH 337 -#define TILDE 338 -#define PLUS 339 -#define STAR 340 -#define SLASH 341 -#define PERCENT 342 -#define LEFT_ANGLE 343 -#define RIGHT_ANGLE 344 -#define VERTICAL_BAR 345 -#define CARET 346 -#define AMPERSAND 347 -#define QUESTION 348 +#define SAMPLER_EXTERNAL_OES 298 +#define IDENTIFIER 299 +#define TYPE_NAME 300 +#define FLOATCONSTANT 301 +#define INTCONSTANT 302 +#define BOOLCONSTANT 303 +#define FIELD_SELECTION 304 +#define LEFT_OP 305 +#define RIGHT_OP 306 +#define INC_OP 307 +#define DEC_OP 308 +#define LE_OP 309 +#define GE_OP 310 +#define EQ_OP 311 +#define NE_OP 312 +#define AND_OP 313 +#define OR_OP 314 +#define XOR_OP 315 +#define MUL_ASSIGN 316 +#define DIV_ASSIGN 317 +#define ADD_ASSIGN 318 +#define MOD_ASSIGN 319 +#define LEFT_ASSIGN 320 +#define RIGHT_ASSIGN 321 +#define AND_ASSIGN 322 +#define XOR_ASSIGN 323 +#define OR_ASSIGN 324 +#define SUB_ASSIGN 325 +#define LEFT_PAREN 326 +#define RIGHT_PAREN 327 +#define LEFT_BRACKET 328 +#define RIGHT_BRACKET 329 +#define LEFT_BRACE 330 +#define RIGHT_BRACE 331 +#define DOT 332 +#define COMMA 333 +#define COLON 334 +#define EQUAL 335 +#define SEMICOLON 336 +#define BANG 337 +#define DASH 338 +#define TILDE 339 +#define PLUS 340 +#define STAR 341 +#define SLASH 342 +#define PERCENT 343 +#define LEFT_ANGLE 344 +#define RIGHT_ANGLE 345 +#define VERTICAL_BAR 346 +#define CARET 347 +#define AMPERSAND 348 +#define QUESTION 349 @@ -262,7 +264,7 @@ typedef union YYSTYPE }; } interm; } -/* Line 1529 of yacc.c. */ +/* Line 1489 of yacc.c. */ YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/gfx/angle/src/compiler/intermediate.h b/gfx/angle/src/compiler/intermediate.h index a8af5ab067d2..9618ed5e08e2 100644 --- a/gfx/angle/src/compiler/intermediate.h +++ b/gfx/angle/src/compiler/intermediate.h @@ -410,8 +410,8 @@ protected: // class TIntermUnary : public TIntermOperator { public: - TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {} - TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {} + TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0), useEmulatedFunction(false) {} + TIntermUnary(TOperator o) : TIntermOperator(o), operand(0), useEmulatedFunction(false) {} virtual void traverse(TIntermTraverser*); virtual TIntermUnary* getAsUnaryNode() { return this; } @@ -420,8 +420,12 @@ public: TIntermTyped* getOperand() { return operand; } bool promote(TInfoSink&); + void setUseEmulatedFunction() { useEmulatedFunction = true; } + bool getUseEmulatedFunction() { return useEmulatedFunction; } + protected: TIntermTyped* operand; + bool useEmulatedFunction; // if set to true, replace the function call by an emulated one. }; typedef TVector TIntermSequence; diff --git a/gfx/angle/src/compiler/preprocessor/new/Context.cpp b/gfx/angle/src/compiler/preprocessor/new/Context.cpp new file mode 100644 index 000000000000..70a1b7d94f4b --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Context.cpp @@ -0,0 +1,21 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "Context.h" + +namespace pp +{ + +Context::Context(int count, const char* const string[], const int length[], + TokenVector* output) + : input(count, string, length), + output(output), + lexer(NULL) +{ +} + +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/Context.h b/gfx/angle/src/compiler/preprocessor/new/Context.h new file mode 100644 index 000000000000..d54ee1077748 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Context.h @@ -0,0 +1,31 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_CONTEXT_H_ +#define COMPILER_PREPROCESSOR_CONTEXT_H_ + +#include "Input.h" +#include "Macro.h" +#include "Token.h" + +namespace pp +{ + +struct Context +{ + Context(int count, const char* const string[], const int length[], + TokenVector* output); + + Input input; + TokenVector* output; + + void* lexer; // Lexer handle. + MacroSet macros; // Defined macros. +}; + +} // namespace pp +#endif // COMPILER_PREPROCESSOR_CONTEXT_H_ + diff --git a/gfx/angle/src/compiler/preprocessor/new/Input.cpp b/gfx/angle/src/compiler/preprocessor/new/Input.cpp new file mode 100644 index 000000000000..694c3bda83e0 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Input.cpp @@ -0,0 +1,165 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "Input.h" + +#include + +#include "compiler/debug.h" + +namespace pp +{ + +Input::Input(int count, const char* const string[], const int length[]) + : mCount(count), + mString(string), + mLength(length), + mIndex(-1), + mSize(0), + mError(kErrorNone), + mState(kStateInitial) +{ + ASSERT(mCount >= 0); + switchToNextString(); +} + +bool Input::eof() const +{ + ASSERT(mIndex <= mCount); + return mIndex == mCount; +} + +int Input::read(char* buf, int bufSize) +{ + int nread = 0; + int startIndex = mIndex; + // Keep reading until the buffer is full or the current string is exhausted. + while ((mIndex == startIndex) && (nread < bufSize)) + { + int c = getChar(); + if (c == EOF) + { + if (mState == kStateBlockComment) + mError = kErrorUnexpectedEOF; + break; + } + + switch (mState) + { + case kStateInitial: + if (c == '/') + { + // Potentially a comment. + switch (peekChar()) + { + case '/': + getChar(); // Eat '/'. + mState = kStateLineComment; + break; + case '*': + getChar(); // Eat '*'. + mState = kStateBlockComment; + break; + default: + // Not a comment. + buf[nread++] = c; + break; + } + } else + { + buf[nread++] = c; + } + break; + + case kStateLineComment: + if (c == '\n') + { + buf[nread++] = c; + mState = kStateInitial; + } + break; + + case kStateBlockComment: + if (c == '*' && (peekChar() == '/')) + { + getChar(); // Eat '/'. + buf[nread++] = ' '; // Replace comment with whitespace. + mState = kStateInitial; + } else if (c == '\n') + { + // Line breaks are never skipped. + buf[nread++] = c; + } + break; + + default: + ASSERT(false); + break; + } + } + + return nread; +} + +int Input::getChar() +{ + if (eof()) return EOF; + + const char* str = mString[mIndex]; + int c = str[mSize++]; + + // Switch to next string if the current one is fully read. + int length = stringLength(mIndex); + // We never read from empty string. + ASSERT(length != 0); + if (((length < 0) && (str[mSize] == '\0')) || + ((length > 0) && (mSize == length))) + switchToNextString(); + + return c; +} + +int Input::peekChar() +{ + // Save the current read position. + int index = mIndex; + int size = mSize; + int c = getChar(); + + // Restore read position. + mIndex = index; + mSize = size; + return c; +} + +void Input::switchToNextString() +{ + ASSERT(mIndex < mCount); + + mSize = 0; + do + { + ++mIndex; + } while (!eof() && isStringEmpty(mIndex)); +} + +bool Input::isStringEmpty(int index) +{ + ASSERT(index < mCount); + + const char* str = mString[mIndex]; + int length = stringLength(mIndex); + return (length == 0) || ((length < 0) && (str[0] == '\0')); +} + +int Input::stringLength(int index) +{ + ASSERT(index < mCount); + return mLength ? mLength[index] : -1; +} + +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/Input.h b/gfx/angle/src/compiler/preprocessor/new/Input.h new file mode 100644 index 000000000000..5a1b5d1a4967 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Input.h @@ -0,0 +1,74 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_INPUT_H_ +#define COMPILER_PREPROCESSOR_INPUT_H_ + +namespace pp +{ + +// Reads the given set of strings into input buffer. +// Strips comments. +class Input +{ + public: + Input(int count, const char* const string[], const int length[]); + + enum Error + { + kErrorNone, + kErrorUnexpectedEOF + }; + Error error() const { return mError; } + + // Returns the index of string currently being scanned. + int stringIndex() const { return mIndex; } + // Returns true if EOF has reached. + bool eof() const; + + // Reads up to bufSize characters into buf. + // Returns the number of characters read. + // It replaces each comment by a whitespace. It reads only one string + // at a time so that the lexer has opportunity to update the string number + // for meaningful diagnostic messages. + int read(char* buf, int bufSize); + +private: + enum State + { + kStateInitial, + kStateLineComment, + kStateBlockComment + }; + + int getChar(); + int peekChar(); + // Switches input buffer to the next non-empty string. + // This is called when the current string is fully read. + void switchToNextString(); + // Returns true if the given string is empty. + bool isStringEmpty(int index); + // Return the length of the given string. + // Returns a negative value for null-terminated strings. + int stringLength(int index); + + // Input. + int mCount; + const char* const* mString; + const int* mLength; + + // Current read position. + int mIndex; // Index of string currently being scanned. + int mSize; // Size of string already scanned. + + // Current error and state. + Error mError; + State mState; +}; + +} // namespace pp +#endif // COMPILER_PREPROCESSOR_INPUT_H_ + diff --git a/gfx/angle/src/compiler/preprocessor/new/Macro.h b/gfx/angle/src/compiler/preprocessor/new/Macro.h new file mode 100644 index 000000000000..bb5e64ae580a --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Macro.h @@ -0,0 +1,34 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_MACRO_H_ +#define COMPILER_PREPROCESSOR_MACRO_H_ + +#include +#include + +#include "Token.h" + +namespace pp +{ + +struct Macro +{ + enum Type + { + kTypeObj, + kTypeFunc + }; + Type type; + std::string identifier; + TokenVector parameters; + TokenVector replacements; +}; +typedef std::map MacroSet; + +} // namespace pp +#endif COMPILER_PREPROCESSOR_MACRO_H_ + diff --git a/gfx/angle/src/compiler/preprocessor/new/Preprocessor.cpp b/gfx/angle/src/compiler/preprocessor/new/Preprocessor.cpp new file mode 100644 index 000000000000..3dc246c9d7aa --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Preprocessor.cpp @@ -0,0 +1,43 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "Preprocessor.h" + +#include "compiler/debug.h" +#include "Context.h" + +namespace pp +{ + +bool Preprocessor::process(int count, + const char* const string[], + const int length[]) +{ + ASSERT((count >=0) && (string != NULL)); + if ((count < 0) || (string == NULL)) + return false; + + clearResults(); + Context context(count, string, length, &mTokens); + if (!initLexer(&context)) + return false; + + bool success = parse(&context); + + destroyLexer(&context); + return success; +} + +void Preprocessor::clearResults() +{ + for (TokenVector::iterator i = mTokens.begin(); i != mTokens.end(); ++i) + delete (*i); + + mTokens.clear(); +} + +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/Preprocessor.h b/gfx/angle/src/compiler/preprocessor/new/Preprocessor.h new file mode 100644 index 000000000000..f8e4c8e53d1e --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Preprocessor.h @@ -0,0 +1,42 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_ +#define COMPILER_PREPROCESSOR_PREPROCESSOR_H_ + +#include "common/angleutils.h" +#include "Token.h" + +namespace pp +{ + +struct Context; + +class Preprocessor +{ + public: + Preprocessor() { } + + bool process(int count, const char* const string[], const int length[]); + + TokenIterator begin() const { return mTokens.begin(); } + TokenIterator end() const { return mTokens.end(); } + + private: + DISALLOW_COPY_AND_ASSIGN(Preprocessor); + + static bool initLexer(Context* context); + static void destroyLexer(Context* context); + static bool parse(Context* context); + + void clearResults(); + + TokenVector mTokens; // Output. +}; + +} // namespace pp +#endif // COMPILER_PREPROCESSOR_PREPROCESSOR_H_ + diff --git a/gfx/angle/src/compiler/preprocessor/new/Token.cpp b/gfx/angle/src/compiler/preprocessor/new/Token.cpp new file mode 100644 index 000000000000..cedd9abe29e6 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Token.cpp @@ -0,0 +1,58 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#include "Token.h" + +#include "token_type.h" + +static const int kLocationLineSize = 16; // in bits. +static const int kLocationLineMask = (1 << kLocationLineSize) - 1; + +namespace pp +{ + +Token::Location Token::encodeLocation(int line, int file) +{ + return (file << kLocationLineSize) | (line & kLocationLineMask); +} + +void Token::decodeLocation(Location loc, int* line, int* file) +{ + if (file) *file = loc >> kLocationLineSize; + if (line) *line = loc & kLocationLineMask; +} + +Token::Token(Location location, int type, std::string* value) + : mLocation(location), + mType(type), + mValue(value) +{ +} + +Token::~Token() { + delete mValue; +} + +std::ostream& operator<<(std::ostream& out, const Token& token) +{ + switch (token.type()) + { + case SPACE: + out << " "; + break; + case INT_CONSTANT: + case FLOAT_CONSTANT: + case IDENTIFIER: + out << *(token.value()); + break; + default: + out << static_cast(token.type()); + break; + } + return out; +} +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/Token.h b/gfx/angle/src/compiler/preprocessor/new/Token.h new file mode 100644 index 000000000000..904735204163 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/Token.h @@ -0,0 +1,44 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_TOKEN_H_ +#define COMPILER_PREPROCESSOR_TOKEN_H_ + +#include +#include + +namespace pp +{ + +class Token +{ + public: + typedef int Location; + static Location encodeLocation(int line, int file); + static void decodeLocation(Location loc, int* line, int* file); + + // Takes ownership of string. + Token(Location location, int type, std::string* value); + ~Token(); + + Location location() const { return mLocation; } + int type() const { return mType; } + const std::string* value() const { return mValue; } + + private: + Location mLocation; + int mType; + std::string* mValue; +}; + +typedef std::vector TokenVector; +typedef TokenVector::const_iterator TokenIterator; + +extern std::ostream& operator<<(std::ostream& out, const Token& token); + +} // namepsace pp +#endif // COMPILER_PREPROCESSOR_TOKEN_H_ + diff --git a/gfx/angle/src/compiler/preprocessor/new/generate_parser.sh b/gfx/angle/src/compiler/preprocessor/new/generate_parser.sh new file mode 100644 index 000000000000..5b32f71ac2af --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/generate_parser.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Generates GLSL ES preprocessor - pp_lex.cpp, pp_tab.h, and pp_tab.cpp + +run_flex() +{ +input_file=$script_dir/$1.l +output_source=$script_dir/$1_lex.cpp +flex --noline --nounistd --outfile=$output_source $input_file +} + +run_bison() +{ +input_file=$script_dir/$1.y +output_header=$script_dir/$1_tab.h +output_source=$script_dir/$1_tab.cpp +bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file +} + +script_dir=$(dirname $0) + +# Generate preprocessor +run_flex pp +run_bison pp diff --git a/gfx/angle/src/compiler/preprocessor/new/pp.l b/gfx/angle/src/compiler/preprocessor/new/pp.l new file mode 100644 index 000000000000..514a79c6c257 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/pp.l @@ -0,0 +1,162 @@ +/* +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +This file contains the Lex specification for GLSL ES preprocessor. +Based on Microsoft Visual Studio 2010 Preprocessor Grammar: +http://msdn.microsoft.com/en-us/library/2scxys89.aspx + +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. +*/ + +%top{ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! +} + +%{ +#include "compiler/debug.h" +#include "Context.h" +#include "pp_tab.h" +#include "Preprocessor.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->first_line = yylineno; \ + yylloc->first_column = yycolumn + 1; \ + yycolumn += yyleng; \ + } while(0); + +#define YY_INPUT(buf, result, maxSize) \ + result = readInput(yyextra, buf, maxSize); + +static int readInput(pp::Context* context, char* buf, int maxSize); +%} + +%option noyywrap nounput never-interactive +%option yylineno reentrant bison-bridge bison-locations +%option stack +%option prefix="pp" +%option extra-type="pp::Context*" + +HSPACE [ \t] +HASH ^{HSPACE}*#{HSPACE}* +IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* +PUNCTUATOR [][<>(){}.+-/*%^|&~=!:;,?] + +DECIMAL_CONSTANT [1-9][0-9]* +OCTAL_CONSTANT 0[0-7]* +HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+ + +DIGIT [0-9] +EXPONENT_PART [eE][+-]?{DIGIT}+ +FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".") + +%% + +{HASH} { return HASH; } + +{HASH}define { return HASH_DEFINE_OBJ; } +{HASH}define{HSPACE}+/{IDENTIFIER}"(" { return HASH_DEFINE_FUNC; } +{HASH}undef { return HASH_UNDEF; } + +{HASH}if { return HASH_IF; } +{HASH}ifdef { return HASH_IFDEF; } +{HASH}ifndef { return HASH_IFNDEF; } +{HASH}else { return HASH_ELSE; } +{HASH}elif { return HASH_ELIF; } +{HASH}endif { return HASH_ENDIF; } +"defined" { return DEFINED; } + +{HASH}error { return HASH_ERROR; } +{HASH}pragma { return HASH_PRAGMA; } +{HASH}extension { return HASH_EXTENSION; } +{HASH}version { return HASH_VERSION; } +{HASH}line { return HASH_LINE; } + +{IDENTIFIER} { + yylval->sval = new std::string(yytext, yyleng); + return IDENTIFIER; +} + +{DECIMAL_CONSTANT}|{OCTAL_CONSTANT}|{HEXADECIMAL_CONSTANT} { + yylval->sval = new std::string(yytext, yyleng); + return INT_CONSTANT; +} + +({DIGIT}+{EXPONENT_PART})|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?) { + yylval->sval = new std::string(yytext, yyleng); + return FLOAT_CONSTANT; +} + +{PUNCTUATOR} { return yytext[0]; } + +{HSPACE}+ { return SPACE; } + +\n { + ++yylineno; yycolumn = 0; + return yytext[0]; +} + +<*><> { yyterminate(); } + +%% + +int readInput(pp::Context* context, char* buf, int maxSize) +{ + yyscan_t lexer = context->lexer; + ASSERT(lexer); + + int nread = YY_NULL; + while (!context->input.eof() && + (context->input.error() == pp::Input::kErrorNone) && + (nread == YY_NULL)) + { + int line = 0, file = 0; + pp::Token::decodeLocation(yyget_lineno(lexer), &line, &file); + file = context->input.stringIndex(); + yyset_lineno(pp::Token::encodeLocation(line, file), lexer); + + nread = context->input.read(buf, maxSize); + + if (context->input.error() == pp::Input::kErrorUnexpectedEOF) + { + // TODO(alokp): Report error. + } + } + return nread; +} + +namespace pp { + +bool Preprocessor::initLexer(Context* context) +{ + ASSERT(context->lexer == NULL); + + yyscan_t lexer = 0; + if (yylex_init_extra(context, &lexer)) + return false; + + context->lexer = lexer; + yyrestart(0, lexer); + return true; +} + +void Preprocessor::destroyLexer(Context* context) +{ + ASSERT(context->lexer); + + yylex_destroy(context->lexer); + context->lexer = 0; +} + +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/pp.y b/gfx/angle/src/compiler/preprocessor/new/pp.y new file mode 100644 index 000000000000..df92b84aabc3 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/pp.y @@ -0,0 +1,259 @@ +/* +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +This file contains the Yacc grammar for GLSL ES preprocessor. +Based on Microsoft Visual Studio 2010 Preprocessor Grammar: +http://msdn.microsoft.com/en-us/library/2scxys89.aspx + +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glsl_parser.sh, +WHICH GENERATES THE GLSL ES PARSER. +*/ + +%{ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! + +#include "Context.h" +#include "Preprocessor.h" + +#define YYLEX_PARAM context->lexer +#define YYDEBUG 1 +%} + +%pure-parser +%name-prefix="pp" +%locations +%parse-param {pp::Context* context} + +%union { + int ival; + std::string* sval; + std::vector* slist; + pp::Token* tval; + pp::TokenVector* tlist; +} + +%{ +extern int yylex(YYSTYPE* lvalp, YYLTYPE* llocp, void* lexer); +static void yyerror(YYLTYPE* llocp, + pp::Context* context, + const char* reason); + +static void defineMacro(pp::Context* context, + YYLTYPE* llocp, + pp::Macro::Type type, + const std::string* identifier, + std::vector* parameters, + pp::TokenVector* replacements); +static void undefineMacro(pp::Context* context, const std::string* identifier); +static bool isMacroDefined(pp::Context* context, const std::string* identifier); +static void pushConditionalBlock(pp::Context* context, bool condition); +static void popConditionalBlock(pp::Context* context); +%} + +%token HASH HASH_DEFINE_OBJ HASH_DEFINE_FUNC HASH_UNDEF +%token HASH_IF HASH_IFDEF HASH_IFNDEF HASH_ELSE HASH_ELIF HASH_ENDIF DEFINED +%token HASH_ERROR HASH_PRAGMA HASH_EXTENSION HASH_VERSION HASH_LINE +%token SPACE +%token INT_CONSTANT FLOAT_CONSTANT IDENTIFIER +%type operator +%type parameter_list +%type conditional_token token +%type text_line replacement_token_list conditional_token_list token_list +%% + +input + : /* empty */ + | input line +; + +line + : text_line { + // TODO(alokp): Expand macros. + pp::TokenVector* out = context->output; + out->insert(out->end(), $1->begin(), $1->end()); + delete $1; + } + | control_line +; + +text_line + : '\n' { $$ = NULL; } + | token_list '\n' { $$ = $1; } +; + +control_line + : HASH '\n' + | HASH_DEFINE_OBJ IDENTIFIER replacement_token_list '\n' { + defineMacro(context, & @2, pp::Macro::kTypeObj, $2, NULL, $3); + } + | HASH_DEFINE_FUNC IDENTIFIER '(' parameter_list ')' replacement_token_list '\n' { + defineMacro(context, & @2, pp::Macro::kTypeFunc, $2, $4, $6); + } + | HASH_UNDEF IDENTIFIER '\n' { + undefineMacro(context, $2); + } + | HASH_IF conditional_token_list '\n' { + pushConditionalBlock(context, $2 ? true : false); + } + | HASH_IFDEF IDENTIFIER '\n' { + pushConditionalBlock(context, isMacroDefined(context, $2)); + } + | HASH_IFNDEF IDENTIFIER '\n' { + pushConditionalBlock(context, !isMacroDefined(context, $2)); + } + | HASH_ELIF conditional_token_list '\n' { + } + | HASH_ELSE '\n' { + } + | HASH_ENDIF '\n' { + popConditionalBlock(context); + } + | HASH_ERROR '\n' + | HASH_PRAGMA '\n' + | HASH_EXTENSION '\n' + | HASH_VERSION '\n' + | HASH_LINE '\n' +; + +replacement_token_list + : /* empty */ { $$ = NULL } + | token_list +; + +conditional_token_list + : conditional_token { + $$ = new pp::TokenVector; + $$->push_back($1); + } + | conditional_token_list conditional_token { + $$ = $1; + $$->push_back($2); + } +; + +conditional_token + : DEFINED IDENTIFIER { + } + | DEFINED '(' IDENTIFIER ')' { + } + | token +; + +parameter_list + : /* empty */ { $$ = NULL; } + | IDENTIFIER { + $$ = new std::vector(); + $$->push_back($1); + } + | parameter_list ',' IDENTIFIER { + $$ = $1; + $$->push_back($3); + } +; + +token_list + : token { + $$ = new pp::TokenVector; + $$->push_back($1); + } + | token_list token { + $$ = $1; + $$->push_back($2); + } +; + +token + : operator { + $$ = new pp::Token(@1.first_line, $1, NULL); + } + | SPACE { + $$ = new pp::Token(@1.first_line, SPACE, NULL); + } + | INT_CONSTANT { + $$ = new pp::Token(@1.first_line, INT_CONSTANT, $1); + } + | FLOAT_CONSTANT { + $$ = new pp::Token(@1.first_line, FLOAT_CONSTANT, $1); + } + | IDENTIFIER { + $$ = new pp::Token(@1.first_line, IDENTIFIER, $1); + } +; + +operator + : '[' { $$ = '['; } + | ']' { $$ = ']'; } + | '<' { $$ = '<'; } + | '>' { $$ = '>'; } + | '(' { $$ = '('; } + | ')' { $$ = ')'; } + | '{' { $$ = '{'; } + | '}' { $$ = '}'; } + | '.' { $$ = '.'; } + | '+' { $$ = '+'; } + | '-' { $$ = '-'; } + | '/' { $$ = '/'; } + | '*' { $$ = '*'; } + | '%' { $$ = '%'; } + | '^' { $$ = '^'; } + | '|' { $$ = '|'; } + | '&' { $$ = '&'; } + | '~' { $$ = '~'; } + | '=' { $$ = '='; } + | '!' { $$ = '!'; } + | ':' { $$ = ':'; } + | ';' { $$ = ';'; } + | ',' { $$ = ','; } + | '?' { $$ = '?'; } +; + +%% + +void yyerror(YYLTYPE* llocp, pp::Context* context, const char* reason) +{ +} + +void defineMacro(pp::Context* context, + YYLTYPE* llocp, + pp::Macro::Type type, + const std::string* identifier, + std::vector* parameters, + pp::TokenVector* replacements) +{ +} + +void undefineMacro(pp::Context* context, const std::string* identifier) +{ +} + +bool isMacroDefined(pp::Context* context, const std::string* identifier) +{ + return false; +} + +void pushConditionalBlock(pp::Context* context, bool condition) +{ +} + +void popConditionalBlock(pp::Context* context) +{ +} + +namespace pp { +bool Preprocessor::parse(Context* context) +{ + yydebug = 1; + return yyparse(context) == 0 ? true : false; +} +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/pp_lex.cpp b/gfx/angle/src/compiler/preprocessor/new/pp_lex.cpp new file mode 100644 index 000000000000..b62dfe09bb43 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/pp_lex.cpp @@ -0,0 +1,2276 @@ +#line 16 "compiler/preprocessor/new/pp.l" +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_parser.sh. DO NOT EDIT! + + + +#line 13 "compiler/preprocessor/new/pp_lex.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE pprestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE pplex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via pprestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void pprestart (FILE *input_file ,yyscan_t yyscanner ); +void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE pp_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void pp_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void pp_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void pppush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void pppop_buffer_state (yyscan_t yyscanner ); + +static void ppensure_buffer_stack (yyscan_t yyscanner ); +static void pp_load_buffer_state (yyscan_t yyscanner ); +static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER pp_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +void *ppalloc (yy_size_t ,yyscan_t yyscanner ); +void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void ppfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer pp_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + ppensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + ppensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define ppwrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 23 +#define YY_END_OF_BUFFER 24 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_acclist[57] = + { 0, + 24, 23, 21, 23, 22, 23, 20, 23, 20, 23, + 18, 23, 18, 23, 17, 23, 17, 23, 21, 23, + 1, 23, 21, 19, 19, 18, 18, 17, 17, 21, + 1, 1, 19, 18, 17, 5, 19, 17, 17, 9, + 8, 16, 17, 10, 12, 6, 4, 11, 17, 2, + 7, 13,16387, 15, 8195, 14 + } ; + +static yyconst flex_int16_t yy_accept[104] = + { 0, + 1, 1, 1, 2, 3, 5, 7, 9, 11, 13, + 15, 17, 19, 21, 23, 24, 25, 26, 27, 27, + 27, 27, 28, 29, 30, 31, 32, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 34, 35, 36, + 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, + 37, 38, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 40, 40, 41, 42, 42, + 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, + 45, 46, 46, 47, 47, 47, 48, 48, 50, 51, + 51, 52, 53, 53, 54, 54, 55, 55, 55, 56, + + 56, 57, 57 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 5, 1, 4, 4, 1, 6, + 4, 4, 7, 4, 7, 8, 4, 9, 10, 10, + 10, 10, 10, 10, 10, 11, 11, 4, 4, 4, + 4, 4, 4, 1, 12, 12, 12, 12, 13, 12, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 15, 14, 14, + 4, 1, 4, 4, 14, 1, 16, 12, 12, 17, + + 18, 19, 20, 14, 21, 14, 14, 22, 23, 24, + 25, 26, 14, 27, 28, 29, 30, 31, 14, 32, + 14, 14, 4, 4, 4, 4, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[33] = + { 0, + 1, 2, 1, 1, 1, 3, 1, 1, 4, 4, + 4, 5, 6, 7, 7, 5, 5, 6, 5, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7 + } ; + +static yyconst flex_int16_t yy_base[109] = + { 0, + 0, 17, 171, 172, 168, 172, 172, 3, 27, 52, + 0, 151, 27, 69, 166, 26, 28, 1, 21, 40, + 0, 0, 0, 148, 50, 0, 0, 148, 42, 146, + 143, 136, 138, 143, 47, 66, 69, 0, 139, 140, + 60, 141, 130, 127, 65, 131, 138, 136, 125, 74, + 83, 127, 129, 130, 130, 126, 121, 127, 126, 126, + 124, 121, 122, 111, 120, 113, 172, 172, 117, 108, + 110, 114, 114, 172, 108, 111, 108, 103, 101, 172, + 172, 85, 172, 79, 81, 172, 71, 0, 71, 51, + 172, 172, 44, 65, 28, 172, 42, 19, 172, 9, + + 172, 172, 100, 104, 108, 111, 116, 121 + } ; + +static yyconst flex_int16_t yy_def[109] = + { 0, + 103, 103, 102, 102, 102, 102, 102, 102, 102, 102, + 104, 104, 102, 102, 102, 105, 105, 9, 18, 102, + 106, 10, 104, 104, 102, 14, 14, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 106, 104, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 104, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 104, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 104, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 104, 102, 102, + 102, 102, 102, 107, 102, 102, 108, 102, 102, 108, + + 102, 0, 102, 102, 102, 102, 102, 102 + } ; + +static yyconst flex_int16_t yy_nxt[205] = + { 0, + 4, 5, 6, 7, 4, 7, 7, 8, 9, 10, + 10, 16, 16, 16, 99, 102, 12, 4, 13, 6, + 7, 14, 7, 7, 8, 9, 10, 10, 25, 19, + 19, 26, 102, 12, 17, 18, 18, 19, 35, 20, + 35, 21, 101, 35, 20, 35, 36, 99, 37, 37, + 37, 25, 98, 50, 26, 51, 51, 51, 21, 17, + 22, 22, 22, 41, 20, 42, 94, 96, 43, 20, + 27, 95, 94, 44, 37, 37, 37, 37, 37, 37, + 54, 59, 51, 51, 51, 28, 29, 55, 60, 30, + 31, 51, 51, 51, 32, 93, 92, 91, 33, 34, + + 11, 11, 11, 11, 11, 11, 11, 23, 23, 23, + 23, 16, 90, 16, 38, 38, 38, 97, 89, 88, + 97, 97, 97, 100, 100, 100, 100, 100, 87, 86, + 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, + 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, + 65, 64, 63, 62, 61, 58, 57, 56, 53, 52, + 49, 48, 47, 46, 45, 40, 39, 15, 24, 15, + 102, 3, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + + 102, 102, 102, 102 + } ; + +static yyconst flex_int16_t yy_chk[205] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 8, 8, 8, 100, 18, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 13, 19, + 19, 13, 18, 2, 9, 9, 9, 9, 16, 9, + 17, 9, 98, 16, 9, 17, 20, 97, 20, 20, + 20, 25, 95, 35, 25, 35, 35, 35, 9, 10, + 10, 10, 10, 29, 10, 29, 94, 93, 29, 10, + 14, 90, 89, 29, 36, 36, 36, 37, 37, 37, + 41, 45, 50, 50, 50, 14, 14, 41, 45, 14, + 14, 51, 51, 51, 14, 87, 85, 84, 14, 14, + + 103, 103, 103, 103, 103, 103, 103, 104, 104, 104, + 104, 105, 82, 105, 106, 106, 106, 107, 79, 78, + 107, 107, 107, 108, 108, 108, 108, 108, 77, 76, + 75, 73, 72, 71, 70, 69, 66, 65, 64, 63, + 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, + 52, 49, 48, 47, 46, 44, 43, 42, 40, 39, + 34, 33, 32, 31, 30, 28, 24, 15, 12, 5, + 3, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + + 102, 102, 102, 102 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[24] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, }; + +#define YY_TRAILING_MASK 0x2000 +#define YY_TRAILING_HEAD_MASK 0x4000 +#define REJECT \ +{ \ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ +yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ +yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ +yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ +++yyg->yy_lp; \ +goto find_rule; \ +} + +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +/* +// +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +This file contains the Lex specification for GLSL ES preprocessor. +Based on Microsoft Visual Studio 2010 Preprocessor Grammar: +http://msdn.microsoft.com/en-us/library/2scxys89.aspx + +IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. +*/ + +#include "compiler/debug.h" +#include "Context.h" +#include "pp_tab.h" +#include "Preprocessor.h" + +#define YY_USER_ACTION \ + do { \ + yylloc->first_line = yylineno; \ + yylloc->first_column = yycolumn + 1; \ + yycolumn += yyleng; \ + } while(0); + +#define YY_INPUT(buf, result, maxSize) \ + result = readInput(yyextra, buf, maxSize); + +static int readInput(pp::Context* context, char* buf, int maxSize); + +#define INITIAL 0 + +#define YY_EXTRA_TYPE pp::Context* + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + yy_state_type *yy_state_buf; + yy_state_type *yy_state_ptr; + char *yy_full_match; + int yy_lp; + + /* These are only needed for trailing context rules, + * but there's no conditional variable for that yet. */ + int yy_looking_for_trail_begin; + int yy_full_lp; + int *yy_full_state; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + YYLTYPE * yylloc_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + + # define yylloc yyg->yylloc_r + +int pplex_init (yyscan_t* scanner); + +int pplex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int pplex_destroy (yyscan_t yyscanner ); + +int ppget_debug (yyscan_t yyscanner ); + +void ppset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner ); + +void ppset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *ppget_in (yyscan_t yyscanner ); + +void ppset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *ppget_out (yyscan_t yyscanner ); + +void ppset_out (FILE * out_str ,yyscan_t yyscanner ); + +int ppget_leng (yyscan_t yyscanner ); + +char *ppget_text (yyscan_t yyscanner ); + +int ppget_lineno (yyscan_t yyscanner ); + +void ppset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * ppget_lval (yyscan_t yyscanner ); + +void ppset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + + YYLTYPE *ppget_lloc (yyscan_t yyscanner ); + + void ppset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int ppwrap (yyscan_t yyscanner ); +#else +extern int ppwrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + + static void yy_push_state (int new_state ,yyscan_t yyscanner); + + static void yy_pop_state (yyscan_t yyscanner ); + + static int yy_top_state (yyscan_t yyscanner ); + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int pplex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); + +#define YY_DECL int pplex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + yylloc = yylloc_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + /* Create the reject buffer large enough to save one state per allowed character. */ + if ( ! yyg->yy_state_buf ) + yyg->yy_state_buf = (yy_state_type *)ppalloc(YY_STATE_BUF_SIZE ,yyscanner); + if ( ! yyg->yy_state_buf ) + YY_FATAL_ERROR( "out of dynamic memory in pplex()" ); + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + ppensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + pp_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_current_state != 102 ); + +yy_find_action: + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yyg->yy_lp]; + if ( yy_act & YY_TRAILING_HEAD_MASK || + yyg->yy_looking_for_trail_begin ) + { + if ( yy_act == yyg->yy_looking_for_trail_begin ) + { + yyg->yy_looking_for_trail_begin = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } + else if ( yy_act & YY_TRAILING_MASK ) + { + yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; + yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; + } + else + { + yyg->yy_full_match = yy_cp; + yyg->yy_full_state = yyg->yy_state_ptr; + yyg->yy_full_lp = yyg->yy_lp; + break; + } + ++yyg->yy_lp; + goto find_rule; + } + --yy_cp; + yy_current_state = *--yyg->yy_state_ptr; + yyg->yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +YY_RULE_SETUP +{ return HASH; } + YY_BREAK +case 2: +YY_RULE_SETUP +{ return HASH_DEFINE_OBJ; } + YY_BREAK +case 3: +YY_RULE_SETUP +{ return HASH_DEFINE_FUNC; } + YY_BREAK +case 4: +YY_RULE_SETUP +{ return HASH_UNDEF; } + YY_BREAK +case 5: +YY_RULE_SETUP +{ return HASH_IF; } + YY_BREAK +case 6: +YY_RULE_SETUP +{ return HASH_IFDEF; } + YY_BREAK +case 7: +YY_RULE_SETUP +{ return HASH_IFNDEF; } + YY_BREAK +case 8: +YY_RULE_SETUP +{ return HASH_ELSE; } + YY_BREAK +case 9: +YY_RULE_SETUP +{ return HASH_ELIF; } + YY_BREAK +case 10: +YY_RULE_SETUP +{ return HASH_ENDIF; } + YY_BREAK +case 11: +YY_RULE_SETUP +{ return DEFINED; } + YY_BREAK +case 12: +YY_RULE_SETUP +{ return HASH_ERROR; } + YY_BREAK +case 13: +YY_RULE_SETUP +{ return HASH_PRAGMA; } + YY_BREAK +case 14: +YY_RULE_SETUP +{ return HASH_EXTENSION; } + YY_BREAK +case 15: +YY_RULE_SETUP +{ return HASH_VERSION; } + YY_BREAK +case 16: +YY_RULE_SETUP +{ return HASH_LINE; } + YY_BREAK +case 17: +YY_RULE_SETUP +{ + yylval->sval = new std::string(yytext, yyleng); + return IDENTIFIER; +} + YY_BREAK +case 18: +YY_RULE_SETUP +{ + yylval->sval = new std::string(yytext, yyleng); + return INT_CONSTANT; +} + YY_BREAK +case 19: +YY_RULE_SETUP +{ + yylval->sval = new std::string(yytext, yyleng); + return FLOAT_CONSTANT; +} + YY_BREAK +case 20: +YY_RULE_SETUP +{ return yytext[0]; } + YY_BREAK +case 21: +YY_RULE_SETUP +{ return SPACE; } + YY_BREAK +case 22: +/* rule 22 can match eol */ +YY_RULE_SETUP +{ + ++yylineno; yycolumn = 0; + return yytext[0]; +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +{ yyterminate(); } + YY_BREAK +case 23: +YY_RULE_SETUP +ECHO; + YY_BREAK + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * pplex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( ppwrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of pplex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + pprestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + yyg->yy_state_ptr = yyg->yy_state_buf; + *yyg->yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yyg->yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 102); + if ( ! yy_is_jam ) + *yyg->yy_state_ptr++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + pprestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( ppwrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void pprestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + ppensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + pp_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + pp_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + pp_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void pp_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * pppop_buffer_state(); + * pppush_buffer_state(new_buffer); + */ + ppensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + pp_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (ppwrap()) processing, but the only time this flag + * is looked at is after ppwrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void pp_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE pp_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) ppalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in pp_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + pp_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with pp_create_buffer() + * @param yyscanner The scanner object. + */ + void pp_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + ppfree((void *) b->yy_ch_buf ,yyscanner ); + + ppfree((void *) b ,yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a pprestart() or at EOF. + */ + static void pp_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + pp_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then pp_init_buffer was _probably_ + * called from pprestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void pp_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + pp_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void pppush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + ppensure_buffer_stack(yyscanner); + + /* This block is copied from pp_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from pp_switch_to_buffer. */ + pp_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void pppop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + pp_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void ppensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)ppalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)pprealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in ppensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE pp_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) ppalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in pp_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + pp_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to pplex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * pp_scan_bytes() instead. + */ +YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return pp_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to pplex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE pp_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) ppalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in pp_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = pp_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in pp_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + + static void yy_push_state (int new_state , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) + { + yy_size_t new_size; + + yyg->yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yyg->yy_start_stack_depth * sizeof( int ); + + if ( ! yyg->yy_start_stack ) + yyg->yy_start_stack = (int *) ppalloc(new_size ,yyscanner ); + + else + yyg->yy_start_stack = (int *) pprealloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); + + if ( ! yyg->yy_start_stack ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); +} + + static void yy_pop_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( --yyg->yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); +} + + static int yy_top_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE ppget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int ppget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int ppget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *ppget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *ppget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int ppget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *ppget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void ppset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void ppset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "ppset_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void ppset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "ppset_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see pp_switch_to_buffer + */ +void ppset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void ppset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int ppget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void ppset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * ppget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void ppset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +YYLTYPE *ppget_lloc (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylloc; +} + +void ppset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylloc = yylloc_param; +} + +/* User-visible API */ + +/* pplex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int pplex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* pplex_init_extra has the same functionality as pplex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to ppalloc in + * the yyextra field. + */ + +int pplex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + ppset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) ppalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + ppset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from pplex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + + yyg->yy_state_buf = 0; + yyg->yy_state_ptr = 0; + yyg->yy_full_match = 0; + yyg->yy_lp = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * pplex_init() + */ + return 0; +} + +/* pplex_destroy is for both reentrant and non-reentrant scanners. */ +int pplex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + pp_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + pppop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + ppfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + ppfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + ppfree ( yyg->yy_state_buf , yyscanner); + yyg->yy_state_buf = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * pplex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + ppfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *ppalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *pprealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void ppfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see pprealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +int readInput(pp::Context* context, char* buf, int maxSize) +{ + yyscan_t lexer = context->lexer; + ASSERT(lexer); + + int nread = YY_NULL; + while (!context->input.eof() && + (context->input.error() == pp::Input::kErrorNone) && + (nread == YY_NULL)) + { + int line = 0, file = 0; + pp::Token::decodeLocation(ppget_lineno(lexer), &line, &file); + file = context->input.stringIndex(); + ppset_lineno(pp::Token::encodeLocation(line, file),lexer); + + nread = context->input.read(buf, maxSize); + + if (context->input.error() == pp::Input::kErrorUnexpectedEOF) + { + // TODO(alokp): Report error. + } + } + return nread; +} + +namespace pp { + +bool Preprocessor::initLexer(Context* context) +{ + ASSERT(context->lexer == NULL); + + yyscan_t lexer = 0; + if (pplex_init_extra(context,&lexer)) + return false; + + context->lexer = lexer; + pprestart(0,lexer); + return true; +} + +void Preprocessor::destroyLexer(Context* context) +{ + ASSERT(context->lexer); + + pplex_destroy(context->lexer); + context->lexer = 0; +} + +} // namespace pp + diff --git a/gfx/angle/src/compiler/preprocessor/new/pp_tab.cpp b/gfx/angle/src/compiler/preprocessor/new/pp_tab.cpp new file mode 100644 index 000000000000..4ef46588eb30 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/pp_tab.cpp @@ -0,0 +1,2120 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse ppparse +#define yylex pplex +#define yyerror pperror +#define yylval pplval +#define yychar ppchar +#define yydebug ppdebug +#define yynerrs ppnerrs +#define yylloc pplloc + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + HASH = 258, + HASH_DEFINE_OBJ = 259, + HASH_DEFINE_FUNC = 260, + HASH_UNDEF = 261, + HASH_IF = 262, + HASH_IFDEF = 263, + HASH_IFNDEF = 264, + HASH_ELSE = 265, + HASH_ELIF = 266, + HASH_ENDIF = 267, + DEFINED = 268, + HASH_ERROR = 269, + HASH_PRAGMA = 270, + HASH_EXTENSION = 271, + HASH_VERSION = 272, + HASH_LINE = 273, + SPACE = 274, + INT_CONSTANT = 275, + FLOAT_CONSTANT = 276, + IDENTIFIER = 277 + }; +#endif +/* Tokens. */ +#define HASH 258 +#define HASH_DEFINE_OBJ 259 +#define HASH_DEFINE_FUNC 260 +#define HASH_UNDEF 261 +#define HASH_IF 262 +#define HASH_IFDEF 263 +#define HASH_IFNDEF 264 +#define HASH_ELSE 265 +#define HASH_ELIF 266 +#define HASH_ENDIF 267 +#define DEFINED 268 +#define HASH_ERROR 269 +#define HASH_PRAGMA 270 +#define HASH_EXTENSION 271 +#define HASH_VERSION 272 +#define HASH_LINE 273 +#define SPACE 274 +#define INT_CONSTANT 275 +#define FLOAT_CONSTANT 276 +#define IDENTIFIER 277 + + + + +/* Copy the first part of user declarations. */ + + +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT! + +#include "Context.h" +#include "Preprocessor.h" + +#define YYLEX_PARAM context->lexer +#define YYDEBUG 1 + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE + +{ + int ival; + std::string* sval; + std::vector* slist; + pp::Token* tval; + pp::TokenVector* tlist; +} +/* Line 187 of yacc.c. */ + + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +extern int yylex(YYSTYPE* lvalp, YYLTYPE* llocp, void* lexer); +static void yyerror(YYLTYPE* llocp, + pp::Context* context, + const char* reason); + +static void defineMacro(pp::Context* context, + YYLTYPE* llocp, + pp::Macro::Type type, + const std::string* identifier, + std::vector* parameters, + pp::TokenVector* replacements); +static void undefineMacro(pp::Context* context, const std::string* identifier); +static bool isMacroDefined(pp::Context* context, const std::string* identifier); +static void pushConditionalBlock(pp::Context* context, bool condition); +static void popConditionalBlock(pp::Context* context); + + +/* Line 216 of yacc.c. */ + + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + YYLTYPE yyls; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 244 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 48 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 12 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 63 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 94 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 277 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 23, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 44, 2, 2, 2, 38, 41, 2, + 24, 25, 37, 34, 26, 35, 33, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 45, 46, + 29, 43, 30, 47, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 27, 2, 28, 39, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 31, 40, 32, 42, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 11, 13, 16, 19, + 24, 32, 36, 40, 44, 48, 52, 55, 58, 61, + 64, 67, 70, 73, 74, 76, 78, 81, 84, 89, + 91, 92, 94, 98, 100, 103, 105, 107, 109, 111, + 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, + 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, + 153, 155, 157, 159 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 49, 0, -1, -1, 49, 50, -1, 51, -1, 52, + -1, 23, -1, 57, 23, -1, 3, 23, -1, 4, + 22, 53, 23, -1, 5, 22, 24, 56, 25, 53, + 23, -1, 6, 22, 23, -1, 7, 54, 23, -1, + 8, 22, 23, -1, 9, 22, 23, -1, 11, 54, + 23, -1, 10, 23, -1, 12, 23, -1, 14, 23, + -1, 15, 23, -1, 16, 23, -1, 17, 23, -1, + 18, 23, -1, -1, 57, -1, 55, -1, 54, 55, + -1, 13, 22, -1, 13, 24, 22, 25, -1, 58, + -1, -1, 22, -1, 56, 26, 22, -1, 58, -1, + 57, 58, -1, 59, -1, 19, -1, 20, -1, 21, + -1, 22, -1, 27, -1, 28, -1, 29, -1, 30, + -1, 24, -1, 25, -1, 31, -1, 32, -1, 33, + -1, 34, -1, 35, -1, 36, -1, 37, -1, 38, + -1, 39, -1, 40, -1, 41, -1, 42, -1, 43, + -1, 44, -1, 45, -1, 46, -1, 26, -1, 47, + -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 74, 74, 76, 80, 86, 90, 91, 95, 96, + 99, 102, 105, 108, 111, 114, 116, 118, 121, 122, + 123, 124, 125, 129, 130, 134, 138, 145, 147, 149, + 153, 154, 158, 165, 169, 176, 179, 182, 185, 188, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "HASH", "HASH_DEFINE_OBJ", + "HASH_DEFINE_FUNC", "HASH_UNDEF", "HASH_IF", "HASH_IFDEF", "HASH_IFNDEF", + "HASH_ELSE", "HASH_ELIF", "HASH_ENDIF", "DEFINED", "HASH_ERROR", + "HASH_PRAGMA", "HASH_EXTENSION", "HASH_VERSION", "HASH_LINE", "SPACE", + "INT_CONSTANT", "FLOAT_CONSTANT", "IDENTIFIER", "'\\n'", "'('", "')'", + "','", "'['", "']'", "'<'", "'>'", "'{'", "'}'", "'.'", "'+'", "'-'", + "'/'", "'*'", "'%'", "'^'", "'|'", "'&'", "'~'", "'='", "'!'", "':'", + "';'", "'?'", "$accept", "input", "line", "text_line", "control_line", + "replacement_token_list", "conditional_token_list", "conditional_token", + "parameter_list", "token_list", "token", "operator", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 10, 40, 41, 44, 91, 93, 60, + 62, 123, 125, 46, 43, 45, 47, 42, 37, 94, + 124, 38, 126, 61, 33, 58, 59, 63 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 48, 49, 49, 50, 50, 51, 51, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 53, 53, 54, 54, 55, 55, 55, + 56, 56, 56, 57, 57, 58, 58, 58, 58, 58, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 2, 2, 4, + 7, 3, 3, 3, 3, 3, 2, 2, 2, 2, + 2, 2, 2, 0, 1, 1, 2, 2, 4, 1, + 0, 1, 3, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, + 38, 39, 6, 44, 45, 62, 40, 41, 42, 43, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 63, 3, 4, 5, + 0, 33, 35, 8, 23, 0, 0, 0, 0, 25, + 29, 0, 0, 16, 0, 17, 18, 19, 20, 21, + 22, 7, 34, 0, 24, 30, 11, 27, 0, 12, + 26, 13, 14, 15, 9, 31, 0, 0, 23, 0, + 28, 0, 32, 10 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 47, 48, 49, 73, 58, 59, 86, 74, + 60, 52 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -29 +static const yytype_int16 yypact[] = +{ + -29, 1, -29, -9, 29, 33, 35, 139, 36, 37, + 38, 139, 39, 40, 41, 42, 43, 44, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + 168, -29, -29, -29, 197, 45, 47, 30, 69, -29, + -29, 48, 49, -29, 104, -29, -29, -29, -29, -29, + -29, -29, -29, 51, 197, 46, -29, -29, 53, -29, + -29, -29, -29, -29, -29, -29, -23, 52, 197, 54, + -29, 55, -29, -29 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -29, -29, -29, -29, -29, -28, 68, -8, -29, 79, + -1, -29 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 51, 2, 88, 89, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 53, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 72, + 80, 54, 77, 51, 78, 55, 80, 56, 61, 62, + 91, 63, 65, 66, 67, 68, 69, 70, 85, 75, + 76, 81, 82, 72, 84, 87, 92, 90, 93, 64, + 50, 0, 57, 0, 0, 0, 0, 51, 18, 19, + 20, 21, 79, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 57, 0, 0, + 0, 0, 0, 18, 19, 20, 21, 83, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 57, 0, 0, 0, 0, 0, 18, 19, + 20, 21, 0, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 18, 19, 20, + 21, 71, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 18, 19, 20, 21, + 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46 +}; + +static const yytype_int8 yycheck[] = +{ + 1, 0, 25, 26, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 23, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 50, + 58, 22, 22, 54, 24, 22, 64, 22, 22, 22, + 88, 23, 23, 23, 23, 23, 23, 23, 22, 24, + 23, 23, 23, 74, 23, 22, 22, 25, 23, 11, + 1, -1, 13, -1, -1, -1, -1, 88, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 13, -1, -1, + -1, -1, -1, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 13, -1, -1, -1, -1, -1, 19, 20, + 21, 22, -1, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 19, 20, 21, 22, + -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 49, 0, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 50, 51, 52, + 57, 58, 59, 23, 22, 22, 22, 13, 54, 55, + 58, 22, 22, 23, 54, 23, 23, 23, 23, 23, + 23, 23, 58, 53, 57, 24, 23, 22, 24, 23, + 55, 23, 23, 23, 23, 22, 56, 22, 25, 26, + 25, 53, 22, 23 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, context, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, &yylloc) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location, context); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, pp::Context* context) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + pp::Context* context; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); + YYUSE (context); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, pp::Context* context) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + pp::Context* context; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, pp::Context* context) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule, context) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; + pp::Context* context; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) , context); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule, context); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, pp::Context* context) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; + pp::Context* context; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (context); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (pp::Context* context); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (pp::Context* context) +#else +int +yyparse (context) + pp::Context* context; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; +/* Location data for the look-ahead symbol. */ +YYLTYPE yylloc; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 0; +#endif + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + YYSTACK_RELOCATE (yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: + + { + // TODO(alokp): Expand macros. + pp::TokenVector* out = context->output; + out->insert(out->end(), (yyvsp[(1) - (1)].tlist)->begin(), (yyvsp[(1) - (1)].tlist)->end()); + delete (yyvsp[(1) - (1)].tlist); + ;} + break; + + case 6: + + { (yyval.tlist) = NULL; ;} + break; + + case 7: + + { (yyval.tlist) = (yyvsp[(1) - (2)].tlist); ;} + break; + + case 9: + + { + defineMacro(context, & (yylsp[(2) - (4)]), pp::Macro::kTypeObj, (yyvsp[(2) - (4)].sval), NULL, (yyvsp[(3) - (4)].tlist)); + ;} + break; + + case 10: + + { + defineMacro(context, & (yylsp[(2) - (7)]), pp::Macro::kTypeFunc, (yyvsp[(2) - (7)].sval), (yyvsp[(4) - (7)].slist), (yyvsp[(6) - (7)].tlist)); + ;} + break; + + case 11: + + { + undefineMacro(context, (yyvsp[(2) - (3)].sval)); + ;} + break; + + case 12: + + { + pushConditionalBlock(context, (yyvsp[(2) - (3)].tlist) ? true : false); + ;} + break; + + case 13: + + { + pushConditionalBlock(context, isMacroDefined(context, (yyvsp[(2) - (3)].sval))); + ;} + break; + + case 14: + + { + pushConditionalBlock(context, !isMacroDefined(context, (yyvsp[(2) - (3)].sval))); + ;} + break; + + case 15: + + { + ;} + break; + + case 16: + + { + ;} + break; + + case 17: + + { + popConditionalBlock(context); + ;} + break; + + case 23: + + { (yyval.tlist) = NULL ;} + break; + + case 25: + + { + (yyval.tlist) = new pp::TokenVector; + (yyval.tlist)->push_back((yyvsp[(1) - (1)].tval)); + ;} + break; + + case 26: + + { + (yyval.tlist) = (yyvsp[(1) - (2)].tlist); + (yyval.tlist)->push_back((yyvsp[(2) - (2)].tval)); + ;} + break; + + case 27: + + { + ;} + break; + + case 28: + + { + ;} + break; + + case 30: + + { (yyval.slist) = NULL; ;} + break; + + case 31: + + { + (yyval.slist) = new std::vector(); + (yyval.slist)->push_back((yyvsp[(1) - (1)].sval)); + ;} + break; + + case 32: + + { + (yyval.slist) = (yyvsp[(1) - (3)].slist); + (yyval.slist)->push_back((yyvsp[(3) - (3)].sval)); + ;} + break; + + case 33: + + { + (yyval.tlist) = new pp::TokenVector; + (yyval.tlist)->push_back((yyvsp[(1) - (1)].tval)); + ;} + break; + + case 34: + + { + (yyval.tlist) = (yyvsp[(1) - (2)].tlist); + (yyval.tlist)->push_back((yyvsp[(2) - (2)].tval)); + ;} + break; + + case 35: + + { + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, (yyvsp[(1) - (1)].ival), NULL); + ;} + break; + + case 36: + + { + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, SPACE, NULL); + ;} + break; + + case 37: + + { + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, INT_CONSTANT, (yyvsp[(1) - (1)].sval)); + ;} + break; + + case 38: + + { + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, FLOAT_CONSTANT, (yyvsp[(1) - (1)].sval)); + ;} + break; + + case 39: + + { + (yyval.tval) = new pp::Token((yylsp[(1) - (1)]).first_line, IDENTIFIER, (yyvsp[(1) - (1)].sval)); + ;} + break; + + case 40: + + { (yyval.ival) = '['; ;} + break; + + case 41: + + { (yyval.ival) = ']'; ;} + break; + + case 42: + + { (yyval.ival) = '<'; ;} + break; + + case 43: + + { (yyval.ival) = '>'; ;} + break; + + case 44: + + { (yyval.ival) = '('; ;} + break; + + case 45: + + { (yyval.ival) = ')'; ;} + break; + + case 46: + + { (yyval.ival) = '{'; ;} + break; + + case 47: + + { (yyval.ival) = '}'; ;} + break; + + case 48: + + { (yyval.ival) = '.'; ;} + break; + + case 49: + + { (yyval.ival) = '+'; ;} + break; + + case 50: + + { (yyval.ival) = '-'; ;} + break; + + case 51: + + { (yyval.ival) = '/'; ;} + break; + + case 52: + + { (yyval.ival) = '*'; ;} + break; + + case 53: + + { (yyval.ival) = '%'; ;} + break; + + case 54: + + { (yyval.ival) = '^'; ;} + break; + + case 55: + + { (yyval.ival) = '|'; ;} + break; + + case 56: + + { (yyval.ival) = '&'; ;} + break; + + case 57: + + { (yyval.ival) = '~'; ;} + break; + + case 58: + + { (yyval.ival) = '='; ;} + break; + + case 59: + + { (yyval.ival) = '!'; ;} + break; + + case 60: + + { (yyval.ival) = ':'; ;} + break; + + case 61: + + { (yyval.ival) = ';'; ;} + break; + + case 62: + + { (yyval.ival) = ','; ;} + break; + + case 63: + + { (yyval.ival) = '?'; ;} + break; + + +/* Line 1267 of yacc.c. */ + + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (&yylloc, context, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, context, yymsg); + } + else + { + yyerror (&yylloc, context, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc, context); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp, context); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (&yylloc, context, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, context); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp, context); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + + + +void yyerror(YYLTYPE* llocp, pp::Context* context, const char* reason) +{ +} + +void defineMacro(pp::Context* context, + YYLTYPE* llocp, + pp::Macro::Type type, + const std::string* identifier, + std::vector* parameters, + pp::TokenVector* replacements) +{ +} + +void undefineMacro(pp::Context* context, const std::string* identifier) +{ +} + +bool isMacroDefined(pp::Context* context, const std::string* identifier) +{ + return false; +} + +void pushConditionalBlock(pp::Context* context, bool condition) +{ +} + +void popConditionalBlock(pp::Context* context) +{ +} + +namespace pp { +bool Preprocessor::parse(Context* context) +{ + yydebug = 1; + return yyparse(context) == 0 ? true : false; +} +} // namespace pp + + diff --git a/gfx/angle/src/compiler/preprocessor/new/pp_tab.h b/gfx/angle/src/compiler/preprocessor/new/pp_tab.h new file mode 100644 index 000000000000..34f6237c9488 --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/pp_tab.h @@ -0,0 +1,122 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + HASH = 258, + HASH_DEFINE_OBJ = 259, + HASH_DEFINE_FUNC = 260, + HASH_UNDEF = 261, + HASH_IF = 262, + HASH_IFDEF = 263, + HASH_IFNDEF = 264, + HASH_ELSE = 265, + HASH_ELIF = 266, + HASH_ENDIF = 267, + DEFINED = 268, + HASH_ERROR = 269, + HASH_PRAGMA = 270, + HASH_EXTENSION = 271, + HASH_VERSION = 272, + HASH_LINE = 273, + SPACE = 274, + INT_CONSTANT = 275, + FLOAT_CONSTANT = 276, + IDENTIFIER = 277 + }; +#endif +/* Tokens. */ +#define HASH 258 +#define HASH_DEFINE_OBJ 259 +#define HASH_DEFINE_FUNC 260 +#define HASH_UNDEF 261 +#define HASH_IF 262 +#define HASH_IFDEF 263 +#define HASH_IFNDEF 264 +#define HASH_ELSE 265 +#define HASH_ELIF 266 +#define HASH_ENDIF 267 +#define DEFINED 268 +#define HASH_ERROR 269 +#define HASH_PRAGMA 270 +#define HASH_EXTENSION 271 +#define HASH_VERSION 272 +#define HASH_LINE 273 +#define SPACE 274 +#define INT_CONSTANT 275 +#define FLOAT_CONSTANT 276 +#define IDENTIFIER 277 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE + +{ + int ival; + std::string* sval; + std::vector* slist; + pp::Token* tval; + pp::TokenVector* tlist; +} +/* Line 1489 of yacc.c. */ + + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + diff --git a/gfx/angle/src/compiler/preprocessor/new/token_type.h b/gfx/angle/src/compiler/preprocessor/new/token_type.h new file mode 100644 index 000000000000..343a9419031a --- /dev/null +++ b/gfx/angle/src/compiler/preprocessor/new/token_type.h @@ -0,0 +1,13 @@ +// +// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +#ifndef COMPILER_PREPROCESSOR_TOKEN_TYPE_H_ +#define COMPILER_PREPROCESSOR_TOKEN_TYPE_H_ + +#include "pp_tab.h" + +#endif // COMPILER_PREPROCESSOR_TOKEN_TYPE_H_ + diff --git a/gfx/angle/src/libEGL/Display.cpp b/gfx/angle/src/libEGL/Display.cpp index b8b5e2f29503..791eca4f3a41 100644 --- a/gfx/angle/src/libEGL/Display.cpp +++ b/gfx/angle/src/libEGL/Display.cpp @@ -11,6 +11,7 @@ #include "libEGL/Display.h" #include +#include #include #include "common/debug.h" @@ -31,7 +32,41 @@ namespace egl { -Display::Display(HDC deviceContext) : mDc(deviceContext) +namespace +{ + typedef std::map DisplayMap; + DisplayMap displays; +} + +egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) +{ + if (displays.find(displayId) != displays.end()) + { + return displays[displayId]; + } + + egl::Display *display = NULL; + + if (displayId == EGL_DEFAULT_DISPLAY) + { + display = new egl::Display(displayId, (HDC)NULL, false); + } + else if (displayId == EGL_SOFTWARE_DISPLAY_ANGLE) + { + display = new egl::Display(displayId, (HDC)NULL, true); + } + else + { + // FIXME: Check if displayId is a valid display device context + + display = new egl::Display(displayId, (HDC)displayId, false); + } + + displays[displayId] = display; + return display; +} + +Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext) { mD3d9Module = NULL; @@ -51,11 +86,20 @@ Display::Display(HDC deviceContext) : mDc(deviceContext) mMinSwapInterval = 1; mMaxSwapInterval = 1; + mSoftwareDevice = software; + mDisplayId = displayId; } Display::~Display() { terminate(); + + DisplayMap::iterator thisDisplay = displays.find(mDisplayId); + + if (thisDisplay != displays.end()) + { + displays.erase(thisDisplay); + } } bool Display::initialize() @@ -65,7 +109,14 @@ bool Display::initialize() return true; } - mD3d9Module = GetModuleHandle(TEXT("d3d9.dll")); + if (mSoftwareDevice) + { + mD3d9Module = GetModuleHandle(TEXT("swiftshader_d3d9.dll")); + } + else + { + mD3d9Module = GetModuleHandle(TEXT("d3d9.dll")); + } if (mD3d9Module == NULL) { terminate(); @@ -141,6 +192,8 @@ bool Display::initialize() if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);} if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);} + mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier); + const D3DFORMAT renderTargetFormats[] = { D3DFMT_A1R5G5B5, @@ -295,8 +348,11 @@ void Display::startScene() if (!mSceneStarted) { long result = mDevice->BeginScene(); - ASSERT(SUCCEEDED(result)); - mSceneStarted = true; + if (SUCCEEDED(result)) { + // This is defensive checking against the device being + // lost at unexpected times. + mSceneStarted = true; + } } } @@ -304,8 +360,9 @@ void Display::endScene() { if (mSceneStarted) { - long result = mDevice->EndScene(); - ASSERT(SUCCEEDED(result)); + // EndScene can fail if the device was lost, for example due + // to a TDR during a draw call. + mDevice->EndScene(); mSceneStarted = false; } } @@ -688,6 +745,11 @@ D3DCAPS9 Display::getDeviceCaps() return mDeviceCaps; } +D3DADAPTER_IDENTIFIER9 *Display::getAdapterIdentifier() +{ + return &mAdapterIdentifier; +} + bool Display::isDeviceLost() { if (mDeviceEx) @@ -711,7 +773,7 @@ void Display::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray) } } -bool Display::getCompressedTextureSupport() +bool Display::getDXT1TextureSupport() { D3DDISPLAYMODE currentDisplayMode; mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); @@ -719,6 +781,22 @@ bool Display::getCompressedTextureSupport() return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1)); } +bool Display::getDXT3TextureSupport() +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3)); +} + +bool Display::getDXT5TextureSupport() +{ + D3DDISPLAYMODE currentDisplayMode; + mD3d9->GetAdapterDisplayMode(mAdapter, ¤tDisplayMode); + + return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5)); +} + bool Display::getFloatTextureSupport(bool *filtering, bool *renderable) { D3DDISPLAYMODE currentDisplayMode; @@ -845,6 +923,12 @@ D3DPRESENT_PARAMETERS Display::getDefaultPresentParameters() void Display::initExtensionString() { mExtensionString += "EGL_ANGLE_query_surface_pointer "; + HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll")); + + if (swiftShader) + { + mExtensionString += "EGL_ANGLE_software_display "; + } if (isD3d9ExDevice()) { mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle "; diff --git a/gfx/angle/src/libEGL/Display.h b/gfx/angle/src/libEGL/Display.h index f377db445cbe..f241670e2968 100644 --- a/gfx/angle/src/libEGL/Display.h +++ b/gfx/angle/src/libEGL/Display.h @@ -29,8 +29,6 @@ namespace egl class Display { public: - Display(HDC deviceContext); - ~Display(); bool initialize(); @@ -39,6 +37,8 @@ class Display virtual void startScene(); virtual void endScene(); + static egl::Display *getDisplay(EGLNativeDisplayType displayId); + bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); @@ -60,9 +60,12 @@ class Display virtual IDirect3DDevice9 *getDevice(); virtual D3DCAPS9 getDeviceCaps(); + virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier(); bool isDeviceLost(); virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); - virtual bool getCompressedTextureSupport(); + virtual bool getDXT1TextureSupport(); + virtual bool getDXT3TextureSupport(); + virtual bool getDXT5TextureSupport(); virtual bool getEventQuerySupport(); virtual bool getFloatTextureSupport(bool *filtering, bool *renderable); virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable); @@ -78,8 +81,11 @@ class Display private: DISALLOW_COPY_AND_ASSIGN(Display); + Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software); + D3DPRESENT_PARAMETERS getDefaultPresentParameters(); + EGLNativeDisplayType mDisplayId; const HDC mDc; HMODULE mD3d9Module; @@ -91,11 +97,13 @@ class Display IDirect3DDevice9 *mDevice; IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported. D3DCAPS9 mDeviceCaps; + D3DADAPTER_IDENTIFIER9 mAdapterIdentifier; HWND mDeviceWindow; bool mSceneStarted; EGLint mMaxSwapInterval; EGLint mMinSwapInterval; + bool mSoftwareDevice; typedef std::set SurfaceSet; SurfaceSet mSurfaceSet; diff --git a/gfx/angle/src/libEGL/Makefile.in b/gfx/angle/src/libEGL/Makefile.in index 778a00b60807..438a28d6f5d8 100644 --- a/gfx/angle/src/libEGL/Makefile.in +++ b/gfx/angle/src/libEGL/Makefile.in @@ -98,6 +98,7 @@ CPPSRCS = \ ValidateLimitations.cpp \ ForLoopUnroll.cpp \ MapLongVariableNames.cpp \ + BuiltInFunctionEmulator.cpp \ $(NULL) # flex/yacc generated files @@ -113,6 +114,9 @@ CPPSRCS += \ TranslatorHLSL.cpp \ UnfoldSelect.cpp \ SearchSymbol.cpp \ + OutputESSL.cpp \ + OutputGLSLBase.cpp \ + TranslatorESSL.cpp \ $(NULL) CSRCS = \ @@ -141,6 +145,7 @@ CPPSRCS += \ $(NULL) DEFFILE = $(srcdir)/libEGL.def +RCFILE = $(srcdir)/libEGL.rc include $(topsrcdir)/config/rules.mk diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp index fc837ac537e2..007e055f9f73 100644 --- a/gfx/angle/src/libEGL/Surface.cpp +++ b/gfx/angle/src/libEGL/Surface.cpp @@ -22,6 +22,23 @@ namespace egl { + +namespace +{ +const int versionWindowsVista = MAKEWORD(0x00, 0x06); +const int versionWindows7 = MAKEWORD(0x01, 0x06); + +// Return the version of the operating system in a format suitable for ordering +// comparison. +int getComparableOSVersion() +{ + DWORD version = GetVersion(); + int majorVersion = LOBYTE(LOWORD(version)); + int minorVersion = HIBYTE(LOWORD(version)); + return MAKEWORD(minorVersion, majorVersion); +} +} + Surface::Surface(Display *display, const Config *config, HWND window) : mDisplay(display), mConfig(config), mWindow(window) { @@ -78,7 +95,7 @@ bool Surface::initialize() // Modify present parameters for this window, if we are composited, // to minimize the amount of queuing done by DWM between our calls to // present and the actual screen. - if (mWindow && (LOWORD(GetVersion()) >= 0x60)) { + if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) { BOOL isComposited; HRESULT result = DwmIsCompositionEnabled(&isComposited); if (SUCCEEDED(result) && isComposited) { @@ -165,7 +182,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) D3DPRESENT_PARAMETERS presentParameters = {0}; HRESULT result; - bool useFlipEx = (LOWORD(GetVersion()) >= 0x61) && mDisplay->isD3d9ExDevice(); + bool useFlipEx = (getComparableOSVersion() >= versionWindows7) && mDisplay->isD3d9ExDevice(); // FlipEx causes unseemly stretching when resizing windows AND when one // draws outside of the WM_PAINT callback. While this is seldom a problem in @@ -215,7 +232,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) if (FAILED(result)) { - ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); + ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL); ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result); release(); diff --git a/gfx/angle/src/libEGL/libEGL.cpp b/gfx/angle/src/libEGL/libEGL.cpp index 8689a4eccec6..89986e66edd0 100644 --- a/gfx/angle/src/libEGL/libEGL.cpp +++ b/gfx/angle/src/libEGL/libEGL.cpp @@ -99,18 +99,7 @@ EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id) try { - // FIXME: Return the same EGLDisplay handle when display_id already created a display - - if (display_id == EGL_DEFAULT_DISPLAY) - { - return new egl::Display((HDC)NULL); - } - else - { - // FIXME: Check if display_id is a valid display device context - - return new egl::Display((HDC)display_id); - } + return egl::Display::getDisplay(display_id); } catch(std::bad_alloc&) { diff --git a/gfx/angle/src/libEGL/libEGL.vcproj b/gfx/angle/src/libEGL/libEGL.vcproj index 9fe54f2febb4..3f04a0e7001c 100644 --- a/gfx/angle/src/libEGL/libEGL.vcproj +++ b/gfx/angle/src/libEGL/libEGL.vcproj @@ -12,6 +12,9 @@ + @@ -144,7 +147,7 @@ AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib" LinkIncremental="1" ModuleDefinitionFile="libEGL.def" - DelayLoadDLLs="dwmapi.lib" + DelayLoadDLLs="dwmapi.dll" GenerateDebugInformation="true" SubSystem="2" OptimizeReferences="2" @@ -176,6 +179,168 @@ CommandLine="@echo on mkdir "$(ProjectDir)..\..\lib\$(ConfigurationName)\" copy "$(OutDir)\libEGL.dll" "$(ProjectDir)..\..\lib\$(ConfigurationName)\" copy "$(OutDir)\libEGL.lib" "$(ProjectDir)..\..\lib\$(ConfigurationName)\" @echo off " /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp index 82d148a41ba6..287272428941 100644 --- a/gfx/angle/src/libGLESv2/Context.cpp +++ b/gfx/angle/src/libGLESv2/Context.cpp @@ -156,8 +156,11 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) : m mHasBeenCurrent = false; - mSupportsCompressedTextures = false; + mSupportsDXT1Textures = false; + mSupportsDXT3Textures = false; + mSupportsDXT5Textures = false; mSupportsEventQueries = false; + mNumCompressedTextureFormats = 0; mMaxSupportedSamples = 0; mMaskedClearSavedState = NULL; markAllStateDirty(); @@ -280,7 +283,9 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) mMaxSupportedSamples = max; mSupportsEventQueries = display->getEventQuerySupport(); - mSupportsCompressedTextures = display->getCompressedTextureSupport(); + mSupportsDXT1Textures = display->getDXT1TextureSupport(); + mSupportsDXT3Textures = display->getDXT3TextureSupport(); + mSupportsDXT5Textures = display->getDXT5TextureSupport(); mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures); mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures); mSupportsLuminanceTextures = display->getLuminanceTextureSupport(); @@ -288,7 +293,22 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16); + mNumCompressedTextureFormats = 0; + if (supportsDXT1Textures()) + { + mNumCompressedTextureFormats += 2; + } + if (supportsDXT3Textures()) + { + mNumCompressedTextureFormats += 1; + } + if (supportsDXT5Textures()) + { + mNumCompressedTextureFormats += 1; + } + initExtensionString(); + initRendererString(); mState.viewportX = 0; mState.viewportY = 0; @@ -1240,18 +1260,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break; case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break; case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - { - if (supportsCompressedTextures()) - { - // at current, only GL_COMPRESSED_RGB_S3TC_DXT1_EXT and - // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT are supported - *params = 2; - } - else - { - *params = 0; - } - } + params[0] = mNumCompressedTextureFormats; break; case GL_MAX_SAMPLES_ANGLE: { @@ -1307,10 +1316,18 @@ bool Context::getIntegerv(GLenum pname, GLint *params) break; case GL_COMPRESSED_TEXTURE_FORMATS: { - if (supportsCompressedTextures()) + if (supportsDXT1Textures()) { - params[0] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - params[1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + *params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + *params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + } + if (supportsDXT3Textures()) + { + *params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE; + } + if (supportsDXT5Textures()) + { + *params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE; } } break; @@ -1422,7 +1439,12 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu // application. switch (pname) { - case GL_COMPRESSED_TEXTURE_FORMATS: /* no compressed texture formats are supported */ + case GL_COMPRESSED_TEXTURE_FORMATS: + { + *type = GL_INT; + *numParams = mNumCompressedTextureFormats; + } + break; case GL_SHADER_BINARY_FORMATS: { *type = GL_INT; @@ -1737,6 +1759,15 @@ void Context::applyState(GLenum drawMode) GLint alwaysFront = !isTriangleMode(drawMode); programObject->setUniform1iv(pointsOrLines, 1, &alwaysFront); + egl::Display *display = getDisplay(); + D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier(); + bool zeroColorMaskAllowed = identifier->VendorId != 0x1002; + // Apparently some ATI cards have a bug where a draw with a zero color + // write mask can cause later draws to have incorrect results. Instead, + // set a nonzero color write mask but modify the blend state so that no + // drawing is done. + // http://code.google.com/p/angleproject/issues/detail?id=169 + if (mCullStateDirty || mFrontFaceDirty) { if (mState.cullFace) @@ -1766,6 +1797,12 @@ void Context::applyState(GLenum drawMode) mDepthStateDirty = false; } + if (!zeroColorMaskAllowed && (mMaskStateDirty || mBlendStateDirty)) + { + mBlendStateDirty = true; + mMaskStateDirty = true; + } + if (mBlendStateDirty) { if (mState.blend) @@ -1874,8 +1911,22 @@ void Context::applyState(GLenum drawMode) if (mMaskStateDirty) { - device->SetRenderState(D3DRS_COLORWRITEENABLE, es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen, - mState.colorMaskBlue, mState.colorMaskAlpha)); + int colorMask = es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen, + mState.colorMaskBlue, mState.colorMaskAlpha); + if (colorMask == 0 && !zeroColorMaskAllowed) + { + // Enable green channel, but set blending so nothing will be drawn. + device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_GREEN); + device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + + device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO); + device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); + device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); + } + else + { + device->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask); + } device->SetRenderState(D3DRS_ZWRITEENABLE, mState.depthMask ? TRUE : FALSE); mMaskStateDirty = false; @@ -2129,8 +2180,11 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum switch (result) { + // It turns out that D3D will sometimes produce more error + // codes than those documented. case D3DERR_DRIVERINTERNALERROR: case D3DERR_DEVICELOST: + case D3DERR_DEVICEHUNG: return error(GL_OUT_OF_MEMORY); default: UNREACHABLE(); @@ -2854,7 +2908,7 @@ void Context::drawClosingLine(unsigned int first, unsigned int last) { device->SetIndices(mClosingIB->getBuffer()); - device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, offset, 1); + device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, last, offset, 1); } else { @@ -3021,9 +3075,19 @@ bool Context::supportsEventQueries() const return mSupportsEventQueries; } -bool Context::supportsCompressedTextures() const +bool Context::supportsDXT1Textures() const { - return mSupportsCompressedTextures; + return mSupportsDXT1Textures; +} + +bool Context::supportsDXT3Textures() const +{ + return mSupportsDXT3Textures; +} + +bool Context::supportsDXT5Textures() const +{ + return mSupportsDXT5Textures; } bool Context::supportsFloatTextures() const @@ -3298,11 +3362,21 @@ void Context::initExtensionString() mExtensionString += "GL_NV_fence "; } - if (supportsCompressedTextures()) + if (supportsDXT1Textures()) { mExtensionString += "GL_EXT_texture_compression_dxt1 "; } + if (supportsDXT3Textures()) + { + mExtensionString += "GL_ANGLE_texture_compression_dxt3 "; + } + + if (supportsDXT5Textures()) + { + mExtensionString += "GL_ANGLE_texture_compression_dxt5 "; + } + if (supportsFloatTextures()) { mExtensionString += "GL_OES_texture_float "; @@ -3350,6 +3424,21 @@ const char *Context::getExtensionString() const return mExtensionString.c_str(); } +void Context::initRendererString() +{ + egl::Display *display = getDisplay(); + D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier(); + + mRendererString = "ANGLE ("; + mRendererString += identifier->Description; + mRendererString += ")"; +} + +const char *Context::getRendererString() const +{ + return mRendererString.c_str(); +} + void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask) diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h index 30026544cb5e..75fdce6ad490 100644 --- a/gfx/angle/src/libGLESv2/Context.h +++ b/gfx/angle/src/libGLESv2/Context.h @@ -436,8 +436,11 @@ class Context GLsizei getMaxSupportedSamples() const; int getNearestSupportedSamples(D3DFORMAT format, int requested) const; const char *getExtensionString() const; + const char *getRendererString() const; bool supportsEventQueries() const; - bool supportsCompressedTextures() const; + bool supportsDXT1Textures() const; + bool supportsDXT3Textures() const; + bool supportsDXT5Textures() const; bool supportsFloatTextures() const; bool supportsFloatLinearFilter() const; bool supportsFloatRenderableTextures() const; @@ -478,6 +481,9 @@ class Context bool cullSkipsDraw(GLenum drawMode); bool isTriangleMode(GLenum drawMode); + void initExtensionString(); + void initRendererString(); + const egl::Config *const mConfig; State mState; @@ -493,8 +499,8 @@ class Context FenceMap mFenceMap; HandleAllocator mFenceHandleAllocator; - void initExtensionString(); std::string mExtensionString; + std::string mRendererString; VertexDataManager *mVertexDataManager; IndexDataManager *mIndexDataManager; @@ -532,7 +538,9 @@ class Context std::map mMultiSampleSupport; GLsizei mMaxSupportedSamples; bool mSupportsEventQueries; - bool mSupportsCompressedTextures; + bool mSupportsDXT1Textures; + bool mSupportsDXT3Textures; + bool mSupportsDXT5Textures; bool mSupportsFloatTextures; bool mSupportsFloatLinearFilter; bool mSupportsFloatRenderableTextures; @@ -542,6 +550,7 @@ class Context bool mSupportsLuminanceTextures; bool mSupportsLuminanceAlphaTextures; bool mSupports32bitIndices; + int mNumCompressedTextureFormats; // state caching flags bool mClearStateDirty; diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in index 513c70c13616..bf465e4804f2 100644 --- a/gfx/angle/src/libGLESv2/Makefile.in +++ b/gfx/angle/src/libGLESv2/Makefile.in @@ -98,6 +98,7 @@ CPPSRCS = \ ValidateLimitations.cpp \ ForLoopUnroll.cpp \ MapLongVariableNames.cpp \ + BuiltInFunctionEmulator.cpp \ $(NULL) # flex/yacc generated files @@ -113,6 +114,9 @@ CPPSRCS += \ TranslatorHLSL.cpp \ UnfoldSelect.cpp \ SearchSymbol.cpp \ + OutputESSL.cpp \ + OutputGLSLBase.cpp \ + TranslatorESSL.cpp \ $(NULL) CSRCS = \ @@ -153,7 +157,7 @@ CPPSRCS += \ $(NULL) DEFFILE = $(srcdir)/libGLESv2.def - +RCFILE = $(srcdir)/libGLESv2.rc include $(topsrcdir)/config/rules.mk diff --git a/gfx/angle/src/libGLESv2/Shader.cpp b/gfx/angle/src/libGLESv2/Shader.cpp index 21c638551615..f66b2c52ab7a 100644 --- a/gfx/angle/src/libGLESv2/Shader.cpp +++ b/gfx/angle/src/libGLESv2/Shader.cpp @@ -36,7 +36,7 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso { ShBuiltInResources resources; ShInitBuiltInResources(&resources); - Context *context = getContext(); + Context *context = getContext(); resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS; resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS; @@ -48,8 +48,8 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso resources.MaxDrawBuffers = MAX_DRAW_BUFFERS; resources.OES_standard_derivatives = 1; - mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources); - mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources); + mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources); + mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources); } } diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp index a432c14d1b85..de3f1c08e66b 100644 --- a/gfx/angle/src/libGLESv2/Texture.cpp +++ b/gfx/angle/src/libGLESv2/Texture.cpp @@ -14,9 +14,9 @@ #include -#if _MSC_VER <= 1400 -#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR -#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR +#if _MSC_VER <= 1400 +#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR +#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR #endif #include @@ -55,6 +55,8 @@ bool Texture::Image::isRenderable() const case D3DFMT_L8: case D3DFMT_A8L8: case D3DFMT_DXT1: + case D3DFMT_DXT3: + case D3DFMT_DXT5: return false; case D3DFMT_A8R8G8B8: case D3DFMT_X8R8G8B8: @@ -75,6 +77,14 @@ D3DFORMAT Texture::Image::getD3DFormat() const { return D3DFMT_DXT1; } + else if (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE) + { + return D3DFMT_DXT3; + } + else if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE) + { + return D3DFMT_DXT5; + } else if (type == GL_FLOAT) { return D3DFMT_A32B32G32R32F; @@ -773,6 +783,132 @@ void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs } void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const { + switch (getD3DFormat()) + { + case D3DFMT_DXT1: + loadDXT1ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case D3DFMT_DXT3: + loadDXT3ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + case D3DFMT_DXT5: + loadDXT5ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); + break; + } +} + +static void FlipCopyDXT1BlockFull(const unsigned int* source, unsigned int* dest) { + // A DXT1 block layout is: + // [0-1] color0. + // [2-3] color1. + // [4-7] color bitmap, 2 bits per pixel. + // So each of the 4-7 bytes represents one line, flipping a block is just + // flipping those bytes. + + // First 32-bits is two RGB565 colors shared by tile and does not need to be modified. + dest[0] = source[0]; + + // Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors. All rows should be flipped. + dest[1] = (source[1] >> 24) | + ((source[1] << 8) & 0x00FF0000) | + ((source[1] >> 8) & 0x0000FF00) | + (source[1] << 24); +} + +// Flips the first 2 lines of a DXT1 block in the y direction. +static void FlipCopyDXT1BlockHalf(const unsigned int* source, unsigned int* dest) { + // See layout above. + dest[0] = source[0]; + dest[1] = ((source[1] << 8) & 0x0000FF00) | + ((source[1] >> 8) & 0x000000FF); +} + +// Flips a full DXT3 block in the y direction. +static void FlipCopyDXT3BlockFull(const unsigned int* source, unsigned int* dest) { + // A DXT3 block layout is: + // [0-7] alpha bitmap, 4 bits per pixel. + // [8-15] a DXT1 block. + + // First and Second 32 bits are 4bit per pixel alpha and need to be flipped. + dest[0] = (source[1] >> 16) | (source[1] << 16); + dest[1] = (source[0] >> 16) | (source[0] << 16); + + // And flip the DXT1 block using the above function. + FlipCopyDXT1BlockFull(source + 2, dest + 2); +} + +// Flips the first 2 lines of a DXT3 block in the y direction. +static void FlipCopyDXT3BlockHalf(const unsigned int* source, unsigned int* dest) { + // See layout above. + dest[0] = (source[1] >> 16) | (source[1] << 16); + FlipCopyDXT1BlockHalf(source + 2, dest + 2); +} + +// Flips a full DXT5 block in the y direction. +static void FlipCopyDXT5BlockFull(const unsigned int* source, unsigned int* dest) { + // A DXT5 block layout is: + // [0] alpha0. + // [1] alpha1. + // [2-7] alpha bitmap, 3 bits per pixel. + // [8-15] a DXT1 block. + + // The alpha bitmap doesn't easily map lines to bytes, so we have to + // interpret it correctly. Extracted from + // http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt : + // + // The 6 "bits" bytes of the block are decoded into one 48-bit integer: + // + // bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 + + // 256 * (bits_4 + 256 * bits_5)))) + // + // bits is a 48-bit unsigned integer, from which a three-bit control code + // is extracted for a texel at location (x,y) in the block using: + // + // code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0] + // + // where bit 47 is the most significant and bit 0 is the least + // significant bit. + const unsigned char* sourceBytes = static_cast(static_cast(source)); + unsigned char* destBytes = static_cast(static_cast(dest)); + unsigned int line_0_1 = sourceBytes[2] + 256 * (sourceBytes[3] + 256 * sourceBytes[4]); + unsigned int line_2_3 = sourceBytes[5] + 256 * (sourceBytes[6] + 256 * sourceBytes[7]); + // swap lines 0 and 1 in line_0_1. + unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | + ((line_0_1 & 0xfff000) >> 12); + // swap lines 2 and 3 in line_2_3. + unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) | + ((line_2_3 & 0xfff000) >> 12); + destBytes[0] = sourceBytes[0]; + destBytes[1] = sourceBytes[1]; + destBytes[2] = line_3_2 & 0xff; + destBytes[3] = (line_3_2 & 0xff00) >> 8; + destBytes[4] = (line_3_2 & 0xff0000) >> 16; + destBytes[5] = line_1_0 & 0xff; + destBytes[6] = (line_1_0 & 0xff00) >> 8; + destBytes[7] = (line_1_0 & 0xff0000) >> 16; + + // And flip the DXT1 block using the above function. + FlipCopyDXT1BlockFull(source + 2, dest + 2); +} + +// Flips the first 2 lines of a DXT5 block in the y direction. +static void FlipCopyDXT5BlockHalf(const unsigned int* source, unsigned int* dest) { + // See layout above. + const unsigned char* sourceBytes = static_cast(static_cast(source)); + unsigned char* destBytes = static_cast(static_cast(dest)); + unsigned int line_0_1 = sourceBytes[2] + 256 * (sourceBytes[3] + 256 * sourceBytes[4]); + unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | + ((line_0_1 & 0xfff000) >> 12); + destBytes[0] = sourceBytes[0]; + destBytes[1] = sourceBytes[1]; + destBytes[2] = line_1_0 & 0xff; + destBytes[3] = (line_1_0 & 0xff00) >> 8; + destBytes[4] = (line_1_0 & 0xff0000) >> 16; + FlipCopyDXT1BlockHalf(source + 2, dest + 2); +} + +void Texture::loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, int inputPitch, const void *input, size_t outputPitch, void *output) const { ASSERT(xoffset % 4 == 0); @@ -784,29 +920,24 @@ void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei widt const unsigned int *source = reinterpret_cast(input); unsigned int *dest = reinterpret_cast(output); + // Round width up in case it is less than 4. + int blocksAcross = (width + 3) / 4; + int intsAcross = blocksAcross * 2; + switch (height) { case 1: - // Round width up in case it is 1. - for (int x = 0; x < (width + 1) / 2; x += 2) + for (int x = 0; x < intsAcross; x += 2) { - // First 32-bits is two RGB565 colors shared by tile and does not need to be modified. + // just copy the block dest[x] = source[x]; - - // Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors, the last 3 rows being unused. No flipping should occur. dest[x + 1] = source[x + 1]; } break; case 2: - // Round width up in case it is 1. - for (int x = 0; x < (width + 1) / 2; x += 2) + for (int x = 0; x < intsAcross; x += 2) { - // First 32-bits is two RGB565 colors shared by tile and does not need to be modified. - dest[x] = source[x]; - - // Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors, the last 2 rows being unused. Only the top 2 rows should be flipped. - dest[x + 1] = ((source[x + 1] << 8) & 0x0000FF00) | - ((source[x + 1] >> 8) & 0x000000FF); + FlipCopyDXT1BlockHalf(source + x, dest + x); } break; default: @@ -816,17 +947,109 @@ void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei widt const unsigned int *source = reinterpret_cast(static_cast(input) + y * inputPitch); unsigned int *dest = reinterpret_cast(static_cast(output) + (y + yoffset) * outputPitch + xoffset * 8); - // Round width up in case it is 1. - for (int x = 0; x < (width + 1) / 2; x += 2) + for (int x = 0; x < intsAcross; x += 2) { - // First 32-bits is two RGB565 colors shared by tile and does not need to be modified. - dest[x] = source[x]; + FlipCopyDXT1BlockFull(source + x, dest + x); + } + } + break; + } +} - // Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors. All rows should be flipped. - dest[x + 1] = (source[x + 1] >> 24) | - ((source[x + 1] << 8) & 0x00FF0000) | - ((source[x + 1] >> 8) & 0x0000FF00) | - (source[x + 1] << 24); +void Texture::loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const +{ + ASSERT(xoffset % 4 == 0); + ASSERT(yoffset % 4 == 0); + ASSERT(width % 4 == 0 || width == 2 || width == 1); + ASSERT(inputPitch % 16 == 0); + ASSERT(outputPitch % 16 == 0); + + const unsigned int *source = reinterpret_cast(input); + unsigned int *dest = reinterpret_cast(output); + + // Round width up in case it is less than 4. + int blocksAcross = (width + 3) / 4; + int intsAcross = blocksAcross * 4; + + switch (height) + { + case 1: + for (int x = 0; x < intsAcross; x += 4) + { + // just copy the block + dest[x] = source[x]; + dest[x + 1] = source[x + 1]; + dest[x + 2] = source[x + 2]; + dest[x + 3] = source[x + 3]; + } + break; + case 2: + for (int x = 0; x < intsAcross; x += 4) + { + FlipCopyDXT3BlockHalf(source + x, dest + x); + } + break; + default: + ASSERT(height % 4 == 0); + for (int y = 0; y < height / 4; ++y) + { + const unsigned int *source = reinterpret_cast(static_cast(input) + y * inputPitch); + unsigned int *dest = reinterpret_cast(static_cast(output) + (y + yoffset) * outputPitch + xoffset * 16); + + for (int x = 0; x < intsAcross; x += 4) + { + FlipCopyDXT3BlockFull(source + x, dest + x); + } + } + break; + } +} + +void Texture::loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const +{ + ASSERT(xoffset % 4 == 0); + ASSERT(yoffset % 4 == 0); + ASSERT(width % 4 == 0 || width == 2 || width == 1); + ASSERT(inputPitch % 16 == 0); + ASSERT(outputPitch % 16 == 0); + + const unsigned int *source = reinterpret_cast(input); + unsigned int *dest = reinterpret_cast(output); + + // Round width up in case it is less than 4. + int blocksAcross = (width + 3) / 4; + int intsAcross = blocksAcross * 4; + + switch (height) + { + case 1: + for (int x = 0; x < intsAcross; x += 4) + { + // just copy the block + dest[x] = source[x]; + dest[x + 1] = source[x + 1]; + dest[x + 2] = source[x + 2]; + dest[x + 3] = source[x + 3]; + } + break; + case 2: + for (int x = 0; x < intsAcross; x += 4) + { + FlipCopyDXT5BlockHalf(source + x, dest + x); + } + break; + default: + ASSERT(height % 4 == 0); + for (int y = 0; y < height / 4; ++y) + { + const unsigned int *source = reinterpret_cast(static_cast(input) + y * inputPitch); + unsigned int *dest = reinterpret_cast(static_cast(output) + (y + yoffset) * outputPitch + xoffset * 16); + + for (int x = 0; x < intsAcross; x += 4) + { + FlipCopyDXT5BlockFull(source + x, dest + x); } } break; @@ -2261,6 +2484,9 @@ void TextureCubeMap::convertToRenderTarget() return error(GL_OUT_OF_MEMORY); } + + source->Release(); + dest->Release(); } } } diff --git a/gfx/angle/src/libGLESv2/Texture.h b/gfx/angle/src/libGLESv2/Texture.h index 5bdb2fb0fa2b..95045b8fbedf 100644 --- a/gfx/angle/src/libGLESv2/Texture.h +++ b/gfx/angle/src/libGLESv2/Texture.h @@ -185,6 +185,12 @@ class Texture : public RefCountObject int inputPitch, const void *input, size_t outputPitch, void *output) const; void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, int inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const; + void loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const; static unsigned int issueSerial(); diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp index 23957fe6d2ea..da1aa14ef181 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.cpp +++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp @@ -772,6 +772,8 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: break; default: return error(GL_INVALID_ENUM); @@ -821,9 +823,27 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna return error(GL_INVALID_ENUM); } - if (!context->supportsCompressedTextures()) - { - return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + switch (internalformat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + if (!context->supportsDXT1Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + if (!context->supportsDXT3Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + if (!context->supportsDXT5Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + default: UNREACHABLE(); } if (imageSize != gl::ComputeCompressedSize(width, height, internalformat)) @@ -897,6 +917,8 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: break; default: return error(GL_INVALID_ENUM); @@ -916,9 +938,27 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs return error(GL_INVALID_VALUE); } - if (!context->supportsCompressedTextures()) - { - return error(GL_INVALID_ENUM); // in this case, it's as though the format switch has failed. + switch (format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + if (!context->supportsDXT1Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + if (!context->supportsDXT3Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + if (!context->supportsDXT5Textures()) + { + return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed + } + break; + default: UNREACHABLE(); } if (imageSize != gl::ComputeCompressedSize(width, height, format)) @@ -929,7 +969,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs if (xoffset % 4 != 0 || yoffset % 4 != 0) { return error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction - // does not exist unless DXT1 textures are supported. + // does not exist unless DXT textures are supported. } if (target == GL_TEXTURE_2D) @@ -1093,7 +1133,27 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - if (context->supportsCompressedTextures()) + if (context->supportsDXT1Textures()) + { + return error(GL_INVALID_OPERATION); + } + else + { + return error(GL_INVALID_ENUM); + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + if (context->supportsDXT3Textures()) + { + return error(GL_INVALID_OPERATION); + } + else + { + return error(GL_INVALID_ENUM); + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + if (context->supportsDXT5Textures()) { return error(GL_INVALID_OPERATION); } @@ -1245,6 +1305,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: return error(GL_INVALID_OPERATION); default: return error(GL_INVALID_OPERATION); @@ -3160,7 +3222,7 @@ const GLubyte* __stdcall glGetString(GLenum name) case GL_VENDOR: return (GLubyte*)"Google Inc."; case GL_RENDERER: - return (GLubyte*)"ANGLE"; + return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); case GL_VERSION: return (GLubyte*)"OpenGL ES 2.0 (ANGLE "VERSION_STRING")"; case GL_SHADING_LANGUAGE_VERSION: @@ -4467,6 +4529,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: break; default: return error(GL_INVALID_VALUE); @@ -4511,10 +4575,10 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL return error(GL_INVALID_ENUM); } - if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || - format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) - { - if (context->supportsCompressedTextures()) + switch (format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + if (context->supportsDXT1Textures()) { return error(GL_INVALID_OPERATION); } @@ -4522,6 +4586,29 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL { return error(GL_INVALID_ENUM); } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + if (context->supportsDXT3Textures()) + { + return error(GL_INVALID_OPERATION); + } + else + { + return error(GL_INVALID_ENUM); + } + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + if (context->supportsDXT5Textures()) + { + return error(GL_INVALID_OPERATION); + } + else + { + return error(GL_INVALID_ENUM); + } + break; + default: + break; } if (type == GL_FLOAT) diff --git a/gfx/angle/src/libGLESv2/mathutil.h b/gfx/angle/src/libGLESv2/mathutil.h index 20cc6a3f1c9f..5111b9805f16 100644 --- a/gfx/angle/src/libGLESv2/mathutil.h +++ b/gfx/angle/src/libGLESv2/mathutil.h @@ -8,10 +8,10 @@ #ifndef LIBGLESV2_MATHUTIL_H_ #define LIBGLESV2_MATHUTIL_H_ - -#if _MSC_VER <= 1400 -#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR -#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR + +#if _MSC_VER <= 1400 +#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR +#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR #endif #include diff --git a/gfx/angle/src/libGLESv2/utilities.cpp b/gfx/angle/src/libGLESv2/utilities.cpp index ba23fd365c6c..01cca3c05f71 100644 --- a/gfx/angle/src/libGLESv2/utilities.cpp +++ b/gfx/angle/src/libGLESv2/utilities.cpp @@ -200,18 +200,23 @@ GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f); break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE: + case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE: + return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f); default: return 0; } - return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f); } bool IsCompressed(GLenum format) { if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || - format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) + format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || + format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE || + format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE) { return true; } diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp index 23b5e2d7560c..d01392bd4c8e 100644 --- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp +++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp @@ -371,10 +371,21 @@ _cairo_dwrite_glyph_run_from_glyphs(cairo_glyph_t *glyphs, } } else { *transformed = 1; - + // Transforming positions by the inverse matrix, then by the original + // matrix later may introduce small errors, especially because the + // D2D matrix is single-precision whereas the cairo one is double. + // This is a problem when glyph positions were originally at exactly + // half-pixel locations, which eventually round to whole pixels for + // GDI rendering - the errors introduced here cause them to round in + // unpredictable directions, instead of all rounding in a consistent + // way, leading to poor glyph spacing (bug 675383). + // To mitigate this, nudge the positions by a tiny amount to try and + // ensure that after the two transforms, they'll still round in a + // consistent direction. + const double EPSILON = 0.0001; for (int i = 0; i < num_glyphs; i++) { indices[i] = (WORD) glyphs[i].index; - double x = glyphs[i].x; + double x = glyphs[i].x + EPSILON; double y = glyphs[i].y; cairo_matrix_transform_point(&scaled_font->mat_inverse, &x, &y); // Since we will multiply by our ctm matrix later for rotation effects @@ -1353,10 +1364,11 @@ _cairo_dwrite_show_glyphs_on_surface(void *surface, run.fontEmSize = (FLOAT)scaled_font->font_matrix.yy; } else { transform = TRUE; - + // See comment about EPSILON in _cairo_dwrite_glyph_run_from_glyphs + const double EPSILON = 0.0001; for (int i = 0; i < num_glyphs; i++) { indices[i] = (WORD) glyphs[i].index; - double x = glyphs[i].x - fontArea.left; + double x = glyphs[i].x - fontArea.left + EPSILON; double y = glyphs[i].y - fontArea.top; cairo_matrix_transform_point(&dwritesf->mat_inverse, &x, &y); /** diff --git a/gfx/layers/ImageLayers.h b/gfx/layers/ImageLayers.h index fd1868916c98..f1ebe3c47fe2 100644 --- a/gfx/layers/ImageLayers.h +++ b/gfx/layers/ImageLayers.h @@ -452,6 +452,11 @@ public: PRUint8 *CopyData(Data& aDest, gfxIntSize& aDestSize, PRUint32& aDestBufferSize, const Data& aData); + /** + * Return a buffer to store image data in. + * The default implementation returns memory that can + * be freed wit delete[] + */ virtual PRUint8* AllocateBuffer(PRUint32 aSize); /** diff --git a/gfx/layers/basic/BasicImages.cpp b/gfx/layers/basic/BasicImages.cpp index 21ea307354ad..065596b82d17 100644 --- a/gfx/layers/basic/BasicImages.cpp +++ b/gfx/layers/basic/BasicImages.cpp @@ -206,7 +206,7 @@ BasicPlanarYCbCrImage::SetData(const Data& aData) prescale ? mScaleHint.height : aData.mPicSize.height); mStride = gfxASurface::FormatStrideForWidth(format, size.width); - mBuffer = new PRUint8[size.height * mStride]; + mBuffer = AllocateBuffer(size.height * mStride); if (!mBuffer) { // out of memory return; diff --git a/ipc/chromium/src/base/process_util_linux.cc b/ipc/chromium/src/base/process_util_linux.cc index 08c0043c08d7..dee9b8a7a999 100644 --- a/ipc/chromium/src/base/process_util_linux.cc +++ b/ipc/chromium/src/base/process_util_linux.cc @@ -19,6 +19,13 @@ #include "base/string_tokenizer.h" #include "base/string_util.h" +#ifdef MOZ_MEMORY_ANDROID +extern "C" { +extern void _malloc_prefork(void); +extern void _malloc_postfork(void); +} +#endif + namespace { enum ParsingState { @@ -44,7 +51,17 @@ bool LaunchApp(const std::vector& argv, const environment_map& env_vars_to_set, bool wait, ProcessHandle* process_handle, ProcessArchitecture arch) { +#ifdef MOZ_MEMORY_ANDROID + /* We specifically don't call pthread_atfork in jemalloc because it is not + available in bionic until 2.3. However without it, jemalloc could + potentially deadlock, when stl allocates memory through jemalloc, after + fork and before execvp. Therefore, we must manually inform jemalloc here */ + ::_malloc_prefork(); +#endif pid_t pid = fork(); +#ifdef MOZ_MEMORY_ANDROID + ::_malloc_postfork(); +#endif if (pid < 0) return false; diff --git a/js/jsd/jsd_scpt.c b/js/jsd/jsd_scpt.c index 584ea54f39c5..360f97d7f080 100644 --- a/js/jsd/jsd_scpt.c +++ b/js/jsd/jsd_scpt.c @@ -530,8 +530,10 @@ jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line) jsuword pc; JSCrossCompartmentCall *call; + if( !jsdscript ) + return 0; #ifdef LIVEWIRE - if( jsdscript && jsdscript->lwscript ) + if( jsdscript->lwscript ) { uintN newline; jsdlw_RawToProcessedLineNumber(jsdc, jsdscript, line, &newline); diff --git a/js/src/assembler/TestMain.cpp b/js/src/assembler/TestMain.cpp index 40f308597d33..dab36bb8122f 100644 --- a/js/src/assembler/TestMain.cpp +++ b/js/src/assembler/TestMain.cpp @@ -110,7 +110,7 @@ void test1 ( void ) // constructor for LinkBuffer asks ep to allocate r-x memory, // then copies it there. - JSC::LinkBuffer patchBuffer(am, ep); + JSC::LinkBuffer patchBuffer(am, ep, JSC::METHOD_CODE); // finalize JSC::MacroAssemblerCodeRef cr = patchBuffer.finalizeCode(); @@ -266,7 +266,7 @@ void test2 ( void ) // constructor for LinkBuffer asks ep to allocate r-x memory, // then copies it there. - JSC::LinkBuffer patchBuffer(am, ep); + JSC::LinkBuffer patchBuffer(am, ep, JSC::METHOD_CODE); // finalize JSC::MacroAssemblerCodeRef cr = patchBuffer.finalizeCode(); @@ -453,7 +453,7 @@ void test3 ( void ) // constructor for LinkBuffer asks ep to allocate r-x memory, // then copies it there. - JSC::LinkBuffer patchBuffer(am, ep); + JSC::LinkBuffer patchBuffer(am, ep, JSC::METHOD_CODE); // finalize JSC::MacroAssemblerCodeRef cr = patchBuffer.finalizeCode(); @@ -663,7 +663,7 @@ void test4 ( void ) // constructor for LinkBuffer asks ep to allocate r-x memory, // then copies it there. - JSC::LinkBuffer patchBuffer(am, ep); + JSC::LinkBuffer patchBuffer(am, ep, JSC::METHOD_CODE); // now fix up any branches/calls //JSC::FunctionPtr target = JSC::FunctionPtr::FunctionPtr( &cube ); @@ -869,7 +869,7 @@ void test5 ( void ) // constructor for LinkBuffer asks ep to allocate r-x memory, // then copies it there. - JSC::LinkBuffer patchBuffer(am, ep); + JSC::LinkBuffer patchBuffer(am, ep, JSC::METHOD_CODE); // now fix up any branches/calls JSC::FunctionPtr target = JSC::FunctionPtr::FunctionPtr( &cube ); diff --git a/js/src/assembler/assembler/ARMAssembler.cpp b/js/src/assembler/assembler/ARMAssembler.cpp index 771c8cf1ea26..f67b6f99e23e 100644 --- a/js/src/assembler/assembler/ARMAssembler.cpp +++ b/js/src/assembler/assembler/ARMAssembler.cpp @@ -634,14 +634,14 @@ inline void ARMAssembler::fixUpOffsets(void * buffer) } } -void* ARMAssembler::executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp) +void* ARMAssembler::executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp, CodeKind kind) { // 64-bit alignment is required for next constant pool and JIT code as well m_buffer.flushWithoutBarrier(true); if (m_buffer.uncheckedSize() & 0x7) bkpt(0); - void * data = m_buffer.executableAllocAndCopy(allocator, poolp); + void * data = m_buffer.executableAllocAndCopy(allocator, poolp, kind); if (data) fixUpOffsets(data); return data; diff --git a/js/src/assembler/assembler/ARMAssembler.h b/js/src/assembler/assembler/ARMAssembler.h index ff932cfb5419..9e6e8e140358 100644 --- a/js/src/assembler/assembler/ARMAssembler.h +++ b/js/src/assembler/assembler/ARMAssembler.h @@ -987,7 +987,7 @@ namespace JSC { return loadBranchTarget(ARMRegisters::pc, cc, useConstantPool); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp); + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp, CodeKind kind); void executableCopy(void* buffer); void fixUpOffsets(void* buffer); diff --git a/js/src/assembler/assembler/ARMv7Assembler.h b/js/src/assembler/assembler/ARMv7Assembler.h index e1478ba2c91d..54c866f21399 100644 --- a/js/src/assembler/assembler/ARMv7Assembler.h +++ b/js/src/assembler/assembler/ARMv7Assembler.h @@ -1558,9 +1558,9 @@ public: return m_formatter.size(); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp) + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind) { - void* copy = m_formatter.executableAllocAndCopy(allocator, poolp); + void* copy = m_formatter.executableAllocAndCopy(allocator, poolp, kind); unsigned jumpCount = m_jumpsToLink.size(); for (unsigned i = 0; i < jumpCount; ++i) { @@ -1909,8 +1909,8 @@ private: size_t size() const { return m_buffer.size(); } bool isAligned(int alignment) const { return m_buffer.isAligned(alignment); } void* data() const { return m_buffer.data(); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp) { - return m_buffer.executableAllocAndCopy(allocator, poolp); + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind) { + return m_buffer.executableAllocAndCopy(allocator, poolp, kind); } bool oom() const { return m_buffer.oom(); } diff --git a/js/src/assembler/assembler/AssemblerBuffer.h b/js/src/assembler/assembler/AssemblerBuffer.h index e94d89bf08ed..ee759105a412 100644 --- a/js/src/assembler/assembler/AssemblerBuffer.h +++ b/js/src/assembler/assembler/AssemblerBuffer.h @@ -137,14 +137,14 @@ namespace JSC { * The user must check for a NULL return value, which means * no code was generated, or there was an OOM. */ - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp) + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind) { if (m_oom || m_size == 0) { *poolp = NULL; return 0; } - void* result = allocator->alloc(m_size, poolp); + void* result = allocator->alloc(m_size, poolp, kind); if (!result) { *poolp = NULL; return 0; diff --git a/js/src/assembler/assembler/AssemblerBufferWithConstantPool.h b/js/src/assembler/assembler/AssemblerBufferWithConstantPool.h index ea9d6a0f258f..ab51196fda77 100644 --- a/js/src/assembler/assembler/AssemblerBufferWithConstantPool.h +++ b/js/src/assembler/assembler/AssemblerBufferWithConstantPool.h @@ -194,10 +194,10 @@ public: return AssemblerBuffer::size(); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp) + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind) { flushConstantPool(false); - return AssemblerBuffer::executableAllocAndCopy(allocator, poolp); + return AssemblerBuffer::executableAllocAndCopy(allocator, poolp, kind); } void putIntWithConstantInt(uint32_t insn, uint32_t constant, bool isReusable = false) diff --git a/js/src/assembler/assembler/LinkBuffer.h b/js/src/assembler/assembler/LinkBuffer.h index eac984c8d466..9161c8b8a11f 100644 --- a/js/src/assembler/assembler/LinkBuffer.h +++ b/js/src/assembler/assembler/LinkBuffer.h @@ -64,8 +64,9 @@ class LinkBuffer { public: // 'ok' should be checked after this constructor is called; it's false if OOM occurred. LinkBuffer(MacroAssembler* masm, ExecutableAllocator* executableAllocator, - ExecutablePool** poolp, bool* ok) + ExecutablePool** poolp, bool* ok, CodeKind codeKind) { + m_codeKind = codeKind; m_code = executableAllocAndCopy(*masm, executableAllocator, poolp); m_executablePool = *poolp; m_size = masm->m_assembler.size(); // must come after call to executableAllocAndCopy()! @@ -75,20 +76,22 @@ public: *ok = !!m_code; } - LinkBuffer() + LinkBuffer(CodeKind kind) : m_executablePool(NULL) , m_code(NULL) , m_size(0) + , m_codeKind(kind) #ifndef NDEBUG , m_completed(false) #endif { } - LinkBuffer(uint8* ncode, size_t size) + LinkBuffer(uint8* ncode, size_t size, CodeKind kind) : m_executablePool(NULL) , m_code(ncode) , m_size(size) + , m_codeKind(kind) #ifndef NDEBUG , m_completed(false) #endif @@ -200,7 +203,7 @@ protected: void *executableAllocAndCopy(MacroAssembler &masm, ExecutableAllocator *allocator, ExecutablePool **poolp) { - return masm.m_assembler.executableAllocAndCopy(allocator, poolp); + return masm.m_assembler.executableAllocAndCopy(allocator, poolp, m_codeKind); } void performFinalization() @@ -217,6 +220,7 @@ protected: ExecutablePool* m_executablePool; void* m_code; size_t m_size; + CodeKind m_codeKind; #ifndef NDEBUG bool m_completed; #endif diff --git a/js/src/assembler/assembler/SparcAssembler.h b/js/src/assembler/assembler/SparcAssembler.h index 733b17b194d4..e44a23e52c56 100644 --- a/js/src/assembler/assembler/SparcAssembler.h +++ b/js/src/assembler/assembler/SparcAssembler.h @@ -1045,9 +1045,9 @@ namespace JSC { return reinterpret_cast(reinterpret_cast(code) + destination.m_offset); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp) + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp, CodeKind kind) { - return m_buffer.executableAllocAndCopy(allocator, poolp); + return m_buffer.executableAllocAndCopy(allocator, poolp, kind); } void* executableCopy(void* buffer) diff --git a/js/src/assembler/assembler/X86Assembler.h b/js/src/assembler/assembler/X86Assembler.h index db9106398154..26b5e1e7572d 100644 --- a/js/src/assembler/assembler/X86Assembler.h +++ b/js/src/assembler/assembler/X86Assembler.h @@ -2491,9 +2491,9 @@ public: return dst.m_offset - src.m_offset; } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp) + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool **poolp, CodeKind kind) { - return m_formatter.executableAllocAndCopy(allocator, poolp); + return m_formatter.executableAllocAndCopy(allocator, poolp, kind); } void executableCopy(void* buffer) @@ -2843,8 +2843,8 @@ private: bool oom() const { return m_buffer.oom(); } bool isAligned(int alignment) const { return m_buffer.isAligned(alignment); } void* data() const { return m_buffer.data(); } - void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp) { - return m_buffer.executableAllocAndCopy(allocator, poolp); + void* executableAllocAndCopy(ExecutableAllocator* allocator, ExecutablePool** poolp, CodeKind kind) { + return m_buffer.executableAllocAndCopy(allocator, poolp, kind); } private: diff --git a/js/src/assembler/jit/ExecutableAllocator.cpp b/js/src/assembler/jit/ExecutableAllocator.cpp index 14c747915ff1..ca8cab52ec4a 100644 --- a/js/src/assembler/jit/ExecutableAllocator.cpp +++ b/js/src/assembler/jit/ExecutableAllocator.cpp @@ -37,15 +37,19 @@ ExecutablePool::~ExecutablePool() m_allocator->releasePoolPages(this); } -size_t -ExecutableAllocator::getCodeSize() const +void +ExecutableAllocator::getCodeStats(size_t& method, size_t& regexp, size_t& unused) const { - size_t n = 0; + method = 0; + regexp = 0; + unused = 0; + for (ExecPoolHashSet::Range r = m_pools.all(); !r.empty(); r.popFront()) { ExecutablePool* pool = r.front(); - n += pool->m_allocation.size; + method += pool->m_mjitCodeMethod; + regexp += pool->m_mjitCodeRegexp; + unused += pool->m_allocation.size - pool->m_mjitCodeMethod - pool->m_mjitCodeRegexp; } - return n; } } diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h index dfd8b7217deb..eeefd797dbe4 100644 --- a/js/src/assembler/jit/ExecutableAllocator.h +++ b/js/src/assembler/jit/ExecutableAllocator.h @@ -81,6 +81,8 @@ namespace JSC { class ExecutableAllocator; + enum CodeKind { METHOD_CODE, REGEXP_CODE }; + // These are reference-counted. A new one starts with a count of 1. class ExecutablePool { @@ -102,6 +104,10 @@ private: // Reference count for automatic reclamation. unsigned m_refCount; + + // Number of bytes currently used for Method and Regexp JIT code. + size_t m_mjitCodeMethod; + size_t m_mjitCodeRegexp; public: // Flag for downstream use, whether to try to release references to this pool. @@ -133,16 +139,22 @@ private: ExecutablePool(ExecutableAllocator* allocator, Allocation a) : m_allocator(allocator), m_freePtr(a.pages), m_end(m_freePtr + a.size), m_allocation(a), - m_refCount(1), m_destroy(false), m_gcNumber(0) + m_refCount(1), m_mjitCodeMethod(0), m_mjitCodeRegexp(0), m_destroy(false), m_gcNumber(0) { } ~ExecutablePool(); - void* alloc(size_t n) + void* alloc(size_t n, CodeKind kind) { JS_ASSERT(n <= available()); void *result = m_freePtr; m_freePtr += n; + + if ( kind == REGEXP_CODE ) + m_mjitCodeRegexp += n; + else + m_mjitCodeMethod += n; + return result; } @@ -185,7 +197,7 @@ public: // alloc() returns a pointer to some memory, and also (by reference) a // pointer to reference-counted pool. The caller owns a reference to the // pool; i.e. alloc() increments the count before returning the object. - void* alloc(size_t n, ExecutablePool** poolp) + void* alloc(size_t n, ExecutablePool** poolp, CodeKind type) { // Round 'n' up to a multiple of word size; if all allocations are of // word sized quantities, then all subsequent allocations will be @@ -202,7 +214,7 @@ public: // This alloc is infallible because poolForSize() just obtained // (found, or created if necessary) a pool that had enough space. - void *result = (*poolp)->alloc(n); + void *result = (*poolp)->alloc(n, type); JS_ASSERT(result); return result; } @@ -213,7 +225,7 @@ public: m_pools.remove(m_pools.lookup(pool)); // this asserts if |pool| is not in m_pools } - size_t getCodeSize() const; + void getCodeStats(size_t& method, size_t& regexp, size_t& unused) const; private: static size_t pageSize; @@ -358,7 +370,7 @@ public: // // Modify "start" and "end" to avoid GCC 4.3.0-4.4.2 bug in // mips_expand_synci_loop that may execute synci one more time. - // "start" points to the fisrt byte of the cache line. + // "start" points to the first byte of the cache line. // "end" points to the last byte of the line before the last cache line. // Because size is always a multiple of 4, this is safe to set // "end" to the last byte. diff --git a/js/src/assembler/jit/ExecutableAllocatorOS2.cpp b/js/src/assembler/jit/ExecutableAllocatorOS2.cpp index 675b604ae914..b0879c8ac699 100644 --- a/js/src/assembler/jit/ExecutableAllocatorOS2.cpp +++ b/js/src/assembler/jit/ExecutableAllocatorOS2.cpp @@ -44,7 +44,7 @@ ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n) if (DosAllocMem(&allocation, n, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) && DosAllocMem(&allocation, n, PAG_COMMIT|PAG_READ|PAG_WRITE)) CRASH(); - ExecutablePool::Allocation alloc = {reinterpret_cast(allocation), n}; + ExecutablePool::Allocation alloc = { reinterpret_cast(allocation), n }; return alloc; } diff --git a/js/src/assembler/jit/ExecutableAllocatorWin.cpp b/js/src/assembler/jit/ExecutableAllocatorWin.cpp index da6e756cfa66..1d070e83c1f2 100644 --- a/js/src/assembler/jit/ExecutableAllocatorWin.cpp +++ b/js/src/assembler/jit/ExecutableAllocatorWin.cpp @@ -42,7 +42,7 @@ size_t ExecutableAllocator::determinePageSize() ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n) { void *allocation = VirtualAlloc(0, n, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); - ExecutablePool::Allocation alloc = {reinterpret_cast(allocation), n}; + ExecutablePool::Allocation alloc = { reinterpret_cast(allocation), n }; return alloc; } diff --git a/js/src/config/makefiles/target_export.mk b/js/src/config/makefiles/target_export.mk new file mode 100644 index 000000000000..318feb8f949a --- /dev/null +++ b/js/src/config/makefiles/target_export.mk @@ -0,0 +1,68 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS)) + +.PHONY: export $(PARALLEL_DIRS_export) + +############### +## TIER targets +############### +export_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +export:: $(PARALLEL_DIRS_export) + +$(PARALLEL_DIRS_export): %_export: %/Makefile + +@$(call SUBMAKE,export,$*) +endif + +export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR)) + $(LOOP_OVER_DIRS) + $(LOOP_OVER_TOOL_DIRS) diff --git a/js/src/config/makefiles/target_libs.mk b/js/src/config/makefiles/target_libs.mk new file mode 100644 index 000000000000..707fdd179d83 --- /dev/null +++ b/js/src/config/makefiles/target_libs.mk @@ -0,0 +1,141 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS)) + +.PHONY: libs $(PARALLEL_DIRS_libs) + +############### +## TIER targets +############### +libs_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +libs:: $(PARALLEL_DIRS_libs) + +$(PARALLEL_DIRS_libs): %_libs: %/Makefile + +@$(call SUBMAKE,libs,$*) +endif + + +#################### +## +#################### +ifdef EXPORT_LIBRARY +ifeq ($(EXPORT_LIBRARY),1) +ifdef IS_COMPONENT +EXPORT_LIBRARY = $(DEPTH)/staticlib/components +else +EXPORT_LIBRARY = $(DEPTH)/staticlib +endif +else +# If EXPORT_LIBRARY has a value, we'll be installing there. We also need to cleanup there +GARBAGE += $(foreach lib,$(LIBRARY),$(EXPORT_LIBRARY)/$(lib)) +endif +endif # EXPORT_LIBRARY + +libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY) +ifndef NO_DIST_INSTALL +ifdef LIBRARY +ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build + $(INSTALL) $(IFLAGS1) $(LIBRARY) $(EXPORT_LIBRARY) +endif # EXPORT_LIBRARY +ifdef DIST_INSTALL +ifdef IS_COMPONENT + $(error Shipping static component libs makes no sense.) +else + $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib +endif +endif # DIST_INSTALL +endif # LIBRARY +ifdef SHARED_LIBRARY +ifdef IS_COMPONENT + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components + $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY) +ifndef NO_COMPONENTS_MANIFEST + @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest" + @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)" +endif +else # ! IS_COMPONENT +ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) +ifndef NO_INSTALL_IMPORT_LIBRARY + $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib +endif +else + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib +endif + $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET) +endif # IS_COMPONENT +endif # SHARED_LIBRARY +ifdef PROGRAM + $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET) +endif +ifdef SIMPLE_PROGRAMS + $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET) +endif +ifdef HOST_PROGRAM + $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin +endif +ifdef HOST_SIMPLE_PROGRAMS + $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin +endif +ifdef HOST_LIBRARY + $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib +endif +ifdef JAVA_LIBRARY +ifdef IS_COMPONENT + $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components +else + $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET) +endif +endif # JAVA_LIBRARY +endif # !NO_DIST_INSTALL + $(LOOP_OVER_DIRS) + +# EOF diff --git a/js/src/config/makefiles/target_tools.mk b/js/src/config/makefiles/target_tools.mk new file mode 100644 index 000000000000..1147d910d0de --- /dev/null +++ b/js/src/config/makefiles/target_tools.mk @@ -0,0 +1,72 @@ +# -*- makefile -*- +# vim:set ts=8 sw=8 sts=8 noet: +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# The Mozilla Foundation +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chase Phillips +# Benjamin Smedberg +# Jeff Walden +# Joey Armstrong +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS)) + +.PHONY: tools $(PARALLEL_DIRS_tools) + +############### +## TIER targets +############### +tools_tier_%: + @$(ECHO) "$@" + @$(MAKE_TIER_SUBMAKEFILES) + $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir))) + +################# +## Common targets +################# +ifdef PARALLEL_DIRS +tools:: $(PARALLEL_DIRS_tools) + +$(PARALLEL_DIRS_tools): %_tools: %/Makefile + +@$(call SUBMAKE,tools,$*) +endif + +tools:: $(SUBMAKEFILES) $(MAKE_DIRS) + $(LOOP_OVER_DIRS) +ifneq (,$(strip $(TOOL_DIRS))) + $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir))) +endif + +# EOF diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 230a638f643c..88eb6fc2ba84 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -1,3 +1,4 @@ +# -*- makefile -*- # vim:set ts=8 sw=8 sts=8 noet: # # ***** BEGIN LICENSE BLOCK ***** @@ -24,6 +25,7 @@ # Chase Phillips # Benjamin Smedberg # Jeff Walden +# Joey Armstrong # # Alternatively, the contents of this file may be used under the terms of # either of the GNU General Public License Version 2 or later (the "GPL"), @@ -489,15 +491,6 @@ LOOP_OVER_TOOL_DIRS = \ $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir))) endif -ifdef PARALLEL_DIRS -# create a bunch of fake targets for order-only processing -PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS)) -PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS)) -PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS)) - -.PHONY: $(PARALLEL_DIRS_export) $(PARALLEL_DIRS_libs) $(PARALLEL_DIRS_tools) -endif - # # Now we can differentiate between objects used to build a library, and # objects used to build an executable in the same directory. @@ -736,21 +729,6 @@ endif MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs))) -export_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir))) - -libs_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir))) - -tools_tier_%: - @$(ECHO) "$@" - @$(MAKE_TIER_SUBMAKEFILES) - $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir))) - $(foreach tier,$(TIERS),tier_$(tier)):: @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)" $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir))) @@ -774,29 +752,8 @@ ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS)) $(LOOP_OVER_TOOL_DIRS) endif -ifdef PARALLEL_DIRS -export:: $(PARALLEL_DIRS_export) - -$(PARALLEL_DIRS_export): %_export: %/Makefile - +@$(call SUBMAKE,export,$*) -endif - -export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR)) - $(LOOP_OVER_DIRS) - $(LOOP_OVER_TOOL_DIRS) - -ifdef PARALLEL_DIRS -tools:: $(PARALLEL_DIRS_tools) - -$(PARALLEL_DIRS_tools): %_tools: %/Makefile - +@$(call SUBMAKE,tools,$*) -endif - -tools:: $(SUBMAKEFILES) $(MAKE_DIRS) - $(LOOP_OVER_DIRS) -ifneq (,$(strip $(TOOL_DIRS))) - $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir))) -endif +include $(topsrcdir)/config/makefiles/target_export.mk +include $(topsrcdir)/config/makefiles/target_tools.mk # # Rule to create list of libraries for final link @@ -826,86 +783,9 @@ DSO_LDOPTS_DEPS = $(call DO_EXPAND_LIBS,$(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFI GLOBAL_DEPS += Makefile Makefile.in $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk ############################################## -ifdef PARALLEL_DIRS -libs:: $(PARALLEL_DIRS_libs) - -$(PARALLEL_DIRS_libs): %_libs: %/Makefile - +@$(call SUBMAKE,libs,$*) -endif - -ifdef EXPORT_LIBRARY -ifeq ($(EXPORT_LIBRARY),1) -ifdef IS_COMPONENT -EXPORT_LIBRARY = $(DEPTH)/staticlib/components -else -EXPORT_LIBRARY = $(DEPTH)/staticlib -endif -else -# If EXPORT_LIBRARY has a value, we'll be installing there. We also need to cleanup there -GARBAGE += $(foreach lib,$(LIBRARY),$(EXPORT_LIBRARY)/$(lib)) -endif -endif # EXPORT_LIBRARY - -libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY) -ifndef NO_DIST_INSTALL -ifdef LIBRARY -ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build - $(INSTALL) $(IFLAGS1) $(LIBRARY) $(EXPORT_LIBRARY) -endif # EXPORT_LIBRARY -ifdef DIST_INSTALL -ifdef IS_COMPONENT - $(error Shipping static component libs makes no sense.) -else - $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib -endif -endif # DIST_INSTALL -endif # LIBRARY -ifdef SHARED_LIBRARY -ifdef IS_COMPONENT - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components - $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY) -ifndef NO_COMPONENTS_MANIFEST - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest" - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)" -endif -else # ! IS_COMPONENT -ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) -ifndef NO_INSTALL_IMPORT_LIBRARY - $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib -endif -else - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib -endif - $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET) -endif # IS_COMPONENT -endif # SHARED_LIBRARY -ifdef PROGRAM - $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET) -endif -ifdef SIMPLE_PROGRAMS - $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET) -endif -ifdef HOST_PROGRAM - $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin -endif -ifdef HOST_SIMPLE_PROGRAMS - $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin -endif -ifdef HOST_LIBRARY - $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib -endif -ifdef JAVA_LIBRARY -ifdef IS_COMPONENT - $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components -else - $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET) -endif -endif # JAVA_LIBRARY -endif # !NO_DIST_INSTALL - $(LOOP_OVER_DIRS) +include $(topsrcdir)/config/makefiles/target_libs.mk ############################################## - ifndef NO_PROFILE_GUIDED_OPTIMIZE ifdef MOZ_PROFILE_USE ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) diff --git a/js/src/configure.in b/js/src/configure.in index 5b1500c8f790..d1aa21da2883 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -1559,8 +1559,6 @@ dnl ======================================================== dnl GNU specific defaults dnl ======================================================== if test "$GNU_CC"; then - # FIXME: Let us build with strict aliasing. bug 414641. - CFLAGS="$CFLAGS -fno-strict-aliasing" MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@' DSO_LDOPTS='-shared' @@ -1631,8 +1629,6 @@ else fi if test "$GNU_CXX"; then - # FIXME: Let us build with strict aliasing. bug 414641. - CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" # Turn on GNU specific features _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor" if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 5c0f886c0316..d164cb0d789f 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -1020,6 +1020,29 @@ struct ConvertImpl { }; #endif +// C++ doesn't guarantee that exact values are the only ones that will +// round-trip. In fact, on some platforms, including SPARC, there are pairs of +// values, a uint64 and a double, such that neither value is exactly +// representable in the other type, but they cast to each other. +#ifdef SPARC +// Simulate x86 overflow behavior +template<> +struct ConvertImpl { + static JS_ALWAYS_INLINE JSUint64 Convert(jsdouble d) { + return d >= 0xffffffffffffffff ? + 0x8000000000000000 : JSUint64(d); + } +}; + +template<> +struct ConvertImpl { + static JS_ALWAYS_INLINE JSInt64 Convert(jsdouble d) { + return d >= 0x7fffffffffffffff ? + 0x8000000000000000 : JSInt64(d); + } +}; +#endif + template static JS_ALWAYS_INLINE TargetType Convert(FromType d) { diff --git a/js/src/jit-test/tests/basic/bug561359-1.js b/js/src/jit-test/tests/basic/bug561359-1.js new file mode 100644 index 000000000000..4439174e06da --- /dev/null +++ b/js/src/jit-test/tests/basic/bug561359-1.js @@ -0,0 +1,4 @@ +for (let z = 0; z < 2; z++) { + with ({x: function () {}}) + f = x; +} diff --git a/js/src/jit-test/tests/basic/bug561359-2.js b/js/src/jit-test/tests/basic/bug561359-2.js new file mode 100644 index 000000000000..017b9bf3384a --- /dev/null +++ b/js/src/jit-test/tests/basic/bug561359-2.js @@ -0,0 +1,8 @@ +function f(s) { + var obj = {m: function () { return a; }}; + eval(s); + return obj; +} +var obj = f("var a = 'right';"); +var a = 'wrong'; +assertEq(obj.m(), 'right'); diff --git a/js/src/jit-test/tests/basic/bug652054.js b/js/src/jit-test/tests/basic/bug652054.js new file mode 100644 index 000000000000..9c43865a88bc --- /dev/null +++ b/js/src/jit-test/tests/basic/bug652054.js @@ -0,0 +1,55 @@ +var M4x4 = {}; +M4x4.mul = function M4x4_mul(a, b, r) { + a11 = a[0] + a21 = a[1] + a31 = a[2] + a12 = a[4] + a22 = a[5] + a32 = a[6] + a13 = a[8] + a23 = a[9] + a33 = a[10] + a14 = a[12] + a24 = a[13] + a34 = a[14] + b[3] + b[4] + b13 = b[8] + b23 = b[9] + b33 = b[10] + b43 = b[11] + r[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43 + r[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43 + r[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43 + return r; +}; +M4x4.scale3 = function M4x4_scale3(x, y, z, m) { + m[0] *= x; + m[3] *= x; + m[4] *= y; + m[11] *= z; +}; +M4x4.makeLookAt = function M4x4_makeLookAt() { + tm1 = Float32Array(16); + tm2 = Float32Array(16); + r = new Float32Array(16) + return M4x4.mul(tm1, tm2, r); +}; +var jellyfish = {}; +jellyfish.order = []; +function jellyfishInstance() {} +jellyfishInstance.prototype.drawShadow = function () { + pMatrix = M4x4.makeLookAt(); + M4x4.mul(M4x4.makeLookAt(), pMatrix, pMatrix); + M4x4.scale3(6, 180, 0, pMatrix); +} +function drawScene() { + jellyfish.order.push([0, 0]) + jellyfish[0] = new jellyfishInstance() + for (var i = 0, j = 0; i < jellyfish.count, j < 30; ++j) { + jellyfish.order[i][0] + jellyfish[0].drawShadow(); + } +} +drawScene(); + diff --git a/js/src/jit-test/tests/basic/bug679977.js b/js/src/jit-test/tests/basic/bug679977.js new file mode 100644 index 000000000000..f11311945d1e --- /dev/null +++ b/js/src/jit-test/tests/basic/bug679977.js @@ -0,0 +1,26 @@ +var Test = function (foo) { + var a = []; + + this.fillArray = function() { + a = []; + for (var i = 0; i < 10; i++) + a.push(0); + assertEq(a.length, 10); + } + + foo.go(this); +}; + +// Import assertEq now to prevent global object shape from changing. +assertEq(true, true); + +(new Test({ go: function(p) { + p.fill = function() { + p.fillArray(); + } +}})).fill(); + +new Test({ go: function(p) { + for (var k = 0; k < 10; k++) + p.fillArray(); +}}); diff --git a/js/src/js.msg b/js/src/js.msg index 339c5176d4e9..107e4f96de50 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -313,7 +313,7 @@ MSG_DEF(JSMSG_EVAL_ARITY, 226, 0, JSEXN_TYPEERR, "eval accepts only MSG_DEF(JSMSG_MISSING_FUN_ARG, 227, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}") MSG_DEF(JSMSG_JSON_BAD_PARSE, 228, 1, JSEXN_SYNTAXERR, "JSON.parse: {0}") MSG_DEF(JSMSG_JSON_BAD_STRINGIFY, 229, 0, JSEXN_ERR, "JSON.stringify") -MSG_DEF(JSMSG_XDR_CLOSURE_WRAPPER, 230, 1, JSEXN_INTERNALERR, "can't XDR closure wrapper for function {0}") +MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 230, 0, JSEXN_TYPEERR, "value is not a function or undefined") MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 231, 0, JSEXN_TYPEERR, "value is not a non-null object") MSG_DEF(JSMSG_DEPRECATED_OCTAL, 232, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated") MSG_DEF(JSMSG_STRICT_CODE_WITH, 233, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements") @@ -369,5 +369,4 @@ MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 282, 0, JSEXN_TYPEERR, "invalid script off MSG_DEF(JSMSG_DEBUG_BAD_LINE, 283, 0, JSEXN_TYPEERR, "invalid line number") MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 284, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee") MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 285, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object") -MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 286, 0, JSEXN_TYPEERR, "value is not a function or undefined") -MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 287, 0, JSEXN_ERR, "stack frame is not running JavaScript code") +MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 286, 0, JSEXN_ERR, "stack frame is not running JavaScript code") diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index a2fe42b83298..52add2ed664b 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -50,6 +50,7 @@ #include "jswatchpoint.h" #include "jswrapper.h" #include "assembler/wtf/Platform.h" +#include "assembler/jit/ExecutableAllocator.h" #include "yarr/BumpPointerAllocator.h" #include "methodjit/MethodJIT.h" #include "methodjit/PolyIC.h" @@ -176,10 +177,16 @@ JSCompartment::ensureJaegerCompartmentExists(JSContext *cx) return true; } -size_t -JSCompartment::getMjitCodeSize() const +void +JSCompartment::getMjitCodeStats(size_t& method, size_t& regexp, size_t& unused) const { - return jaegerCompartment_ ? jaegerCompartment_->execAlloc()->getCodeSize() : 0; + if (jaegerCompartment_) { + jaegerCompartment_->execAlloc()->getCodeStats(method, regexp, unused); + } else { + method = 0; + regexp = 0; + unused = 0; + } } #endif @@ -234,8 +241,7 @@ JSCompartment::wrap(JSContext *cx, Value *vp) /* * Wrappers should really be parented to the wrapped parent of the wrapped * object, but in that case a wrapped global object would have a NULL - * parent without being a proper global object (JSCLASS_IS_GLOBAL). Instead -, + * parent without being a proper global object (JSCLASS_IS_GLOBAL). Instead, * we parent all wrappers to the global object in their home compartment. * This loses us some transparency, and is generally very cheesy. */ @@ -585,6 +591,8 @@ JSCompartment::sweep(JSContext *cx, uint32 releaseInterval) } # endif + bool discardScripts = !active && (releaseInterval != 0 || hasDebugModeCodeToDrop); + #if defined JS_METHODJIT && defined JS_MONOIC /* @@ -595,7 +603,6 @@ JSCompartment::sweep(JSContext *cx, uint32 releaseInterval) * for compartments which currently have active stack frames. */ uint32 counter = 1; - bool discardScripts = !active && (releaseInterval != 0 || hasDebugModeCodeToDrop); if (discardScripts) hasDebugModeCodeToDrop = false; diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 044d4ca2f4eb..f53b30a83801 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -455,7 +455,7 @@ struct JS_FRIEND_API(JSCompartment) { bool ensureJaegerCompartmentExists(JSContext *cx); - size_t getMjitCodeSize() const; + void getMjitCodeStats(size_t& method, size_t& regexp, size_t& unused) const; #endif WTF::BumpPointerAllocator *regExpAllocator; diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 8a0ae7c9607f..3d5484c68a4d 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -1608,14 +1608,7 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) } return false; } - if (fun->u.i.wrapper) { - JSAutoByteString funNameBytes; - if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XDR_CLOSURE_WRAPPER, name); - return false; - } - JS_ASSERT((fun->u.i.wrapper & ~1U) == 0); - firstword = (fun->u.i.skipmin << 2) | (fun->u.i.wrapper << 1) | !!fun->atom; + firstword = (fun->u.i.skipmin << 2) | !!fun->atom; flagsword = (fun->nargs << 16) | fun->flags; } else { fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, NULL, NULL); @@ -1639,7 +1632,6 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp) JS_ASSERT((flagsword & JSFUN_KINDMASK) >= JSFUN_INTERPRETED); fun->flags = uint16(flagsword); fun->u.i.skipmin = uint16(firstword >> 2); - fun->u.i.wrapper = JSPackedBool((firstword >> 1) & 1); } /* @@ -2483,7 +2475,6 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs, JS_ASSERT(!native); JS_ASSERT(nargs == 0); fun->u.i.skipmin = 0; - fun->u.i.wrapper = false; fun->u.i.script = NULL; } else { fun->u.n.clasp = NULL; diff --git a/js/src/jsfun.h b/js/src/jsfun.h index f92860e786dd..c1861cf5720f 100644 --- a/js/src/jsfun.h +++ b/js/src/jsfun.h @@ -120,12 +120,6 @@ struct JSFunction : public JSObject_Slots2 uint16 skipmin; /* net skip amount up (toward zero) from script->staticLevel to nearest upvar, including upvars in nested functions */ - JSPackedBool wrapper; /* true if this function is a wrapper that - rewrites bytecode optimized for a function - judged non-escaping by the compiler, which - then escaped via the debugger or a rogue - indirect eval; if true, then this function - object's proto is the wrapped object */ js::Shape *names; /* argument and variable names */ } i; void *nativeOrScript; diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 39bae9745f8a..ebf002215f03 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -2017,8 +2017,7 @@ TypeCompartment::setPendingNukeTypes(JSContext *cx) void TypeCompartment::nukeTypes(JSContext *cx) { - JSCompartment *compartment = cx->compartment; - JS_ASSERT(this == &compartment->types); + JS_ASSERT(this == &cx->compartment->types); /* * This is the usual response if we encounter an OOM while adding a type @@ -2060,7 +2059,8 @@ TypeCompartment::nukeTypes(JSContext *cx) #ifdef JS_METHODJIT - mjit::ExpandInlineFrames(cx->compartment); + JSCompartment *compartment = cx->compartment; + mjit::ExpandInlineFrames(compartment); /* Throw away all JIT code in the compartment, but leave everything else alone. */ for (JSCList *cursor = compartment->scripts.next; diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 6e08389b361d..97c4b8d656a8 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -1936,6 +1936,8 @@ Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode) #define MONITOR_BRANCH_TRACEVIS #endif +#endif /* !JS_TRACER */ + #define RESTORE_INTERP_VARS() \ JS_BEGIN_MACRO \ SET_SCRIPT(regs.fp()->script()); \ @@ -1954,8 +1956,6 @@ Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode) CHECK_INTERRUPT_HANDLER(); \ JS_END_MACRO -#endif /* !JS_TRACER */ - /* * Prepare to call a user-supplied branch handler, and abort the script * if it returns false. @@ -5014,7 +5014,7 @@ BEGIN_CASE(JSOP_LAMBDA) if (fun->isNullClosure()) { parent = ®s.fp()->scopeChain(); - if (obj->getParent() == parent) { + if (fun->joinable()) { jsbytecode *pc2 = AdvanceOverBlockchainOp(regs.pc + JSOP_LAMBDA_LENGTH); JSOp op2 = JSOp(*pc2); @@ -5049,41 +5049,39 @@ BEGIN_CASE(JSOP_LAMBDA) fun->setMethodAtom(script->getAtom(GET_FULL_INDEX(pc2 - regs.pc))); break; } - } else if (fun->joinable()) { - if (op2 == JSOP_CALL) { - /* - * Array.prototype.sort and String.prototype.replace are - * optimized as if they are special form. We know that they - * won't leak the joined function object in obj, therefore - * we don't need to clone that compiler- created function - * object for identity/mutation reasons. - */ - int iargc = GET_ARGC(pc2); + } else if (op2 == JSOP_CALL) { + /* + * Array.prototype.sort and String.prototype.replace are + * optimized as if they are special form. We know that they + * won't leak the joined function object in obj, therefore + * we don't need to clone that compiler-created function + * object for identity/mutation reasons. + */ + int iargc = GET_ARGC(pc2); - /* - * Note that we have not yet pushed obj as the final argument, - * so regs.sp[1 - (iargc + 2)], and not regs.sp[-(iargc + 2)], - * is the callee for this JSOP_CALL. - */ - const Value &cref = regs.sp[1 - (iargc + 2)]; - JSObject *callee; + /* + * Note that we have not yet pushed obj as the final argument, + * so regs.sp[1 - (iargc + 2)], and not regs.sp[-(iargc + 2)], + * is the callee for this JSOP_CALL. + */ + const Value &cref = regs.sp[1 - (iargc + 2)]; + JSObject *callee; - if (IsFunctionObject(cref, &callee)) { - JSFunction *calleeFun = callee->getFunctionPrivate(); - if (Native native = calleeFun->maybeNative()) { - if ((iargc == 1 && native == array_sort) || - (iargc == 2 && native == str_replace)) { - break; - } + if (IsFunctionObject(cref, &callee)) { + JSFunction *calleeFun = callee->getFunctionPrivate(); + if (Native native = calleeFun->maybeNative()) { + if ((iargc == 1 && native == array_sort) || + (iargc == 2 && native == str_replace)) { + break; } } - } else if (op2 == JSOP_NULL) { - pc2 += JSOP_NULL_LENGTH; - op2 = JSOp(*pc2); - - if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) - break; } + } else if (op2 == JSOP_NULL) { + pc2 += JSOP_NULL_LENGTH; + op2 = JSOp(*pc2); + + if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) + break; } } } else { diff --git a/js/src/jsparse.cpp b/js/src/jsparse.cpp index 2cd88825e090..0039664d07ce 100644 --- a/js/src/jsparse.cpp +++ b/js/src/jsparse.cpp @@ -311,7 +311,9 @@ bool JSFunctionBox::joinable() const { return function()->isNullClosure() && - !(tcflags & (TCF_FUN_USES_ARGUMENTS | TCF_FUN_USES_OWN_NAME)); + (tcflags & (TCF_FUN_USES_ARGUMENTS | + TCF_FUN_USES_OWN_NAME | + TCF_COMPILE_N_GO)) == TCF_COMPILE_N_GO; } bool @@ -2272,8 +2274,9 @@ CanFlattenUpvar(JSDefinition *dn, JSFunctionBox *funbox, uint32 tcflags) /* * If this function is reaching up across an enclosing funarg, then we - * cannot copy dn's value into a flat closure slot (the display stops - * working once the funarg escapes). + * cannot copy dn's value into a flat closure slot. The flat closure + * code assumes the upvars to be copied are in frames still on the + * stack. */ if (!afunbox || afunbox->node->isFunArg()) return false; @@ -2412,48 +2415,56 @@ DeoptimizeUsesWithin(JSDefinition *dn, const TokenPos &pos) return ndeoptimized != 0; } +static void +ConsiderUnbranding(JSFunctionBox *funbox) +{ + /* + * We've already recursively set our kids' kinds, which also classifies + * enclosing functions holding upvars referenced in those descendants' + * bodies. So now we can check our "methods". + * + * Despecialize from branded method-identity-based shape to shape- or + * slot-based shape if this function smells like a constructor and too many + * of its methods are *not* joinable null closures (i.e., they have one or + * more upvars fetched via the display). + */ + bool returnsExpr = !!(funbox->tcflags & TCF_RETURN_EXPR); +#if JS_HAS_EXPR_CLOSURES + { + JSParseNode *pn2 = funbox->node->pn_body; + if (PN_TYPE(pn2) == TOK_UPVARS) + pn2 = pn2->pn_tree; + if (PN_TYPE(pn2) == TOK_ARGSBODY) + pn2 = pn2->last(); + if (PN_TYPE(pn2) != TOK_LC) + returnsExpr = true; + } +#endif + if (!returnsExpr) { + uintN methodSets = 0, slowMethodSets = 0; + + for (JSParseNode *method = funbox->methods; method; method = method->pn_link) { + JS_ASSERT(PN_OP(method) == JSOP_LAMBDA || PN_OP(method) == JSOP_LAMBDA_FC); + ++methodSets; + if (!method->pn_funbox->joinable()) + ++slowMethodSets; + } + + if (funbox->shouldUnbrand(methodSets, slowMethodSets)) + funbox->tcflags |= TCF_FUN_UNBRAND_THIS; + } +} + void Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) { - for (;;) { + for (; funbox; funbox = funbox->siblings) { JSParseNode *fn = funbox->node; JSParseNode *pn = fn->pn_body; if (funbox->kids) { setFunctionKinds(funbox->kids, tcflags); - - /* - * We've unwound from recursively setting our kids' kinds, which - * also classifies enclosing functions holding upvars referenced in - * those descendants' bodies. So now we can check our "methods". - * - * Despecialize from branded method-identity-based shape to shape- - * or slot-based shape if this function smells like a constructor - * and too many of its methods are *not* joinable null closures - * (i.e., they have one or more upvars fetched via the display). - */ - JSParseNode *pn2 = pn; - if (PN_TYPE(pn2) == TOK_UPVARS) - pn2 = pn2->pn_tree; - if (PN_TYPE(pn2) == TOK_ARGSBODY) - pn2 = pn2->last(); - -#if JS_HAS_EXPR_CLOSURES - if (PN_TYPE(pn2) == TOK_LC) -#endif - if (!(funbox->tcflags & TCF_RETURN_EXPR)) { - uintN methodSets = 0, slowMethodSets = 0; - - for (JSParseNode *method = funbox->methods; method; method = method->pn_link) { - JS_ASSERT(PN_OP(method) == JSOP_LAMBDA || PN_OP(method) == JSOP_LAMBDA_FC); - ++methodSets; - if (!method->pn_funbox->joinable()) - ++slowMethodSets; - } - - if (funbox->shouldUnbrand(methodSets, slowMethodSets)) - funbox->tcflags |= TCF_FUN_UNBRAND_THIS; - } + ConsiderUnbranding(funbox); } JSFunction *fun = funbox->function(); @@ -2464,54 +2475,13 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) /* nothing to do */ } else if (funbox->inAnyDynamicScope()) { JS_ASSERT(!fun->isNullClosure()); - } else if (pn->pn_type != TOK_UPVARS) { - /* - * No lexical dependencies => null closure, for best performance. - * A null closure needs no scope chain, but alas we've coupled - * principals-finding to scope (for good fundamental reasons, but - * the implementation overloads the parent slot and we should fix - * that). See, e.g., the JSOP_LAMBDA case in jsinterp.cpp. - * - * In more detail: the ES3 spec allows the implementation to create - * "joined function objects", or not, at its discretion. But real- - * world implementations always create unique function objects for - * closures, and this can be detected via mutation. Open question: - * do popular implementations create unique function objects for - * null closures? - * - * FIXME: bug 476950. - */ - fun->setKind(JSFUN_NULL_CLOSURE); } else { - AtomDefnMapPtr upvars = pn->pn_names; - JS_ASSERT(!upvars->empty()); + uintN hasUpvars = false; + bool canFlatten = true; - if (!fn->isFunArg()) { - /* - * This function is Algol-like, it never escapes. - * - * Check that at least one outer lexical binding was assigned - * to (global variables don't count). This is conservative: we - * could limit assignments to those in the current function, - * but that's too much work. As with flat closures (handled - * below), we optimize for the case where outer bindings are - * not reassigned anywhere. - */ - AtomDefnRange r = upvars->all(); - for (; !r.empty(); r.popFront()) { - JSDefinition *defn = r.front().value(); - JSDefinition *lexdep = defn->resolve(); - - if (!lexdep->isFreeVar()) { - JS_ASSERT(lexdep->frameLevel() <= funbox->level); - break; - } - } - - if (r.empty()) - fun->setKind(JSFUN_NULL_CLOSURE); - } else { - uintN nupvars = 0, nflattened = 0; + if (pn->pn_type == TOK_UPVARS) { + AtomDefnMapPtr upvars = pn->pn_names; + JS_ASSERT(!upvars->empty()); /* * For each lexical dependency from this closure to an outer @@ -2523,51 +2493,39 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) JSDefinition *lexdep = defn->resolve(); if (!lexdep->isFreeVar()) { - ++nupvars; - if (CanFlattenUpvar(lexdep, funbox, *tcflags)) { - ++nflattened; - continue; + hasUpvars = true; + if (!CanFlattenUpvar(lexdep, funbox, *tcflags)) { + /* + * Can't flatten. Enclosing functions holding + * variables used by this function will be flagged + * heavyweight below. FIXME bug 545759: re-enable + * partial flat closures. + */ + canFlatten = false; + break; } - - /* - * FIXME bug 545759: to test nflattened != 0 instead of - * nflattened == nupvars below, we'll need to avoid n^2 - * bugs such as 617430 in uncommenting the following: - * - * if (DeoptimizeUsesWithin(lexdep, funbox->node->pn_body->pn_pos)) - * FlagHeavyweights(lexdep, funbox, tcflags); - * - * For now it's best to avoid this tedious, use-wise - * deoptimization and let fun remain an unoptimized - * closure. This is safe because we leave fun's kind - * set to interpreted, so all functions holding its - * upvars will be flagged as heavyweight. - */ } } + } - if (nupvars == 0) { - fun->setKind(JSFUN_NULL_CLOSURE); - } else if (nflattened == nupvars) { - /* - * We made it all the way through the upvar loop, so it's - * safe to optimize to a flat closure. - */ - fun->setKind(JSFUN_FLAT_CLOSURE); - switch (PN_OP(fn)) { - case JSOP_DEFFUN: - fn->pn_op = JSOP_DEFFUN_FC; - break; - case JSOP_DEFLOCALFUN: - fn->pn_op = JSOP_DEFLOCALFUN_FC; - break; - case JSOP_LAMBDA: - fn->pn_op = JSOP_LAMBDA_FC; - break; - default: - /* js_EmitTree's case TOK_FUNCTION: will select op. */ - JS_ASSERT(PN_OP(fn) == JSOP_NOP); - } + if (!hasUpvars) { + /* No lexical dependencies => null closure, for best performance. */ + fun->setKind(JSFUN_NULL_CLOSURE); + } else if (canFlatten) { + fun->setKind(JSFUN_FLAT_CLOSURE); + switch (PN_OP(fn)) { + case JSOP_DEFFUN: + fn->pn_op = JSOP_DEFFUN_FC; + break; + case JSOP_DEFLOCALFUN: + fn->pn_op = JSOP_DEFLOCALFUN_FC; + break; + case JSOP_LAMBDA: + fn->pn_op = JSOP_LAMBDA_FC; + break; + default: + /* js_EmitTree's case TOK_FUNCTION: will select op. */ + JS_ASSERT(PN_OP(fn) == JSOP_NOP); } } } @@ -2595,10 +2553,6 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags) if (funbox->joinable()) fun->setJoinable(); - - funbox = funbox->siblings; - if (!funbox) - break; } } @@ -4482,8 +4436,6 @@ CloneParseTree(JSParseNode *opn, JSTreeContext *tc) #endif /* JS_HAS_DESTRUCTURING */ -extern const char js_with_statement_str[]; - static JSParseNode * ContainsStmt(JSParseNode *pn, TokenKind tt) { diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 3c1fc548a387..cc024c099109 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -154,7 +154,7 @@ using namespace js::tjit; /* Implement embedder-specific nanojit members. */ -/* +/* * Nanojit requires infallible allocations most of the time. We satisfy this by * reserving some space in each allocator which is used as a fallback if * rt->calloc_() fails. Ideally this reserve space should be big enough to allow @@ -2433,7 +2433,7 @@ TraceRecorder::TraceRecorder(JSContext* cx, TraceMonitor *tm, LIns* counterValue = w.ldiVolatile(counterPtr); LIns* test = w.ltiN(counterValue, LOOP_COUNT_MAX); LIns *branch = w.jfUnoptimizable(test); - /* + /* * stiVolatile() uses ACCSET_STORE_ANY; If LICM is implemented * (bug 545406) this counter will need its own region. */ @@ -2924,7 +2924,7 @@ ContainsUnrechableGCThingImpl(JSContext *cx, TreeFragment *f) if (f->visiting) return false; f->visiting = true; - + if (!f->code()) return false; @@ -2972,7 +2972,7 @@ ClearVisitingFlag(TreeFragment *f) * Recursively check if the fragment and its dependent and linked trees has * dead GC things. As the trees can point to each other we use the visiting * flag to detect already visited fragments. The flag is cleared after we - * walked the whole graph in the separated ClearVisitingFlag function. + * walked the whole graph in the separated ClearVisitingFlag function. */ static bool ContainsUnrechableGCThing(JSContext *cx, TreeFragment *f) @@ -2994,7 +2994,7 @@ TraceMonitor::sweep(JSContext *cx) recorderTree = recorder->getTree(); shouldAbortRecording = HasUnreachableGCThings(cx, recorderTree); } - + for (size_t i = 0; i < FRAGMENT_TABLE_SIZE; ++i) { TreeFragment** fragp = &vmfragments[i]; while (TreeFragment* frag = *fragp) { @@ -3008,7 +3008,7 @@ TraceMonitor::sweep(JSContext *cx) fragp = &frag->next; continue; } - + debug_only_printf(LC_TMTracer, "TreeFragment peer %p has dead gc thing." "Disconnecting tree %p with ip %p\n", @@ -4381,7 +4381,7 @@ TraceRecorder::snapshot(ExitType exitType) } else if (pendingSpecializedNative && (pendingSpecializedNative->flags & JSTN_RETURN_NULLABLE_OBJ)) { typemap[stackSlots - 1] = JSVAL_TYPE_OBJORNULL; - } + } /* Now restore the the original pc (after which early returns are ok). */ if (resumeAfter) { @@ -4852,7 +4852,7 @@ class SlotMap : public SlotVisitorBase JS_ASSERT(info.type == JSVAL_TYPE_INT32 || info.type == JSVAL_TYPE_DOUBLE); /* * This should only happen if the slot has a trivial conversion, i.e. - * IsPromotedInt32() is true. We check this. + * IsPromotedInt32() is true. We check this. * * Note that getFromTracker() will return NULL if the slot was * never used, in which case we don't do the check. We could @@ -4862,7 +4862,7 @@ class SlotMap : public SlotVisitorBase */ LIns* ins = mRecorder.getFromTrackerImpl(info.vp); JS_ASSERT_IF(ins, IsPromotedInt32(ins)); - } else + } else #endif if (info.lastCheck == TypeCheck_Demote) { JS_ASSERT(info.type == JSVAL_TYPE_INT32 || info.type == JSVAL_TYPE_DOUBLE); @@ -4918,7 +4918,7 @@ class DefaultSlotMap : public SlotMap DefaultSlotMap(TraceRecorder& tr) : SlotMap(tr) { } - + virtual ~DefaultSlotMap() { } @@ -6268,7 +6268,7 @@ IsEntryTypeCompatible(const Value &v, JSValueType type) } else if (v.isDouble()) { int32_t _; - ok = (type == JSVAL_TYPE_DOUBLE) || + ok = (type == JSVAL_TYPE_DOUBLE) || (type == JSVAL_TYPE_INT32 && JSDOUBLE_IS_INT32(v.toDouble(), &_)); } else if (v.isObject()) { @@ -6579,7 +6579,7 @@ TracerState::~TracerState() JS_ASSERT(JS_THREAD_DATA(cx)->onTraceCompartment == cx->compartment); JS_THREAD_DATA(cx)->onTraceCompartment = NULL; } - + traceMonitor->tracerState = prev; traceMonitor->tracecx = NULL; } @@ -6738,7 +6738,7 @@ ExecuteTree(JSContext* cx, TraceMonitor* tm, TreeFragment* f, CurrentLine(cx), js_CodeName[fp->hasImacropc() ? *fp->imacropc() : *cx->regs().pc]); #endif - + #ifdef JS_METHODJIT if (cx->methodJitEnabled) { if (lr->exitType == LOOP_EXIT && f->iters < MIN_LOOP_ITERS @@ -7331,7 +7331,7 @@ TraceRecorder::monitorRecording(JSOp op) JS_ASSERT(!addPropShapeBefore); JS_ASSERT(traceMonitor == cx->compartment->traceMonitor()); - + TraceMonitor &localtm = *traceMonitor; debug_only_stmt( JSContext *localcx = cx; ) assertInsideLoop(); @@ -7927,7 +7927,7 @@ PurgeScriptFragments(TraceMonitor* tm, JSScript* script) "Purging fragments for JSScript %p.\n", (void*)script); /* A recorder script is being evaluated and can not be destroyed or GC-ed. */ - JS_ASSERT_IF(tm->recorder, + JS_ASSERT_IF(tm->recorder, JS_UPTRDIFF(tm->recorder->getTree()->ip, script->code) >= script->length); for (LoopProfileMap::Enum e(*tm->loopProfiles); !e.empty(); e.popFront()) { @@ -8293,15 +8293,27 @@ TraceRecorder::callProp(JSObject* obj, JSProperty* prop, jsid id, const Value*& LIns* obj_ins; JSObject* parent = cx->fp()->callee().getParent(); - LIns* parent_ins = w.ldpObjParent(get(&cx->fp()->calleev())); + LIns *callee_ins = get(&cx->fp()->calleev()); + LIns* parent_ins = w.ldpObjParent(callee_ins); CHECK_STATUS(traverseScopeChain(parent, parent_ins, obj, obj_ins)); if (!cfp) { - // Because the parent guard in guardCallee ensures this Call object - // will be the same object now and on trace, and because once a Call - // object loses its frame it never regains one, on trace we will also - // have a null private in the Call object. So all we need to do is - // write the value to the Call object's slot. + // We need to guard that this Call object will be the same one on + // trace, as we can arrive here without having gone through + // guardCallee. Once a Call object loses its frame it never regains + // one, so on trace we will also have a null private in the Call + // object. All we need to do is write the value to the Call object's + // slot. + VMSideExit *branchExit = snapshot(BRANCH_EXIT); + if (parent != globalObj) { + if (!parent->isCall()) + RETURN_STOP("closure scoped by neither the global object nor a Call object"); + + guard(true, + w.eqp(w.ldpObjParent(callee_ins), w.immpObjGC(parent)), + branchExit); + } + if (shape->getterOp() == GetCallArg) { JS_ASSERT(slot < ArgClosureTraits::slot_count(obj)); slot += ArgClosureTraits::slot_offset(obj); @@ -8315,7 +8327,7 @@ TraceRecorder::callProp(JSObject* obj, JSProperty* prop, jsid id, const Value*& // Now assert that our use of shape->shortid was in fact kosher. JS_ASSERT(shape->hasShortID()); - ins = unbox_slot(obj, obj_ins, slot, snapshot(BRANCH_EXIT)); + ins = unbox_slot(obj, obj_ins, slot, branchExit); } else { ClosureVarInfo* cv = new (traceAlloc()) ClosureVarInfo(); cv->slot = slot; @@ -8422,13 +8434,13 @@ TraceRecorder::tryToDemote(LOpcode op, jsdouble v0, jsdouble v1, LIns* s0, LIns* * at record-time, and the oracle doesn't direct us otherwise, we * speculatively emit a demoted (integer) operation, betting that at * runtime we will get integer results again. - * + * * We also have to protect against various edge cases. For example, * to protect against overflow we emit a guard that will inform the oracle * on overflow and cause a non-demoted trace to be attached that uses * floating-point math for this operation; the exception to this case is * if the operands guarantee that the result will be an integer (e.g. - * z = d0 * d1 with 0 <= (d0|d1) <= 0xffff guarantees z <= fffe0001). + * z = d0 * d1 with 0 <= (d0|d1) <= 0xffff guarantees z <= fffe0001). */ if (!oracle || oracle->isInstructionUndemotable(cx->regs().pc) || @@ -8499,7 +8511,7 @@ TraceRecorder::tryToDemote(LOpcode op, jsdouble v0, jsdouble v1, LIns* s0, LIns* } /* - * A would-be negative zero result can only occur if we have + * A would-be negative zero result can only occur if we have * mul(0, -n) or mul(-n, 0), where n != 0. In particular, a multiply * where one operand is a positive immediate cannot result in negative * zero. @@ -9733,7 +9745,7 @@ TraceRecorder::stobj_set_fslot(LIns *obj_ins, unsigned slot, const Value &v, LIn } void -TraceRecorder::stobj_set_dslot(LIns *obj_ins, unsigned slot, LIns*& slots_ins, +TraceRecorder::stobj_set_dslot(LIns *obj_ins, unsigned slot, LIns*& slots_ins, const Value &v, LIns* v_ins) { if (!slots_ins) @@ -10116,7 +10128,7 @@ TraceRecorder::getThis(LIns*& this_ins) return RECORD_CONTINUE; } - JS_ASSERT(fp->callee().getGlobal() == globalObj); + JS_ASSERT(fp->callee().getGlobal() == globalObj); Value& thisv = fp->thisValue(); if (thisv.isObject() || fp->fun()->inStrictMode()) { @@ -10359,7 +10371,7 @@ TraceRecorder::putActivationObjects() if (nslots) { slots_ins = w.allocp(sizeof(Value) * nslots); for (int i = 0; i < nslots; ++i) { - box_value_into(fp->slots()[i], get(&fp->slots()[i]), + box_value_into(fp->slots()[i], get(&fp->slots()[i]), AllocSlotsAddress(slots_ins, i)); } } else { @@ -12603,7 +12615,7 @@ GetPropertyByName(JSContext* cx, JSObject* obj, JSString** namep, Value* vp) SetBuiltinError(tm); return false; } - + return WasBuiltinSuccessful(tm); } JS_DEFINE_CALLINFO_4(static, BOOL_FAIL, GetPropertyByName, CONTEXT, OBJECT, STRINGPTR, VALUEPTR, @@ -13085,7 +13097,7 @@ SetPropertyByName(JSContext* cx, JSObject* obj, JSString** namep, Value* vp, JSB } return WasBuiltinSuccessful(tm); } -JS_DEFINE_CALLINFO_5(static, BOOL_FAIL, SetPropertyByName, +JS_DEFINE_CALLINFO_5(static, BOOL_FAIL, SetPropertyByName, CONTEXT, OBJECT, STRINGPTR, VALUEPTR, BOOL, 0, ACCSET_STORE_ANY) @@ -13225,7 +13237,7 @@ TraceRecorder::setElem(int lval_spindex, int idx_spindex, int v_spindex) JSObject* tarray = js::TypedArray::getTypedArray(obj); // The index was on the stack and is therefore a LIR float; force it to - // be an integer. + // be an integer. CHECK_STATUS_A(makeNumberInt32(idx_ins, &idx_ins)); // Ensure idx >= 0 && idx < length (by using uint32) @@ -13291,7 +13303,7 @@ TraceRecorder::setElem(int lval_spindex, int idx_spindex, int v_spindex) // Do nothing, this is already a float break; default: - JS_NOT_REACHED("Unknown typed array type in tracer"); + JS_NOT_REACHED("Unknown typed array type in tracer"); } switch (js::TypedArray::getType(tarray)) { @@ -13315,7 +13327,7 @@ TraceRecorder::setElem(int lval_spindex, int idx_spindex, int v_spindex) w.stdTypedArrayElement(typed_v_ins, data_ins, pidx_ins); break; default: - JS_NOT_REACHED("Unknown typed array type in tracer"); + JS_NOT_REACHED("Unknown typed array type in tracer"); } } else if (idx.toInt32() < 0 || !obj->isDenseArray()) { CHECK_STATUS_A(initOrSetPropertyByIndex(obj_ins, idx_ins, &v, @@ -13326,7 +13338,7 @@ TraceRecorder::setElem(int lval_spindex, int idx_spindex, int v_spindex) VMSideExit* mismatchExit = snapshot(MISMATCH_EXIT); // Make sure the array is actually dense. - if (!obj->isDenseArray()) + if (!obj->isDenseArray()) return ARECORD_STOP; guardDenseArray(obj_ins, branchExit); @@ -15456,30 +15468,30 @@ TraceRecorder::record_JSOP_LAMBDA() * JSOP_INITMETHOD logic governing the early ARECORD_CONTINUE returns below * must agree with the corresponding break-from-do-while(0) logic there. */ - if (fun->isNullClosure() && fun->getParent() == &cx->fp()->scopeChain()) { - jsbytecode *pc2 = AdvanceOverBlockchainOp(cx->regs().pc + JSOP_LAMBDA_LENGTH); - JSOp op2 = JSOp(*pc2); + if (fun->isNullClosure()) { + if (fun->joinable()) { + jsbytecode *pc2 = AdvanceOverBlockchainOp(cx->regs().pc + JSOP_LAMBDA_LENGTH); + JSOp op2 = JSOp(*pc2); - if (op2 == JSOP_INITMETHOD) { - stack(0, w.immpObjGC(fun)); - return ARECORD_CONTINUE; - } - - if (op2 == JSOP_SETMETHOD) { - Value lval = stackval(-1); - - if (!lval.isPrimitive() && lval.toObject().canHaveMethodBarrier()) { + if (op2 == JSOP_INITMETHOD) { stack(0, w.immpObjGC(fun)); return ARECORD_CONTINUE; } - } else if (fun->joinable()) { - if (op2 == JSOP_CALL) { + + if (op2 == JSOP_SETMETHOD) { + Value lval = stackval(-1); + + if (!lval.isPrimitive() && lval.toObject().canHaveMethodBarrier()) { + stack(0, w.immpObjGC(fun)); + return ARECORD_CONTINUE; + } + } else if (op2 == JSOP_CALL) { /* * Array.prototype.sort and String.prototype.replace are * optimized as if they are special form. We know that they - * won't leak the joined function object in obj, therefore - * we don't need to clone that compiler- created function - * object for identity/mutation reasons. + * won't leak the joined function object in obj, therefore we + * don't need to clone that compiler-created function object + * for identity/mutation reasons. */ int iargc = GET_ARGC(pc2); @@ -16734,7 +16746,7 @@ RecordTracePoint(JSContext* cx, TraceMonitor* tm, bool* blacklist, bool execAllo return TPA_Error; JS_ASSERT(!cx->isExceptionPending()); - + return TPA_RanStuff; } @@ -17094,7 +17106,7 @@ LoopProfile::profileOperation(JSContext* cx, JSOp op) if (op == JSOP_LOOKUPSWITCH) branchMultiplier *= GET_UINT16(pc + JUMP_OFFSET_LEN); - + if (numAllOps >= MAX_PROFILE_OPS) { debug_only_print0(LC_TMProfiler, "Profiling complete (maxops)\n"); tm->profile->decide(cx); @@ -17165,7 +17177,7 @@ LoopProfile::profileOperation(JSContext* cx, JSOp op) } else { stackClear(); } - + return ProfContinue; } @@ -17214,7 +17226,7 @@ LoopProfile::isCompilationUnprofitable(JSContext *cx, uintN goodOps) if (goodOps <= 22 && allOps[OP_FWDJUMP]) return true; - + /* Ensure that inner loops aren't fleeting. */ for (uintN i=0; iprofiled = true; prof->traceOK = false; diff --git a/js/src/methodjit/BaseCompiler.h b/js/src/methodjit/BaseCompiler.h index 0864357ba411..8fa97348449c 100644 --- a/js/src/methodjit/BaseCompiler.h +++ b/js/src/methodjit/BaseCompiler.h @@ -112,7 +112,8 @@ class LinkerHelper : public JSC::LinkBuffer #endif public: - LinkerHelper(Assembler &masm) : masm(masm) + LinkerHelper(Assembler &masm, JSC::CodeKind kind) : JSC::LinkBuffer(kind) + , masm(masm) #ifdef DEBUG , verifiedRange(false) #endif diff --git a/js/src/methodjit/Compiler.cpp b/js/src/methodjit/Compiler.cpp index 18d539206217..081c838ba19a 100644 --- a/js/src/methodjit/Compiler.cpp +++ b/js/src/methodjit/Compiler.cpp @@ -110,7 +110,7 @@ mjit::Compiler::Compiler(JSContext *cx, JSScript *outerScript, bool isConstructi traceICs(CompilerAllocPolicy(cx, *thisFromCtor())), #endif #if defined JS_POLYIC - pics(CompilerAllocPolicy(cx, *thisFromCtor())), + pics(CompilerAllocPolicy(cx, *thisFromCtor())), getElemICs(CompilerAllocPolicy(cx, *thisFromCtor())), setElemICs(CompilerAllocPolicy(cx, *thisFromCtor())), #endif @@ -860,8 +860,8 @@ mjit::Compiler::finishThisUp(JITScript **jitp) jumpTableOffsets.length() * sizeof(void *); JSC::ExecutablePool *execPool; - uint8 *result = - (uint8 *)script->compartment->jaegerCompartment()->execAlloc()->alloc(codeSize, &execPool); + uint8 *result = (uint8 *)script->compartment->jaegerCompartment()->execAlloc()-> + alloc(codeSize, &execPool, JSC::METHOD_CODE); if (!result) { js_ReportOutOfMemory(cx); return Compile_Error; @@ -870,9 +870,9 @@ mjit::Compiler::finishThisUp(JITScript **jitp) JSC::ExecutableAllocator::makeWritable(result, codeSize); masm.executableCopy(result); stubcc.masm.executableCopy(result + masm.size()); - - JSC::LinkBuffer fullCode(result, codeSize); - JSC::LinkBuffer stubCode(result + masm.size(), stubcc.size()); + + JSC::LinkBuffer fullCode(result, codeSize, JSC::METHOD_CODE); + JSC::LinkBuffer stubCode(result + masm.size(), stubcc.size(), JSC::METHOD_CODE); size_t nNmapLive = loopEntries.length(); for (size_t i = 0; i < script->length; i++) { @@ -927,7 +927,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp) } jit->pcLengths = pcLengths; - /* + /* * WARNING: mics(), callICs() et al depend on the ordering of these * variable-length sections. See JITScript's declaration for details. */ @@ -1107,7 +1107,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp) fullCode.locationOf(callICs[i].funGuard); jitCallICs[i].joinPointOffset = offset; JS_ASSERT(jitCallICs[i].joinPointOffset == offset); - + /* Compute the OOL call offset. */ offset = stubCode.locationOf(callICs[i].oolCall) - stubCode.locationOf(callICs[i].slowPathStart); @@ -1167,7 +1167,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp) if (equalityICs[i].jumpToStub.isSet()) jitEqualityICs[i].jumpToStub = fullCode.locationOf(equalityICs[i].jumpToStub.get()); jitEqualityICs[i].fallThrough = fullCode.locationOf(equalityICs[i].fallThrough); - + stubCode.patch(equalityICs[i].addrLabel, &jitEqualityICs[i]); } @@ -1204,7 +1204,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp) jitTraceICs[i].loopCounterStart = hotloop; jitTraceICs[i].loopCounter = hotloop < prevCount ? 1 : hotloop - prevCount; #endif - + stubCode.patch(traceICs[i].addrLabel, &jitTraceICs[i]); } #endif /* JS_MONOIC */ @@ -1565,7 +1565,7 @@ mjit::Compiler::generateMethod() /********************** * BEGIN COMPILER OPS * - **********************/ + **********************/ lastPC = PC; @@ -1936,7 +1936,7 @@ mjit::Compiler::generateMethod() frame.pop(); pushSyncedEntry(0); } - END_CASE(JSOP_DELPROP) + END_CASE(JSOP_DELPROP) BEGIN_CASE(JSOP_DELELEM) { @@ -2465,20 +2465,26 @@ mjit::Compiler::generateMethod() JSObjStubFun stub = stubs::Lambda; uint32 uses = 0; - jsbytecode *pc2 = AdvanceOverBlockchainOp(PC + JSOP_LAMBDA_LENGTH); - JSOp next = JSOp(*pc2); - - if (next == JSOP_INITMETHOD) { - stub = stubs::LambdaForInit; - } else if (next == JSOP_SETMETHOD) { - stub = stubs::LambdaForSet; - uses = 1; - } else if (fun->joinable()) { - if (next == JSOP_CALL) { - stub = stubs::LambdaJoinableForCall; - uses = frame.frameSlots(); + jsbytecode *pc2 = NULL; + if (fun->joinable()) { + pc2 = AdvanceOverBlockchainOp(PC + JSOP_LAMBDA_LENGTH); + JSOp next = JSOp(*pc2); + + if (next == JSOP_INITMETHOD) { + stub = stubs::LambdaJoinableForInit; + } else if (next == JSOP_SETMETHOD) { + stub = stubs::LambdaJoinableForSet; + uses = 1; + } else if (next == JSOP_CALL) { + int iargc = GET_ARGC(pc2); + if (iargc == 1 || iargc == 2) { + stub = stubs::LambdaJoinableForCall; + uses = frame.frameSlots(); + } } else if (next == JSOP_NULL) { - stub = stubs::LambdaJoinableForNull; + pc2 += JSOP_NULL_LENGTH; + if (JSOp(*pc2) == JSOP_CALL && GET_ARGC(pc2) == 0) + stub = stubs::LambdaJoinableForNull; } } @@ -2712,7 +2718,7 @@ mjit::Compiler::generateMethod() /********************** * END COMPILER OPS * - **********************/ + **********************/ if (cx->typeInferenceEnabled() && PC == lastPC + analyze::GetBytecodeLength(lastPC)) { /* @@ -4031,7 +4037,7 @@ mjit::Compiler::compareTwoValues(JSContext *cx, JSOp op, const Value &lhs, const } } else { double ld, rd; - + /* These should be infallible w/ primitives. */ JS_ALWAYS_TRUE(ToNumber(cx, lhs, &ld)); JS_ALWAYS_TRUE(ToNumber(cx, rhs, &rd)); @@ -4525,7 +4531,7 @@ mjit::Compiler::jsop_callprop_generic(JSAtom *atom) RETURN_IF_OOM(false); - /* + /* * Initialize op labels. We use GetPropLabels here because we have the same patching * requirements for CallProp. */ @@ -4559,7 +4565,7 @@ mjit::Compiler::jsop_callprop_str(JSAtom *atom) { if (!globalObj) { jsop_callprop_slow(atom); - return true; + return true; } /* @@ -4622,7 +4628,7 @@ mjit::Compiler::jsop_callprop_obj(JSAtom *atom) JS_ASSERT(top->isTypeKnown()); JS_ASSERT(top->getKnownType() == JSVAL_TYPE_OBJECT); - + RESERVE_IC_SPACE(masm); pic.pc = PC; @@ -4683,7 +4689,7 @@ mjit::Compiler::jsop_callprop_obj(JSAtom *atom) frame.storeRegs(-2, shapeReg, objReg, knownPushedType(0)); BarrierState barrier = testBarrier(shapeReg, objReg); - /* + /* * Assert correctness of hardcoded offsets. * No type guard: type is asserted. */ @@ -5420,7 +5426,7 @@ mjit::Compiler::jsop_this() { frame.pushThis(); - /* + /* * In strict mode code, we don't wrap 'this'. * In direct-call eval code, we wrapped 'this' before entering the eval. * In global code, 'this' is always an object. @@ -5840,7 +5846,7 @@ mjit::Compiler::jsop_getgname(uint32 index) masm.loadPtr(Address(objReg, offsetof(JSObject, slots)), objReg); Address address(objReg, slot); - + /* Allocate any register other than objReg. */ RegisterID treg = frame.allocReg(); /* After dreg is loaded, it's safe to clobber objReg. */ @@ -6138,7 +6144,7 @@ mjit::Compiler::jsop_instanceof() OOL_STUBCALL(stubs::InstanceOf, REJOIN_FALLTHROUGH); firstSlow = stubcc.masm.jump(); } - + /* This is sadly necessary because the error case needs the object. */ frame.dup(); @@ -6359,7 +6365,7 @@ mjit::Compiler::finishLoop(jsbytecode *head) #ifdef DEBUG if (IsJaegerSpewChannelActive(JSpew_Regalloc)) { RegisterAllocation *alloc = analysis->getAllocation(head); - JaegerSpew(JSpew_Regalloc, "loop allocation at %u:", head - script->code); + JaegerSpew(JSpew_Regalloc, "loop allocation at %u:", unsigned(head - script->code)); frame.dumpAllocation(alloc); } #endif diff --git a/js/src/methodjit/FrameState.cpp b/js/src/methodjit/FrameState.cpp index e4de49a8c45f..21b2502ed522 100644 --- a/js/src/methodjit/FrameState.cpp +++ b/js/src/methodjit/FrameState.cpp @@ -584,7 +584,7 @@ FrameState::computeAllocation(jsbytecode *target) /* State must be synced at exception and switch targets, and at traps. */ #ifdef DEBUG if (IsJaegerSpewChannelActive(JSpew_Regalloc)) { - JaegerSpew(JSpew_Regalloc, "allocation at %u:", target - a->script->code); + JaegerSpew(JSpew_Regalloc, "allocation at %u:", unsigned(target - a->script->code)); dumpAllocation(alloc); } #endif @@ -635,7 +635,7 @@ FrameState::computeAllocation(jsbytecode *target) #ifdef DEBUG if (IsJaegerSpewChannelActive(JSpew_Regalloc)) { - JaegerSpew(JSpew_Regalloc, "allocation at %u:", target - a->script->code); + JaegerSpew(JSpew_Regalloc, "allocation at %u:", unsigned(target - a->script->code)); dumpAllocation(alloc); } #endif diff --git a/js/src/methodjit/MonoIC.cpp b/js/src/methodjit/MonoIC.cpp index 34e3dd7d6033..1db197b18f65 100644 --- a/js/src/methodjit/MonoIC.cpp +++ b/js/src/methodjit/MonoIC.cpp @@ -224,7 +224,7 @@ AttachSetGlobalNameStub(VMFrame &f, ic::SetGlobalNameIC *ic, JSObject *obj, cons Jump done = masm.jump(); JITScript *jit = f.jit(); - LinkerHelper linker(masm); + LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = linker.init(f.cx); if (!ep) return Lookup_Error; @@ -340,7 +340,7 @@ class EqualityICLinker : public LinkerHelper public: EqualityICLinker(Assembler &masm, VMFrame &f) - : LinkerHelper(masm), f(f) + : LinkerHelper(masm, JSC::METHOD_CODE), f(f) { } bool init(JSContext *cx) { @@ -701,7 +701,7 @@ class CallCompiler : public BaseCompiler masm.load32(FrameAddress(offsetof(VMFrame, u.call.dynamicArgc)), JSParamReg_Argc); masm.jump(t0); - LinkerHelper linker(masm); + LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = poolForSize(linker, CallICInfo::Pool_ScriptStub); if (!ep) return false; @@ -718,7 +718,7 @@ class CallCompiler : public BaseCompiler (unsigned long) masm.size()); if (f.regs.inlined()) { - JSC::LinkBuffer code((uint8 *) cs.executableAddress(), masm.size()); + JSC::LinkBuffer code((uint8 *) cs.executableAddress(), masm.size(), JSC::METHOD_CODE); code.patch(inlined, f.regs.inlined()); } @@ -783,7 +783,7 @@ class CallCompiler : public BaseCompiler Jump funGuard = masm.branchPtr(Assembler::NotEqual, t0, ImmPtr(fun)); Jump done = masm.jump(); - LinkerHelper linker(masm); + LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = poolForSize(linker, CallICInfo::Pool_ClosureStub); if (!ep) return false; @@ -1037,7 +1037,7 @@ class CallCompiler : public BaseCompiler masm.storePtr(ImmPtr(NULL), FrameAddress(offsetof(VMFrame, stubRejoin))); masm.throwInJIT(); - LinkerHelper linker(masm); + LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = poolForSize(linker, CallICInfo::Pool_NativeStub); if (!ep) THROWV(true); @@ -1336,7 +1336,7 @@ ic::GenerateArgumentCheckStub(VMFrame &f) Jump done = masm.jump(); - LinkerHelper linker(masm); + LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = linker.init(f.cx); if (!ep) return; diff --git a/js/src/methodjit/PolyIC.cpp b/js/src/methodjit/PolyIC.cpp index b26682bbd072..7576e2cf5752 100644 --- a/js/src/methodjit/PolyIC.cpp +++ b/js/src/methodjit/PolyIC.cpp @@ -122,7 +122,7 @@ class PICLinker : public LinkerHelper public: PICLinker(Assembler &masm, ic::BasePolyIC &ic) - : LinkerHelper(masm), ic(ic) + : LinkerHelper(masm, JSC::METHOD_CODE), ic(ic) { } bool init(JSContext *cx) { @@ -2978,7 +2978,7 @@ SetElementIC::attachHoleStub(JSContext *cx, JSObject *obj, int32 keyval) JS_ASSERT(!execPool); JS_ASSERT(!inlineHoleGuardPatched); - LinkerHelper buffer(masm); + LinkerHelper buffer(masm, JSC::METHOD_CODE); execPool = buffer.init(cx); if (!execPool) return error(cx); @@ -3059,7 +3059,7 @@ SetElementIC::attachTypedArray(JSContext *cx, JSObject *obj, int32 key) // by a GC or shape regenerated GC. We let this stub live for the lifetime // of the script. JS_ASSERT(!execPool); - LinkerHelper buffer(masm); + LinkerHelper buffer(masm, JSC::METHOD_CODE); execPool = buffer.init(cx); if (!execPool) return error(cx); diff --git a/js/src/methodjit/StubCalls.cpp b/js/src/methodjit/StubCalls.cpp index 3adf6878ea57..752680127f99 100644 --- a/js/src/methodjit/StubCalls.cpp +++ b/js/src/methodjit/StubCalls.cpp @@ -1481,28 +1481,23 @@ stubs::RegExp(VMFrame &f, JSObject *regex) } JSObject * JS_FASTCALL -stubs::LambdaForInit(VMFrame &f, JSFunction *fun) +stubs::LambdaJoinableForInit(VMFrame &f, JSFunction *fun) { - JSObject *obj = fun; jsbytecode *nextpc = (jsbytecode *) f.scratch; - if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { - fun->setMethodAtom(f.script()->getAtom(GET_SLOTNO(nextpc))); - return obj; - } - return Lambda(f, fun); + JS_ASSERT(fun->joinable()); + fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(nextpc))); + return fun; } JSObject * JS_FASTCALL -stubs::LambdaForSet(VMFrame &f, JSFunction *fun) +stubs::LambdaJoinableForSet(VMFrame &f, JSFunction *fun) { - JSObject *obj = fun; + JS_ASSERT(fun->joinable()); jsbytecode *nextpc = (jsbytecode *) f.scratch; - if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { - const Value &lref = f.regs.sp[-1]; - if (lref.isObject() && lref.toObject().canHaveMethodBarrier()) { - fun->setMethodAtom(f.script()->getAtom(GET_SLOTNO(nextpc))); - return obj; - } + const Value &lref = f.regs.sp[-1]; + if (lref.isObject() && lref.toObject().canHaveMethodBarrier()) { + fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(nextpc))); + return fun; } return Lambda(f, fun); } @@ -1510,36 +1505,34 @@ stubs::LambdaForSet(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun) { - JSObject *obj = fun; + JS_ASSERT(fun->joinable()); jsbytecode *nextpc = (jsbytecode *) f.scratch; - if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { - /* - * Array.prototype.sort and String.prototype.replace are - * optimized as if they are special form. We know that they - * won't leak the joined function object in obj, therefore - * we don't need to clone that compiler- created function - * object for identity/mutation reasons. - */ - int iargc = GET_ARGC(nextpc); - /* - * Note that we have not yet pushed obj as the final argument, - * so regs.sp[1 - (iargc + 2)], and not regs.sp[-(iargc + 2)], - * is the callee for this JSOP_CALL. - */ - const Value &cref = f.regs.sp[1 - (iargc + 2)]; - JSObject *callee; + /* + * Array.prototype.sort and String.prototype.replace are optimized as if + * they are special form. We know that they won't leak the joined function + * object fun, therefore we don't need to clone that compiler-created + * function object for identity/mutation reasons. + */ + int iargc = GET_ARGC(nextpc); - if (IsFunctionObject(cref, &callee)) { - JSFunction *calleeFun = callee->getFunctionPrivate(); - Native native = calleeFun->maybeNative(); + /* + * Note that we have not yet pushed fun as the final argument, so + * regs.sp[1 - (iargc + 2)], and not regs.sp[-(iargc + 2)], is the callee + * for this JSOP_CALL. + */ + const Value &cref = f.regs.sp[1 - (iargc + 2)]; + JSObject *callee; - if (native) { - if (iargc == 1 && native == array_sort) - return obj; - if (iargc == 2 && native == str_replace) - return obj; - } + if (IsFunctionObject(cref, &callee)) { + JSFunction *calleeFun = callee->getFunctionPrivate(); + Native native = calleeFun->maybeNative(); + + if (native) { + if (iargc == 1 && native == array_sort) + return fun; + if (iargc == 2 && native == str_replace) + return fun; } } return Lambda(f, fun); @@ -1548,23 +1541,13 @@ stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun) JSObject * JS_FASTCALL stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun) { - JSObject *obj = fun; - jsbytecode *nextpc = (jsbytecode *) f.scratch; - if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) { - jsbytecode *pc2 = nextpc + JSOP_NULL_LENGTH; - JSOp op2 = JSOp(*pc2); - - if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) - return obj; - } - return Lambda(f, fun); + JS_ASSERT(fun->joinable()); + return fun; } JSObject * JS_FASTCALL stubs::Lambda(VMFrame &f, JSFunction *fun) { - JSObject *obj = fun; - JSObject *parent; if (fun->isNullClosure()) { parent = &f.fp()->scopeChain(); @@ -1574,7 +1557,7 @@ stubs::Lambda(VMFrame &f, JSFunction *fun) THROWV(NULL); } - obj = CloneFunctionObject(f.cx, fun, parent, true); + JSObject *obj = CloneFunctionObject(f.cx, fun, parent, true); if (!obj) THROWV(NULL); diff --git a/js/src/methodjit/StubCalls.h b/js/src/methodjit/StubCalls.h index 3fdecfb35839..a59a77ba2bad 100644 --- a/js/src/methodjit/StubCalls.h +++ b/js/src/methodjit/StubCalls.h @@ -156,8 +156,8 @@ JSObject * JS_FASTCALL DefLocalFun(VMFrame &f, JSFunction *fun); JSObject * JS_FASTCALL DefLocalFun_FC(VMFrame &f, JSFunction *fun); JSObject * JS_FASTCALL RegExp(VMFrame &f, JSObject *regex); JSObject * JS_FASTCALL Lambda(VMFrame &f, JSFunction *fun); -JSObject * JS_FASTCALL LambdaForInit(VMFrame &f, JSFunction *fun); -JSObject * JS_FASTCALL LambdaForSet(VMFrame &f, JSFunction *fun); +JSObject * JS_FASTCALL LambdaJoinableForInit(VMFrame &f, JSFunction *fun); +JSObject * JS_FASTCALL LambdaJoinableForSet(VMFrame &f, JSFunction *fun); JSObject * JS_FASTCALL LambdaJoinableForCall(VMFrame &f, JSFunction *fun); JSObject * JS_FASTCALL LambdaJoinableForNull(VMFrame &f, JSFunction *fun); JSObject * JS_FASTCALL FlatLambda(VMFrame &f, JSFunction *fun); diff --git a/js/src/methodjit/StubCompiler.cpp b/js/src/methodjit/StubCompiler.cpp index a42726d1fddd..aa0c5dc27bba 100644 --- a/js/src/methodjit/StubCompiler.cpp +++ b/js/src/methodjit/StubCompiler.cpp @@ -209,8 +209,8 @@ StubCompiler::emitStubCall(void *ptr, RejoinState rejoin, int32 slots) void StubCompiler::fixCrossJumps(uint8 *ncode, size_t offset, size_t total) { - JSC::LinkBuffer fast(ncode, total); - JSC::LinkBuffer slow(ncode + offset, total - offset); + JSC::LinkBuffer fast(ncode, total, JSC::METHOD_CODE); + JSC::LinkBuffer slow(ncode + offset, total - offset, JSC::METHOD_CODE); for (size_t i = 0; i < exits.length(); i++) fast.link(exits[i].from, slow.locationOf(exits[i].to)); diff --git a/js/src/methodjit/TrampolineCompiler.cpp b/js/src/methodjit/TrampolineCompiler.cpp index eb8a34929afb..141b4a4dbccc 100644 --- a/js/src/methodjit/TrampolineCompiler.cpp +++ b/js/src/methodjit/TrampolineCompiler.cpp @@ -41,6 +41,7 @@ #include "TrampolineCompiler.h" #include "StubCalls.h" #include "assembler/assembler/LinkBuffer.h" +#include "assembler/jit/ExecutableAllocator.h" namespace js { namespace mjit { @@ -96,7 +97,7 @@ TrampolineCompiler::compileTrampoline(Trampolines::TrampolinePtr *where, JS_ASSERT(entry.isSet()); bool ok; - JSC::LinkBuffer buffer(&masm, execAlloc, poolp, &ok); + JSC::LinkBuffer buffer(&masm, execAlloc, poolp, &ok, JSC::METHOD_CODE); if (!ok) return false; masm.finalize(buffer); diff --git a/js/src/nanojit/NativeX64.cpp b/js/src/nanojit/NativeX64.cpp index 18e6ba1321a2..fc0e70b498b4 100644 --- a/js/src/nanojit/NativeX64.cpp +++ b/js/src/nanojit/NativeX64.cpp @@ -493,7 +493,7 @@ namespace nanojit void Assembler::CVTSQ2SD(R l, R r) { emitprr(X64_cvtsq2sd,l,r); asm_output("cvtsq2sd %s, %s",RQ(l),RQ(r)); } void Assembler::CVTSI2SD(R l, R r) { emitprr(X64_cvtsi2sd,l,r); asm_output("cvtsi2sd %s, %s",RQ(l),RL(r)); } void Assembler::CVTSS2SD(R l, R r) { emitprr(X64_cvtss2sd,l,r); asm_output("cvtss2sd %s, %s",RQ(l),RL(r)); } - void Assembler::CVTSD2SS(R l, R r) { emitprr(X64_cvtsd2ss,l,r); asm_output("cvtsd2ss %s, %s",RL(l),RQ(r)); } + void Assembler::CVTSD2SS(R l, R r) { emitprr(X64_cvtsd2ss,l,r); asm_output("cvtsd2ss %s, %s",RQ(l),RQ(r)); } void Assembler::CVTSD2SI(R l, R r) { emitprr(X64_cvtsd2si,l,r); asm_output("cvtsd2si %s, %s",RL(l),RQ(r)); } void Assembler::CVTTSD2SI(R l, R r) { emitprr(X64_cvttsd2si,l,r);asm_output("cvttsd2si %s, %s",RL(l),RQ(r));} void Assembler::UCOMISD( R l, R r) { emitprr(X64_ucomisd, l,r); asm_output("ucomisd %s, %s", RQ(l),RQ(r)); } @@ -1727,9 +1727,12 @@ namespace nanojit break; } case LIR_std2f: { - Register b = getBaseReg(base, d, BaseRegs); Register r = findRegFor(value, FpRegs); Register t = registerAllocTmp(FpRegs & ~rmask(r)); + // Here, it is safe to call getBaseReg after registerAllocTmp + // because BaseRegs does not overlap with FpRegs, so getBaseReg + // will not allocate register |t|. + Register b = getBaseReg(base, d, BaseRegs); MOVSSMR(t, d, b); // store CVTSD2SS(t, r); // cvt to single-precision diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 5b8185dc1fe7..f038a7c3d580 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -2666,11 +2666,16 @@ static JSBool Clear(JSContext *cx, uintN argc, jsval *vp) { JSObject *obj; - if (argc != 0 && !JS_ValueToObject(cx, JS_ARGV(cx, vp)[0], &obj)) - return JS_FALSE; + if (argc == 0) { + obj = JS_GetGlobalForScopeChain(cx); + if (!obj) + return false; + } else if (!JS_ValueToObject(cx, JS_ARGV(cx, vp)[0], &obj)) { + return false; + } JS_ClearScope(cx, obj); JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; + return true; } static JSBool @@ -4037,9 +4042,12 @@ MJitCodeStats(JSContext *cx, uintN argc, jsval *vp) #ifdef JS_METHODJIT JSRuntime *rt = cx->runtime; AutoLockGC lock(rt); - size_t n = 0; + size_t n = 0, method, regexp, unused; for (JSCompartment **c = rt->compartments.begin(); c != rt->compartments.end(); ++c) - n += (*c)->getMjitCodeSize(); + { + (*c)->getMjitCodeStats(method, regexp, unused); + n += method + regexp + unused; + } JS_SET_RVAL(cx, vp, INT_TO_JSVAL(n)); #else JS_SET_RVAL(cx, vp, JSVAL_VOID); diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index bf3a80e90ae4..6536a9470c72 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -1051,12 +1051,8 @@ StackIter::settleOnNewState() if (op == JSOP_CALL || op == JSOP_FUNCALL) { uintN argc = GET_ARGC(pc_); DebugOnly spoff = sp_ - fp_->base(); -#ifdef DEBUG - if (cx_->stackIterAssertionEnabled) { - JS_ASSERT_IF(!fp_->hasImacropc(), - spoff == js_ReconstructStackDepth(cx_, fp_->script(), pc_)); - } -#endif + JS_ASSERT_IF(cx_->stackIterAssertionEnabled && !fp_->hasImacropc(), + spoff == js_ReconstructStackDepth(cx_, fp_->script(), pc_)); Value *vp = sp_ - (2 + argc); CrashIfInvalidSlot(fp_, vp); diff --git a/js/src/xpconnect/src/xpccomponents.cpp b/js/src/xpconnect/src/xpccomponents.cpp index 2c1513eb8e4c..db5f796898d9 100644 --- a/js/src/xpconnect/src/xpccomponents.cpp +++ b/js/src/xpconnect/src/xpccomponents.cpp @@ -1637,7 +1637,7 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponents_ID) #define XPC_MAP_WANT_CALL #define XPC_MAP_WANT_CONSTRUCT #define XPC_MAP_WANT_HASINSTANCE -#define XPC_MAP_FLAGS 0 +#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE #include "xpc_map_end.h" /* This will #undef the above */ @@ -1865,7 +1865,7 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponents_Exception) #define XPC_MAP_WANT_CALL #define XPC_MAP_WANT_CONSTRUCT #define XPC_MAP_WANT_HASINSTANCE -#define XPC_MAP_FLAGS 0 +#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE #include "xpc_map_end.h" /* This will #undef the above */ @@ -2426,7 +2426,7 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponents_Constructor) #define XPC_MAP_WANT_CALL #define XPC_MAP_WANT_CONSTRUCT #define XPC_MAP_WANT_HASINSTANCE -#define XPC_MAP_FLAGS 0 +#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE #include "xpc_map_end.h" /* This will #undef the above */ @@ -2757,6 +2757,13 @@ nsXPCComponents_Utils::LookupMethod() return NS_ERROR_XPC_BAD_CONVERT_JS; JSObject* obj = JSVAL_TO_OBJECT(argv[0]); + while(obj && !obj->isWrapper() && !IS_WRAPPER_CLASS(obj->getClass())) + obj = JS_GetPrototype(cx, obj); + + if(!obj) + return NS_ERROR_XPC_BAD_CONVERT_JS; + + argv[0] = OBJECT_TO_JSVAL(obj); rv = nsXPConnect::GetXPConnect()->GetJSObjectOfWrapper(cx, obj, &obj); if(NS_FAILED(rv)) return rv; diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index f1a2342cf40a..961704a0fd6b 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -1265,10 +1265,11 @@ GetCompartmentScriptsSize(JSCompartment *c) #ifdef JS_METHODJIT -PRInt64 -GetCompartmentMjitCodeSize(JSCompartment *c) +void +GetCompartmentMjitCodeStats(JSCompartment *c, size_t& method, size_t& regexp, + size_t& unused) { - return c->getMjitCodeSize(); + c->getMjitCodeStats(method, regexp, unused); } PRInt64 @@ -1339,7 +1340,11 @@ CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment) // Get the compartment-level numbers. curr->scripts = GetCompartmentScriptsSize(compartment); #ifdef JS_METHODJIT - curr->mjitCode = GetCompartmentMjitCodeSize(compartment); + size_t method, regexp, unused; + GetCompartmentMjitCodeStats(compartment, method, regexp, unused); + curr->mjitCodeMethod = method; + curr->mjitCodeRegexp = regexp; + curr->mjitCodeUnused = unused; curr->mjitData = GetCompartmentMjitDataSize(compartment); #endif #ifdef JS_TRACER @@ -1799,11 +1804,24 @@ ReportCompartmentStats(const CompartmentStats &stats, #ifdef JS_METHODJIT ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, - "mjit-code"), - nsIMemoryReporter::KIND_NONHEAP, stats.mjitCode, + "mjit-code/method"), + nsIMemoryReporter::KIND_NONHEAP, stats.mjitCodeMethod, "Memory used by the method JIT to hold the compartment's generated code.", callback, closure); + ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, + "mjit-code/regexp"), + nsIMemoryReporter::KIND_NONHEAP, stats.mjitCodeRegexp, + "Memory used by the regexp JIT to hold the compartment's generated code.", + callback, closure); + + ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, + "mjit-code/unused"), + nsIMemoryReporter::KIND_NONHEAP, stats.mjitCodeUnused, + "Memory allocated by the method and/or regexp JIT to hold the " + "compartment's code, but which is currently unused.", + callback, closure); + ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, "mjit-data"), nsIMemoryReporter::KIND_HEAP, stats.mjitData, diff --git a/js/src/xpconnect/src/xpcpublic.h b/js/src/xpconnect/src/xpcpublic.h index 71c3cf4b9eb0..d6ea915558b0 100644 --- a/js/src/xpconnect/src/xpcpublic.h +++ b/js/src/xpconnect/src/xpcpublic.h @@ -213,7 +213,9 @@ struct CompartmentStats PRInt64 scripts; #ifdef JS_METHODJIT - PRInt64 mjitCode; + PRInt64 mjitCodeMethod; + PRInt64 mjitCodeRegexp; + PRInt64 mjitCodeUnused; PRInt64 mjitData; #endif #ifdef JS_TRACER diff --git a/js/src/xpconnect/tests/chrome/Makefile.in b/js/src/xpconnect/tests/chrome/Makefile.in index df534dd35368..6c2ed11f4cd7 100644 --- a/js/src/xpconnect/tests/chrome/Makefile.in +++ b/js/src/xpconnect/tests/chrome/Makefile.in @@ -51,6 +51,7 @@ _CHROME_FILES = \ test_bug533596.xul \ test_doublewrappedcompartments.xul \ test_evalInSandbox.xul \ + file_evalInSandbox.html \ test_sandboxImport.xul \ test_wrappers.xul \ test_bug484459.xul \ @@ -68,7 +69,7 @@ _CHROME_FILES = \ test_bug658560.xul \ test_APIExposer.xul \ test_bug664689.xul \ - test_precisegc.xul \ + test_precisegc.xul \ $(NULL) # Disabled until this test gets updated to test the new proxy based diff --git a/js/src/xpconnect/tests/chrome/file_evalInSandbox.html b/js/src/xpconnect/tests/chrome/file_evalInSandbox.html new file mode 100644 index 000000000000..fb58f2bb411a --- /dev/null +++ b/js/src/xpconnect/tests/chrome/file_evalInSandbox.html @@ -0,0 +1 @@ + diff --git a/js/src/xpconnect/tests/chrome/test_evalInSandbox.xul b/js/src/xpconnect/tests/chrome/test_evalInSandbox.xul index cc957b76e103..0ec19727c765 100644 --- a/js/src/xpconnect/tests/chrome/test_evalInSandbox.xul +++ b/js/src/xpconnect/tests/chrome/test_evalInSandbox.xul @@ -13,12 +13,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596 - - diff --git a/js/src/yarr/YarrJIT.cpp b/js/src/yarr/YarrJIT.cpp index 323364df3034..9cdfbd4bb112 100644 --- a/js/src/yarr/YarrJIT.cpp +++ b/js/src/yarr/YarrJIT.cpp @@ -2397,7 +2397,7 @@ public: // XXX yarr-oom ExecutablePool *pool; bool ok; - LinkBuffer linkBuffer(this, globalData->regexAllocator, &pool, &ok); + LinkBuffer linkBuffer(this, globalData->regexAllocator, &pool, &ok, REGEXP_CODE); m_backtrackingState.linkDataLabels(linkBuffer); jitObject.set(linkBuffer.finalizeCode()); jitObject.setFallBack(m_shouldFallBack); diff --git a/layout/reftests/border-radius/reftest.list b/layout/reftests/border-radius/reftest.list index b2aa05d5b73f..2a244d4e0d3e 100644 --- a/layout/reftests/border-radius/reftest.list +++ b/layout/reftests/border-radius/reftest.list @@ -37,7 +37,7 @@ random == corner-2.html corner-2-ref.svg # right corners different radius than l fails == clipping-1.html clipping-1-ref.html # background color should completely fill box; bug 466572 != clipping-2.html about:blank # background color clipped to inner/outer border, can't get # great tests for this due to antialiasing problems described in bug 466572 -== clipping-3.html clipping-3-ref.xhtml # edge of border-radius clips an underlying object's background, Android failure is bug 650569 +== clipping-3.html clipping-3-ref.xhtml # edge of border-radius clips an underlying object's background # Tests for clipping the contents of replaced elements and overflow!=visible != clipping-4-ref.html clipping-4-notref.html diff --git a/layout/reftests/image-element/reftest.list b/layout/reftests/image-element/reftest.list index d4bf5aff13d9..bbed68f04745 100644 --- a/layout/reftests/image-element/reftest.list +++ b/layout/reftests/image-element/reftest.list @@ -16,7 +16,7 @@ random-if(d2d) == element-paint-transform-02.html element-paint-transform-02-ref == element-paint-background-size-02.html element-paint-background-size-02-ref.html == element-paint-transform-repeated.html element-paint-transform-repeated-ref.html == element-paint-transform-03.html element-paint-transform-03-ref.html -== element-paint-native-widget.html element-paint-native-widget-ref.html # bug 650589 +== element-paint-native-widget.html element-paint-native-widget-ref.html == element-paint-subimage-sampling-restriction.html about:blank == element-paint-clippath.html element-paint-clippath-ref.html == element-paint-sharpness-01a.html element-paint-sharpness-01b.html diff --git a/layout/reftests/reftest.list b/layout/reftests/reftest.list index ea30982b5269..87b7fe969430 100644 --- a/layout/reftests/reftest.list +++ b/layout/reftests/reftest.list @@ -273,6 +273,9 @@ include text-transform/reftest.list # -moz-transform/ include transform/reftest.list +# 3d transforms - disabled currently +#include transform-3d/reftest.list + # unicode/ (verify that we don't do expend effort doing unicode-aware case checks) include unicode/reftest.list diff --git a/layout/reftests/transform-3d/backface-visibility-1a.html b/layout/reftests/transform-3d/backface-visibility-1a.html new file mode 100644 index 000000000000..0c1d0a3a64e9 --- /dev/null +++ b/layout/reftests/transform-3d/backface-visibility-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/backface-visibility-1b.html b/layout/reftests/transform-3d/backface-visibility-1b.html new file mode 100644 index 000000000000..8590a6f60092 --- /dev/null +++ b/layout/reftests/transform-3d/backface-visibility-1b.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/matrix3d-1-ref.html b/layout/reftests/transform-3d/matrix3d-1-ref.html new file mode 100644 index 000000000000..fac2def083b3 --- /dev/null +++ b/layout/reftests/transform-3d/matrix3d-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/matrix3d-1a.html b/layout/reftests/transform-3d/matrix3d-1a.html new file mode 100644 index 000000000000..5f9798368dd0 --- /dev/null +++ b/layout/reftests/transform-3d/matrix3d-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/matrix3d-2-ref.html b/layout/reftests/transform-3d/matrix3d-2-ref.html new file mode 100644 index 000000000000..628bb934b629 --- /dev/null +++ b/layout/reftests/transform-3d/matrix3d-2-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/matrix3d-2a.html b/layout/reftests/transform-3d/matrix3d-2a.html new file mode 100644 index 000000000000..a101d8094c02 --- /dev/null +++ b/layout/reftests/transform-3d/matrix3d-2a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/perspective-origin-1a.html b/layout/reftests/transform-3d/perspective-origin-1a.html new file mode 100644 index 000000000000..c918e05bafd4 --- /dev/null +++ b/layout/reftests/transform-3d/perspective-origin-1a.html @@ -0,0 +1,11 @@ + + + + +
+
+ Test Text +
+
+ + diff --git a/layout/reftests/transform-3d/perspective-origin-1b.html b/layout/reftests/transform-3d/perspective-origin-1b.html new file mode 100644 index 000000000000..ee934dec1392 --- /dev/null +++ b/layout/reftests/transform-3d/perspective-origin-1b.html @@ -0,0 +1,11 @@ + + + + +
+
+ Test Text +
+
+ + diff --git a/layout/reftests/transform-3d/preserve3d-1-ref.html b/layout/reftests/transform-3d/preserve3d-1-ref.html new file mode 100644 index 000000000000..2c8803171f63 --- /dev/null +++ b/layout/reftests/transform-3d/preserve3d-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/preserve3d-1a.html b/layout/reftests/transform-3d/preserve3d-1a.html new file mode 100644 index 000000000000..f099f4e22c48 --- /dev/null +++ b/layout/reftests/transform-3d/preserve3d-1a.html @@ -0,0 +1,15 @@ + + + + +
+
+
+
+ Test Text +
+
+
+
+ + diff --git a/layout/reftests/transform-3d/preserve3d-1b.html b/layout/reftests/transform-3d/preserve3d-1b.html new file mode 100644 index 000000000000..ef535fcce62d --- /dev/null +++ b/layout/reftests/transform-3d/preserve3d-1b.html @@ -0,0 +1,11 @@ + + + + +
+
+ Test Text +
+
+ + diff --git a/layout/reftests/transform-3d/reftest.list b/layout/reftests/transform-3d/reftest.list new file mode 100644 index 000000000000..837e6afa6f23 --- /dev/null +++ b/layout/reftests/transform-3d/reftest.list @@ -0,0 +1,27 @@ +== rotatey-1a.html rotatey-1-ref.html +== rotatex-1a.html rotatex-1-ref.html +# Check that scaleZ(-1) rotateX(180deg) is the same as rotateY(180deg) +== scalezrotatex-1.html scalezrotatex-1-ref.html +# Check that the perspectve() transform function results in some visual changes +!= rotatex-perspective-1a.html rotatex-1-ref.html +# Check that -moz-perspective results in visual changes to child transformed elements +!= rotatex-perspective-1b.html rotatex-1-ref.html +# -moz-perspective should only apply to child elements +== rotatex-perspective-1c.html rotatex-1-ref.html +== scalez-1a.html scalez-1-ref.html +fails == preserve3d-1a.html preserve3d-1-ref.html +== preserve3d-1b.html about:blank +== scale3d-z.html scalez-1-ref.html +== scale3d-all.html scale3d-1-ref.html +== scale3d-xz.html scale3d-2-ref.html +== translatez-1a.html translatez-1-ref.html +!= translatez-1b.html translatez-1-ref.html +== translate3d-1a.html translate3d-1-ref.html +== matrix3d-1a.html matrix3d-1-ref.html +== matrix3d-2a.html matrix3d-2-ref.html +== rotate3d-1a.html rotatex-1-ref.html +== rotate3d-2a.html rotatey-1-ref.html +!= backface-visibility-1a.html about:blank +== backface-visibility-1b.html about:blank +!= perspective-origin-1a.html rotatex-perspective-1a.html +== perspective-origin-1b.html perspective-origin-1a.html diff --git a/layout/reftests/transform-3d/rotate3d-1a.html b/layout/reftests/transform-3d/rotate3d-1a.html new file mode 100644 index 000000000000..ba2d222e466c --- /dev/null +++ b/layout/reftests/transform-3d/rotate3d-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotate3d-2a.html b/layout/reftests/transform-3d/rotate3d-2a.html new file mode 100644 index 000000000000..edf3c1be4b52 --- /dev/null +++ b/layout/reftests/transform-3d/rotate3d-2a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatex-1-ref.html b/layout/reftests/transform-3d/rotatex-1-ref.html new file mode 100644 index 000000000000..0ee28cfe8054 --- /dev/null +++ b/layout/reftests/transform-3d/rotatex-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatex-1a.html b/layout/reftests/transform-3d/rotatex-1a.html new file mode 100644 index 000000000000..f0c6b018385f --- /dev/null +++ b/layout/reftests/transform-3d/rotatex-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatex-perspective-1a.html b/layout/reftests/transform-3d/rotatex-perspective-1a.html new file mode 100644 index 000000000000..0b8671e7a01d --- /dev/null +++ b/layout/reftests/transform-3d/rotatex-perspective-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatex-perspective-1b.html b/layout/reftests/transform-3d/rotatex-perspective-1b.html new file mode 100644 index 000000000000..d8be199534ad --- /dev/null +++ b/layout/reftests/transform-3d/rotatex-perspective-1b.html @@ -0,0 +1,11 @@ + + + + +
+
+ Test Text +
+
+ + diff --git a/layout/reftests/transform-3d/rotatex-perspective-1c.html b/layout/reftests/transform-3d/rotatex-perspective-1c.html new file mode 100644 index 000000000000..9cae306962b4 --- /dev/null +++ b/layout/reftests/transform-3d/rotatex-perspective-1c.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatey-1-ref.html b/layout/reftests/transform-3d/rotatey-1-ref.html new file mode 100644 index 000000000000..0b3339824ca9 --- /dev/null +++ b/layout/reftests/transform-3d/rotatey-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/rotatey-1a.html b/layout/reftests/transform-3d/rotatey-1a.html new file mode 100644 index 000000000000..359105b01ee2 --- /dev/null +++ b/layout/reftests/transform-3d/rotatey-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scale3d-1-ref.html b/layout/reftests/transform-3d/scale3d-1-ref.html new file mode 100644 index 000000000000..1c0fe5014554 --- /dev/null +++ b/layout/reftests/transform-3d/scale3d-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scale3d-2-ref.html b/layout/reftests/transform-3d/scale3d-2-ref.html new file mode 100644 index 000000000000..664d1d4f35bf --- /dev/null +++ b/layout/reftests/transform-3d/scale3d-2-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scale3d-all.html b/layout/reftests/transform-3d/scale3d-all.html new file mode 100644 index 000000000000..afe4639aa3ee --- /dev/null +++ b/layout/reftests/transform-3d/scale3d-all.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scale3d-xz.html b/layout/reftests/transform-3d/scale3d-xz.html new file mode 100644 index 000000000000..81d090979468 --- /dev/null +++ b/layout/reftests/transform-3d/scale3d-xz.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scale3d-z.html b/layout/reftests/transform-3d/scale3d-z.html new file mode 100644 index 000000000000..e168dabc246e --- /dev/null +++ b/layout/reftests/transform-3d/scale3d-z.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scalez-1-ref.html b/layout/reftests/transform-3d/scalez-1-ref.html new file mode 100644 index 000000000000..6efdc2681bd1 --- /dev/null +++ b/layout/reftests/transform-3d/scalez-1-ref.html @@ -0,0 +1,10 @@ + + + + +
+ Test Text +
+ + + diff --git a/layout/reftests/transform-3d/scalez-1a.html b/layout/reftests/transform-3d/scalez-1a.html new file mode 100644 index 000000000000..5661addc1681 --- /dev/null +++ b/layout/reftests/transform-3d/scalez-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scalezrotatex-1-ref.html b/layout/reftests/transform-3d/scalezrotatex-1-ref.html new file mode 100644 index 000000000000..2f250fd78601 --- /dev/null +++ b/layout/reftests/transform-3d/scalezrotatex-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/scalezrotatex-1.html b/layout/reftests/transform-3d/scalezrotatex-1.html new file mode 100644 index 000000000000..2cc10c840579 --- /dev/null +++ b/layout/reftests/transform-3d/scalezrotatex-1.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/translate3d-1-ref.html b/layout/reftests/transform-3d/translate3d-1-ref.html new file mode 100644 index 000000000000..da16f712fa45 --- /dev/null +++ b/layout/reftests/transform-3d/translate3d-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/translate3d-1a.html b/layout/reftests/transform-3d/translate3d-1a.html new file mode 100644 index 000000000000..418d1278694f --- /dev/null +++ b/layout/reftests/transform-3d/translate3d-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/translatez-1-ref.html b/layout/reftests/transform-3d/translatez-1-ref.html new file mode 100644 index 000000000000..81e1bab2f9b4 --- /dev/null +++ b/layout/reftests/transform-3d/translatez-1-ref.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/translatez-1a.html b/layout/reftests/transform-3d/translatez-1a.html new file mode 100644 index 000000000000..a19a128b2692 --- /dev/null +++ b/layout/reftests/transform-3d/translatez-1a.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/reftests/transform-3d/translatez-1b.html b/layout/reftests/transform-3d/translatez-1b.html new file mode 100644 index 000000000000..7e6f1dead100 --- /dev/null +++ b/layout/reftests/transform-3d/translatez-1b.html @@ -0,0 +1,9 @@ + + + + +
+ Test Text +
+ + diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 9aa1978a73c9..0a25ef7c90f2 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -939,7 +939,9 @@ var gCSSProperties = { "translate(-moz-calc(5px - 3 * 10%), 50px)", "translate(-50px, -moz-calc(5px - 10% * 3))", "matrix(1, 0, 0, 1, -moz-calc(5px * 3), -moz-calc(10% - 3px))" - ], + ].concat(SpecialPowers.getBoolPref("layout.3d-transforms.enabled") ? [ + "translatez(1px)", "translatez(4em)", "translatez(-4px)", "translatez(0px)", "translatez(2px) translatez(5px)", "translate3d(3px, 4px, 5px)", "translate3d(2em, 3px, 1em)", "translatex(2px) translate3d(4px, 5px, 6px) translatey(1px)", "scale3d(4, 4, 4)", "scale3d(-2, 3, -7)", "scalez(4)", "scalez(-6)", "rotate3d(2, 3, 4, 45deg)", "rotate3d(-3, 7, 0, 12rad)", "rotatex(15deg)", "rotatey(-12grad)", "rotatez(72rad)", "perspective(1000px)", "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)" + ] : []), invalid_values: ["1px", "#0000ff", "red", "auto", "translatex(1px 1px)", "translatex(translatex(1px))", "translatex(#0000ff)", "translatex(red)", "translatey()", "matrix(1, 2, 3, 4, 5, 6)", "matrix(1px, 2px, 3px, 4px, 5px, 6px)", "scale(150%)", "skewx(red)", "matrix(1%, 0, 0, 0, 0px, 0px)", "matrix(0, 1%, 2, 3, 4px,5px)", "matrix(0, 1, 2%, 3, 4px, 5px)", "matrix(0, 1, 2, 3%, 4%, 5%)", /* invalid calc() values */ "translatey(-moz-min(5px,10%))", @@ -947,7 +949,9 @@ var gCSSProperties = { "translate(10px, -moz-calc(min(5px,10%)))", "translate(-moz-calc(max(5px,10%)), 10%)", "matrix(1, 0, 0, 1, -moz-max(5px * 3), -moz-calc(10% - 3px))" - ] + ].concat(SpecialPowers.getBoolPref("layout.3d-transforms.enabled") ? [ + "perspective(0px)", "perspective(-10px)", "matrix3d(dinosaur)", "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)", "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)", "rotatey(words)", "rotatex(7)", "translate3d(3px, 4px, 1px, 7px)" + ] : []) }, "-moz-transform-origin": { domProp: "MozTransformOrigin", diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index 5657b7d9a2a3..f9656484c7c8 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -349,6 +349,11 @@ function get_distance(prop, v1, v2) .computeAnimationDistance(div, prop, v1, v2); } +function transform3D_enabled() +{ + return SpecialPowers.getBoolPref("layout.3d-transforms.enabled"); +} + function check_distance(prop, start, quarter, end) { var sq = get_distance(prop, start, quarter); @@ -1268,16 +1273,44 @@ function test_transform_transition(prop) { { start: 'none', end: 'rotate(360deg)', expected_uncomputed: 'rotate(90deg)', expected: c('rotate(90deg)') }, + { start: 'none', end: 'rotatez(360deg)', + expected_uncomputed: 'rotate(90deg)', + expected: c('rotate(90deg)'), + requires_3d: true }, { start: 'none', end: 'rotate(720deg)', expected_uncomputed: 'rotate(180deg)', expected: c('rotate(180deg)') }, + { start: 'none', end: 'rotate(720deg)', + expected_uncomputed: 'rotatez(180deg)', + expected: c('rotate(180deg)'), + requires_3d: true }, { start: 'none', end: 'rotate(1080deg)', expected_uncomputed: 'rotate(270deg)', expected: c('rotate(270deg)') }, + { start: 'none', end: 'rotate(1080deg)', + expected_uncomputed: 'rotate(270deg)', + expected: c('rotatez(270deg)'), + requires_3d: true }, { start: 'none', end: 'rotate(1440deg)', expected_uncomputed: 'rotate(360deg)', expected: c('scale(1)'), round_error_ok: true }, + { start: 'none', end: 'rotatey(60deg)', + expected_uncomputed: 'rotatey(15deg)', + expected: c('rotatey(15deg)'), + requires_3d: true }, + { start: 'none', end: 'rotatey(720deg)', + expected_uncomputed: 'rotatey(180deg)', + expected: c('rotatey(180deg)'), + requires_3d: true }, + { start: 'none', end: 'rotatex(60deg)', + expected_uncomputed: 'rotatex(15deg)', + expected: c('rotatex(15deg)'), + requires_3d: true }, + { start: 'none', end: 'rotatex(720deg)', + expected_uncomputed: 'rotatex(180deg)', + expected: c('rotatex(180deg)'), + requires_3d: true }, // translate { start: 'translate(20px)', end: 'none', @@ -1292,6 +1325,14 @@ function test_transform_transition(prop) { { start: 'translateY(-40px)', end: 'none', expected_uncomputed: 'translateY(-30px)', expected: 'matrix(1, 0, 0, 1, 0px, -30px)' }, + { start: 'translateZ(40px)', end: 'none', + expected_uncomputed: 'translateZ(30px)', + expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 30, 1)', + requires_3d: true }, + { start: 'none', end: 'translate3D(40px, 60px, -40px)', + expected_uncomputed: 'translate3D(10px, 15px, -10px)', + expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 15, -10, 1)', + requires_3d: true }, // percentages are relative to 300px (width) and 50px (height) // per the prerequisites in property_database.js { start: 'translate(20%)', end: 'none', @@ -1361,6 +1402,14 @@ function test_transform_transition(prop) { { start: 'scaleY(5)', end: 'none', expected_uncomputed: 'scaleY(4)', expected: 'matrix(1, 0, 0, 4, 0px, 0px)' }, + { start: 'scaleZ(5)', end: 'none', + expected_uncomputed: 'scaleZ(4)', + expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1)', + requires_3d: true }, + { start: 'none', end: 'scale3D(5, 5, 5)', + expected_uncomputed: 'scale3D(2, 2, 2)', + expected: 'matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)', + requires_3d: true }, // skew { start: 'skewX(45deg)', end: 'none', @@ -1521,6 +1570,9 @@ function test_transform_transition(prop) { for (var i in tests) { var test = tests[i]; + if (test.requires_3d && !transform3D_enabled()) { + continue; + } div.style.setProperty("-moz-transition-property", "none", ""); div.style.setProperty(prop, test.start, ""); cs.getPropertyValue(prop); diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 68c3300c9f95..3885a57c93c8 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -204,8 +204,8 @@ public: PRBool IsFirstInserted() const; void SetFirstInserted(PRBool aValue); - PRBool GetContentHeight() const; - void SetContentHeight(nscoord aTwipValue); + nscoord GetContentHeight() const; + void SetContentHeight(nscoord aTwipValue); PRBool HasStyleHeight() const; diff --git a/layout/xul/base/src/grid/reftests/reftest.list b/layout/xul/base/src/grid/reftests/reftest.list index 72ceac1e47c9..212c3112bdef 100644 --- a/layout/xul/base/src/grid/reftests/reftest.list +++ b/layout/xul/base/src/grid/reftests/reftest.list @@ -5,14 +5,14 @@ == row-or-column-sizing-1.xul row-or-column-sizing-4.xul == z-order-1.xul z-order-1-ref.xul == z-order-2.xul z-order-2-ref.xul -== not-full-basic.xul not-full-basic-ref.xhtml # bug 650597 -== not-full-grid-pack-align.xul not-full-basic-ref.xhtml # bug 650597 +== not-full-basic.xul not-full-basic-ref.xhtml +== not-full-grid-pack-align.xul not-full-basic-ref.xhtml == not-full-row-group-align.xul not-full-row-group-align-ref.xhtml # does anyone want/need this behavior? == not-full-row-group-pack.xul not-full-row-group-pack-ref.xhtml -== not-full-row-group-direction.xul not-full-row-group-direction-ref.xhtml # bug 650597 -== not-full-row-leaf-align.xul not-full-basic-ref.xhtml # bug 650597 -== not-full-row-leaf-pack.xul not-full-row-leaf-pack-ref.xhtml # bug 650597 -== not-full-row-leaf-direction.xul not-full-row-leaf-pack-ref.xhtml # bug 650597 +== not-full-row-group-direction.xul not-full-row-group-direction-ref.xhtml +== not-full-row-leaf-align.xul not-full-basic-ref.xhtml +== not-full-row-leaf-pack.xul not-full-row-leaf-pack-ref.xhtml +== not-full-row-leaf-direction.xul not-full-row-leaf-pack-ref.xhtml fails-if(Android) == scrollable-columns.xul scrollable-columns-ref.xhtml # bug 650597 fails == scrollable-rows.xul scrollable-rows-ref.xhtml == sizing-2d.xul sizing-2d-ref.xul diff --git a/memory/jemalloc/jemalloc.c b/memory/jemalloc/jemalloc.c index ecadadd54181..98bae833e597 100644 --- a/memory/jemalloc/jemalloc.c +++ b/memory/jemalloc/jemalloc.c @@ -1266,8 +1266,13 @@ static #endif bool malloc_init_hard(void); +#ifdef MOZ_MEMORY_ANDROID +void _malloc_prefork(void); +void _malloc_postfork(void); +#else static void _malloc_prefork(void); static void _malloc_postfork(void); +#endif #ifdef MOZ_MEMORY_DARWIN /* @@ -5606,6 +5611,8 @@ MALLOC_OUT: #if (!defined(MOZ_MEMORY_WINDOWS) && !defined(MOZ_MEMORY_DARWIN) && !defined(MOZ_MEMORY_ANDROID)) /* Prevent potential deadlock on malloc locks after fork. */ + /* XXX on Android there is no pthread_atfork, so we specifically + call _malloc_prefork and _malloc_postfork in process_util_linux.cc */ pthread_atfork(_malloc_prefork, _malloc_postfork, _malloc_postfork); #endif @@ -6436,7 +6443,11 @@ _msize(const void *ptr) * is threaded here. */ +#ifdef MOZ_MEMORY_ANDROID +void +#else static void +#endif _malloc_prefork(void) { unsigned i; @@ -6454,7 +6465,11 @@ _malloc_prefork(void) malloc_mutex_lock(&huge_mtx); } +#ifdef MOZ_MEMORY_ANDROID +void +#else static void +#endif _malloc_postfork(void) { unsigned i; diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index 14dcd2dd4d81..b9801e4c73c5 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -452,10 +452,15 @@ static int GetColorTableSize(BITMAPINFOHEADER* aHeader) } case 16: case 32: - if (aHeader->biCompression == BI_RGB) + // If we have BI_BITFIELDS compression, we would normally need 3 DWORDS for + // the bitfields mask which would be stored in the color table; However, + // we instead force the bitmap to request data of type BI_RGB so the color + // table should be of size 0. + // Setting aHeader->biCompression = BI_RGB forces the later call to + // GetDIBits to return to us BI_RGB data. + if (aHeader->biCompression == BI_BITFIELDS) + aHeader->biCompression = BI_RGB; colorTableSize = 0; - else if (aHeader->biCompression == BI_BITFIELDS) - colorTableSize = 3 * sizeof(DWORD); break; case 24: colorTableSize = 0; diff --git a/modules/libpr0n/decoders/nsBMPDecoder.cpp b/modules/libpr0n/decoders/nsBMPDecoder.cpp index c2b49127093b..7ea081982fd2 100644 --- a/modules/libpr0n/decoders/nsBMPDecoder.cpp +++ b/modules/libpr0n/decoders/nsBMPDecoder.cpp @@ -67,6 +67,7 @@ nsBMPDecoder::nsBMPDecoder() { mColors = nsnull; mRow = nsnull; + mImageData = nsnull; mCurPos = mPos = mNumColors = mRowBytes = 0; mOldLine = mCurLine = 1; // Otherwise decoder will never start mState = eRLEStateInitial; diff --git a/modules/libpr0n/decoders/nsICODecoder.cpp b/modules/libpr0n/decoders/nsICODecoder.cpp index 07563b74950a..f78a98b6c2ea 100644 --- a/modules/libpr0n/decoders/nsICODecoder.cpp +++ b/modules/libpr0n/decoders/nsICODecoder.cpp @@ -184,6 +184,15 @@ nsICODecoder::ExtractBPPFromBitmap(PRInt8 *bih) return bitsPerPixel; } +PRInt32 +nsICODecoder::ExtractBIHSizeFromBitmap(PRInt8 *bih) +{ + PRInt32 headerSize; + memcpy(&headerSize, bih, sizeof(headerSize)); + headerSize = LITTLE_TO_NATIVE32(headerSize); + return headerSize; +} + void nsICODecoder::SetHotSpotIfCursor() { if (!mIsCursor) { @@ -360,9 +369,16 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) // If we have a BMP inside the ICO and we have read the BIH header if (!mIsPNG && mPos == mImageOffset + BITMAPINFOSIZE) { + + // Make sure we have a sane value for the bitmap information header + PRInt32 bihSize = ExtractBIHSizeFromBitmap(reinterpret_cast(mBIHraw)); + if (bihSize != BITMAPINFOSIZE) { + PostDataError(); + return; + } // We are extracting the BPP from the BIH header as it should be trusted // over the one we have from the icon header - mBPP = ExtractBPPFromBitmap((PRInt8*)mBIHraw); + mBPP = ExtractBPPFromBitmap(reinterpret_cast(mBIHraw)); // Init the bitmap decoder which will do most of the work for us // It will do everything except the AND mask which isn't present in bitmaps @@ -400,6 +416,11 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) return; } + // We have the size. If we're doing a size decode, we got what + // we came for. + if (IsSizeDecode()) + return; + // Sometimes the ICO BPP header field is not filled out // so we should trust the contained resource over our own // information. @@ -487,7 +508,12 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) mCurLine--; mRowBytes = 0; - PRUint32* imageData = static_cast(mContainedDecoder.get())->GetImageData(); + PRUint32* imageData = + static_cast(mContainedDecoder.get())->GetImageData(); + if (!imageData) { + PostDataError(); + return; + } PRUint32* decoded = imageData + mCurLine * mDirEntry.mWidth; PRUint32* decoded_end = decoded + mDirEntry.mWidth; PRUint8* p = mRow, *p_end = mRow + rowSize; diff --git a/modules/libpr0n/decoders/nsICODecoder.h b/modules/libpr0n/decoders/nsICODecoder.h index 9e21ca69c6b0..ce1f2721b53f 100644 --- a/modules/libpr0n/decoders/nsICODecoder.h +++ b/modules/libpr0n/decoders/nsICODecoder.h @@ -73,6 +73,8 @@ private: PRBool FillBitmapFileHeaderBuffer(PRInt8 *bfh); // Fixes the height of a BMP information header field void FillBitmapInformationBufferHeight(PRInt8 *bih); + // Extract bitmap info header size count from BMP information header + PRInt32 ExtractBIHSizeFromBitmap(PRInt8 *bih); // Extract bit count from BMP information header PRInt32 ExtractBPPFromBitmap(PRInt8 *bih); // Calculates the row size in bytes for the AND mask table diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index aa98bbc7bb63..f9846d8efb35 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3346,4 +3346,4 @@ pref("alerts.totalOpenTime", 4000); pref("alerts.disableSlidingEffect", false); //3D Transforms -pref("layout.3d-transforms.enabled, false); +pref("layout.3d-transforms.enabled", false); diff --git a/modules/libreg/include/VerReg.h b/modules/libreg/include/VerReg.h index 0090d7277e4d..b6359e9909a2 100644 --- a/modules/libreg/include/VerReg.h +++ b/modules/libreg/include/VerReg.h @@ -94,7 +94,7 @@ VR_INTERFACE(REGERR) VR_UninstallDeleteFileFromList(char *component_path, char * VR_INTERFACE(REGERR) VR_UninstallDeleteSharedFilesKey(char *regPackageName); VR_INTERFACE(REGERR) VR_UninstallDestroy(char *regPackageName); VR_INTERFACE(REGERR) VR_EnumUninstall(REGENUM *state, char* userPackageName, - int32 len1, char*regPackageName, int32 len2, PRBool bSharedList); + int32 len1, char*regPackageName, int32 len2, XP_Bool bSharedList); VR_INTERFACE(REGERR) VR_GetUninstallUserName(char *regPackageName, char *outbuf, uint32 buflen); PR_END_EXTERN_C diff --git a/netwerk/base/src/nsAutodialWin.cpp b/netwerk/base/src/nsAutodialWin.cpp index 3504fdfa6ccc..14767b466bc8 100644 --- a/netwerk/base/src/nsAutodialWin.cpp +++ b/netwerk/base/src/nsAutodialWin.cpp @@ -377,7 +377,7 @@ PRBool nsAutodial::IsRASConnected() DWORD structSize = sizeof(rasConn); if (!LoadRASapi32DLL()) - return NS_ERROR_NULL_POINTER; + return PR_FALSE; DWORD result = (*mpRasEnumConnections)(&rasConn, &structSize, &connections); @@ -671,7 +671,7 @@ PRBool nsAutodial::IsAutodialServiceEnabled(int location) if (!LoadRASapi32DLL()) return PR_FALSE; - PRBool enabled; + BOOL enabled; if ((*mpRasGetAutodialEnable)(location, &enabled) != ERROR_SUCCESS) { LOGE(("Autodial: Error calling RasGetAutodialEnable()")); diff --git a/netwerk/base/src/nsStandardURL.h b/netwerk/base/src/nsStandardURL.h index b144d522c429..790e76a0e085 100644 --- a/netwerk/base/src/nsStandardURL.h +++ b/netwerk/base/src/nsStandardURL.h @@ -338,7 +338,7 @@ nsStandardURL::Prepath() } inline const nsDependentCSubstring -nsStandardURL::Userpass(int includeDelim) +nsStandardURL::Userpass(PRBool includeDelim) { PRUint32 pos=0, len=0; // if there is no username, then there can be no password diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 5291d958d115..73c40275fc71 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -73,8 +73,7 @@ HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding) CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &handler); NS_ASSERTION(handler, "no http handler"); - mTabParent = do_QueryInterface(static_cast( - static_cast(iframeEmbedding))); + mTabParent = do_QueryObject(static_cast(iframeEmbedding)); } HttpChannelParent::~HttpChannelParent() diff --git a/other-licenses/android/APKOpen.cpp b/other-licenses/android/APKOpen.cpp index a13c7049fbdd..c5f59db0074e 100644 --- a/other-licenses/android/APKOpen.cpp +++ b/other-licenses/android/APKOpen.cpp @@ -189,7 +189,7 @@ find_cdir_entry (struct cdir_entry *entry, int count, const char *name) if (letoh16(entry->filename_size) == name_size && !memcmp(entry->data, name, name_size)) return entry; - entry = (struct cdir_entry *)((void *)entry + cdir_entry_size(entry)); + entry = (struct cdir_entry *)((char *)entry + cdir_entry_size(entry)); } return NULL; } @@ -254,7 +254,7 @@ static uint32_t simple_write(int fd, const void *buf, uint32_t count) { uint32_t out_offset = 0; while (out_offset < count) { - uint32_t written = write(fd, buf + out_offset, + uint32_t written = write(fd, (const char *)buf + out_offset, count - out_offset); if (written == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) @@ -445,8 +445,8 @@ static void * mozload(const char * path, void *zip, #endif struct cdir_entry *entry = find_cdir_entry(cdir_start, cdir_entries, path); - struct local_file_header *file = (struct local_file_header *)(zip + letoh32(entry->offset)); - void * data = ((void *)&file->data) + letoh16(file->filename_size) + letoh16(file->extra_field_size); + struct local_file_header *file = (struct local_file_header *)((char *)zip + letoh32(entry->offset)); + void * data = ((char *)&file->data) + letoh16(file->filename_size) + letoh16(file->extra_field_size); void * handle; if (extractLibs) { @@ -570,8 +570,8 @@ extractBuf(const char * path, void *zip, struct cdir_entry *cdir_start, uint16_t cdir_entries) { struct cdir_entry *entry = find_cdir_entry(cdir_start, cdir_entries, path); - struct local_file_header *file = (struct local_file_header *)(zip + letoh32(entry->offset)); - void * data = ((void *)&file->data) + letoh16(file->filename_size) + letoh16(file->extra_field_size); + struct local_file_header *file = (struct local_file_header *)((char *)zip + letoh32(entry->offset)); + void * data = ((char *)&file->data) + letoh16(file->filename_size) + letoh16(file->extra_field_size); void * buf = malloc(letoh32(entry->uncompressed_size)); if (buf == (void *)-1) { @@ -627,10 +627,10 @@ loadLibs(const char *apkName) getrusage(RUSAGE_SELF, &usage1); void *zip = map_file(apkName); - struct cdir_end *dirend = (struct cdir_end *)(zip + zip_size - sizeof(*dirend)); + struct cdir_end *dirend = (struct cdir_end *)((char *)zip + zip_size - sizeof(*dirend)); while ((void *)dirend > zip && letoh32(dirend->signature) != CDIR_END_SIG) - dirend = (struct cdir_end *)((void *)dirend - 1); + dirend = (struct cdir_end *)((char *)dirend - 1); if (letoh32(dirend->signature) != CDIR_END_SIG) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't find end of central directory record"); return; @@ -639,7 +639,7 @@ loadLibs(const char *apkName) uint32_t cdir_offset = letoh32(dirend->cdir_offset); uint16_t cdir_entries = letoh16(dirend->cdir_entries); - struct cdir_entry *cdir_start = (struct cdir_entry *)(zip + cdir_offset); + struct cdir_entry *cdir_start = (struct cdir_entry *)((char *)zip + cdir_offset); lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping)); #ifdef MOZ_CRASHREPORTER diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 7442b4acba91..dd1ae0cae454 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -882,7 +882,7 @@ CNavDTD::HandleDefaultStartToken(CToken* aToken, eHTMLTags aChildTag, if (mParserCommand != eViewFragment) { PRBool theChildAgrees = PR_TRUE; PRInt32 theIndex = mBodyContext->GetCount(); - PRBool theParentContains = PR_FALSE; + PRInt32 theParentContains = 0; do { eHTMLTags theParentTag = mBodyContext->TagAt(--theIndex); diff --git a/security/manager/Makefile.in b/security/manager/Makefile.in index c61132eacc6a..9f590c842fd8 100644 --- a/security/manager/Makefile.in +++ b/security/manager/Makefile.in @@ -265,7 +265,7 @@ DEFAULT_GMAKE_FLAGS += \ OS_RELEASE="2.6" \ OS_PTHREAD= \ STANDARDS_CFLAGS="-std=gnu89" \ - DSO_CFLAGS="$(CFLAGS) -DCHECK_FORK_GETPID -DRTLD_NOLOAD=0 -DANDROID_VERSION=$(ANDROID_VERSION) -include $(ABS_topsrcdir)/security/manager/android_stub.h" \ + ARCHFLAG="$(CFLAGS) -DCHECK_FORK_GETPID -DRTLD_NOLOAD=0 -DANDROID_VERSION=$(ANDROID_VERSION) -include $(ABS_topsrcdir)/security/manager/android_stub.h" \ DSO_LDOPTS="-shared $(LDFLAGS) $(WRAP_MALLOC_CFLAGS) $(WRAP_MALLOC_LIB) " \ $(NULL) endif diff --git a/toolkit/components/downloads/test/unit/test_history_expiration.js b/toolkit/components/downloads/test/unit/test_history_expiration.js index 6fef4ce602ea..6143c0d8f2ac 100644 --- a/toolkit/components/downloads/test/unit/test_history_expiration.js +++ b/toolkit/components/downloads/test/unit/test_history_expiration.js @@ -92,8 +92,9 @@ function run_test() getService(Ci.nsINavHistoryService); // Add the download to places // Add the visit in the past to circumvent possible VM timing bugs - let yesterday = Date.now() - 24 * 60 * 60 * 1000; - histsvc.addVisit(theURI, yesterday * 1000, null, + // Go back by 8 days, since expiration ignores history in the last 7 days. + let expirableTime = Date.now() - 8 * 24 * 60 * 60 * 1000; + histsvc.addVisit(theURI, expirableTime * 1000, null, histsvc.TRANSITION_DOWNLOAD, false, 0); // Get the download manager as history observer and batch expirations diff --git a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp index 91c98284b87b..f57b2d18d4b2 100644 --- a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp +++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp @@ -233,10 +233,14 @@ nsParentalControlsServiceWin::RequestURIOverride(nsIURI *aTarget, nsIInterfaceRe if (hWnd == nsnull) hWnd = GetDesktopWindow(); + BOOL ret; nsRefPtr wpcws; - if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) + if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) { wpcws->RequestURLOverride(hWnd, NS_ConvertUTF8toUTF16(spec).get(), - 0, NULL, _retval); + 0, NULL, &ret); + *_retval = ret; + } + return NS_OK; } @@ -308,11 +312,14 @@ nsParentalControlsServiceWin::RequestURIOverrides(nsIArray *aTargets, nsIInterfa if (!uriIdx) return NS_ERROR_INVALID_ARG; - + + BOOL ret; nsRefPtr wpcws; - if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) + if (SUCCEEDED(mPC->GetWebSettings(NULL, getter_AddRefs(wpcws)))) { wpcws->RequestURLOverride(hWnd, NS_ConvertUTF8toUTF16(rootSpec).get(), - uriIdx, (LPCWSTR*)arrUrls.get(), _retval); + uriIdx, (LPCWSTR*)arrUrls.get(), &ret); + *_retval = ret; + } // Free up the allocated strings in our array for (idx = 0; idx < uriIdx; idx++) diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 1c4ab49379c8..51a34b77298a 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -128,14 +128,27 @@ using namespace mozilla::places; #define PREF_FRECENCY_UNVISITED_BOOKMARK_BONUS "frecency.unvisitedBookmarkBonus" #define PREF_FRECENCY_UNVISITED_TYPED_BONUS "frecency.unvisitedTypedBonus" -#define PREF_CACHE_TO_MEMORY_PERCENTAGE "database.cache_to_memory_percentage" - #define PREF_FORCE_DATABASE_REPLACEMENT "database.replaceOnStartup" -// Default integer value for PREF_CACHE_TO_MEMORY_PERCENTAGE. -// This is 6% of machine memory, giving 15MB for a user with 256MB of memory. -// Out of this cache, SQLite will use at most the size of the database file. -#define DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE 6 +// To calculate the cache size we take into account the available physical +// memory and the current database size. This is the percentage of memory +// we reserve for the former case. +#define DATABASE_CACHE_TO_MEMORY_PERC 2 +// The minimum size of the cache. We should never work without a cache, since +// that would badly hurt WAL journaling mode. +#define DATABASE_CACHE_MIN_BYTES (PRUint64)5242880 // 5MiB + +// We calculate an optimal database size, based on hardware specs. This +// pertains more to expiration, but the code is pretty much the same used for +// cache_size, so it's here to reduce code duplication. +// This percentage of disk size is used to protect against calculating a too +// large size on disks with tiny quota or available space. +#define DATABASE_TO_DISK_PERC 2 +// Maximum size of the optimal database. High-end hardware has plenty of +// memory and disk space, but performances don't grow linearly. +#define DATABASE_MAX_SIZE (PRInt64)167772160 // 160MiB +// Used to share the calculated optimal database size with other components. +#define PREF_OPTIMAL_DATABASE_SIZE "history.expiration.transient_optimal_database_size" // If the physical memory size is not available, use MEMSIZE_FALLBACK_BYTES // instead. Must stay in sync with the code in nsPlacesExpiration.js. @@ -681,16 +694,19 @@ nsNavHistory::SetJournalMode(enum JournalMode aJournalMode) nsresult nsNavHistory::InitDB() { + // WARNING: any statement executed before setting the journal mode must be + // finalized, since SQLite doesn't allow changing the journal mode if there + // is any outstanding statement. + { // Get the page size. This may be different than the default if the // database file already existed with a different page size. nsCOMPtr statement; - nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA page_size"), - getter_AddRefs(statement)); + nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( + "PRAGMA page_size" + ), getter_AddRefs(statement)); NS_ENSURE_SUCCESS(rv, rv); - - PRBool hasResult; - mozStorageStatementScoper scoper(statement); + PRBool hasResult = PR_FALSE; rv = statement->ExecuteStep(&hasResult); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && hasResult, NS_ERROR_FAILURE); rv = statement->GetInt32(0, &mDBPageSize); @@ -703,29 +719,67 @@ nsNavHistory::InitDB() "PRAGMA temp_store = MEMORY")); NS_ENSURE_SUCCESS(rv, rv); - // Compute the size of the database cache using the device's memory size. + // We want to work with a cache that is at a maximum half of the database + // size. We also want it to respect the available memory size. + + // Calculate memory size, fallback to a meaningful value if it fails. + PRUint64 memSizeBytes = PR_GetPhysicalMemorySize(); + if (memSizeBytes == 0) { + memSizeBytes = MEMSIZE_FALLBACK_BYTES; + } + + PRUint64 cacheSize = memSizeBytes * DATABASE_CACHE_TO_MEMORY_PERC / 100; + + // Calculate an optimal database size for expiration purposes. + // We usually want to work with a cache that is half the database size. + // Limit the size to avoid extreme values on high-end hardware. + PRInt64 optimalDatabaseSize = NS_MIN(static_cast(cacheSize) * 2, + DATABASE_MAX_SIZE); + + // Protect against a full disk or tiny quota. + PRInt64 diskAvailableBytes = 0; + nsCOMPtr localDB = do_QueryInterface(mDBFile); + if (localDB && + NS_SUCCEEDED(localDB->GetDiskSpaceAvailable(&diskAvailableBytes)) && + diskAvailableBytes > 0) { + optimalDatabaseSize = NS_MIN(optimalDatabaseSize, + diskAvailableBytes * DATABASE_TO_DISK_PERC / 100); + } + + // Share the calculated size if it's meaningful. + if (optimalDatabaseSize < PR_INT32_MAX) { + (void)mPrefBranch->SetIntPref(PREF_OPTIMAL_DATABASE_SIZE, + static_cast(optimalDatabaseSize)); + } + + // Get the current database size. Due to chunked growth we have to use + // page_count to evaluate it. + PRUint64 databaseSizeBytes = 0; + { + nsCOMPtr statement; + nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( + "PRAGMA page_count" + ), getter_AddRefs(statement)); + NS_ENSURE_SUCCESS(rv, rv); + PRBool hasResult = PR_FALSE; + rv = statement->ExecuteStep(&hasResult); + NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && hasResult, NS_ERROR_FAILURE); + PRInt32 pageCount = 0; + rv = statement->GetInt32(0, &pageCount); + NS_ENSURE_SUCCESS(rv, rv); + databaseSizeBytes = pageCount * mDBPageSize; + } + + // Set cache to a maximum of half the database size. + cacheSize = NS_MIN(cacheSize, databaseSizeBytes / 2); + // Ensure we never work without a minimum cache. + cacheSize = NS_MAX(cacheSize, DATABASE_CACHE_MIN_BYTES); + + // Set the number of cached pages. // We don't use PRAGMA default_cache_size, since the database could be moved // among different devices and the value would adapt accordingly. - PRInt32 cachePercentage; - if (NS_FAILED(mPrefBranch->GetIntPref(PREF_CACHE_TO_MEMORY_PERCENTAGE, - &cachePercentage))) - cachePercentage = DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE; - // Sanity checks, we allow values between 0 (disable cache) and 50%. - if (cachePercentage > 50) - cachePercentage = 50; - if (cachePercentage < 0) - cachePercentage = 0; - - static PRUint64 physMem = PR_GetPhysicalMemorySize(); - if (physMem == 0) - physMem = MEMSIZE_FALLBACK_BYTES; - - PRUint64 cacheSize = physMem * cachePercentage / 100; - - // Compute number of cached pages, this will be our cache size. - PRUint64 cachePages = cacheSize / mDBPageSize; nsCAutoString cacheSizePragma("PRAGMA cache_size = "); - cacheSizePragma.AppendInt(cachePages); + cacheSizePragma.AppendInt(cacheSize / mDBPageSize); rv = mDBConn->ExecuteSimpleSQL(cacheSizePragma); NS_ENSURE_SUCCESS(rv, rv); @@ -1397,9 +1451,8 @@ nsNavHistory::MigrateV7Up(mozIStorageConnection* aDBConn) rv = aDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_PLACES_FRECENCY); NS_ENSURE_SUCCESS(rv, rv); - // for place: items and unvisited livemark items, we need to set - // the frecency to 0 so that they don't show up in url bar autocomplete - rv = FixInvalidFrecenciesForExcludedPlaces(); + // Invalidate all frecencies, since they need recalculation. + rv = invalidateFrecencies(EmptyCString()); NS_ENSURE_SUCCESS(rv, rv); } @@ -2433,35 +2486,41 @@ nsNavHistory::GetHasHistoryEntries(PRBool* aHasEntries) nsresult -nsNavHistory::FixInvalidFrecenciesForExcludedPlaces() +nsNavHistory::invalidateFrecencies(const nsCString& aPlaceIdsQueryString) { - // for every moz_place that has an invalid frecency (< 0) and - // is an unvisited child of a livemark feed, or begins with "place:", - // set frecency to 0 so that it is excluded from url bar autocomplete. - nsCOMPtr dbUpdateStatement; - nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( - "UPDATE moz_places " - "SET frecency = 0 WHERE id IN (" - "SELECT h.id FROM moz_places h " - "WHERE h.url >= 'place:' AND h.url < 'place;' " - "UNION ALL " - // Unvisited child of a livemark - "SELECT b.fk FROM moz_bookmarks b " - "JOIN moz_places h ON b.fk = h.id AND visit_count = 0 AND frecency < 0 " - "JOIN moz_bookmarks bp ON bp.id = b.parent " - "JOIN moz_items_annos a ON a.item_id = bp.id " - "JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id " - "WHERE n.name = :anno_name " - ")"), - getter_AddRefs(dbUpdateStatement)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = dbUpdateStatement->BindUTF8StringByName( - NS_LITERAL_CSTRING("anno_name"), NS_LITERAL_CSTRING(LMANNO_FEEDURI) + // Exclude place: queries and unvisited livemark children from autocomplete, + // by setting their frecency to zero. + nsCAutoString invalideFrecenciesSQLFragment( + "UPDATE moz_places SET frecency = (CASE " + "WHEN url BETWEEN 'place:' AND 'place;' " + "THEN 0 " + "WHEN id IN (SELECT b.fk FROM moz_bookmarks b " + "JOIN moz_bookmarks bp ON bp.id = b.parent " + "JOIN moz_items_annos a ON a.item_id = bp.id " + "JOIN moz_anno_attributes n ON n.id = a.anno_attribute_id " + "WHERE b.fk = moz_places.id AND visit_count = 0 " + "AND n.name = :anno_name) " + "THEN 0 " + "ELSE -1 " + "END) " ); - NS_ENSURE_SUCCESS(rv, rv); - rv = dbUpdateStatement->Execute(); + if (!aPlaceIdsQueryString.IsEmpty()) { + invalideFrecenciesSQLFragment.AppendLiteral("WHERE id IN("); + invalideFrecenciesSQLFragment.Append(aPlaceIdsQueryString); + invalideFrecenciesSQLFragment.AppendLiteral(")"); + } + + nsCOMPtr stmt = + GetStatementByStoragePool(invalideFrecenciesSQLFragment); + NS_ENSURE_STATE(stmt); + nsresult rv = stmt->BindUTF8StringByName( + NS_LITERAL_CSTRING("anno_name"), NS_LITERAL_CSTRING(LMANNO_FEEDURI) + ); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr ps; + rv = stmt->ExecuteAsync(nsnull, getter_AddRefs(ps)); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -2621,7 +2680,7 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI, rv = stmt->GetInt32(2, &oldTypedState); NS_ENSURE_SUCCESS(rv, rv); - PRBool oldHiddenState = 0; + PRInt32 oldHiddenState = 0; rv = stmt->GetInt32(3, &oldHiddenState); NS_ENSURE_SUCCESS(rv, rv); @@ -4087,11 +4146,8 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString) mozStorageTransaction transaction(mDBConn, PR_FALSE); - nsresult rv = PreparePlacesForVisitsDelete(aPlaceIdsQueryString); - NS_ENSURE_SUCCESS(rv, rv); - // Delete all visits for the specified place ids. - rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( + nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( "DELETE FROM moz_historyvisits WHERE place_id IN (") + aPlaceIdsQueryString + NS_LITERAL_CSTRING(")")); @@ -4107,47 +4163,6 @@ nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString) } -/** - * Prepares for deletion places that are about to have all their visits removed. - * This is an internal method used by RemovePagesInternal and - * RemoveVisitsByTimeframe. This method does not execute in a transaction, so - * callers should make sure they begin one if needed. - * - * @param aPlaceIdsQueryString - * A comma-separated list of place IDs, each of which is about to have - * all its visits removed - */ -nsresult -nsNavHistory::PreparePlacesForVisitsDelete(const nsCString& aPlaceIdsQueryString) -{ - // Return early if there is nothing to delete. - if (aPlaceIdsQueryString.IsEmpty()) - return NS_OK; - - // if a moz_place is annotated or was a bookmark, - // we won't delete it, but we will delete the moz_visits - // so we need to reset the frecency. Note, we set frecency to - // -visit_count, as we use that value in our "on idle" query - // to figure out which places to recalculate frecency first. - // Pay attention to not set frecency = 0 if visit_count = 0 - nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( - "UPDATE moz_places " - "SET frecency = -MAX(visit_count, 1) " - "WHERE id IN ( " - "SELECT h.id " - "FROM moz_places h " - "WHERE h.id IN ( ") + aPlaceIdsQueryString + NS_LITERAL_CSTRING(") " - "AND ( " - "EXISTS (SELECT b.id FROM moz_bookmarks b WHERE b.fk =h.id) " - "OR EXISTS (SELECT a.id FROM moz_annos a WHERE a.place_id = h.id) " - ") " - ")")); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; -} - - /** * Performs cleanup on places that just had all their visits removed, including * deletion of those places. This is an internal method used by @@ -4225,10 +4240,8 @@ nsNavHistory::CleanupPlacesOnVisitsDelete(const nsCString& aPlaceIdsQueryString) ") ")); NS_ENSURE_SUCCESS(rv, rv); - // If we have removed all visits to a livemark's child, we need to fix its - // frecency, or it would appear in the url bar autocomplete. - // XXX this might be dog slow, further degrading delete perf. - rv = FixInvalidFrecenciesForExcludedPlaces(); + // Invalidate frecencies of touched places, since they need recalculation. + rv = invalidateFrecencies(aPlaceIdsQueryString); NS_ENSURE_SUCCESS(rv, rv); // Finally notify about the removed URIs. @@ -4515,9 +4528,6 @@ nsNavHistory::RemoveVisitsByTimeframe(PRTime aBeginTime, PRTime aEndTime) mozStorageTransaction transaction(mDBConn, PR_FALSE); - rv = PreparePlacesForVisitsDelete(deletePlaceIdsQueryString); - NS_ENSURE_SUCCESS(rv, rv); - // Delete all visits within the timeframe. nsCOMPtr deleteVisitsStmt; rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( @@ -4557,33 +4567,10 @@ nsNavHistory::RemoveAllPages() { NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread"); - mozStorageTransaction transaction(mDBConn, PR_FALSE); - - // reset frecency for all items that will _not_ be deleted - // Note, we set frecency to -visit_count since we use that value in our - // idle query to figure out which places to recalcuate frecency first. - // We must do this before deleting visits. nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( - "UPDATE moz_places SET frecency = -MAX(visit_count, 1) " - "WHERE id IN(SELECT b.fk FROM moz_bookmarks b WHERE b.fk NOTNULL)")); - NS_ENSURE_SUCCESS(rv, rv); - - // Expire visits, then let the paranoid functions do the cleanup for us. - rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( "DELETE FROM moz_historyvisits")); NS_ENSURE_SUCCESS(rv, rv); - // Some of the remaining places could be place: urls or - // unvisited livemark items, so setting the frecency to -1 - // will cause them to show up in the url bar autocomplete - // call FixInvalidFrecenciesForExcludedPlaces to handle that scenario. - rv = FixInvalidFrecenciesForExcludedPlaces(); - if (NS_FAILED(rv)) - NS_WARNING("failed to fix invalid frecencies"); - - rv = transaction.Commit(); - NS_ENSURE_SUCCESS(rv, rv); - // Clear the registered embed visits. clearEmbedVisits(); @@ -4594,6 +4581,11 @@ nsNavHistory::RemoveAllPages() NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers, nsINavHistoryObserver, OnClearHistory()); + // Invalidate frecencies for the remaining places. This must happen + // after the notification to ensure it runs enqueued to expiration. + rv = invalidateFrecencies(EmptyCString()); + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to fix invalid frecencies"); + return NS_OK; } diff --git a/toolkit/components/places/nsNavHistory.h b/toolkit/components/places/nsNavHistory.h index 90f71dbb0ab1..84d73e99c2ec 100644 --- a/toolkit/components/places/nsNavHistory.h +++ b/toolkit/components/places/nsNavHistory.h @@ -268,9 +268,14 @@ public: nsresult FixInvalidFrecencies(); /** - * Set the frecencies of excluded places so they don't show up in queries + * Invalidate the frecencies of a list of places so they will be recalculated + * at the first idle-daily notification. + * + * @param aPlacesIdsQueryString + * Query string containing list of places to be invalidated. If it's + * an empty string all places will be invalidated. */ - nsresult FixInvalidFrecenciesForExcludedPlaces(); + nsresult invalidateFrecencies(const nsCString& aPlaceIdsQueryString); /** * Returns a pointer to the storage connection used by history. This @@ -728,7 +733,6 @@ protected: nsresult MigrateV11Up(mozIStorageConnection *aDBConn); nsresult RemovePagesInternal(const nsCString& aPlaceIdsQueryString); - nsresult PreparePlacesForVisitsDelete(const nsCString& aPlaceIdsQueryString); nsresult CleanupPlacesOnVisitsDelete(const nsCString& aPlaceIdsQueryString); nsresult AddURIInternal(nsIURI* aURI, PRTime aTime, PRBool aRedirect, diff --git a/toolkit/components/places/nsPlacesExpiration.js b/toolkit/components/places/nsPlacesExpiration.js index db3fc4e0d53f..00297b7a0669 100644 --- a/toolkit/components/places/nsPlacesExpiration.js +++ b/toolkit/components/places/nsPlacesExpiration.js @@ -109,16 +109,10 @@ const PREF_READONLY_CALCULATED_MAX_URIS = "transient_current_max_pages"; const PREF_INTERVAL_SECONDS = "interval_seconds"; const PREF_INTERVAL_SECONDS_NOTSET = 3 * 60; -// The percentage of system memory we will use for the database's cache. -// Use the same value set in nsNavHistory.cpp. We use the size of the cache to -// evaluate how many pages we can store before going over it. -const PREF_DATABASE_CACHE_PER_MEMORY_PERCENTAGE = - "places.history.cache_per_memory_percentage"; -const PREF_DATABASE_CACHE_PER_MEMORY_PERCENTAGE_NOTSET = 6; - -// Minimum number of unique URIs to retain. This is used when system-info -// returns bogus values. -const MIN_URIS = 1000; +// An optimal database size calculated by history. Used to evaluate a limit +// to the number of pages we may retain before hitting performance issues. +const PREF_OPTIMAL_DATABASE_SIZE = "transient_optimal_database_size"; +const PREF_OPTIMAL_DATABASE_SIZE_NOTSET = 167772160; // 160MiB // Max number of entries to expire at each expiration step. // This value is globally used for different kind of data we expire, can be @@ -141,14 +135,10 @@ const EXPIRE_AGGRESSIVITY_MULTIPLIER = 3; // This is the average size in bytes of an URI entry in the database. // Magic numbers are determined through analysis of the distribution of a ratio -// between number of unique URIs and database size among our users. We use a -// more pessimistic ratio on single cores, since we handle some stuff in a -// separate thread. +// between number of unique URIs and database size among our users. // Based on these values we evaluate how many unique URIs we can handle before -// going over the database maximum cache size. If we are over the maximum -// number of entries, we will expire. -const URIENTRY_AVG_SIZE_MIN = 2000; -const URIENTRY_AVG_SIZE_MAX = 3000; +// starting expiring some. +const URIENTRY_AVG_SIZE = 1600; // Seconds of idle time before starting a larger expiration step. // Notice during idle we stop the expiration timer since we don't want to hurt @@ -210,6 +200,8 @@ const EXPIRATION_QUERIES = { // Finds visits to be expired. Will return nothing if we are not over the // unique URIs limit. + // This explicitly excludes any visits added in the last 7 days, to protect + // users with thousands of bookmarks from constantly losing history. QUERY_FIND_VISITS_TO_EXPIRE: { sql: "INSERT INTO expiration_notify " + "(v_id, url, guid, visit_date, expected_results) " @@ -217,6 +209,7 @@ const EXPIRATION_QUERIES = { + "FROM moz_historyvisits v " + "JOIN moz_places h ON h.id = v.place_id " + "WHERE (SELECT COUNT(*) FROM moz_places) > :max_uris " + + "AND visit_date < strftime('%s','now','localtime','start of day','-7 days','utc') * 1000000 " + "ORDER BY v.visit_date ASC " + "LIMIT :limit_visits", actions: ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN | ACTION.IDLE | @@ -235,6 +228,10 @@ const EXPIRATION_QUERIES = { // Finds orphan URIs in the database. // Notice we won't notify single removed URIs on removeAllPages, so we don't // run this query in such a case, but just delete URIs. + // This could run in the middle of adding a visit or bookmark to a new page. + // In such a case since it is async, could end up expiring the orphan page + // before it actually gets the new visit or bookmark. + // Thus, since new pages get frecency -1, we filter on that. QUERY_FIND_URIS_TO_EXPIRE: { sql: "INSERT INTO expiration_notify " + "(p_id, url, guid, visit_date, expected_results) " @@ -244,7 +241,7 @@ const EXPIRATION_QUERIES = { + "LEFT JOIN moz_bookmarks b ON h.id = b.fk " + "WHERE v.id IS NULL " + "AND b.id IS NULL " - + "AND h.ROWID <> IFNULL(:null_skips_last, (SELECT MAX(ROWID) FROM moz_places)) " + + "AND frecency <> -1 " + "LIMIT :limit_uris", actions: ACTION.TIMED | ACTION.TIMED_OVERLIMIT | ACTION.SHUTDOWN | ACTION.IDLE | ACTION.DEBUG @@ -733,7 +730,8 @@ nsPlacesExpiration.prototype = { _isIdleObserver: false, _expireOnIdle: false, set expireOnIdle(aExpireOnIdle) { - // Observe idle regardless, since we want to stop timed expiration. + // Observe idle regardless aExpireOnIdle, since we always want to stop + // timed expiration on idle, to preserve mobile battery life. if (!this._isIdleObserver && !this._shuttingDown) { this._idle.addIdleObserver(this, IDLE_TIMEOUT_SECONDS); this._isIdleObserver = true; @@ -764,38 +762,15 @@ nsPlacesExpiration.prototype = { catch(e) {} if (this._urisLimit < 0) { - // If physical memory size is not available, use MEMSIZE_FALLBACK_BYTES - // instead. Must stay in sync with the code in nsNavHistory.cpp. - const MEMSIZE_FALLBACK_BYTES = 268435456; // 256 M - - // The preference did not exist or has a negative value, so we calculate a - // limit based on hardware. - let memsize = this._sys.getProperty("memsize"); // Memory size in bytes. - if (memsize <= 0) - memsize = MEMSIZE_FALLBACK_BYTES; - - let cpucount = this._sys.getProperty("cpucount"); // CPU count. - const AVG_SIZE_PER_URIENTRY = cpucount > 1 ? URIENTRY_AVG_SIZE_MIN - : URIENTRY_AVG_SIZE_MAX; - // We will try to live inside the database cache size, since working out - // of it can be really slow. - let cache_percentage = PREF_DATABASE_CACHE_PER_MEMORY_PERCENTAGE_NOTSET; + // The preference did not exist or has a negative value. + // Calculate the number of unique places that may fit an optimal database + // size on this hardware. If there are more than these unique pages, + // some will be expired. + let optimalDatabaseSize = PREF_OPTIMAL_DATABASE_SIZE_NOTSET; try { - let prefs = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - cache_percentage = - prefs.getIntPref(PREF_DATABASE_CACHE_PER_MEMORY_PERCENTAGE); - if (cache_percentage < 0) { - cache_percentage = 0; - } - else if (cache_percentage > 50) { - cache_percentage = 50; - } - } - catch(e) {} - let cachesize = memsize * cache_percentage / 100; - this._urisLimit = Math.max(MIN_URIS, - parseInt(cachesize / AVG_SIZE_PER_URIENTRY)); + optimalDatabaseSize = this._prefBranch.getIntPref(PREF_OPTIMAL_DATABASE_SIZE); + } catch (ex) {} + this._urisLimit = Math.ceil(optimalDatabaseSize / URIENTRY_AVG_SIZE); } // Expose the calculated limit to other components. this._prefBranch.setIntPref(PREF_READONLY_CALCULATED_MAX_URIS, @@ -827,6 +802,11 @@ nsPlacesExpiration.prototype = { // Skip expiration during batch mode. if (this._inBatchMode) return; + // Don't try to further expire after shutdown. + if (this._shuttingDown && + aAction != ACTION.SHUTDOWN && aAction != ACTION.CLEAN_SHUTDOWN) { + return; + } let boundStatements = []; for (let queryType in EXPIRATION_QUERIES) { @@ -901,18 +881,6 @@ nsPlacesExpiration.prototype = { aLimit == LIMIT.DEBUG && baseLimit == -1 ? 0 : baseLimit; break; case "QUERY_FIND_URIS_TO_EXPIRE": - // We could run in the middle of adding a new visit or bookmark to - // a new page. In such a case since we are async, we could end up - // expiring the page before it actually gets the visit or bookmark, - // thinking it's an orphan. So we never expire the last added page - // when expiration does not run on user action. - if (aAction != ACTION.TIMED && aAction != ACTION.TIMED_OVERLIMIT && - aAction != ACTION.IDLE) { - params.null_skips_last = -1; - } - else { - params.null_skips_last = null; - } params.limit_uris = baseLimit; break; case "QUERY_SILENT_EXPIRE_ORPHAN_URIS": diff --git a/toolkit/components/places/tests/expiration/head_expiration.js b/toolkit/components/places/tests/expiration/head_expiration.js index 16d91865db6a..db9914b41cf3 100644 --- a/toolkit/components/places/tests/expiration/head_expiration.js +++ b/toolkit/components/places/tests/expiration/head_expiration.js @@ -128,3 +128,20 @@ function clearHistoryEnabled() { } catch(ex) {} } + +/** + * Returns a PRTime in the past usable to add expirable visits. + * + * @note Expiration ignores any visit added in the last 7 days, but it's + * better be safe against DST issues, by going back one day more. + */ +function getExpirablePRTime() { + let dateObj = new Date(); + // Normalize to midnight + dateObj.setHours(0); + dateObj.setMinutes(0); + dateObj.setSeconds(0); + dateObj.setMilliseconds(0); + dateObj = new Date(dateObj.getTime() - 8 * 86400000); + return dateObj.getTime() * 1000; +} diff --git a/toolkit/components/places/tests/expiration/test_annos_expire_history.js b/toolkit/components/places/tests/expiration/test_annos_expire_history.js index 8bff5c08cbca..e416232d120b 100644 --- a/toolkit/components/places/tests/expiration/test_annos_expire_history.js +++ b/toolkit/components/places/tests/expiration/test_annos_expire_history.js @@ -62,7 +62,7 @@ function run_test() { setMaxPages(0); // Add some visited page and a couple expire with history annotations for each. - let now = Date.now() * 1000; + let now = getExpirablePRTime(); for (let i = 0; i < 5; i++) { let pageURI = uri("http://page_anno." + i + ".mozilla.org/"); hs.addVisit(pageURI, now++, null, hs.TRANSITION_TYPED, false, 0); diff --git a/toolkit/components/places/tests/expiration/test_annos_expire_never.js b/toolkit/components/places/tests/expiration/test_annos_expire_never.js index 9a21d5ee9fbb..4fa413ed837a 100644 --- a/toolkit/components/places/tests/expiration/test_annos_expire_never.js +++ b/toolkit/components/places/tests/expiration/test_annos_expire_never.js @@ -65,7 +65,7 @@ function run_test() { setMaxPages(0); // Add some visited page and a couple expire never annotations for each. - let now = Date.now() * 1000; + let now = getExpirablePRTime(); for (let i = 0; i < 5; i++) { let pageURI = uri("http://page_anno." + i + ".mozilla.org/"); hs.addVisit(pageURI, now++, null, hs.TRANSITION_TYPED, false, 0); diff --git a/toolkit/components/places/tests/expiration/test_debug_expiration.js b/toolkit/components/places/tests/expiration/test_debug_expiration.js index c9eca0eb03e9..919e4a1dc7f9 100644 --- a/toolkit/components/places/tests/expiration/test_debug_expiration.js +++ b/toolkit/components/places/tests/expiration/test_debug_expiration.js @@ -8,7 +8,7 @@ * only expire orphan entries, unless -1 is passed as limit. */ -let gNow = Date.now() * 1000; +let gNow = getExpirablePRTime(); add_test(function test_expire_orphans() { diff --git a/toolkit/components/places/tests/expiration/test_notifications_onDeleteURI.js b/toolkit/components/places/tests/expiration/test_notifications_onDeleteURI.js index 8063ed331475..b51b9299fe37 100644 --- a/toolkit/components/places/tests/expiration/test_notifications_onDeleteURI.js +++ b/toolkit/components/places/tests/expiration/test_notifications_onDeleteURI.js @@ -100,7 +100,7 @@ function run_next_test() { gCurrentTest.receivedNotifications = 0; // Setup visits. - let now = Date.now() * 1000; + let now = getExpirablePRTime(); for (let i = 0; i < gCurrentTest.addPages; i++) { let page = "http://" + gTestIndex + "." + i + ".mozilla.org/"; hs.addVisit(uri(page), now++, null, hs.TRANSITION_TYPED, false, 0); diff --git a/toolkit/components/places/tests/expiration/test_notifications_onDeleteVisits.js b/toolkit/components/places/tests/expiration/test_notifications_onDeleteVisits.js index 560eaa05b3dd..4e264c91f9ae 100644 --- a/toolkit/components/places/tests/expiration/test_notifications_onDeleteVisits.js +++ b/toolkit/components/places/tests/expiration/test_notifications_onDeleteVisits.js @@ -117,7 +117,7 @@ function run_next_test() { gCurrentTest.receivedNotifications = 0; // Setup visits. - let now = Date.now() * 1000; + let now = getExpirablePRTime(); for (let j = 0; j < gCurrentTest.visitsPerPage; j++) { for (let i = 0; i < gCurrentTest.addPages; i++) { let page = "http://" + gTestIndex + "." + i + ".mozilla.org/"; diff --git a/toolkit/components/places/tests/expiration/test_pref_maxpages.js b/toolkit/components/places/tests/expiration/test_pref_maxpages.js index 7dab1db81d3a..0633245789ad 100644 --- a/toolkit/components/places/tests/expiration/test_pref_maxpages.js +++ b/toolkit/components/places/tests/expiration/test_pref_maxpages.js @@ -121,7 +121,7 @@ function run_next_test() { gCurrentTest.receivedNotifications = 0; // Setup visits. - let now = Date.now() * 1000; + let now = getExpirablePRTime(); for (let i = 0; i < gCurrentTest.addPages; i++) { hs.addVisit(uri("http://" + gTestIndex + "." + i + ".mozilla.org/"), now++, null, hs.TRANSITION_TYPED, false, 0); diff --git a/toolkit/components/places/tests/unit/test_history_removeAllPages.js b/toolkit/components/places/tests/unit/test_history_removeAllPages.js index 64ce0d7d3125..d46a561ee25c 100644 --- a/toolkit/components/places/tests/unit/test_history_removeAllPages.js +++ b/toolkit/components/places/tests/unit/test_history_removeAllPages.js @@ -77,10 +77,11 @@ let historyObserver = { // check browserHistory returns no entries do_check_eq(0, PlacesUtils.bhistory.count); - let expirationObserver = { - observe: function (aSubject, aTopic, aData) { - Services.obs.removeObserver(this, aTopic, false); + Services.obs.addObserver(function observeExpiration(aSubject, aTopic, aData) + { + Services.obs.removeObserver(observeExpiration, aTopic, false); + waitForAsyncUpdates(function () { // Check that frecency for not cleared items (bookmarks) has been converted // to -MAX(visit_count, 1), so we will be able to recalculate frecency // starting from most frecent bookmarks. @@ -90,7 +91,7 @@ let historyObserver = { stmt.finalize(); stmt = mDBConn.createStatement( - "SELECT h.id FROM moz_places h WHERE h.frecency = -2 " + + "SELECT h.id FROM moz_places h WHERE h.frecency < 0 " + "AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1"); do_check_true(stmt.executeStep()); stmt.finalize(); @@ -154,11 +155,8 @@ let historyObserver = { stmt.finalize(); do_test_finished(); - } - } - Services.obs.addObserver(expirationObserver, - PlacesUtils.TOPIC_EXPIRATION_FINISHED, - false); + }); + }, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); }, QueryInterface: XPCOMUtils.generateQI([ diff --git a/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js b/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js index 981d2405ac2b..c9f9fac7df59 100644 --- a/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js +++ b/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js @@ -382,8 +382,8 @@ var gTests = [ do_check_true(bmsvc.isBookmarked(TEST_URI)); waitForAsyncUpdates(function () { - print("Frecency should be -visit_count.") - do_check_eq(frecencyForUrl(TEST_URI), -10); + print("Frecency should be negative.") + do_check_true(frecencyForUrl(TEST_URI) < 0); run_next_test(); }); } diff --git a/toolkit/mozapps/readstrings/readstrings.cpp b/toolkit/mozapps/readstrings/readstrings.cpp index 04421913da97..d3d36f8268fc 100644 --- a/toolkit/mozapps/readstrings/readstrings.cpp +++ b/toolkit/mozapps/readstrings/readstrings.cpp @@ -43,11 +43,6 @@ #include "readstrings.h" #include "errors.h" -// Defined bool stuff here to reduce external dependencies -typedef int PRBool; -#define PR_TRUE 1 -#define PR_FALSE 0 - #ifdef XP_WIN # define NS_tfopen _wfopen # define OPEN_MODE L"rb" @@ -187,7 +182,7 @@ ReadStrings(const NS_tchar *path, fileContents[flen] = '\0'; char *buffer = fileContents; - PRBool inStringsSection = PR_FALSE; + bool inStringsSection = false; unsigned int read = 0; @@ -209,7 +204,7 @@ ReadStrings(const NS_tchar *path, // we could frankly decide that this INI file is malformed right // here and stop, but we won't... keep going, looking for // a well-formed [section] to continue working with - inStringsSection = PR_FALSE; + inStringsSection = false; } else { if (section) diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 59141196873e..c069d143035c 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -1578,7 +1578,7 @@ LaunchWinPostProcess(const WCHAR *appExe) wcscat(cmdline, exearg); if (!_wcsnicmp(exeasync, L"false", 6) || !_wcsnicmp(exeasync, L"0", 2)) - async = PR_FALSE; + async = false; // We want to launch the post update helper app to update the Windows // registry even if there is a failure with removing the uninstall.update diff --git a/toolkit/xre/glxtest.cpp b/toolkit/xre/glxtest.cpp index 1680c1e2dd79..25dcfe374600 100644 --- a/toolkit/xre/glxtest.cpp +++ b/toolkit/xre/glxtest.cpp @@ -59,6 +59,10 @@ #include #include "nscore.h" +#ifdef __SUNPRO_CC +#include +#endif + namespace mozilla { namespace widget { // the read end of the pipe, which will be used by GfxInfo diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index 9c5d0dbdc5e1..5f656e408d22 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -164,17 +164,6 @@ #define NS_CONSTRUCTOR_FASTCALL #endif -/* - * NS_DEFCALL undoes the effect of a global regparm/stdcall setting - * so that xptcall works correctly. - */ -#if defined(__i386__) && defined(__GNUC__) && \ - (__GNUC__ >= 3) && !defined(XP_OS2) -#define NS_DEFCALL __attribute__ ((regparm (0), cdecl)) -#else -#define NS_DEFCALL -#endif - #ifdef NS_WIN32 #define NS_IMPORT __declspec(dllimport) @@ -217,7 +206,7 @@ #define NS_IMPORT_(type) NS_EXTERNAL_VIS_(type) #define NS_EXPORT NS_EXTERNAL_VIS #define NS_EXPORT_(type) NS_EXTERNAL_VIS_(type) -#define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL +#define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type #define NS_IMETHODIMP_(type) type #define NS_METHOD_(type) type #define NS_CALLBACK_(_type, _name) _type (* _name) diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 8c2b8fefbc25..0e09a535f2ef 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -1900,7 +1900,7 @@ PRBool nsXULWindow::ConstrainToZLevel(PRBool aImmediate, *aPlacement = nsWindowZRelative; if (aImmediate) { - nsCOMPtr ourBase = do_QueryInterface(static_cast(this)); + nsCOMPtr ourBase = do_QueryObject(this); if (ourBase) { nsCOMPtr ourWidget; ourBase->GetMainWidget(getter_AddRefs(ourWidget));