diff options
Diffstat (limited to 'cpp/src/FreezeScript')
37 files changed, 0 insertions, 23290 deletions
diff --git a/cpp/src/FreezeScript/.depend.mak b/cpp/src/FreezeScript/.depend.mak deleted file mode 100755 index 60b7f82fb62..00000000000 --- a/cpp/src/FreezeScript/.depend.mak +++ /dev/null @@ -1,1896 +0,0 @@ - -AssignVisitor.obj: \ - AssignVisitor.cpp \ - "AssignVisitor.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - -Data.obj: \ - Data.cpp \ - "$(includedir)\IceUtil\DisableWarnings.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "Exception.h" \ - "$(includedir)\IceUtil\InputUtil.h" \ - -Error.obj: \ - Error.cpp \ - "Error.h" \ - "$(includedir)\Slice\Parser.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "Exception.h" \ - "Util.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - -Functions.obj: \ - Functions.cpp \ - "Functions.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\IceUtil\UUID.h" \ - "$(includedir)\IceUtil\StringUtil.h" \ - -Exception.obj: \ - Exception.cpp \ - "Exception.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\IceUtil\Config.h" \ - -Parser.obj: \ - Parser.cpp \ - "Parser.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "GrammarUtil.h" \ - -Print.obj: \ - Print.cpp \ - "Print.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\IceUtil\OutputUtil.h" \ - -Util.obj: \ - Util.cpp \ - "Util.h" \ - "$(includedir)\Slice\Parser.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "Exception.h" \ - "$(includedir)\Freeze\Catalog.h" \ - "$(includedir)\Freeze\Map.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Freeze\DB.h" \ - "$(includedir)\Freeze\Exception.h" \ - "$(includedir)\Freeze\Connection.h" \ - "$(includedir)\Freeze\Transaction.h" \ - "$(includedir)\Freeze\Initialize.h" \ - "$(includedir)\Freeze\EvictorF.h" \ - "$(includedir)\Freeze\ConnectionF.h" \ - "$(includedir)\Freeze\Index.h" \ - "$(includedir)\Slice\Preprocessor.h" \ - -Grammar.obj: \ - Grammar.cpp \ - "GrammarUtil.h" \ - "Parser.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - -Scanner.obj: \ - Scanner.cpp \ - "$(includedir)\IceUtil\ScannerConfig.h" \ - "$(includedir)\IceUtil\Config.h" \ - "GrammarUtil.h" \ - "Parser.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Grammar.h" \ - "$(includedir)\IceUtil\InputUtil.h" \ - -TransformAnalyzer.obj: \ - TransformAnalyzer.cpp \ - "TransformAnalyzer.h" \ - "$(includedir)\Slice\Parser.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\IceUtil\OutputUtil.h" \ - "Util.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - -TransformVisitor.obj: \ - TransformVisitor.cpp \ - "TransformVisitor.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\IceUtil\InputUtil.h" \ - -Transformer.obj: \ - Transformer.cpp \ - "Transformer.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "$(includedir)\Freeze\Connection.h" \ - "$(includedir)\Freeze\Transaction.h" \ - "Data.h" \ - "Error.h" \ - "Parser.h" \ - "TransformVisitor.h" \ - "AssignVisitor.h" \ - "Print.h" \ - "Functions.h" \ - "Exception.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\Freeze\Catalog.h" \ - "$(includedir)\Freeze\Map.h" \ - "$(includedir)\Freeze\DB.h" \ - "$(includedir)\Freeze\Exception.h" \ - "$(includedir)\Freeze\Initialize.h" \ - "$(includedir)\Freeze\EvictorF.h" \ - "$(includedir)\Freeze\ConnectionF.h" \ - "$(includedir)\Freeze\Index.h" \ - "$(includedir)\IceXML\Parser.h" \ - "$(includedir)\IceUtil\InputUtil.h" \ - -transformdb.obj: \ - transformdb.cpp \ - "Transformer.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "$(includedir)\Freeze\Connection.h" \ - "$(includedir)\Freeze\Transaction.h" \ - "Data.h" \ - "Error.h" \ - "TransformAnalyzer.h" \ - "$(includedir)\IceUtil\OutputUtil.h" \ - "Exception.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\Freeze\Initialize.h" \ - "$(includedir)\Freeze\EvictorF.h" \ - "$(includedir)\Freeze\ConnectionF.h" \ - "$(includedir)\Freeze\Index.h" \ - "$(includedir)\Freeze\DB.h" \ - "$(includedir)\Freeze\Catalog.h" \ - "$(includedir)\Freeze\Map.h" \ - "$(includedir)\Freeze\Exception.h" \ - "$(includedir)\IceUtil\Options.h" \ - "$(includedir)\IceUtil\RecMutex.h" \ - "$(includedir)\IceUtil\FileUtil.h" \ - -DumpDescriptors.obj: \ - DumpDescriptors.cpp \ - "DumpDescriptors.h" \ - "Parser.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "$(includedir)\IceXML\Parser.h" \ - "AssignVisitor.h" \ - "Print.h" \ - "Functions.h" \ - "Exception.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "$(includedir)\IceUtil\InputUtil.h" \ - -DumpDB.obj: \ - DumpDB.cpp \ - "DumpDescriptors.h" \ - "Parser.h" \ - "Data.h" \ - "$(includedir)\Ice\Ice.h" \ - "$(includedir)\IceUtil\PushDisableWarnings.h" \ - "$(includedir)\Ice\Config.h" \ - "$(includedir)\IceUtil\Config.h" \ - "$(includedir)\Ice\DeprecatedStringConverter.h" \ - "$(includedir)\Ice\CommunicatorF.h" \ - "$(includedir)\Ice\ProxyF.h" \ - "$(includedir)\IceUtil\Shared.h" \ - "$(includedir)\IceUtil\Atomic.h" \ - "$(includedir)\Ice\ProxyHandle.h" \ - "$(includedir)\IceUtil\Handle.h" \ - "$(includedir)\IceUtil\Exception.h" \ - "$(includedir)\Ice\ObjectF.h" \ - "$(includedir)\Ice\Handle.h" \ - "$(includedir)\Ice\Exception.h" \ - "$(includedir)\Ice\Format.h" \ - "$(includedir)\Ice\StreamF.h" \ - "$(includedir)\Ice\LocalObject.h" \ - "$(includedir)\Ice\LocalObjectF.h" \ - "$(includedir)\Ice\StreamHelpers.h" \ - "$(includedir)\IceUtil\ScopedArray.h" \ - "$(includedir)\IceUtil\Iterator.h" \ - "$(includedir)\IceUtil\Optional.h" \ - "$(includedir)\IceUtil\UndefSysMacros.h" \ - "$(includedir)\IceUtil\PopDisableWarnings.h" \ - "$(includedir)\IceUtil\StringConverter.h" \ - "$(includedir)\Ice\Plugin.h" \ - "$(includedir)\Ice\LoggerF.h" \ - "$(includedir)\Ice\BuiltinSequences.h" \ - "$(includedir)\Ice\Initialize.h" \ - "$(includedir)\IceUtil\Timer.h" \ - "$(includedir)\IceUtil\Thread.h" \ - "$(includedir)\IceUtil\Mutex.h" \ - "$(includedir)\IceUtil\Lock.h" \ - "$(includedir)\IceUtil\ThreadException.h" \ - "$(includedir)\IceUtil\Time.h" \ - "$(includedir)\IceUtil\MutexProtocol.h" \ - "$(includedir)\IceUtil\Monitor.h" \ - "$(includedir)\IceUtil\Cond.h" \ - "$(includedir)\Ice\PropertiesF.h" \ - "$(includedir)\Ice\Proxy.h" \ - "$(includedir)\Ice\ProxyFactoryF.h" \ - "$(includedir)\Ice\ConnectionIF.h" \ - "$(includedir)\Ice\RequestHandlerF.h" \ - "$(includedir)\Ice\EndpointF.h" \ - "$(includedir)\Ice\EndpointTypes.h" \ - "$(includedir)\Ice\ObjectAdapterF.h" \ - "$(includedir)\Ice\ReferenceF.h" \ - "$(includedir)\Ice\BatchRequestQueueF.h" \ - "$(includedir)\Ice\AsyncResult.h" \ - "$(includedir)\IceUtil\UniquePtr.h" \ - "$(includedir)\Ice\ConnectionF.h" \ - "$(includedir)\Ice\InstanceF.h" \ - "$(includedir)\Ice\AsyncResultF.h" \ - "$(includedir)\Ice\ObserverHelper.h" \ - "$(includedir)\Ice\Instrumentation.h" \ - "$(includedir)\Ice\Current.h" \ - "$(includedir)\Ice\Identity.h" \ - "$(includedir)\Ice\Version.h" \ - "$(includedir)\Ice\BasicStream.h" \ - "$(includedir)\Ice\Object.h" \ - "$(includedir)\Ice\IncomingAsyncF.h" \ - "$(includedir)\Ice\ObjectFactoryF.h" \ - "$(includedir)\Ice\ObjectFactoryManagerF.h" \ - "$(includedir)\Ice\Buffer.h" \ - "$(includedir)\Ice\Protocol.h" \ - "$(includedir)\Ice\SlicedDataF.h" \ - "$(includedir)\Ice\UserExceptionFactory.h" \ - "$(includedir)\Ice\FactoryTable.h" \ - "$(includedir)\Ice\InstrumentationF.h" \ - "$(includedir)\Ice\Dispatcher.h" \ - "$(includedir)\Ice\BatchRequestInterceptor.h" \ - "$(includedir)\Ice\LocalException.h" \ - "$(includedir)\Ice\PropertiesAdmin.h" \ - "$(includedir)\Ice\GCObject.h" \ - "$(includedir)\IceUtil\MutexPtrLock.h" \ - "$(includedir)\Ice\Incoming.h" \ - "$(includedir)\Ice\ServantLocatorF.h" \ - "$(includedir)\Ice\ServantManagerF.h" \ - "$(includedir)\Ice\ResponseHandlerF.h" \ - "$(includedir)\Ice\IncomingAsync.h" \ - "$(includedir)\Ice\Properties.h" \ - "$(includedir)\Ice\Logger.h" \ - "$(includedir)\Ice\LoggerUtil.h" \ - "$(includedir)\Ice\RemoteLogger.h" \ - "$(includedir)\Ice\FactoryTableInit.h" \ - "$(includedir)\Ice\DefaultObjectFactory.h" \ - "$(includedir)\Ice\ObjectFactory.h" \ - "$(includedir)\Ice\Communicator.h" \ - "$(includedir)\Ice\RouterF.h" \ - "$(includedir)\Ice\LocatorF.h" \ - "$(includedir)\Ice\PluginF.h" \ - "$(includedir)\Ice\ImplicitContextF.h" \ - "$(includedir)\Ice\FacetMap.h" \ - "$(includedir)\Ice\CommunicatorAsync.h" \ - "$(includedir)\Ice\ObjectAdapter.h" \ - "$(includedir)\Ice\Endpoint.h" \ - "$(includedir)\Ice\ServantLocator.h" \ - "$(includedir)\Ice\SlicedData.h" \ - "$(includedir)\Ice\OutgoingAsync.h" \ - "$(includedir)\Ice\OutgoingAsyncF.h" \ - "$(includedir)\Ice\Process.h" \ - "$(includedir)\Ice\Application.h" \ - "$(includedir)\Ice\Connection.h" \ - "$(includedir)\Ice\ConnectionAsync.h" \ - "$(includedir)\Ice\Functional.h" \ - "$(includedir)\IceUtil\Functional.h" \ - "$(includedir)\Ice\Stream.h" \ - "$(includedir)\Ice\ImplicitContext.h" \ - "$(includedir)\Ice\Locator.h" \ - "$(includedir)\Ice\ProcessF.h" \ - "$(includedir)\Ice\Router.h" \ - "$(includedir)\Ice\DispatchInterceptor.h" \ - "$(includedir)\Ice\NativePropertiesAdmin.h" \ - "$(includedir)\Ice\Metrics.h" \ - "$(includedir)\Ice\SliceChecksums.h" \ - "$(includedir)\Ice\SliceChecksumDict.h" \ - "$(includedir)\Ice\Service.h" \ - "$(includedir)\Ice\RegisterPlugins.h" \ - "$(includedir)\Slice\Parser.h" \ - "Error.h" \ - "$(includedir)\IceXML\Parser.h" \ - "Util.h" \ - "$(includedir)\Freeze\CatalogData.h" \ - "Exception.h" \ - "$(includedir)\Freeze\Initialize.h" \ - "$(includedir)\Freeze\EvictorF.h" \ - "$(includedir)\Freeze\ConnectionF.h" \ - "$(includedir)\Freeze\Index.h" \ - "$(includedir)\Freeze\DB.h" \ - "$(includedir)\Freeze\Transaction.h" \ - "$(includedir)\Freeze\Connection.h" \ - "$(includedir)\IceUtil\OutputUtil.h" \ - "$(includedir)\IceUtil\Options.h" \ - "$(includedir)\IceUtil\RecMutex.h" \ - "$(includedir)\IceUtil\FileUtil.h" \ diff --git a/cpp/src/FreezeScript/AssignVisitor.cpp b/cpp/src/FreezeScript/AssignVisitor.cpp deleted file mode 100644 index ef112688117..00000000000 --- a/cpp/src/FreezeScript/AssignVisitor.cpp +++ /dev/null @@ -1,595 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/AssignVisitor.h> -#include <FreezeScript/Util.h> -#include <climits> - -using namespace std; - -FreezeScript::AssignVisitor::AssignVisitor(const DataPtr& src, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, bool convert, - const string& context) : - _src(src), _factory(factory), _errorReporter(errorReporter), _convert(convert), - _context(context) -{ -} - -void -FreezeScript::AssignVisitor::visitBoolean(const BooleanDataPtr& dest) -{ - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - string v = s->getValue(); - if(v == "true") - { - dest->setValue(true); - } - else if(v == "false") - { - dest->setValue(false); - } - else - { - conversionError(dest->getType(), _src->getType(), v); - } - } - else - { - dest->setValue(_src->booleanValue(_convert)); - } -} - -void -FreezeScript::AssignVisitor::visitInteger(const IntegerDataPtr& dest) -{ - dest->setValue(_src->integerValue(_convert), true); -} - -void -FreezeScript::AssignVisitor::visitDouble(const DoubleDataPtr& dest) -{ - dest->setValue(_src->doubleValue(_convert)); -} - -void -FreezeScript::AssignVisitor::visitString(const StringDataPtr& dest) -{ - dest->setValue(_src->stringValue(_convert)); -} - -void -FreezeScript::AssignVisitor::visitProxy(const ProxyDataPtr& dest) -{ - ProxyDataPtr p = ProxyDataPtr::dynamicCast(_src); - if(p) - { - dest->setValue(p->getValue()); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - dest->setValue(s->getValue(), false); - } - else - { - typeMismatchError(dest->getType(), _src->getType()); - } - } -} - -void -FreezeScript::AssignVisitor::visitStruct(const StructDataPtr& dest) -{ - Slice::StructPtr type = Slice::StructPtr::dynamicCast(dest->getType()); - assert(type); - StructDataPtr src = StructDataPtr::dynamicCast(_src); - if(src && isCompatible(type, src->getType())) - { - // - // Assign members with the same name. - // - DataMemberMap srcMap = src->getMembers(); - DataMemberMap destMap = dest->getMembers(); - string typeName = typeToString(type); - for(DataMemberMap::iterator p = destMap.begin(); p != destMap.end(); ++p) - { - DataMemberMap::iterator q = srcMap.find(p->first); - if(q != srcMap.end()) - { - string context = typeName + " member " + p->first + " value"; - AssignVisitor v(q->second, _factory, _errorReporter, _convert, context); - p->second->visit(v); - } - } - } - else - { - typeMismatchError(type, _src->getType()); - } -} - -void -FreezeScript::AssignVisitor::visitSequence(const SequenceDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - SequenceDataPtr src = SequenceDataPtr::dynamicCast(_src); - if(src && isCompatible(type, src->getType())) - { - DataList& srcElements = src->getElements(); - DataList destElements; - Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(type); - assert(seqType); - Slice::TypePtr elemType = seqType->type(); - string typeName = typeToString(type); - for(DataList::const_iterator p = srcElements.begin(); p != srcElements.end(); ++p) - { - DataPtr element = _factory->create(elemType, false); - Destroyer<DataPtr> elementDestroyer(element); - AssignVisitor v(*p, _factory, _errorReporter, _convert, typeName + " element"); - element->visit(v); - destElements.push_back(element); - elementDestroyer.release(); - } - DataList& l = dest->getElements(); - l.swap(destElements); - } - else - { - typeMismatchError(type, _src->getType()); - } -} - -void -FreezeScript::AssignVisitor::visitEnum(const EnumDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - IntegerDataPtr i = IntegerDataPtr::dynamicCast(_src); - if(i) - { - if(_convert) - { - Ice::Long l = i->integerValue(); - if(l < 0 || l > INT_MAX || !dest->setValue(static_cast<Ice::Int>(l))) - { - rangeError(i->toString(), type); - } - } - else - { - conversionError(type, i->getType(), i->toString()); - } - } - else - { - string name; - EnumDataPtr e = EnumDataPtr::dynamicCast(_src); - if(e && isCompatible(type, _src->getType())) - { - name = e->toString(); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - name = s->getValue(); - } - else - { - typeMismatchError(type, _src->getType()); - } - } - - if(!dest->setValueAsString(name)) - { - conversionError(type, _src->getType(), name); - } - } -} - -void -FreezeScript::AssignVisitor::visitDictionary(const DictionaryDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - DictionaryDataPtr d = DictionaryDataPtr::dynamicCast(_src); - if(d && isCompatible(type, _src->getType())) - { - DataMap& srcMap = d->getElements(); - DataMap destMap; - Slice::DictionaryPtr dictType = Slice::DictionaryPtr::dynamicCast(type); - assert(dictType); - Slice::TypePtr keyType = dictType->keyType(); - Slice::TypePtr valueType = dictType->valueType(); - string typeName = typeToString(type); - for(DataMap::const_iterator p = srcMap.begin(); p != srcMap.end(); ++p) - { - DataPtr key = _factory->create(keyType, false); - Destroyer<DataPtr> keyDestroyer(key); - DataPtr value = _factory->create(valueType, false); - Destroyer<DataPtr> valueDestroyer(value); - - AssignVisitor keyVisitor(p->first, _factory, _errorReporter, _convert, typeName + " key"); - key->visit(keyVisitor); - - AssignVisitor valueVisitor(p->second, _factory, _errorReporter, _convert, typeName + " value"); - value->visit(valueVisitor); - - DataMap::const_iterator q = destMap.find(key); - if(q != destMap.end()) - { - error("duplicate dictionary key in " + typeToString(dictType)); - } - else - { - destMap.insert(DataMap::value_type(key, value)); - keyDestroyer.release(); - valueDestroyer.release(); - } - } - DataMap& m = dest->getElements(); - m.swap(destMap); - } - else - { - typeMismatchError(type, _src->getType()); - } -} - -void -FreezeScript::AssignVisitor::visitObject(const ObjectRefPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - ObjectRefPtr src = ObjectRefPtr::dynamicCast(_src); - if(!src) - { - typeMismatchError(type, _src->getType()); - } - - ObjectDataPtr srcValue = src->getValue(); - Slice::TypePtr srcType = src->getType(); - if(!srcValue) - { - // - // Allow a nil value from type Object. - // - if(Slice::BuiltinPtr::dynamicCast(srcType) || isCompatible(type, srcType)) - { - dest->setValue(0); - } - else - { - typeMismatchError(type, srcType); - } - } - else - { - Slice::TypePtr srcValueType = srcValue->getType(); - if(isCompatible(type, srcValueType)) - { - dest->setValue(srcValue); - } - else - { - typeMismatchError(type, srcValueType); - } - } -} - -bool -FreezeScript::AssignVisitor::isCompatible(const Slice::TypePtr& dest, const Slice::TypePtr& src) -{ - Slice::BuiltinPtr b1 = Slice::BuiltinPtr::dynamicCast(dest); - if(b1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - switch(b1->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindString: - { - return true; - } - case Slice::Builtin::KindBool: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - } - - return false; - } - case Slice::Builtin::KindBool: - { - if(b2 && (b2->kind() == Slice::Builtin::KindBool || b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - { - return true; - } - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - } - - return false; - } - case Slice::Builtin::KindString: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObjectProxy: - { - return true; - } - case Slice::Builtin::KindObject: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - - return false; - } - else if(Slice::EnumPtr::dynamicCast(src)) - { - return true; - } - else if(Slice::ProxyPtr::dynamicCast(src)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindObject: - { - // - // Allow transformation from Object to class. Validation has to - // be done during transformation, when the actual type of - // an instance can be compared for compatibility with the - // new type. - // - Slice::ClassDeclPtr cl = Slice::ClassDeclPtr::dynamicCast(src); - if(cl || (b2 && b2->kind() == Slice::Builtin::KindObject)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindObjectProxy: - { - Slice::ProxyPtr p = Slice::ProxyPtr::dynamicCast(src); - if(p || (b2 && b2->kind() == Slice::Builtin::KindObjectProxy) || - (b2 && b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindLocalObject: - { - assert(false); - return false; - } - } - - assert(false); - } - - Slice::ClassDeclPtr cl1 = Slice::ClassDeclPtr::dynamicCast(dest); - if(cl1) - { - Slice::ClassDeclPtr cl2 = Slice::ClassDeclPtr::dynamicCast(src); - if(cl2 && checkClasses(cl1, cl2)) - { - return true; - } - - return false; - } - - Slice::StructPtr s1 = Slice::StructPtr::dynamicCast(dest); - if(s1) - { - Slice::StructPtr s2 = Slice::StructPtr::dynamicCast(src); - if(s2 && s1->scoped() == s2->scoped()) - { - return true; - } - - return false; - } - - Slice::ProxyPtr p1 = Slice::ProxyPtr::dynamicCast(dest); - if(p1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - if(b2 && (b2->kind() == Slice::Builtin::KindObjectProxy || b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - Slice::ProxyPtr p2 = Slice::ProxyPtr::dynamicCast(src); - if(p2 && checkClasses(p1->_class(), p2->_class())) - { - return true; - } - - return false; - } - - Slice::DictionaryPtr d1 = Slice::DictionaryPtr::dynamicCast(dest); - if(d1) - { - Slice::DictionaryPtr d2 = Slice::DictionaryPtr::dynamicCast(src); - if(d2) - { - return isCompatible(d1->keyType(), d2->keyType()) && - isCompatible(d1->valueType(), d2->valueType()); - } - - return false; - } - - Slice::SequencePtr seq1 = Slice::SequencePtr::dynamicCast(dest); - if(seq1) - { - Slice::SequencePtr seq2 = Slice::SequencePtr::dynamicCast(src); - if(seq2) - { - return isCompatible(seq1->type(), seq2->type()); - } - - return false; - } - - Slice::EnumPtr e1 = Slice::EnumPtr::dynamicCast(dest); - if(e1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - if(b2 && b2->kind() == Slice::Builtin::KindString) - { - return true; - } - - Slice::EnumPtr e2 = Slice::EnumPtr::dynamicCast(src); - if(e2 && e1->scoped() == e2->scoped()) - { - return true; - } - - return false; - } - - assert(false); - return false; -} - -bool -FreezeScript::AssignVisitor::checkClasses(const Slice::ClassDeclPtr& dest, const Slice::ClassDeclPtr& src) -{ - string s1 = dest->scoped(); - string s2 = src->scoped(); - if(s1 == s2) - { - return true; - } - else - { - Slice::ClassDefPtr def = src->definition(); - if(!def) - { - error("class " + s2 + " declared but not defined"); - } - return def->isA(s1); - } - - return false; -} - -void -FreezeScript::AssignVisitor::typeMismatchError(const Slice::TypePtr& dest, const Slice::TypePtr& src) -{ - ostringstream ostr; - ostr << "unable to transform"; - if(!_context.empty()) - { - ostr << ' ' << _context; - } - ostr << " from " << typeToString(src) << " to " << typeToString(dest); - error(ostr.str()); -} - -void -FreezeScript::AssignVisitor::conversionError(const Slice::TypePtr& dest, const Slice::TypePtr& src, - const string& value) -{ - ostringstream ostr; - ostr << "unable to convert"; - if(!_context.empty()) - { - ostr << ' ' << _context; - } - ostr << " `" << value << "' from " << typeToString(src) << " to " << typeToString(dest); - error(ostr.str()); -} - -void -FreezeScript::AssignVisitor::rangeError(const string& value, const Slice::TypePtr& type) -{ - ostringstream ostr; - if(!_context.empty()) - { - ostr << _context << ' '; - } - ostr << "`" << value << "' is out of range for type " << typeToString(type); - error(ostr.str()); -} - -void -FreezeScript::AssignVisitor::error(const string& msg) -{ - _errorReporter->error(msg); -} diff --git a/cpp/src/FreezeScript/AssignVisitor.h b/cpp/src/FreezeScript/AssignVisitor.h deleted file mode 100644 index ea346a2799f..00000000000 --- a/cpp/src/FreezeScript/AssignVisitor.h +++ /dev/null @@ -1,54 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_ASSIGN_VISITOR_H -#define FREEZE_SCRIPT_ASSIGN_VISITOR_H - -#include <FreezeScript/Data.h> - -namespace FreezeScript -{ - -class AssignVisitor : public DataVisitor -{ -public: - - AssignVisitor(const DataPtr&, const DataFactoryPtr&, const ErrorReporterPtr&, bool, - const std::string& = std::string()); - - virtual void visitBoolean(const BooleanDataPtr&); - virtual void visitInteger(const IntegerDataPtr&); - virtual void visitDouble(const DoubleDataPtr&); - virtual void visitString(const StringDataPtr&); - virtual void visitProxy(const ProxyDataPtr&); - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitEnum(const EnumDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); - -private: - - bool isCompatible(const Slice::TypePtr&, const Slice::TypePtr&); - bool checkClasses(const Slice::ClassDeclPtr&, const Slice::ClassDeclPtr&); - void typeMismatchError(const Slice::TypePtr&, const Slice::TypePtr&); - void conversionError(const Slice::TypePtr&, const Slice::TypePtr&, const std::string&); - void rangeError(const std::string&, const Slice::TypePtr&); - void error(const std::string&); - - DataPtr _src; - DataFactoryPtr _factory; - ErrorReporterPtr _errorReporter; - bool _convert; - std::string _context; // Provides additional detail for use in warning messages. -}; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp deleted file mode 100644 index 96964e2cf15..00000000000 --- a/cpp/src/FreezeScript/Data.cpp +++ /dev/null @@ -1,2585 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceUtil/DisableWarnings.h> -#include <FreezeScript/Data.h> -#include <FreezeScript/Util.h> -#include <FreezeScript/Exception.h> -#include <IceUtil/InputUtil.h> -#include <climits> - -using namespace std; -using namespace IceUtil; - -namespace FreezeScript -{ - -// -// ObjectWriter -// -class ObjectWriter : public Ice::ObjectWriter -{ -public: - - ObjectWriter(const ObjectDataPtr&); - - virtual void write(const Ice::OutputStreamPtr&) const; - -private: - - ObjectDataPtr _value; -}; - -// -// ReadObjectCallback -// -class ReadObjectCallback : public Ice::ReadObjectCallback -{ -public: - - ReadObjectCallback(const ObjectRefPtr&); - - virtual void invoke(const Ice::ObjectPtr&); - -private: - - ObjectRefPtr _ref; -}; - -// -// ObjectReader -// -class ObjectReader : public Ice::ObjectReader -{ -public: - - ObjectReader(const DataFactoryPtr&, const Slice::TypePtr&); - - virtual void read(const Ice::InputStreamPtr&); - - ObjectDataPtr getValue() const; - -private: - - DataFactoryPtr _factory; - Slice::TypePtr _type; - ObjectDataPtr _value; -}; -typedef IceUtil::Handle<ObjectReader> ObjectReaderPtr; - -} // End of namespace Transform - -// -// ObjectWriter -// -FreezeScript::ObjectWriter::ObjectWriter(const ObjectDataPtr& value) : - _value(value) -{ -} - -void -FreezeScript::ObjectWriter::write(const Ice::OutputStreamPtr& out) const -{ - out->startObject(0); - - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(_value->_type); - Slice::ClassDefPtr type; - if(decl) - { - type = decl->definition(); - } - while(type) - { - Slice::ClassDefPtr base; - Slice::ClassList bases = type->bases(); - if(!bases.empty() && !bases.front()->isInterface()) - { - base = bases.front(); - } - - out->startSlice(type->scoped(), type->compactId(), !base); - Slice::DataMemberList members = type->dataMembers(); - for(Slice::DataMemberList::iterator p = members.begin(); p != members.end(); ++p) - { - DataMemberMap::const_iterator q = _value->_members.find((*p)->name()); - assert(q != _value->_members.end()); - q->second->marshal(out); - } - out->endSlice(); - - type = base; - } - - out->endObject(); -} - -// -// ObjectReader -// -FreezeScript::ObjectReader::ObjectReader(const DataFactoryPtr& factory, const Slice::TypePtr& type) : - _factory(factory), _type(type) -{ -} - -void -FreezeScript::ObjectReader::read(const Ice::InputStreamPtr& in) -{ - const_cast<ObjectDataPtr&>(_value) = new ObjectData(_factory, _type, true); - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(_type); - Slice::ClassDefPtr type; - if(decl) - { - type = decl->definition(); - } - - in->startObject(); - - while(type) - { - Slice::ClassDefPtr base; - Slice::ClassList bases = type->bases(); - if(!bases.empty() && !bases.front()->isInterface()) - { - base = bases.front(); - } - - in->startSlice(); - - Slice::DataMemberList members = type->dataMembers(); - for(Slice::DataMemberList::iterator p = members.begin(); p != members.end(); ++p) - { - DataMemberMap::iterator q = _value->_members.find((*p)->name()); - assert(q != _value->_members.end()); - q->second->unmarshal(in); - } - - in->endSlice(); - - type = base; - } - - in->endObject(false); -} - -FreezeScript::ObjectDataPtr -FreezeScript::ObjectReader::getValue() const -{ - return _value; -} - -// -// DataFactory -// -FreezeScript::DataFactory::DataFactory(const Ice::CommunicatorPtr& communicator, const Slice::UnitPtr& unit, - const ErrorReporterPtr& errorReporter) : - _communicator(communicator), _unit(unit), _errorReporter(errorReporter) -{ -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::create(const Slice::TypePtr& type, bool readOnly) -{ - DataPtr data = createImpl(type, readOnly); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createBoolean(bool b, bool readOnly) -{ - DataPtr data = new BooleanData(getBuiltin(Slice::Builtin::KindBool), _errorReporter, readOnly, b); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createInteger(Ice::Long i, bool readOnly) -{ - DataPtr data = new IntegerData(getBuiltin(Slice::Builtin::KindLong), _errorReporter, readOnly, i); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createDouble(double d, bool readOnly) -{ - DataPtr data = new DoubleData(getBuiltin(Slice::Builtin::KindDouble), _errorReporter, readOnly, d); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createString(const string& s, bool readOnly) -{ - DataPtr data = new StringData(this, getBuiltin(Slice::Builtin::KindString), _errorReporter, readOnly, s); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createNil(bool readOnly) -{ - DataPtr data = new ObjectRef(this, getBuiltin(Slice::Builtin::KindObject), readOnly); - if(!readOnly) - { - initialize(data); - } - return data; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createObject(const Slice::TypePtr& type, bool readOnly) -{ - ObjectRefPtr obj; - Slice::ClassDeclPtr cl = Slice::ClassDeclPtr::dynamicCast(type); - if(cl) - { - Slice::ClassDefPtr def = cl->definition(); - if(!def) - { - _errorReporter->error("class " + cl->scoped() + " declared but not defined"); - } - obj = new ObjectRef(this, cl, readOnly); - } - else - { - Slice::BuiltinPtr b = Slice::BuiltinPtr::dynamicCast(type); - if(b && b->kind() == Slice::Builtin::KindObject) - { - obj = new ObjectRef(this, b, readOnly); - } - } - - if(!obj) - { - _errorReporter->error("type `" + typeToString(type) + "' is not a class"); - } - - obj->instantiate(); - - if(!readOnly) - { - initialize(obj); - } - - return obj; -} - -Slice::BuiltinPtr -FreezeScript::DataFactory::getBuiltin(Slice::Builtin::Kind kind) const -{ - return _unit->builtin(kind); -} - -Ice::CommunicatorPtr -FreezeScript::DataFactory::getCommunicator() const -{ - return _communicator; -} - -FreezeScript::ErrorReporterPtr -FreezeScript::DataFactory::getErrorReporter() const -{ - return _errorReporter; -} - -FreezeScript::DataPtr -FreezeScript::DataFactory::createImpl(const Slice::TypePtr& type, bool readOnly) -{ - Slice::BuiltinPtr builtin = Slice::BuiltinPtr::dynamicCast(type); - if(builtin) - { - switch(builtin->kind()) - { - case Slice::Builtin::KindBool: - return new BooleanData(builtin, _errorReporter, readOnly); - - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - return new IntegerData(builtin, _errorReporter, readOnly); - - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - return new DoubleData(builtin, _errorReporter, readOnly); - - case Slice::Builtin::KindString: - return new StringData(this, builtin, _errorReporter, readOnly); - - case Slice::Builtin::KindObject: - return new ObjectRef(this, builtin, readOnly); - - case Slice::Builtin::KindObjectProxy: - return new ProxyData(builtin, _communicator, _errorReporter, readOnly); - - case Slice::Builtin::KindLocalObject: - assert(false); - return 0; - } - } - - Slice::SequencePtr seq = Slice::SequencePtr::dynamicCast(type); - if(seq) - { - return new SequenceData(this, seq, _errorReporter, readOnly); - } - - Slice::ProxyPtr proxy = Slice::ProxyPtr::dynamicCast(type); - if(proxy) - { - return new ProxyData(proxy, _communicator, _errorReporter, readOnly); - } - - Slice::StructPtr st = Slice::StructPtr::dynamicCast(type); - if(st) - { - return new StructData(this, st, _errorReporter, readOnly); - } - - Slice::EnumPtr en = Slice::EnumPtr::dynamicCast(type); - if(en) - { - return new EnumData(en, _errorReporter, readOnly); - } - - Slice::DictionaryPtr dict = Slice::DictionaryPtr::dynamicCast(type); - if(dict) - { - return new DictionaryData(this, dict, _errorReporter, readOnly); - } - - Slice::ClassDeclPtr cl = Slice::ClassDeclPtr::dynamicCast(type); - if(cl) - { - Slice::ClassDefPtr def = cl->definition(); - if(!def) - { - _errorReporter->error("class " + cl->scoped() + " declared but not defined"); - } - return new ObjectRef(this, cl, readOnly); - } - - return 0; -} - -void -FreezeScript::DataFactory::initialize(const DataPtr&) -{ -} - -// -// Data -// -FreezeScript::Data::Data(const ErrorReporterPtr& errorReporter, bool readOnly) : - _errorReporter(errorReporter), _readOnly(readOnly) -{ -} - -FreezeScript::Data::~Data() -{ -} - -bool -FreezeScript::Data::readOnly() const -{ - return _readOnly; -} - -// -// PrimitiveData -// -FreezeScript::PrimitiveData::PrimitiveData(const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly) -{ -} - -FreezeScript::DataPtr -FreezeScript::PrimitiveData::getMember(const string&) const -{ - return 0; -} - -FreezeScript::DataPtr -FreezeScript::PrimitiveData::getElement(const DataPtr&) const -{ - _errorReporter->error("element requested of primitive value"); - return 0; -} - -void -FreezeScript::PrimitiveData::destroy() -{ -} - -// -// BooleanData -// -FreezeScript::BooleanData::BooleanData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(false) -{ -} - -FreezeScript::BooleanData::BooleanData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly, bool value) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(value) -{ -} - -bool -FreezeScript::BooleanData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::BooleanData::operator!=(const Data& rhs) const -{ - const BooleanData* b = dynamic_cast<const BooleanData*>(&rhs); - if(!b) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != b->_value; -} - -bool -FreezeScript::BooleanData::operator<(const Data& rhs) const -{ - const BooleanData* b = dynamic_cast<const BooleanData*>(&rhs); - if(!b) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < b->_value; -} - -FreezeScript::DataPtr -FreezeScript::BooleanData::clone() const -{ - return new BooleanData(_type, _errorReporter, _readOnly, _value); -} - -Slice::TypePtr -FreezeScript::BooleanData::getType() const -{ - return _type; -} - -void -FreezeScript::BooleanData::marshal(const Ice::OutputStreamPtr& out) const -{ - out->write(_value); -} - -void -FreezeScript::BooleanData::unmarshal(const Ice::InputStreamPtr& in) -{ - in->read(_value); -} - -bool -FreezeScript::BooleanData::booleanValue(bool) const -{ - return _value; -} - -Ice::Long -FreezeScript::BooleanData::integerValue(bool) const -{ - _errorReporter->error("boolean cannot be converted to integer"); - return 0; -} - -double -FreezeScript::BooleanData::doubleValue(bool) const -{ - _errorReporter->error("boolean cannot be converted to double"); - return 0; -} - -string -FreezeScript::BooleanData::stringValue(bool convert) const -{ - if(convert) - { - return toString(); - } - else - { - return string(); - } -} - -string -FreezeScript::BooleanData::toString() const -{ - return (_value ? "true" : "false"); -} - -void -FreezeScript::BooleanData::visit(DataVisitor& visitor) -{ - visitor.visitBoolean(this); -} - -bool -FreezeScript::BooleanData::getValue() const -{ - return _value; -} - -void -FreezeScript::BooleanData::setValue(bool v) -{ - _value = v; -} - -// -// IntegerData -// -FreezeScript::IntegerData::IntegerData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(0) -{ -} - -FreezeScript::IntegerData::IntegerData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly, Ice::Long value) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(value) -{ -} - -bool -FreezeScript::IntegerData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::IntegerData::operator!=(const Data& rhs) const -{ - const IntegerData* i = dynamic_cast<const IntegerData*>(&rhs); - if(!i) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != i->_value; -} - -bool -FreezeScript::IntegerData::operator<(const Data& rhs) const -{ - const IntegerData* i = dynamic_cast<const IntegerData*>(&rhs); - if(!i) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < i->_value; -} - -FreezeScript::DataPtr -FreezeScript::IntegerData::clone() const -{ - return new IntegerData(_type, _errorReporter, _readOnly, _value); -} - -Slice::TypePtr -FreezeScript::IntegerData::getType() const -{ - return _type; -} - -void -FreezeScript::IntegerData::marshal(const Ice::OutputStreamPtr& out) const -{ - rangeCheck(_value, true); - - switch(_type->kind()) - { - case Slice::Builtin::KindByte: - { - out->write(static_cast<Ice::Byte>(_value)); - break; - } - case Slice::Builtin::KindShort: - { - out->write(static_cast<Ice::Short>(_value)); - break; - } - case Slice::Builtin::KindInt: - { - out->write(static_cast<Ice::Int>(_value)); - break; - } - case Slice::Builtin::KindLong: - { - out->write(_value); - break; - } - - case Slice::Builtin::KindBool: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } -} - -void -FreezeScript::IntegerData::unmarshal(const Ice::InputStreamPtr& in) -{ - switch(_type->kind()) - { - case Slice::Builtin::KindByte: - { - Ice::Byte val; - in->read(val); - _value = val & 0xff; - break; - } - case Slice::Builtin::KindShort: - { - Ice::Short val; - in->read(val); - _value = val; - break; - } - case Slice::Builtin::KindInt: - { - Ice::Int val; - in->read(val); - _value = val; - break; - } - case Slice::Builtin::KindLong: - { - Ice::Long val; - in->read(val); - _value = val; - break; - } - - case Slice::Builtin::KindBool: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } -} - -bool -FreezeScript::IntegerData::booleanValue(bool) const -{ - _errorReporter->error("integer cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::IntegerData::integerValue(bool) const -{ - return _value; -} - -double -FreezeScript::IntegerData::doubleValue(bool convert) const -{ - if(convert) - { - return static_cast<double>(_value); - } - else - { - _errorReporter->error("integer cannot be converted to double"); - return 0; - } -} - -string -FreezeScript::IntegerData::stringValue(bool convert) const -{ - if(convert) - { - return toString(); - } - else - { - _errorReporter->error("integer cannot be converted to string"); - return string(); - } -} - -string -FreezeScript::IntegerData::toString() const -{ - return toString(_value); -} - -void -FreezeScript::IntegerData::visit(DataVisitor& visitor) -{ - visitor.visitInteger(this); -} - -Ice::Long -FreezeScript::IntegerData::getValue() const -{ - return _value; -} - -void -FreezeScript::IntegerData::setValue(Ice::Long v, bool fatal) -{ - if(rangeCheck(v, fatal)) - { - _value = v; - } -} - -bool -FreezeScript::IntegerData::rangeCheck(Ice::Long value, bool fatal) const -{ - switch(_type->kind()) - { - case Slice::Builtin::KindByte: - { - if(value < 0 || value > 255) - { - _errorReporter->rangeError(toString(value), _type, fatal); - } - else - { - return true; - } - break; - } - - case Slice::Builtin::KindShort: - { - if(value < SHRT_MIN || value > SHRT_MAX) - { - _errorReporter->rangeError(toString(value), _type, fatal); - } - else - { - return true; - } - break; - } - - case Slice::Builtin::KindInt: - { - if(value < INT_MIN || value > INT_MAX) - { - _errorReporter->rangeError(toString(value), _type, fatal); - } - else - { - return true; - } - break; - } - - case Slice::Builtin::KindLong: - { - return true; - } - - case Slice::Builtin::KindBool: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } - - return false; -} - -string -FreezeScript::IntegerData::toString(Ice::Long value) -{ - char buf[64]; -#ifdef _WIN32 - sprintf_s(buf, "%I64d", value); -#elif defined(ICE_64) - sprintf(buf, "%ld", value); -#else - sprintf(buf, "%lld", value); -#endif - return string(buf); -} - -// -// DoubleData -// -FreezeScript::DoubleData::DoubleData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(0) -{ -} - -FreezeScript::DoubleData::DoubleData(const Slice::BuiltinPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly, double value) : - PrimitiveData(errorReporter, readOnly), _type(type), _value(value) -{ -} - -bool -FreezeScript::DoubleData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::DoubleData::operator!=(const Data& rhs) const -{ - const DoubleData* d = dynamic_cast<const DoubleData*>(&rhs); - if(!d) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != d->_value; -} - -bool -FreezeScript::DoubleData::operator<(const Data& rhs) const -{ - const DoubleData* d = dynamic_cast<const DoubleData*>(&rhs); - if(!d) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < d->_value; -} - -FreezeScript::DataPtr -FreezeScript::DoubleData::clone() const -{ - return new DoubleData(_type, _errorReporter, _readOnly, _value); -} - -Slice::TypePtr -FreezeScript::DoubleData::getType() const -{ - return _type; -} - -void -FreezeScript::DoubleData::marshal(const Ice::OutputStreamPtr& out) const -{ - switch(_type->kind()) - { - case Slice::Builtin::KindFloat: - { - out->write(static_cast<Ice::Float>(_value)); - break; - } - case Slice::Builtin::KindDouble: - { - out->write(_value); - break; - } - - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } -} - -void -FreezeScript::DoubleData::unmarshal(const Ice::InputStreamPtr& in) -{ - switch(_type->kind()) - { - case Slice::Builtin::KindFloat: - { - Ice::Float val; - in->read(val); - _value = val; - break; - } - case Slice::Builtin::KindDouble: - { - in->read(_value); - break; - } - - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } -} - -bool -FreezeScript::DoubleData::booleanValue(bool) const -{ - _errorReporter->error("double cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::DoubleData::integerValue(bool convert) const -{ - if(convert) - { - return static_cast<Ice::Long>(_value); - } - else - { - _errorReporter->error("double cannot be converted to integer"); - return 0; - } -} - -double -FreezeScript::DoubleData::doubleValue(bool) const -{ - return _value; -} - -string -FreezeScript::DoubleData::stringValue(bool convert) const -{ - if(convert) - { - return toString(); - } - else - { - _errorReporter->error("double cannot be converted to string"); - return string(); - } -} - -string -FreezeScript::DoubleData::toString() const -{ - char buff[64]; - sprintf(buff, "%g", _value); - return string(buff); -} - -void -FreezeScript::DoubleData::visit(DataVisitor& visitor) -{ - visitor.visitDouble(this); -} - -double -FreezeScript::DoubleData::getValue() const -{ - return _value; -} - -void -FreezeScript::DoubleData::setValue(double v) -{ - _value = v; -} - -// -// StringData -// -FreezeScript::StringData::StringData(const DataFactoryPtr& factory, const Slice::BuiltinPtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly) : - PrimitiveData(errorReporter, readOnly), _factory(factory), _type(type) -{ - setValue(""); -} - -FreezeScript::StringData::StringData(const DataFactoryPtr& factory, const Slice::BuiltinPtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly, const string& value) : - PrimitiveData(errorReporter, readOnly), _factory(factory), _type(type) -{ - setValue(value); -} - -FreezeScript::DataPtr -FreezeScript::StringData::getMember(const string& member) const -{ - if(member == "length") - { - _length->setValue(static_cast<Ice::Long>(_value.size()), false); - return _length; - } - - return 0; -} - -bool -FreezeScript::StringData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::StringData::operator!=(const Data& rhs) const -{ - const StringData* s = dynamic_cast<const StringData*>(&rhs); - if(!s) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != s->_value; -} - -bool -FreezeScript::StringData::operator<(const Data& rhs) const -{ - const StringData* s = dynamic_cast<const StringData*>(&rhs); - if(!s) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < s->_value; -} - -FreezeScript::DataPtr -FreezeScript::StringData::clone() const -{ - return new StringData(_factory, _type, _errorReporter, _readOnly, _value); -} - -Slice::TypePtr -FreezeScript::StringData::getType() const -{ - return _type; -} - -void -FreezeScript::StringData::marshal(const Ice::OutputStreamPtr& out) const -{ - out->write(_value); -} - -void -FreezeScript::StringData::unmarshal(const Ice::InputStreamPtr& in) -{ - string val; - in->read(val); - setValue(val); -} - -bool -FreezeScript::StringData::booleanValue(bool) const -{ - _errorReporter->error("string cannot be converted to boolean"); - return false; -} - -Ice::Long -FreezeScript::StringData::integerValue(bool) const -{ - _errorReporter->error("string cannot be converted to integer"); - return 0; -} - -double -FreezeScript::StringData::doubleValue(bool) const -{ - _errorReporter->error("string cannot be converted to double"); - return 0; -} - -string -FreezeScript::StringData::stringValue(bool) const -{ - return _value; -} - -string -FreezeScript::StringData::toString() const -{ - return _value; -} - -void -FreezeScript::StringData::visit(DataVisitor& visitor) -{ - visitor.visitString(this); -} - -string -FreezeScript::StringData::getValue() const -{ - return _value; -} - -void -FreezeScript::StringData::setValue(const string& v) -{ - _value = v; - _length = IntegerDataPtr::dynamicCast(_factory->createInteger(static_cast<Ice::Long>(_value.size()), true)); -} - -// -// ProxyData -// -FreezeScript::ProxyData::ProxyData(const Slice::TypePtr& type, const Ice::CommunicatorPtr& communicator, - const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly), _type(type), _communicator(communicator) -{ -} - -FreezeScript::ProxyData::ProxyData(const Slice::TypePtr& type, const Ice::CommunicatorPtr& communicator, - const ErrorReporterPtr& errorReporter, bool readOnly, const Ice::ObjectPrx& value) : - Data(errorReporter, readOnly), _type(type), _communicator(communicator), _value(value) -{ -} - -FreezeScript::DataPtr -FreezeScript::ProxyData::getMember(const string& /*member*/) const -{ - // TODO: Support members (id, facet, etc.)? - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::ProxyData::getElement(const DataPtr&) const -{ - _errorReporter->error("element requested of proxy value"); - return 0; -} - -bool -FreezeScript::ProxyData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::ProxyData::operator!=(const Data& rhs) const -{ - const ProxyData* p = dynamic_cast<const ProxyData*>(&rhs); - if(!p) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != p->_value; -} - -bool -FreezeScript::ProxyData::operator<(const Data& rhs) const -{ - const ProxyData* p = dynamic_cast<const ProxyData*>(&rhs); - if(!p) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < p->_value; -} - -FreezeScript::DataPtr -FreezeScript::ProxyData::clone() const -{ - return new ProxyData(_type, _communicator, _errorReporter, _readOnly, _value); -} - -Slice::TypePtr -FreezeScript::ProxyData::getType() const -{ - return _type; -} - -void -FreezeScript::ProxyData::destroy() -{ -} - -void -FreezeScript::ProxyData::marshal(const Ice::OutputStreamPtr& out) const -{ - out->write(_value); -} - -void -FreezeScript::ProxyData::unmarshal(const Ice::InputStreamPtr& in) -{ - in->read(_value); -} - -bool -FreezeScript::ProxyData::booleanValue(bool) const -{ - _errorReporter->error("proxy cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::ProxyData::integerValue(bool) const -{ - _errorReporter->error("proxy cannot be converted to integer"); - return 0; -} - -double -FreezeScript::ProxyData::doubleValue(bool) const -{ - _errorReporter->error("proxy cannot be converted to double"); - return 0; -} - -string -FreezeScript::ProxyData::stringValue(bool) const -{ - _errorReporter->error("proxy cannot be converted to string"); - return string(); -} - -string -FreezeScript::ProxyData::toString() const -{ - if(_value && _str.empty()) - { - const_cast<string&>(_str) = _communicator->proxyToString(_value); - } - return _str; -} - -void -FreezeScript::ProxyData::visit(DataVisitor& visitor) -{ - visitor.visitProxy(this); -} - -Ice::ObjectPrx -FreezeScript::ProxyData::getValue() const -{ - return _value; -} - -void -FreezeScript::ProxyData::setValue(const string& str, bool fatal) -{ - try - { - _value = _communicator->stringToProxy(str); - _str = str; - } - catch(const Ice::LocalException&) - { - _errorReporter->conversionError(str, _type, fatal); - } -} - -void -FreezeScript::ProxyData::setValue(const Ice::ObjectPrx& v) -{ - _value = v; - _str.clear(); -} - - -// -// StructData -// -FreezeScript::StructData::StructData(const DataFactoryPtr& factory, const Slice::StructPtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly), _type(type) -{ - Slice::DataMemberList members = type->dataMembers(); - for(Slice::DataMemberList::iterator q = members.begin(); q != members.end(); ++q) - { - DataPtr value = factory->create((*q)->type(), _readOnly); - assert(value); - _members[(*q)->name()] = value; - } -} - -FreezeScript::StructData::StructData(const Slice::StructPtr& type, const ErrorReporterPtr& errorReporter, - bool readOnly, const DataMemberMap& members) : - Data(errorReporter, readOnly), _type(type) -{ - for(DataMemberMap::const_iterator p = members.begin(); p != members.end(); ++p) - { - _members[p->first] = p->second->clone(); - } -} - -FreezeScript::DataPtr -FreezeScript::StructData::getMember(const string& member) const -{ - DataMemberMap::const_iterator p = _members.find(member); - if(p != _members.end()) - { - return p->second; - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::StructData::getElement(const DataPtr&) const -{ - _errorReporter->error("element requested of struct value"); - return 0; -} - -bool -FreezeScript::StructData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::StructData::operator!=(const Data& rhs) const -{ - const StructData* s = dynamic_cast<const StructData*>(&rhs); - if(!s || _type->scoped() != s->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - assert(_members.size() == s->_members.size()); - - for(DataMemberMap::const_iterator p = _members.begin(); p != _members.end(); ++p) - { - DataMemberMap::const_iterator q = s->_members.find(p->first); - assert(q != s->_members.end()); - - if(p->second != q->second) - { - return true; - } - } - - return false; -} - -bool -FreezeScript::StructData::operator<(const Data& rhs) const -{ - const StructData* s = dynamic_cast<const StructData*>(&rhs); - if(!s || _type->scoped() != s->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - assert(_members.size() == s->_members.size()); - - for(DataMemberMap::const_iterator p = _members.begin(); p != _members.end(); ++p) - { - DataMemberMap::const_iterator q = s->_members.find(p->first); - assert(q != s->_members.end()); - - if(p->second < q->second) - { - return true; - } - else if(q->second < p->second) - { - return false; - } - } - - return false; -} - -FreezeScript::DataPtr -FreezeScript::StructData::clone() const -{ - return new StructData(_type, _errorReporter, _readOnly, _members); -} - -Slice::TypePtr -FreezeScript::StructData::getType() const -{ - return _type; -} - -void -FreezeScript::StructData::destroy() -{ - for(DataMemberMap::const_iterator p = _members.begin(); p != _members.end(); ++p) - { - p->second->destroy(); - } -} - -void -FreezeScript::StructData::marshal(const Ice::OutputStreamPtr& out) const -{ - Slice::DataMemberList members = _type->dataMembers(); - for(Slice::DataMemberList::iterator p = members.begin(); p != members.end(); ++p) - { - DataMemberMap::const_iterator q = _members.find((*p)->name()); - assert(q != _members.end()); - q->second->marshal(out); - } -} - -void -FreezeScript::StructData::unmarshal(const Ice::InputStreamPtr& in) -{ - Slice::DataMemberList members = _type->dataMembers(); - for(Slice::DataMemberList::iterator p = members.begin(); p != members.end(); ++p) - { - DataMemberMap::const_iterator q = _members.find((*p)->name()); - assert(q != _members.end()); - q->second->unmarshal(in); - } -} - -bool -FreezeScript::StructData::booleanValue(bool) const -{ - _errorReporter->error("struct " + typeToString(_type) + " cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::StructData::integerValue(bool) const -{ - _errorReporter->error("struct " + typeToString(_type) + " cannot be converted to integer"); - return 0; -} - -double -FreezeScript::StructData::doubleValue(bool) const -{ - _errorReporter->error("struct " + typeToString(_type) + " cannot be converted to double"); - return 0; -} - -string -FreezeScript::StructData::stringValue(bool) const -{ - _errorReporter->error("struct " + typeToString(_type) + " cannot be converted to string"); - return string(); -} - -string -FreezeScript::StructData::toString() const -{ - return stringValue(); -} - -void -FreezeScript::StructData::visit(DataVisitor& visitor) -{ - visitor.visitStruct(this); -} - -FreezeScript::DataMemberMap& -FreezeScript::StructData::getMembers() -{ - return _members; -} - -// -// SequenceData -// -FreezeScript::SequenceData::SequenceData(const DataFactoryPtr& factory, const Slice::SequencePtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly), _factory(factory), _type(type) -{ - _length = IntegerDataPtr::dynamicCast(_factory->createInteger(0, true)); -} - -FreezeScript::SequenceData::SequenceData(const DataFactoryPtr& factory, const Slice::SequencePtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly, - const DataList& elements) : - Data(errorReporter, readOnly), _factory(factory), _type(type) -{ - for(DataList::const_iterator p = elements.begin(); p != elements.end(); ++p) - { - _elements.push_back((*p)->clone()); - } - _length = IntegerDataPtr::dynamicCast(_factory->createInteger(static_cast<Ice::Long>(_elements.size()), true)); -} - -FreezeScript::DataPtr -FreezeScript::SequenceData::getMember(const string& member) const -{ - if(member == "length") - { - _length->setValue(static_cast<Ice::Long>(_elements.size()), false); - return _length; - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::SequenceData::getElement(const DataPtr& element) const -{ - IntegerDataPtr i = IntegerDataPtr::dynamicCast(element); - if(!i) - { - _errorReporter->error("invalid sequence index type " + typeToString(element->getType())); - } - - Ice::Long iv = i->integerValue(); - if(iv < 0 || iv >= static_cast<Ice::Long>(_elements.size())) - { - _errorReporter->error("sequence index " + i->toString() + " out of range"); - } - - return _elements[static_cast<DataList::size_type>(iv)]; -} - -bool -FreezeScript::SequenceData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::SequenceData::operator!=(const Data& rhs) const -{ - const SequenceData* s = dynamic_cast<const SequenceData*>(&rhs); - if(!s || _type->scoped() != s->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _elements != s->_elements; -} - -bool -FreezeScript::SequenceData::operator<(const Data& rhs) const -{ - const SequenceData* s = dynamic_cast<const SequenceData*>(&rhs); - if(!s || _type->scoped() != s->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _elements < s->_elements; -} - -FreezeScript::DataPtr -FreezeScript::SequenceData::clone() const -{ - return new SequenceData(_factory, _type, _errorReporter, _readOnly, _elements); -} - -Slice::TypePtr -FreezeScript::SequenceData::getType() const -{ - return _type; -} - -void -FreezeScript::SequenceData::destroy() -{ - for(DataList::const_iterator p = _elements.begin(); p != _elements.end(); ++p) - { - (*p)->destroy(); - } -} - -void -FreezeScript::SequenceData::marshal(const Ice::OutputStreamPtr& out) const -{ - out->writeSize(static_cast<int>(_elements.size())); - for(DataList::const_iterator p = _elements.begin(); p != _elements.end(); ++p) - { - (*p)->marshal(out); - } -} - -void -FreezeScript::SequenceData::unmarshal(const Ice::InputStreamPtr& in) -{ - Slice::TypePtr type = _type->type(); - Ice::Int sz = in->readSize(); - _elements.reserve(sz); - for(Ice::Int i = 0; i < sz; ++i) - { - DataPtr v = _factory->create(type, _readOnly); - v->unmarshal(in); - _elements.push_back(v); - } - _length->setValue(sz, false); -} - -bool -FreezeScript::SequenceData::booleanValue(bool) const -{ - _errorReporter->error("sequence " + typeToString(_type) + " cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::SequenceData::integerValue(bool) const -{ - _errorReporter->error("sequence " + typeToString(_type) + " cannot be converted to integer"); - return 0; -} - -double -FreezeScript::SequenceData::doubleValue(bool) const -{ - _errorReporter->error("sequence " + typeToString(_type) + " cannot be converted to double"); - return 0; -} - -string -FreezeScript::SequenceData::stringValue(bool) const -{ - _errorReporter->error("sequence " + typeToString(_type) + " cannot be converted to string"); - return string(); -} - -string -FreezeScript::SequenceData::toString() const -{ - return stringValue(); -} - -void -FreezeScript::SequenceData::visit(DataVisitor& visitor) -{ - visitor.visitSequence(this); -} - -FreezeScript::DataList& -FreezeScript::SequenceData::getElements() -{ - return _elements; -} - -// -// EnumData -// -FreezeScript::EnumData::EnumData(const Slice::EnumPtr& type, const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly), _type(type), _value(0) -{ - _count = static_cast<int>(type->getEnumerators().size()); -} - -FreezeScript::EnumData::EnumData(const Slice::EnumPtr& type, const ErrorReporterPtr& errorReporter, bool readOnly, - Ice::Int value) : - Data(errorReporter, readOnly), _type(type), _value(value) -{ - _count = static_cast<int>(type->getEnumerators().size()); -} - -FreezeScript::DataPtr -FreezeScript::EnumData::getMember(const string&) const -{ - return 0; -} - -FreezeScript::DataPtr -FreezeScript::EnumData::getElement(const DataPtr&) const -{ - _errorReporter->error("element requested of enum value"); - return 0; -} - -bool -FreezeScript::EnumData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::EnumData::operator!=(const Data& rhs) const -{ - const EnumData* e = dynamic_cast<const EnumData*>(&rhs); - if(!e || _type->scoped() != e->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value != e->_value; -} - -bool -FreezeScript::EnumData::operator<(const Data& rhs) const -{ - const EnumData* e = dynamic_cast<const EnumData*>(&rhs); - if(!e || _type->scoped() != e->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _value < e->_value; -} - -FreezeScript::DataPtr -FreezeScript::EnumData::clone() const -{ - return new EnumData(_type, _errorReporter, _value); -} - -Slice::TypePtr -FreezeScript::EnumData::getType() const -{ - return _type; -} - -void -FreezeScript::EnumData::destroy() -{ -} - -void -FreezeScript::EnumData::marshal(const Ice::OutputStreamPtr& out) const -{ - if(_count <= 127) - { - out->write(static_cast<Ice::Byte>(_value)); - } - else if(_count <= 32767) - { - out->write(static_cast<Ice::Short>(_value)); - } - else - { - out->write(_value); - } -} - -void -FreezeScript::EnumData::unmarshal(const Ice::InputStreamPtr& in) -{ - if(_count <= 127) - { - Ice::Byte val; - in ->read(val); - _value = val & 0xff; - } - else if(_count <= 32767) - { - Ice::Short val; - in->read(val); - _value = val; - } - else - { - in->read(_value); - } -} - -bool -FreezeScript::EnumData::booleanValue(bool) const -{ - _errorReporter->error("enum " + typeToString(_type) + " cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::EnumData::integerValue(bool convert) const -{ - if(convert) - { - return _value; - } - else - { - _errorReporter->error("enum " + typeToString(_type) + " cannot be converted to integer"); - return 0; - } -} - -double -FreezeScript::EnumData::doubleValue(bool) const -{ - _errorReporter->error("enum " + typeToString(_type) + " cannot be converted to double"); - return 0; -} - -string -FreezeScript::EnumData::stringValue(bool) const -{ - _errorReporter->error("enum " + typeToString(_type) + " cannot be converted to string"); - return string(); -} - -string -FreezeScript::EnumData::toString() const -{ - if(_name.empty()) - { - Slice::EnumeratorList l = _type->getEnumerators(); - Slice::EnumeratorList::const_iterator p = l.begin(); - Ice::Int i = _value; - while(i > 0) - { - ++p; - assert(p != l.end()); - --i; - } - const_cast<string&>(_name) = (*p)->name(); - } - return _name; -} - -void -FreezeScript::EnumData::visit(DataVisitor& visitor) -{ - visitor.visitEnum(this); -} - -Ice::Int -FreezeScript::EnumData::getValue() const -{ - return _value; -} - -bool -FreezeScript::EnumData::setValue(Ice::Int v) -{ - if(v >= 0 && v < _count) - { - _value = v; - _name.clear(); - return true; - } - return false; -} - -bool -FreezeScript::EnumData::setValueAsString(const string& v) -{ - Slice::EnumeratorList l = _type->getEnumerators(); - Slice::EnumeratorList::const_iterator p; - Ice::Int i = 0; - for(p = l.begin(); p != l.end(); ++p, ++i) - { - if((*p)->name() == v) - { - _value = i; - _name = v; - break; - } - } - return p != l.end(); -} - -// -// DictionaryData -// -FreezeScript::DictionaryData::DictionaryData(const DataFactoryPtr& factory, const Slice::DictionaryPtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly) : - Data(errorReporter, readOnly), _factory(factory), _type(type) -{ - _length = IntegerDataPtr::dynamicCast(_factory->createInteger(0, true)); -} - -FreezeScript::DictionaryData::DictionaryData(const DataFactoryPtr& factory, const Slice::DictionaryPtr& type, - const ErrorReporterPtr& errorReporter, bool readOnly, const DataMap& m) : - Data(errorReporter, readOnly), _factory(factory), _type(type) -{ - for(DataMap::const_iterator p = m.begin(); p != m.end(); ++p) - { - _map.insert(DataMap::value_type(p->first->clone(), p->second->clone())); - } - _length = IntegerDataPtr::dynamicCast(_factory->createInteger(static_cast<Ice::Long>(_map.size()), true)); -} - -FreezeScript::DataPtr -FreezeScript::DictionaryData::getMember(const string& member) const -{ - if(member == "length") - { - _length->setValue(static_cast<Ice::Long>(_map.size()), false); - return _length; - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::DictionaryData::getElement(const DataPtr& element) const -{ - DataMap::const_iterator p = _map.find(element); - if(p != _map.end()) - { - return p->second; - } - - return 0; -} - -bool -FreezeScript::DictionaryData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::DictionaryData::operator!=(const Data& rhs) const -{ - const DictionaryData* d = dynamic_cast<const DictionaryData*>(&rhs); - if(!d || _type->scoped() != d->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _map != d->_map; -} - -bool -FreezeScript::DictionaryData::operator<(const Data& rhs) const -{ - const DictionaryData* d = dynamic_cast<const DictionaryData*>(&rhs); - if(!d || _type->scoped() != d->_type->scoped()) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - assert(false); - } - - return _map < d->_map; -} - -FreezeScript::DataPtr -FreezeScript::DictionaryData::clone() const -{ - return new DictionaryData(_factory, _type, _errorReporter, _readOnly, _map); -} - -Slice::TypePtr -FreezeScript::DictionaryData::getType() const -{ - return _type; -} - -void -FreezeScript::DictionaryData::destroy() -{ - for(DataMap::const_iterator p = _map.begin(); p != _map.end(); ++p) - { - p->first->destroy(); - p->second->destroy(); - } -} - -void -FreezeScript::DictionaryData::marshal(const Ice::OutputStreamPtr& out) const -{ - out->writeSize(static_cast<int>(_map.size())); - for(DataMap::const_iterator p = _map.begin(); p != _map.end(); ++p) - { - p->first->marshal(out); - p->second->marshal(out); - } -} - -void -FreezeScript::DictionaryData::unmarshal(const Ice::InputStreamPtr& in) -{ - Slice::TypePtr keyType = _type->keyType(); - Slice::TypePtr valueType = _type->valueType(); - - Ice::Int sz = in->readSize(); - - for(Ice::Int i = 0; i < sz; ++i) - { - DataPtr key = _factory->create(keyType, _readOnly); - key->unmarshal(in); - - DataPtr value = _factory->create(valueType, _readOnly); - value->unmarshal(in); - - _map.insert(DataMap::value_type(key, value)); - } - - _length->setValue(static_cast<Ice::Long>(_map.size()), false); -} - -bool -FreezeScript::DictionaryData::booleanValue(bool) const -{ - _errorReporter->error("dictionary " + typeToString(_type) + " cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::DictionaryData::integerValue(bool) const -{ - _errorReporter->error("dictionary " + typeToString(_type) + " cannot be converted to integer"); - return 0; -} - -double -FreezeScript::DictionaryData::doubleValue(bool) const -{ - _errorReporter->error("dictionary " + typeToString(_type) + " cannot be converted to double"); - return 0; -} - -string -FreezeScript::DictionaryData::stringValue(bool) const -{ - _errorReporter->error("dictionary " + typeToString(_type) + " cannot be converted to string"); - return string(); -} - -string -FreezeScript::DictionaryData::toString() const -{ - return stringValue(); -} - -void -FreezeScript::DictionaryData::visit(DataVisitor& visitor) -{ - visitor.visitDictionary(this); -} - -FreezeScript::DataMap& -FreezeScript::DictionaryData::getElements() -{ - return _map; -} - -// -// ObjectData -// -FreezeScript::ObjectData::ObjectData(const DataFactoryPtr& factory, const Slice::TypePtr& type, bool readOnly) : - Data(factory->getErrorReporter(), readOnly), _type(type), _refCount(0) -{ - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(type); - if(decl) - { - Slice::ClassDefPtr def = decl->definition(); - assert(def); - Slice::DataMemberList members = def->allDataMembers(); - for(Slice::DataMemberList::iterator p = members.begin(); p != members.end(); ++p) - { - _members[(*p)->name()] = factory->create((*p)->type(), _readOnly); - } - _id = factory->createString(decl->scoped(), true); - } - else - { - _id = factory->createString("::Ice::Object", true); - } -} - -FreezeScript::DataPtr -FreezeScript::ObjectData::getMember(const string& member) const -{ - if(member == "ice_id") - { - return _id; - } - - DataMemberMap::const_iterator p = _members.find(member); - if(p != _members.end()) - { - return p->second; - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::ObjectData::getElement(const DataPtr& /*element*/) const -{ - _errorReporter->error("element requested of object value"); - return 0; -} - -bool -FreezeScript::ObjectData::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::ObjectData::operator!=(const Data& /*rhs*/) const -{ - _errorReporter->error("object comparison not supported"); - return false; -} - -bool -FreezeScript::ObjectData::operator<(const Data& /*rhs*/) const -{ - _errorReporter->error("object comparison not supported"); - return false; -} - -FreezeScript::DataPtr -FreezeScript::ObjectData::clone() const -{ - assert(false); - return 0; -} - -Slice::TypePtr -FreezeScript::ObjectData::getType() const -{ - return _type; -} - -void -FreezeScript::ObjectData::destroy() -{ - assert(false); -} - -void -FreezeScript::ObjectData::marshal(const Ice::OutputStreamPtr& out) const -{ - if(!_marshaler) - { - const_cast<Ice::ObjectPtr&>(_marshaler) = new ObjectWriter(const_cast<ObjectData*>(this)); - } - out->writeObject(_marshaler); -} - -void -FreezeScript::ObjectData::unmarshal(const Ice::InputStreamPtr& /*in*/) -{ - // - // Unmarshaling is done by ObjectReader. - // - assert(false); -} - -bool -FreezeScript::ObjectData::booleanValue(bool) const -{ - assert(false); - return 0; -} - -Ice::Long -FreezeScript::ObjectData::integerValue(bool) const -{ - assert(false); - return 0; -} - -double -FreezeScript::ObjectData::doubleValue(bool) const -{ - assert(false); - return 0; -} - -string -FreezeScript::ObjectData::stringValue(bool) const -{ - assert(false); - return string(); -} - -string -FreezeScript::ObjectData::toString() const -{ - assert(false); - return string(); -} - -void -FreezeScript::ObjectData::visit(DataVisitor& /*visitor*/) -{ - assert(false); -} - -FreezeScript::DataMemberMap& -FreezeScript::ObjectData::getMembers() -{ - return _members; -} - -void -FreezeScript::ObjectData::incRef() -{ - _refCount++; -} - -void -FreezeScript::ObjectData::decRef() -{ - assert(_refCount > 0); - _refCount--; - if(_refCount == 0) - { - destroyI(); - } -} - -void -FreezeScript::ObjectData::destroyI() -{ - DataMemberMap members = _members; - - _members.clear(); - _marshaler = 0; - - for(DataMemberMap::const_iterator p = members.begin(); p != members.end(); ++p) - { - p->second->destroy(); - } -} - -// -// ObjectRef -// -FreezeScript::ObjectRef::ObjectRef(const DataFactoryPtr& factory, const Slice::TypePtr& type, bool readOnly) : - Data(factory->getErrorReporter(), readOnly), _factory(factory), _type(type) -{ -} - -FreezeScript::ObjectRef::ObjectRef(const DataFactoryPtr& factory, const Slice::TypePtr& type, bool readOnly, - const ObjectDataPtr& value) : - Data(factory->getErrorReporter(), readOnly), _factory(factory), _type(type), _value(value) -{ - _value->incRef(); -} - -FreezeScript::DataPtr -FreezeScript::ObjectRef::getMember(const string& member) const -{ - if(!_value) - { - _errorReporter->error("member `" + member + "' requested of nil object"); - } - - return _value->getMember(member); -} - -FreezeScript::DataPtr -FreezeScript::ObjectRef::getElement(const DataPtr&) const -{ - _errorReporter->error("element requested of object value"); - return 0; -} - -bool -FreezeScript::ObjectRef::operator==(const Data& rhs) const -{ - return !operator!=(rhs); -} - -bool -FreezeScript::ObjectRef::operator!=(const Data& rhs) const -{ - const ObjectRef* r = dynamic_cast<const ObjectRef*>(&rhs); - if(!r) - { - _errorReporter->typeMismatchError(_type, rhs.getType(), true); - } - - // - // Reference comparison. - // - return _value.get() != r->_value.get(); -} - -bool -FreezeScript::ObjectRef::operator<(const Data& /*rhs*/) const -{ - _errorReporter->error("object comparison not supported"); - return false; -} - -FreezeScript::DataPtr -FreezeScript::ObjectRef::clone() const -{ - return new ObjectRef(_factory, _type, _value); -} - -Slice::TypePtr -FreezeScript::ObjectRef::getType() const -{ - return _type; -} - -void -FreezeScript::ObjectRef::destroy() -{ - if(_value) - { - _value->decRef(); - _value = 0; - } -} - -void -FreezeScript::ObjectRef::marshal(const Ice::OutputStreamPtr& out) const -{ - if(!_value) - { - out->writeObject(0); - return; - } - - _value->marshal(out); -} - -FreezeScript::ReadObjectCallback::ReadObjectCallback(const ObjectRefPtr& ref) : - _ref(ref) -{ -} - -void -FreezeScript::ReadObjectCallback::invoke(const Ice::ObjectPtr& p) -{ - if(p) - { - ObjectReaderPtr reader = ObjectReaderPtr::dynamicCast(p); - assert(reader); - - _ref->setValue(reader->getValue()); - } -} - -void -FreezeScript::ObjectRef::unmarshal(const Ice::InputStreamPtr& in) -{ - in->readObject(new ReadObjectCallback(this)); -} - -bool -FreezeScript::ObjectRef::booleanValue(bool) const -{ - _errorReporter->error(typeToString(_type) + " cannot be converted to boolean"); - return 0; -} - -Ice::Long -FreezeScript::ObjectRef::integerValue(bool) const -{ - _errorReporter->error(typeToString(_type) + " cannot be converted to integer"); - return 0; -} - -double -FreezeScript::ObjectRef::doubleValue(bool) const -{ - _errorReporter->error(typeToString(_type) + " cannot be converted to double"); - return 0; -} - -string -FreezeScript::ObjectRef::stringValue(bool) const -{ - _errorReporter->error(typeToString(_type) + " cannot be converted to string"); - return string(); -} - -string -FreezeScript::ObjectRef::toString() const -{ - return stringValue(); -} - -void -FreezeScript::ObjectRef::visit(DataVisitor& visitor) -{ - visitor.visitObject(this); -} - -void -FreezeScript::ObjectRef::instantiate() -{ - ObjectDataPtr data = new ObjectData(_factory, _type, _readOnly); - setValue(data); -} - -FreezeScript::ObjectDataPtr -FreezeScript::ObjectRef::getValue() const -{ - return _value; -} - -void -FreezeScript::ObjectRef::setValue(const ObjectDataPtr& value) -{ - // TODO: Type check? - ObjectDataPtr oldValue = _value; - _value = value; - if(_value) - { - _value->incRef(); - } - if(oldValue) - { - oldValue->decRef(); - } -} - -// -// ObjectFactory -// -Ice::ObjectPtr -FreezeScript::ObjectFactory::create(const string& id) -{ - Ice::ObjectPtr result; - - if(_factory) - { - if(id == Ice::Object::ice_staticId()) - { - result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject)); - } - else - { - Slice::TypeList l = _unit->lookupTypeNoBuiltin(id); - if(!l.empty()) - { - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front()); - if(!decl) - { - _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class"); - } - Slice::ClassDefPtr def = decl->definition(); - if(!def) - { - _factory->getErrorReporter()->error("no class definition for `" + id + "'"); - } - result = new ObjectReader(_factory, decl); - } - } - } - - return result; -} - -void -FreezeScript::ObjectFactory::destroy() -{ -} - -void -FreezeScript::ObjectFactory::activate(const DataFactoryPtr& factory, const Slice::UnitPtr& unit) -{ - assert(!_factory && !_unit); - _factory = factory; - _unit = unit; -} -void -FreezeScript::ObjectFactory::deactivate() -{ - _factory = 0; - _unit = 0; -} - -// -// DataVisitor -// -FreezeScript::DataVisitor::~DataVisitor() -{ -} - -void -FreezeScript::DataVisitor::visitBoolean(const BooleanDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitInteger(const IntegerDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitDouble(const DoubleDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitString(const StringDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitProxy(const ProxyDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitStruct(const StructDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitSequence(const SequenceDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitEnum(const EnumDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitDictionary(const DictionaryDataPtr&) -{ -} - -void -FreezeScript::DataVisitor::visitObject(const ObjectRefPtr&) -{ -} diff --git a/cpp/src/FreezeScript/Data.h b/cpp/src/FreezeScript/Data.h deleted file mode 100644 index 4115611cd89..00000000000 --- a/cpp/src/FreezeScript/Data.h +++ /dev/null @@ -1,618 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_DATA_H -#define FREEZE_SCRIPT_DATA_H - -#include <Ice/Ice.h> -#include <Slice/Parser.h> -#include <FreezeScript/Error.h> - -namespace FreezeScript -{ - -class Data; -typedef IceUtil::Handle<Data> DataPtr; - -class DataVisitor; - -typedef std::map<std::string, DataPtr> DataMemberMap; -typedef std::vector<DataPtr> DataList; -typedef std::map<DataPtr, DataPtr> DataMap; - -class ObjectWriter; -class ObjectReader; - -class ObjectData; -typedef IceUtil::Handle<ObjectData> ObjectDataPtr; - -class DataFactory : public IceUtil::SimpleShared -{ -public: - - DataFactory(const Ice::CommunicatorPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&); - - DataPtr create(const Slice::TypePtr&, bool); - DataPtr createBoolean(bool, bool); - DataPtr createInteger(Ice::Long, bool); - DataPtr createDouble(double, bool); - DataPtr createString(const std::string&, bool); - DataPtr createNil(bool); - DataPtr createObject(const Slice::TypePtr&, bool); - - Slice::BuiltinPtr getBuiltin(Slice::Builtin::Kind) const; - - Ice::CommunicatorPtr getCommunicator() const; - ErrorReporterPtr getErrorReporter() const; - -protected: - - DataPtr createImpl(const Slice::TypePtr&, bool); - - virtual void initialize(const DataPtr&); - - Ice::CommunicatorPtr _communicator; - Slice::UnitPtr _unit; // Only used for creating builtin types. - ErrorReporterPtr _errorReporter; -}; -typedef IceUtil::Handle<DataFactory> DataFactoryPtr; - -class Data : public IceUtil::SimpleShared -{ -public: - - virtual ~Data(); - - virtual DataPtr getMember(const std::string&) const = 0; - virtual DataPtr getElement(const DataPtr&) const = 0; - - virtual bool operator==(const Data&) const = 0; - virtual bool operator!=(const Data&) const = 0; - virtual bool operator<(const Data&) const = 0; - - virtual DataPtr clone() const = 0; - - bool readOnly() const; - virtual Slice::TypePtr getType() const = 0; - virtual void destroy() = 0; - - virtual void marshal(const Ice::OutputStreamPtr&) const = 0; - virtual void unmarshal(const Ice::InputStreamPtr&) = 0; - - virtual bool booleanValue(bool = false) const = 0; - virtual Ice::Long integerValue(bool = false) const = 0; - virtual double doubleValue(bool = false) const = 0; - virtual std::string stringValue(bool = false) const = 0; - virtual std::string toString() const = 0; - - virtual void visit(DataVisitor&) = 0; - -protected: - - Data(const ErrorReporterPtr&, bool); - - ErrorReporterPtr _errorReporter; - bool _readOnly; -}; - -class PrimitiveData : public Data -{ -public: - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual void destroy(); - -protected: - - PrimitiveData(const ErrorReporterPtr&, bool); -}; -typedef IceUtil::Handle<PrimitiveData> PrimitiveDataPtr; - -class BooleanData : public PrimitiveData -{ -public: - - BooleanData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool); - BooleanData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool, bool); - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - bool getValue() const; - void setValue(bool); - -private: - - Slice::BuiltinPtr _type; - bool _value; -}; -typedef IceUtil::Handle<BooleanData> BooleanDataPtr; - -class IntegerData : public PrimitiveData -{ -public: - - IntegerData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool); - IntegerData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool, Ice::Long); - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - Ice::Long getValue() const; - void setValue(Ice::Long, bool); - -private: - - bool rangeCheck(Ice::Long, bool) const; - static std::string toString(Ice::Long); - - Slice::BuiltinPtr _type; - Ice::Long _value; -}; -typedef IceUtil::Handle<IntegerData> IntegerDataPtr; - -class DoubleData : public PrimitiveData -{ -public: - - DoubleData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool); - DoubleData(const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool, double); - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - double getValue() const; - void setValue(double); - -private: - - Slice::BuiltinPtr _type; - double _value; -}; -typedef IceUtil::Handle<DoubleData> DoubleDataPtr; - -class StringData : public PrimitiveData -{ -public: - - StringData(const DataFactoryPtr&, const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool); - StringData(const DataFactoryPtr&, const Slice::BuiltinPtr&, const ErrorReporterPtr&, bool, const std::string&); - - virtual DataPtr getMember(const std::string&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - std::string getValue() const; - void setValue(const std::string&); - -private: - - DataFactoryPtr _factory; - Slice::BuiltinPtr _type; - std::string _value; - IntegerDataPtr _length; -}; -typedef IceUtil::Handle<StringData> StringDataPtr; - -class ProxyData : public Data -{ -public: - - ProxyData(const Slice::TypePtr&, const Ice::CommunicatorPtr&, const ErrorReporterPtr&, bool); - ProxyData(const Slice::TypePtr&, const Ice::CommunicatorPtr&, const ErrorReporterPtr&, bool, const Ice::ObjectPrx&); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - Ice::ObjectPrx getValue() const; - void setValue(const std::string&, bool); - void setValue(const Ice::ObjectPrx&); - -private: - - Slice::TypePtr _type; // Can be Builtin or Proxy - Ice::CommunicatorPtr _communicator; - Ice::ObjectPrx _value; - std::string _str; -}; -typedef IceUtil::Handle<ProxyData> ProxyDataPtr; - -class StructData : public Data -{ -public: - - StructData(const DataFactoryPtr&, const Slice::StructPtr&, const ErrorReporterPtr&, bool); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual void destroy(); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - DataMemberMap& getMembers(); - -private: - - StructData(const Slice::StructPtr&, const ErrorReporterPtr&, bool, const DataMemberMap&); - - Slice::StructPtr _type; - DataMemberMap _members; -}; -typedef IceUtil::Handle<StructData> StructDataPtr; - -class SequenceData : public Data -{ -public: - - SequenceData(const DataFactoryPtr&, const Slice::SequencePtr&, const ErrorReporterPtr&, bool); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - DataList& getElements(); - -private: - - SequenceData(const DataFactoryPtr&, const Slice::SequencePtr&, const ErrorReporterPtr&, bool, const DataList&); - - DataFactoryPtr _factory; - Slice::SequencePtr _type; - DataList _elements; - IntegerDataPtr _length; -}; -typedef IceUtil::Handle<SequenceData> SequenceDataPtr; - -class EnumData : public Data -{ -public: - - EnumData(const Slice::EnumPtr&, const ErrorReporterPtr&, bool); - EnumData(const Slice::EnumPtr&, const ErrorReporterPtr&, bool, Ice::Int); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - Ice::Int getValue() const; - bool setValue(Ice::Int); - bool setValueAsString(const std::string&); - -private: - - Slice::EnumPtr _type; - Ice::Int _value; - std::string _name; - Ice::Int _count; -}; -typedef IceUtil::Handle<EnumData> EnumDataPtr; - -class DictionaryData : public Data -{ -public: - - DictionaryData(const DataFactoryPtr&, const Slice::DictionaryPtr&, const ErrorReporterPtr&, bool); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - DataMap& getElements(); - -private: - - DictionaryData(const DataFactoryPtr&, const Slice::DictionaryPtr&, const ErrorReporterPtr&, bool, const DataMap&); - - DataFactoryPtr _factory; - Slice::DictionaryPtr _type; - DataMap _map; - IntegerDataPtr _length; -}; -typedef IceUtil::Handle<DictionaryData> DictionaryDataPtr; - -class ObjectData : public Data -{ -public: - - ObjectData(const DataFactoryPtr&, const Slice::TypePtr&, bool); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - DataMemberMap& getMembers(); - - void incRef(); - void decRef(); - -private: - - void destroyI(); - - Slice::TypePtr _type; // Can be Builtin (Object) or ClassDecl - DataPtr _facetMap; - DataMemberMap _members; - Ice::ObjectPtr _marshaler; - Ice::Int _refCount; - DataPtr _id; - - friend class ObjectWriter; - friend class ObjectReader; -}; - -class ObjectRef : public Data -{ -public: - - ObjectRef(const DataFactoryPtr&, const Slice::TypePtr&, bool); - ObjectRef(const DataFactoryPtr&, const Slice::TypePtr&, bool, const ObjectDataPtr&); - - virtual DataPtr getMember(const std::string&) const; - virtual DataPtr getElement(const DataPtr&) const; - - virtual bool operator==(const Data&) const; - virtual bool operator!=(const Data&) const; - virtual bool operator<(const Data&) const; - - virtual DataPtr clone() const; - - virtual Slice::TypePtr getType() const; - virtual void destroy(); - - virtual void marshal(const Ice::OutputStreamPtr&) const; - virtual void unmarshal(const Ice::InputStreamPtr&); - - virtual bool booleanValue(bool = false) const; - virtual Ice::Long integerValue(bool = false) const; - virtual double doubleValue(bool = false) const; - virtual std::string stringValue(bool = false) const; - virtual std::string toString() const; - - virtual void visit(DataVisitor&); - - void instantiate(); - ObjectDataPtr getValue() const; - void setValue(const ObjectDataPtr&); - -private: - - DataFactoryPtr _factory; - Slice::TypePtr _type; // Formal type: can be Builtin (Object) or ClassDecl - ObjectDataPtr _value; -}; -typedef IceUtil::Handle<ObjectRef> ObjectRefPtr; - -class ObjectFactory : public Ice::ObjectFactory -{ -public: - - virtual Ice::ObjectPtr create(const std::string&); - virtual void destroy(); - - void activate(const DataFactoryPtr&, const Slice::UnitPtr&); - void deactivate(); - -private: - - DataFactoryPtr _factory; - Slice::UnitPtr _unit; -}; -typedef IceUtil::Handle<ObjectFactory> ObjectFactoryPtr; - -class ClassNotFoundException -{ -public: - - ClassNotFoundException(const std::string& s) : id(s) {} - - std::string id; -}; - -class DataVisitor -{ -public: - - virtual ~DataVisitor(); - - virtual void visitBoolean(const BooleanDataPtr&); - virtual void visitInteger(const IntegerDataPtr&); - virtual void visitDouble(const DoubleDataPtr&); - virtual void visitString(const StringDataPtr&); - virtual void visitProxy(const ProxyDataPtr&); - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitEnum(const EnumDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); -}; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp deleted file mode 100644 index b91ac7e8478..00000000000 --- a/cpp/src/FreezeScript/DumpDB.cpp +++ /dev/null @@ -1,980 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/DumpDescriptors.h> -#include <FreezeScript/Util.h> -#include <FreezeScript/Exception.h> -#include <Freeze/Initialize.h> -#include <Freeze/Connection.h> -#include <IceUtil/OutputUtil.h> -#include <IceUtil/Options.h> -#include <IceUtil/FileUtil.h> -#include <db_cxx.h> -#include <sys/stat.h> -#include <algorithm> - -using namespace std; -using namespace IceUtil; -using namespace IceUtilInternal; - -#ifdef _WIN32 -# define FREEZE_SCRIPT_DB_MODE 0 -#else -# define FREEZE_SCRIPT_DB_MODE (S_IRUSR | S_IWUSR) -#endif - -namespace FreezeScript -{ - -// -// SliceVisitor generates default descriptors. -// -class SliceVisitor : public Slice::ParserVisitor -{ -public: - - SliceVisitor(IceUtilInternal::XMLOutput&, const Slice::TypePtr&, const Slice::TypePtr&, const string&); - - virtual bool visitClassDefStart(const Slice::ClassDefPtr&); - virtual bool visitStructStart(const Slice::StructPtr&); - virtual void visitSequence(const Slice::SequencePtr&); - virtual void visitDictionary(const Slice::DictionaryPtr&); - virtual void visitEnum(const Slice::EnumPtr&); - -private: - - IceUtilInternal::XMLOutput& _out; -}; - -class DescriptorHandler : public IceXML::Handler -{ -public: - - DescriptorHandler(const DataFactoryPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&, - const FreezeScript::ObjectFactoryPtr&); - - virtual void startElement(const std::string&, const IceXML::Attributes&, int, int); - virtual void endElement(const std::string&, int, int); - virtual void characters(const std::string&, int, int); - virtual void error(const std::string&, int, int); - - DumpDBDescriptorPtr descriptor() const; - -private: - - DataFactoryPtr _factory; - Slice::UnitPtr _unit; - ErrorReporterPtr _errorReporter; - DescriptorPtr _current; - DumpDBDescriptorPtr _descriptor; - FreezeScript::ObjectFactoryPtr _objectFactory; -}; - -} - -static void -usage(const string& n) -{ - cerr << "Usage:\n"; - cerr << "\n"; - cerr << n << " [options] dbenv db\n"; - cerr << n << " -c dbenv [db]\n"; - cerr << "\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-DNAME Define NAME as 1.\n" - "-DNAME=DEF Define NAME as DEF.\n" - "-UNAME Remove any definition for NAME.\n" - "-IDIR Put DIR in the include file search path.\n" - "-d, --debug Print debug messages.\n" - "--ice Permit `Ice' prefix (for building Ice source code only).\n" - "--underscore Permit underscores in Slice identifiers.\n" - "-o FILE Output sample descriptors into the file FILE.\n" - "-f FILE Execute the descriptors in the file FILE.\n" - "--load SLICE Load Slice definitions from the file SLICE.\n" - "-e Indicates the database is an Evictor database.\n" - "--key TYPE Specifies the Slice type of the database key.\n" - "--value TYPE Specifies the Slice type of the database value.\n" - "--select EXPR Dump a record only if EXPR is true.\n" - "-c, --catalog Display information about the databases in an\n" - " environment, or about a particular database.\n" - ; -} - -static void -printCatalogData(const string& dbName, const Freeze::CatalogData& data) -{ - cout << dbName << ": "; - if(data.evictor) - { - cout << "Evictor database" << endl; - } - else - { - cout << "Map database" << endl; - cout << " key type = " << data.key << endl; - cout << " value type = " << data.value << endl; - } -} - -static int -run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator, - const FreezeScript::CompactIdResolverIPtr& resolver) -{ - vector<string> cppArgs; - bool debug; - bool ice = true; // Needs to be true in order to create default definitions. - bool underscore; - string outputFile; - string inputFile; - vector<string> slice; - bool evictor; - string keyTypeName; - string valueTypeName; - string selectExpr; - string dbEnvName, dbName; - const string appName = originalArgs[0]; - IceUtilInternal::Options opts; - opts.addOpt("h", "help"); - opts.addOpt("v", "version"); - opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("d", "debug"); - opts.addOpt("", "ice"); - opts.addOpt("", "underscore"); - opts.addOpt("o", "", IceUtilInternal::Options::NeedArg); - opts.addOpt("f", "", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "load", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("e"); - opts.addOpt("", "key", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "value", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "select", IceUtilInternal::Options::NeedArg); - opts.addOpt("c", "catalog"); - - vector<string> args; - try - { - args = opts.parse(originalArgs); - } - catch(const IceUtilInternal::BadOptException& e) - { - cerr << appName << ": " << e.reason << endl; - usage(appName); - return EXIT_FAILURE; - } - - // - // Freeze creates a lock file by default to prevent multiple processes from opening - // the same database environment simultaneously. In the case of a read-only program - // such as dumpdb, however, we still want to be able to open the environment despite - // the lock. This assumes of course that the other process has opened the environment - // with DbPrivate=0. If DbPrivate=0 is also set for dumpdb, we disable the lock. - // - if(!args.empty()) - { - // - // If an argument is present, we assume it is the name of the database environment. - // - Ice::PropertiesPtr props = communicator->getProperties(); - string prefix = "Freeze.DbEnv." + args[0]; - if(props->getPropertyAsIntWithDefault(prefix + ".DbPrivate", 1) <= 0) - { - props->setProperty(prefix + ".LockFile", "0"); - } - } - - if(opts.isSet("h")) - { - usage(appName); - return EXIT_SUCCESS; - } - if(opts.isSet("version")) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - if(opts.isSet("c")) - { - if(args.empty()) - { - cerr << appName << ": no database environment specified." << endl; - usage(appName); - return EXIT_FAILURE; - } - else if(args.size() > 2) - { - usage(appName); - return EXIT_FAILURE; - } - try - { - FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, args[0]); - if(args.size() == 1) - { - if(catalog.empty()) - { - cout << "Catalog is empty." << endl; - } - else - { - cout << "Catalog contents:" << endl; - for(FreezeScript::CatalogDataMap::const_iterator p = catalog.begin(); p != catalog.end(); ++p) - { - cout << endl; - printCatalogData(p->first, p->second); - } - } - } - else - { - FreezeScript::CatalogDataMap::const_iterator p = catalog.find(args[1]); - if(p == catalog.end()) - { - cerr << appName << ": database `" << args[1] << "' not found in environment `" << args[0] << "'." - << endl; - return EXIT_FAILURE; - } - else - { - printCatalogData(p->first, p->second); - } - } - return EXIT_SUCCESS; - } - catch(const FreezeScript::FailureException& ex) - { - cerr << appName << ": " << ex.reason() << endl; - return EXIT_FAILURE; - } - } - if(opts.isSet("D")) - { - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-D" + *i); - } - } - if(opts.isSet("U")) - { - vector<string> optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-U" + *i); - } - } - if(opts.isSet("I")) - { - vector<string> optargs = opts.argVec("I"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-I" + *i); - } - } - debug = opts.isSet("debug"); - - // No need to set --ice option here -- it is always true. - - underscore = opts.isSet("underscore"); - - if(opts.isSet("o")) - { - outputFile = opts.optArg("o"); - } - if(opts.isSet("f")) - { - inputFile = opts.optArg("f"); - } - if(opts.isSet("load")) - { - vector<string> optArgs = opts.argVec("load"); - for(vector<string>::const_iterator i = optArgs.begin(); i != optArgs.end(); ++i) - { - slice.push_back(*i); - } - } - evictor = opts.isSet("e"); - if(opts.isSet("key")) - { - keyTypeName = opts.optArg("key"); - } - if(opts.isSet("value")) - { - valueTypeName = opts.optArg("value"); - } - if(opts.isSet("select")) - { - selectExpr = opts.optArg("select"); - } - - if(outputFile.empty() && args.size() != 2) - { - usage(appName); - return EXIT_FAILURE; - } - - if(!args.empty()) - { - dbEnvName = args[0]; - } - if(args.size() == 2) - { - dbName = args[1]; - } - else - { - usage(appName); - return EXIT_FAILURE; - } - - if(!inputFile.empty() && !selectExpr.empty()) - { - cerr << appName << ": an input file cannot be specified with --select" << endl; - return EXIT_FAILURE; - } - - Slice::UnitPtr unit = Slice::Unit::createUnit(true, true, ice, underscore); - FreezeScript::Destroyer<Slice::UnitPtr> unitD(unit); - if(!FreezeScript::parseSlice(appName, unit, slice, cppArgs, debug, "-D__DUMPDB__")) - { - return EXIT_FAILURE; - } - - FreezeScript::createEvictorSliceTypes(unit); - - FreezeScript::collectCompactIds(unit, resolver); - - // - // If no input file was provided, then we need to generate default descriptors. - // - string descriptors; - if(inputFile.empty()) - { - const string evictorKeyTypeName = "::Ice::Identity"; - const string oldEvictorValueTypeName = "::Freeze::ObjectRecord"; - const string newEvictorValueTypeName = "Object"; - - if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty() && !evictor)) - { - cerr << appName << ": a key type and a value type must be specified" << endl; - usage(appName); - return EXIT_FAILURE; - } - else if(valueTypeName.empty()) - { - try - { - FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, dbEnvName); - FreezeScript::CatalogDataMap::iterator p = catalog.find(dbName); - if(p == catalog.end()) - { - cerr << appName << ": database `" << dbName << "' not found in catalog." << endl; - cerr << "Current catalog databases:" << endl; - for(p = catalog.begin(); p != catalog.end(); ++p) - { - cerr << " " << p->first << endl; - } - return EXIT_FAILURE; - } - else - { - if(p->second.evictor) - { - evictor = true; - } - keyTypeName = p->second.key; - valueTypeName = p->second.value; - - if(evictor && valueTypeName.empty()) - { - valueTypeName = oldEvictorValueTypeName; - } - } - } - catch(const FreezeScript::FailureException& ex) - { - cerr << appName << ": " << ex.reason() << endl; - return EXIT_FAILURE; - } - } - - if(evictor) - { - if(keyTypeName.empty()) - { - keyTypeName = evictorKeyTypeName; - } - if(valueTypeName.empty()) - { - valueTypeName = newEvictorValueTypeName; - } - } - - Slice::TypePtr keyType, valueType; - Slice::TypeList l; - - l = unit->lookupType(keyTypeName, false); - if(l.empty()) - { - cerr << appName << ": unknown key type `" << keyTypeName << "'" << endl; - return EXIT_FAILURE; - } - keyType = l.front(); - - l = unit->lookupType(valueTypeName, false); - if(l.empty()) - { - cerr << appName << ": unknown value type `" << valueTypeName << "'" << endl; - return EXIT_FAILURE; - } - valueType = l.front(); - - ostringstream os; - IceUtilInternal::XMLOutput out(os); - - out << se("dumpdb"); - - FreezeScript::SliceVisitor visitor(out, keyType, valueType, selectExpr); - unit->visit(&visitor, false); - - out << ee; - - descriptors = os.str(); - - if(!outputFile.empty()) - { - IceUtilInternal::ofstream of(outputFile); - if(!of.good()) - { - cerr << appName << ": unable to open file `" << outputFile << "'" << endl; - return EXIT_FAILURE; - } - of << descriptors << endl; - of.close(); - return EXIT_SUCCESS; - } - } - else - { - IceUtilInternal::ifstream in(inputFile); - char buff[1024]; - while(true) - { - in.read(buff, 1024); - descriptors.append(buff, static_cast<size_t>(in.gcount())); - if(in.gcount() < 1024) - { - break; - } - } - in.close(); - } - FreezeScript::ObjectFactoryPtr objectFactory = new FreezeScript::ObjectFactory; - communicator->addObjectFactory(objectFactory, ""); - - DbEnv dbEnv(0); - DbTxn* txn = 0; - Freeze::ConnectionPtr connection; - int status = EXIT_SUCCESS; - try - { -#ifdef _WIN32 - // - // Berkeley DB may use a different C++ runtime. - // - dbEnv.set_alloc(::malloc, ::realloc, ::free); -#endif - - // - // Open the database environment and start a transaction. - // - { - u_int32_t flags = DB_THREAD | DB_CREATE | DB_INIT_TXN | DB_INIT_MPOOL; - dbEnv.open(dbEnvName.c_str(), flags, FREEZE_SCRIPT_DB_MODE); - } - - // - // We're creating a connection just to make sure the database environment - // isn't locked. - // - connection = Freeze::createConnection(communicator, dbEnvName, dbEnv); - - dbEnv.txn_begin(0, &txn, 0); - - FreezeScript::ErrorReporterPtr errorReporter = new FreezeScript::ErrorReporter(cerr, false); - try - { - FreezeScript::DataFactoryPtr factory = new FreezeScript::DataFactory(communicator, unit, errorReporter); - FreezeScript::DescriptorHandler dh(factory, unit, errorReporter, objectFactory); - - istringstream istr(descriptors); - IceXML::Parser::parse(istr, dh); - - FreezeScript::DumpDBDescriptorPtr descriptor = dh.descriptor(); - descriptor->validate(); - - if(evictor) - { - // - // The evictor database file contains multiple databases. We must first - // determine the names of those databases, ignoring any whose names - // begin with "$index:". Each database represents a separate facet, with - // the facet name used as the database name. The database named "$default" - // represents the main object. - // - vector<string> dbNames; - { - Db db(&dbEnv, 0); - db.open(txn, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0); - Dbt dbKey, dbValue; - dbKey.set_flags(DB_DBT_MALLOC); - dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); - - Dbc* dbc = 0; - db.cursor(txn, &dbc, 0); - - while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) - { - string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size()); - if(s.find("$index:") != 0) - { - dbNames.push_back(s); - } - free(dbKey.get_data()); - } - - dbc->close(); - db.close(0); - } - - // - // Dump each database. - // - for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p) - { - string name = *p; - string facet = (name == "$default" ? string("") : name); - Db db(&dbEnv, 0); - db.open(txn, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); - descriptor->dump(communicator, &db, txn, facet); - db.close(0); - } - } - else - { - // - // Dump a map database. - // - Db db(&dbEnv, 0); - db.open(txn, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); - descriptor->dump(communicator, &db, txn, ""); - db.close(0); - } - } - catch(const IceXML::ParserException& ex) - { - errorReporter->error(ex.reason()); - } - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - status = EXIT_FAILURE; - } - catch(...) - { - try - { - if(txn) - { - txn->abort(); - } - dbEnv.close(0); - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - } - if(connection) - { - connection->close(); - connection = 0; - } - throw; - } - - try - { - if(txn) - { - txn->abort(); - } - if(connection) - { - connection->close(); - } - dbEnv.close(0); - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - status = EXIT_FAILURE; - } - - return status; -} - -#ifdef _WIN32 - -int -wmain(int argc, wchar_t* argv[]) - -#else - -int -main(int argc, char* argv[]) - -#endif -{ - Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); - assert(args.size() > 0); - const string appName = args[0]; - - Ice::InitializationData initData; - FreezeScript::CompactIdResolverIPtr resolver = new FreezeScript::CompactIdResolverI; - initData.compactIdResolver = resolver; - - Ice::CommunicatorPtr communicator; - int status = EXIT_SUCCESS; - try - { - communicator = Ice::initialize(args, initData); - status = run(args, communicator, resolver); - } - catch(const FreezeScript::FailureException& ex) - { - string reason = ex.reason(); - cerr << appName << ": " << reason; - if(reason[reason.size() - 1] != '\n') - { - cerr << endl; - } - return EXIT_FAILURE; - } - catch(const std::exception& ex) - { - cerr << appName << ": " << ex.what() << endl; - status = EXIT_FAILURE; - } - catch(...) - { - cerr << appName << ": unknown error" << endl; - return EXIT_FAILURE; - } - - if(communicator) - { - communicator->destroy(); - } - - return status; -} - -// -// SliceVisitor -// -FreezeScript::SliceVisitor::SliceVisitor(IceUtilInternal::XMLOutput& out, const Slice::TypePtr& keyType, - const Slice::TypePtr& valueType, const string& selectExpr) : - _out(out) -{ - out << se("database") << attr("key", typeToString(keyType)) << attr("value", typeToString(valueType)); - out << se("record"); - if(!selectExpr.empty()) - { - out << se("if") << attr("test", selectExpr); - out << se("echo") << attr("message", "Key: ") << attr("value", "key") << ee; - out << se("echo") << attr("message", "Value: ") << attr("value", "value") << ee; - out << ee; - } - else - { - out << se("echo") << attr("message", "Key: ") << attr("value", "key") << ee; - out << se("echo") << attr("message", "Value: ") << attr("value", "value") << ee; - } - out << ee; - out << ee; -} - -bool -FreezeScript::SliceVisitor::visitClassDefStart(const Slice::ClassDefPtr& v) -{ - if(v->isInterface() || v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return false; - } - - _out.newline(); - _out.newline(); - _out << "<!-- class " << scoped << " -->"; - _out << se("dump") << attr("type", scoped) << ee; - - return false; -} - -bool -FreezeScript::SliceVisitor::visitStructStart(const Slice::StructPtr& v) -{ - if(v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return false; - } - - _out.newline(); - _out.newline(); - _out << "<!-- struct " << scoped << " -->"; - _out << se("dump") << attr("type", scoped) << ee; - - return false; -} - -void -FreezeScript::SliceVisitor::visitSequence(const Slice::SequencePtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - _out.newline(); - _out.newline(); - _out << "<!-- sequence " << scoped << " -->"; - _out << se("dump") << attr("type", scoped) << ee; -} - -void -FreezeScript::SliceVisitor::visitDictionary(const Slice::DictionaryPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - _out.newline(); - _out.newline(); - _out << "<!-- dictionary " << scoped << " -->"; - _out << se("dump") << attr("type", scoped) << ee; -} - -void -FreezeScript::SliceVisitor::visitEnum(const Slice::EnumPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - _out.newline(); - _out.newline(); - _out << "<!-- enum " << scoped << " -->"; - _out << se("dump") << attr("type", scoped) << ee; -} - -// -// DescriptorHandler -// -FreezeScript::DescriptorHandler::DescriptorHandler(const DataFactoryPtr& factory, const Slice::UnitPtr& unit, - const ErrorReporterPtr& errorReporter, - const FreezeScript::ObjectFactoryPtr& objectFactory) : - _factory(factory), _unit(unit), _errorReporter(errorReporter), _objectFactory(objectFactory) -{ -} - -void -FreezeScript::DescriptorHandler::startElement(const string& name, const IceXML::Attributes& attributes, int line, - int /*column*/) -{ - DescriptorPtr d; - - if(name == "dumpdb") - { - if(_current) - { - _errorReporter->descriptorError("<dumpdb> must be the top-level element", line); - } - - _descriptor = new DumpDBDescriptor(line, _factory, _errorReporter, attributes, _unit); - d = _descriptor; - } - else if(name == "database") - { - if(!_current) - { - _errorReporter->descriptorError("<database> must be a child of <dumpdb>", line); - } - - d = new DatabaseDescriptor(_current, line, _factory, _errorReporter, attributes, _unit); - } - else if(name == "record") - { - if(!_current) - { - _errorReporter->descriptorError("<record> must be a child of <database>", line); - } - - d = new RecordDescriptor(_current, line, _factory, _errorReporter, attributes, _unit, _objectFactory); - } - else if(name == "dump") - { - if(!_current) - { - _errorReporter->descriptorError("<dump> must be a child of <dumpdb>", line); - } - - d = new DumpDescriptor(_current, line, _factory, _errorReporter, attributes, _unit); - } - else if(name == "set") - { - if(!_current) - { - _errorReporter->descriptorError("<set> cannot be a top-level element", line); - } - - d = new SetDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else if(name == "define") - { - if(!_current) - { - _errorReporter->descriptorError("<define> cannot be a top-level element", line); - } - - d = new DefineDescriptor(_current, line, _factory, _errorReporter, attributes, _unit); - } - else if(name == "add") - { - if(!_current) - { - _errorReporter->descriptorError("<add> cannot be a top-level element", line); - } - - d = new AddDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else if(name == "remove") - { - if(!_current) - { - _errorReporter->descriptorError("<remove> cannot be a top-level element", line); - } - - d = new RemoveDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else if(name == "fail") - { - if(!_current) - { - _errorReporter->descriptorError("<fail> cannot be a top-level element", line); - } - - d = new FailDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else if(name == "echo") - { - if(!_current) - { - _errorReporter->descriptorError("<echo> cannot be a top-level element", line); - } - - d = new EchoDescriptor(_current, line, _factory, _errorReporter, attributes, cout); - } - else if(name == "if") - { - if(!_current) - { - _errorReporter->descriptorError("<if> cannot be a top-level element", line); - } - - d = new IfDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else if(name == "iterate") - { - if(!_current) - { - _errorReporter->descriptorError("<iterate> cannot be a top-level element", line); - } - - d = new IterateDescriptor(_current, line, _factory, _errorReporter, attributes); - } - else - { - _errorReporter->descriptorError("unknown descriptor `" + name + "'", line); - } - - if(_current) - { - _current->addChild(d); - } - _current = d; -} - -void -FreezeScript::DescriptorHandler::endElement(const std::string&, int, int) -{ - assert(_current); - _current = _current->parent(); -} - -void -FreezeScript::DescriptorHandler::characters(const std::string&, int, int) -{ -} - -void -FreezeScript::DescriptorHandler::error(const std::string& msg, int line, int) -{ - _errorReporter->descriptorError(msg, line); -} - -FreezeScript::DumpDBDescriptorPtr -FreezeScript::DescriptorHandler::descriptor() const -{ - return _descriptor; -} diff --git a/cpp/src/FreezeScript/DumpDB.rc b/cpp/src/FreezeScript/DumpDB.rc deleted file mode 100644 index 8167af81e58..00000000000 --- a/cpp/src/FreezeScript/DumpDB.rc +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,7,0,0 - PRODUCTVERSION 3,7,0,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "ZeroC, Inc.\0" - VALUE "FileDescription", "Dump Freeze Database\0" - VALUE "FileVersion", "3.7.0\0" - VALUE "InternalName", "dumpdb\0" - VALUE "LegalCopyright", "\251 2003-2015 ZeroC, Inc.\0" - VALUE "OriginalFilename", "dumpdb.exe\0" - VALUE "ProductName", "Ice\0" - VALUE "ProductVersion", "3.7.0\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/cpp/src/FreezeScript/DumpDescriptors.cpp b/cpp/src/FreezeScript/DumpDescriptors.cpp deleted file mode 100644 index cdf5a204ff4..00000000000 --- a/cpp/src/FreezeScript/DumpDescriptors.cpp +++ /dev/null @@ -1,1953 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/DumpDescriptors.h> -#include <FreezeScript/AssignVisitor.h> -#include <FreezeScript/Print.h> -#include <FreezeScript/Functions.h> -#include <FreezeScript/Exception.h> -#include <FreezeScript/Util.h> -#include <IceUtil/InputUtil.h> -#include <db_cxx.h> -#include <set> -#include <climits> - -using namespace std; - -namespace FreezeScript -{ - -class SymbolTableI; -typedef IceUtil::Handle<SymbolTableI> SymbolTableIPtr; - -class SymbolTableI : public SymbolTable -{ -public: - - SymbolTableI(const DataFactoryPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&, ExecuteInfo*, - const SymbolTablePtr& = SymbolTablePtr()); - - virtual void add(const string&, const DataPtr&); - - virtual DataPtr getValue(const EntityNodePtr&) const; - - virtual DataPtr getConstantValue(const string&) const; - - virtual SymbolTablePtr createChild(); - - virtual Slice::TypePtr lookupType(const string&); - - virtual DataPtr invokeFunction(const string&, const DataPtr&, const DataList&); - -private: - - DataPtr findValue(const string&) const; - - class EntityVisitor : public EntityNodeVisitor - { - public: - - EntityVisitor(SymbolTableI*); - - virtual void visitIdentifier(const string&); - virtual void visitElement(const NodePtr&); - - DataPtr getCurrent() const; - - private: - - SymbolTableI* _table; - DataPtr _current; - bool _error; - }; - - friend class EntityVisitor; - - DataFactoryPtr _factory; - Slice::UnitPtr _unit; - ErrorReporterPtr _errorReporter; - ExecuteInfo* _info; - SymbolTablePtr _parent; - typedef map<string, DataPtr> DataMap; - DataMap _dataMap; - DataMap _constantCache; -}; - -typedef map<string, DumpDescriptorPtr> DumpMap; - -struct ExecuteInfo -{ - Ice::CommunicatorPtr communicator; - Db* db; - DbTxn* txn; - string facet; - SymbolTablePtr symbolTable; - DumpMap dumpMap; - Slice::TypePtr keyType; - Slice::TypePtr valueType; -}; - -class DumpVisitor : public DataVisitor -{ -public: - - DumpVisitor(const DataFactoryPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&, ExecuteInfo*); - - virtual void visitBoolean(const BooleanDataPtr&); - virtual void visitInteger(const IntegerDataPtr&); - virtual void visitDouble(const DoubleDataPtr&); - virtual void visitString(const StringDataPtr&); - virtual void visitProxy(const ProxyDataPtr&); - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitEnum(const EnumDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); - -private: - - // - // Returns true if the contents of the data should be visited. - // - bool dump(const DataPtr&); - - DataFactoryPtr _factory; - Slice::UnitPtr _unit; - ErrorReporterPtr _errorReporter; - ExecuteInfo* _info; - set<const ObjectData*> _objectHistory; -}; - -} // End of namespace FreezeScript - -// -// Descriptor -// -FreezeScript::Descriptor::Descriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter) : - _parent(parent), _line(line), _factory(factory), _errorReporter(errorReporter) -{ -} - -FreezeScript::Descriptor::~Descriptor() -{ -} - -FreezeScript::DescriptorPtr -FreezeScript::Descriptor::parent() const -{ - return _parent; -} - -FreezeScript::NodePtr -FreezeScript::Descriptor::parse(const string& expr) const -{ - return parseExpression(expr, _factory, _errorReporter); -} - -Slice::TypePtr -FreezeScript::Descriptor::findType(const Slice::UnitPtr& u, const string& type) -{ - Slice::TypeList l; - - l = u->lookupType(type, false); - if(l.empty()) - { - _errorReporter->error("unknown type `" + type + "'"); - } - - return l.front(); -} - -// -// SetDescriptor -// -FreezeScript::SetDescriptor::SetDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter) -{ - DescriptorErrorContext ctx(_errorReporter, "set", _line); - - IceXML::Attributes::const_iterator p; - - p = attributes.find("target"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `target' is missing"); - } - NodePtr node = parse(p->second); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _errorReporter->error("`target' attribute is not an entity: `" + p->second + "'"); - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("length"); - if(p != attributes.end()) - { - _lengthStr = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - if(_valueStr.empty() && _lengthStr.empty()) - { - _errorReporter->error("requires a value for attributes `value' or 'length'"); - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } - - if(!_lengthStr.empty()) - { - _length = parse(_lengthStr); - } -} - -void -FreezeScript::SetDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "set", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::SetDescriptor::validate() -{ -} - -void -FreezeScript::SetDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "set", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - DataPtr length; - if(_length) - { - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("value `" + ostr.str() + "' is not a sequence"); - } - - try - { - length = _length->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of length `" + _lengthStr + "' failed:\n" + ex.reason()); - } - - DataList& elements = seq->getElements(); - Ice::Long l = length->integerValue(); - if(l < 0 || l > INT_MAX) - { - _errorReporter->error("sequence length " + length->toString() + " is out of range"); - } - - DataList::size_type len = static_cast<DataList::size_type>(l); - if(len < elements.size()) - { - for(DataList::size_type i = len; i < elements.size(); ++i) - { - elements[i]->destroy(); - } - elements.resize(len); - } - else if(len > elements.size()) - { - Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(seq->getType()); - assert(seqType); - Slice::TypePtr elemType = seqType->type(); - for(DataList::size_type i = elements.size(); i < len; ++i) - { - DataPtr v = _factory->create(elemType, false); - if(value) - { - AssignVisitor visitor(value, _factory, _errorReporter, _convert); - v->visit(visitor); - } - elements.push_back(v); - } - } - } - else - { - AssignVisitor visitor(value, _factory, _errorReporter, _convert); - data->visit(visitor); - } -} - -// -// DefineDescriptor -// -FreezeScript::DefineDescriptor::DefineDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes, const Slice::UnitPtr& unit) : - Descriptor(parent, line, factory, errorReporter) -{ - DescriptorErrorContext ctx(_errorReporter, "define", _line); - - IceXML::Attributes::const_iterator p; - - p = attributes.find("name"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `name' is missing"); - } - _name = p->second; - - p = attributes.find("type"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `type' is missing"); - } - _type = findType(unit, p->second); - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::DefineDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "define", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::DefineDescriptor::validate() -{ -} - -void -FreezeScript::DefineDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "define", _line); - - DataPtr data = _factory->create(_type, false); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - if(value) - { - AssignVisitor visitor(value, _factory, _errorReporter, _convert); - data->visit(visitor); - } - - sym->add(_name, data); -} - -// -// AddDescriptor -// -FreezeScript::AddDescriptor::AddDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter) -{ - DescriptorErrorContext ctx(_errorReporter, "add", _line); - - IceXML::Attributes::const_iterator p; - - string target; - p = attributes.find("target"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _keyStr = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _indexStr = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } - - if(!_keyStr.empty() && !_indexStr.empty()) - { - _errorReporter->error("attributes `key' and `index' are mutually exclusive"); - } - - if(_keyStr.empty() && _indexStr.empty()) - { - _errorReporter->error("one of attributes `key' or `index' is required"); - } - - if(!_keyStr.empty()) - { - _key = parse(_keyStr); - } - - if(!_indexStr.empty()) - { - _index = parse(_indexStr); - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::AddDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "add", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::AddDescriptor::validate() -{ -} - -void -FreezeScript::AddDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "add", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - if(_key) - { - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - if(!dict) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' is not a dictionary"); - } - - Slice::DictionaryPtr type = Slice::DictionaryPtr::dynamicCast(dict->getType()); - assert(type); - - DataPtr key; - Destroyer<DataPtr> keyDestroyer; - try - { - DataPtr v = _key->evaluate(sym); - key = _factory->create(type->keyType(), false); - keyDestroyer.set(key); - AssignVisitor visitor(v, _factory, _errorReporter, _convert); - key->visit(visitor); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of key `" + _keyStr + "' failed:\n" + ex.reason()); - } - - if(dict->getElement(key)) - { - ostringstream ostr; - printData(key, ostr); - _errorReporter->error("key " + ostr.str() + " already exists in dictionary"); - } - - DataPtr elem = _factory->create(type->valueType(), false); - Destroyer<DataPtr> elemDestroyer(elem); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - if(value) - { - AssignVisitor visitor(value, _factory, _errorReporter, _convert); - elem->visit(visitor); - } - DataMap& map = dict->getElements(); - map.insert(DataMap::value_type(key, elem)); - keyDestroyer.release(); - elemDestroyer.release(); - } - else - { - assert(_index); - - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' is not a sequence"); - } - - Slice::SequencePtr type = Slice::SequencePtr::dynamicCast(seq->getType()); - assert(type); - - DataPtr index; - Destroyer<DataPtr> indexDestroyer; - try - { - index = _index->evaluate(sym); - indexDestroyer.set(index); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of index `" + _indexStr + "' failed:\n" + ex.reason()); - } - - DataList& elements = seq->getElements(); - Ice::Long l = index->integerValue(); - DataList::size_type i = static_cast<DataList::size_type>(l); - if(l < 0 || l > INT_MAX || i > elements.size()) - { - _errorReporter->error("sequence index " + index->toString() + " is out of range"); - } - - DataPtr elem = _factory->create(type->type(), false); - Destroyer<DataPtr> elemDestroyer(elem); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - if(value) - { - AssignVisitor visitor(value, _factory, _errorReporter, _convert); - elem->visit(visitor); - } - - elements.insert(elements.begin() + i, elem); - indexDestroyer.release(); - elemDestroyer.release(); - } -} - -// -// RemoveDescriptor -// -FreezeScript::RemoveDescriptor::RemoveDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter) -{ - DescriptorErrorContext ctx(_errorReporter, "remove", _line); - - IceXML::Attributes::const_iterator p; - - string target; - p = attributes.find("target"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _keyStr = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _indexStr = p->second; - } - - if(!_keyStr.empty() && !_indexStr.empty()) - { - _errorReporter->error("attributes `key' and `index' are mutually exclusive"); - } - - if(_keyStr.empty() && _indexStr.empty()) - { - _errorReporter->error("one of attributes `key' or `index' is required"); - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } - - if(!_keyStr.empty()) - { - _key = parse(_keyStr); - } - - if(!_indexStr.empty()) - { - _index = parse(_indexStr); - } -} - -void -FreezeScript::RemoveDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "remove", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::RemoveDescriptor::validate() -{ -} - -void -FreezeScript::RemoveDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "remove", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - if(_key) - { - DataPtr key; - try - { - key = _key->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of key `" + _keyStr + "' failed:\n" + ex.reason()); - } - - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - if(!dict) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' is not a dictionary"); - } - - DataMap& map = dict->getElements(); - DataMap::iterator p = map.find(key); - if(p != map.end()) - { - p->first->destroy(); - p->second->destroy(); - map.erase(p); - } - } - else - { - assert(_index); - - DataPtr index; - try - { - index = _index->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of index `" + _indexStr + "' failed:\n" + ex.reason()); - } - - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' is not a sequence"); - } - - DataList& elements = seq->getElements(); - Ice::Long l = index->integerValue(); - DataList::size_type i = static_cast<DataList::size_type>(l); - if(l < 0 || l > INT_MAX || i >= elements.size()) - { - _errorReporter->error("sequence index " + index->toString() + " is out of range"); - } - - elements[i]->destroy(); - elements.erase(elements.begin() + i); - } -} - -// -// FailDescriptor -// -FreezeScript::FailDescriptor::FailDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter) -{ - IceXML::Attributes::const_iterator p; - - p = attributes.find("test"); - if(p != attributes.end()) - { - _testStr = p->second; - } - - p = attributes.find("message"); - if(p != attributes.end()) - { - _message = p->second; - } - - if(!_testStr.empty()) - { - _test = parse(_testStr); - } - - if(_message.empty()) - { - ostringstream ostr; - ostr << "<fail> executed at line " << line << endl; - _message = ostr.str(); - } -} - -void -FreezeScript::FailDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "fail", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::FailDescriptor::validate() -{ -} - -void -FreezeScript::FailDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "fail", _line); - - if(_test) - { - try - { - DataPtr b = _test->evaluate(sym); - BooleanDataPtr bd = BooleanDataPtr::dynamicCast(b); - if(!bd) - { - _errorReporter->error("expression `" + _testStr + "' does not evaluate to a boolean"); - } - if(!bd->booleanValue()) - { - return; - } - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of expression `" + _testStr + "' failed:\n" + ex.reason()); - } - } - - throw FailureException(__FILE__, __LINE__, _message); -} - -// -// EchoDescriptor -// -FreezeScript::EchoDescriptor::EchoDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes, - ostream& os) : - Descriptor(parent, line, factory, errorReporter), _os(os) -{ - IceXML::Attributes::const_iterator p; - - p = attributes.find("message"); - if(p != attributes.end()) - { - _message = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::EchoDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_errorReporter, "echo", _line); - _errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::EchoDescriptor::validate() -{ -} - -void -FreezeScript::EchoDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*) -{ - DescriptorErrorContext ctx(_errorReporter, "echo", _line); - - if(!_message.empty()) - { - _os << _message; - } - - if(_value) - { - DataPtr v; - try - { - v = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - printData(v, _os); - } - - _os << endl; -} - -// -// ExecutableContainerDescriptor -// -FreezeScript::ExecutableContainerDescriptor::ExecutableContainerDescriptor(const DescriptorPtr& parent, int line, - const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes&, - const string& name) : - Descriptor(parent, line, factory, errorReporter), _name(name) -{ -} - -void -FreezeScript::ExecutableContainerDescriptor::addChild(const DescriptorPtr& child) -{ - _children.push_back(child); -} - -void -FreezeScript::ExecutableContainerDescriptor::validate() -{ - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->validate(); - } -} - -void -FreezeScript::ExecutableContainerDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo* info) -{ - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->execute(sym, info); - } -} - -// -// IfDescriptor -// -FreezeScript::IfDescriptor::IfDescriptor(const DescriptorPtr& parent, int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter), - ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "if") - -{ - DescriptorErrorContext ctx(_errorReporter, "if", _line); - - IceXML::Attributes::const_iterator p = attributes.find("test"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `test' is missing"); - } - _testStr = p->second; - - _test = parse(_testStr); -} - -void -FreezeScript::IfDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo* info) -{ - DescriptorErrorContext ctx(_errorReporter, "if", _line); - - try - { - DataPtr b = _test->evaluate(sym); - BooleanDataPtr bd = BooleanDataPtr::dynamicCast(b); - if(!bd) - { - _errorReporter->error("expression `" + _testStr + "' does not evaluate to a boolean"); - } - if(bd->booleanValue()) - { - ExecutableContainerDescriptor::execute(sym, info); - } - } - catch(const EvaluateException& ex) - { - _errorReporter->error("evaluation of conditional expression `" + _testStr + "' failed:\n" + ex.reason()); - } -} - -// -// IterateDescriptor -// -FreezeScript::IterateDescriptor::IterateDescriptor(const DescriptorPtr& parent, int line, - const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, factory, errorReporter), - ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "iterate") - -{ - DescriptorErrorContext ctx(_errorReporter, "iterate", _line); - - IceXML::Attributes::const_iterator p; - string target; - - p = attributes.find("target"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _key = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _value = p->second; - } - - p = attributes.find("element"); - if(p != attributes.end()) - { - _element = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _index = p->second; - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } -} - -void -FreezeScript::IterateDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo* info) -{ - DescriptorErrorContext ctx(_errorReporter, "iterate", _line); - - DataPtr data = sym->getValue(_target); - - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!dict && !seq) - { - ostringstream ostr; - ostr << _target; - _errorReporter->error("target `" + ostr.str() + "' is not a dictionary or sequence"); - } - - if(dict) - { - if(!_element.empty()) - { - _errorReporter->error("attribute `element' specified for dictionary target"); - } - if(!_index.empty()) - { - _errorReporter->error("attribute `index' specified for dictionary target"); - } - - string key = _key; - if(key.empty()) - { - key = "key"; - } - - string value = _value; - if(value.empty()) - { - value = "value"; - } - - DataMap& map = dict->getElements(); - for(DataMap::iterator p = map.begin(); p != map.end(); ++p) - { - SymbolTablePtr elemSym = sym->createChild(); - elemSym->add(key, p->first); - elemSym->add(value, p->second); - ExecutableContainerDescriptor::execute(elemSym, info); - } - } - else - { - if(!_key.empty()) - { - _errorReporter->error("attribute `key' specified for sequence target"); - } - if(!_value.empty()) - { - _errorReporter->error("attribute `value' specified for sequence target"); - } - - string element = _element; - if(element.empty()) - { - element = "elem"; - } - - string index = _index; - if(index.empty()) - { - index = "i"; - } - - // - // NOTE: Don't use iterator to traverse vector because child descriptors might remove elements. - // - DataList& l = seq->getElements(); - DataList::size_type i = 0; - while(i < l.size()) - { - SymbolTablePtr elemSym = sym->createChild(); - elemSym->add(element, l[i]); - elemSym->add(index, _factory->createInteger(i, true)); - ExecutableContainerDescriptor::execute(elemSym, info); - ++i; - } - } -} - -// -// DumpDescriptor -// -FreezeScript::DumpDescriptor::DumpDescriptor(const DescriptorPtr& parent, int line, - const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes, - const Slice::UnitPtr& unit) : - Descriptor(parent, line, factory, errorReporter), - ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "dump"), - _base(true), - _contents(true) -{ - DescriptorErrorContext ctx(_errorReporter, "dump", _line); - - for(IceXML::Attributes::const_iterator p = attributes.begin(); p != attributes.end(); ++p) - { - if(p->first == "type") - { - if(_type) - { - _errorReporter->error("duplicate attribute `type'"); - } - _type = findType(unit, p->second); - } - else if(p->first == "base") - { - if(p->second == "false") - { - _base = false; - } - else if(p->second != "true") - { - _errorReporter->error("invalid value `" + p->second + "' for attribute `base'"); - } - } - else if(p->first == "contents") - { - if(p->second == "false") - { - _contents = false; - } - else if(p->second != "true") - { - _errorReporter->error("invalid value `" + p->second + "' for attribute `contents'"); - } - } - else - { - _errorReporter->error("unknown attribute `" + p->first + "'"); - } - } - - if(!_type) - { - _errorReporter->error("required attribute `type' is missing"); - } -} - -Slice::TypePtr -FreezeScript::DumpDescriptor::type() const -{ - return _type; -} - -string -FreezeScript::DumpDescriptor::typeName() const -{ - return typeToString(_type); -} - -bool -FreezeScript::DumpDescriptor::base() const -{ - return _base; -} - -bool -FreezeScript::DumpDescriptor::contents() const -{ - return _contents; -} - -// -// RecordDescriptor -// -FreezeScript::RecordDescriptor::RecordDescriptor(const DescriptorPtr& parent, int line, - const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes, - const Slice::UnitPtr& unit, - const FreezeScript::ObjectFactoryPtr& objectFactory) : - Descriptor(parent, line, factory, errorReporter), - ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "record"), - _unit(unit), - _objectFactory(objectFactory) -{ -} - -void -FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& /*sym*/, ExecuteInfo* info) -{ - // - // Temporarily add an object factory. - // - _objectFactory->activate(_factory, _unit); - - // - // Iterate over the database. - // - Dbc* dbc = 0; - info->db->cursor(info->txn, &dbc, 0); - try - { - Dbt dbKey, dbValue; - while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) - { - Ice::ByteSeq keyBytes; - keyBytes.resize(dbKey.get_size()); - memcpy(&keyBytes[0], dbKey.get_data(), dbKey.get_size()); - Ice::InputStreamPtr inKey = Ice::wrapInputStream(info->communicator, keyBytes); - - Ice::ByteSeq valueBytes; - valueBytes.resize(dbValue.get_size()); - memcpy(&valueBytes[0], dbValue.get_data(), dbValue.get_size()); - Ice::InputStreamPtr inValue = Ice::wrapInputStream(info->communicator, valueBytes); - inValue->startEncapsulation(); - - // - // Create data representations of the key and value types. - // - DataPtr keyData = _factory->create(info->keyType, true); - Destroyer<DataPtr> keyDataDestroyer(keyData); - DataPtr valueData = _factory->create(info->valueType, true); - Destroyer<DataPtr> valueDataDestroyer(valueData); - DataPtr facetData = _factory->createString(info->facet, true); - Destroyer<DataPtr> facetDataDestroyer(facetData); - - // - // Unmarshal the key and value. - // - keyData->unmarshal(inKey); - valueData->unmarshal(inValue); - if(info->valueType->usesClasses()) - { - inValue->readPendingObjects(); - } - - // - // Visit the key and value. - // - DumpVisitor visitor(_factory, _unit, _errorReporter, info); - keyData->visit(visitor); - valueData->visit(visitor); - - if(!_children.empty()) - { - // - // Execute the child descriptors. - // - SymbolTablePtr st = new SymbolTableI(_factory, _unit, _errorReporter, info, info->symbolTable); - st->add("key", keyData); - st->add("value", valueData); - st->add("facet", facetData); - ExecutableContainerDescriptor::execute(st, info); - } - } - } - catch(...) - { - if(dbc) - { - dbc->close(); - } - _objectFactory->deactivate(); - throw; - } - - if(dbc) - { - dbc->close(); - } - _objectFactory->deactivate(); -} - -// -// DatabaseDescriptor -// -FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent, int line, - const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& attributes, - const Slice::UnitPtr& unit) : - Descriptor(parent, line, factory, errorReporter), - ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "database"), - _unit(unit) -{ - DescriptorErrorContext ctx(_errorReporter, "database", _line); - - IceXML::Attributes::const_iterator p = attributes.find("key"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `key' is missing"); - } - _key = findType(unit, p->second); - - p = attributes.find("value"); - if(p == attributes.end()) - { - _errorReporter->error("required attribute `value' is missing"); - } - _value = findType(unit, p->second); -} - -void -FreezeScript::DatabaseDescriptor::addChild(const DescriptorPtr& child) -{ - DescriptorErrorContext ctx(_errorReporter, "database", _line); - - RecordDescriptorPtr rec = RecordDescriptorPtr::dynamicCast(child); - if(rec) - { - if(_record) - { - _errorReporter->error("only one <record> element can be specified"); - } - _record = rec; - } - - ExecutableContainerDescriptor::addChild(child); -} - -void -FreezeScript::DatabaseDescriptor::execute(const SymbolTablePtr&, ExecuteInfo* info) -{ - // - // Store the key and value types. - // - info->keyType = _key; - info->valueType = _value; - - ExecutableContainerDescriptor::execute(info->symbolTable, info); -} - -// -// DumpDBDescriptor -// -FreezeScript::DumpDBDescriptor::DumpDBDescriptor(int line, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter, - const IceXML::Attributes& /*attributes*/, const Slice::UnitPtr& unit) : - Descriptor(0, line, factory, errorReporter), _unit(unit), _info(new ExecuteInfo) -{ - _info->symbolTable = new SymbolTableI(factory, unit, errorReporter, _info); -} - -FreezeScript::DumpDBDescriptor::~DumpDBDescriptor() -{ - delete _info; -} - -void -FreezeScript::DumpDBDescriptor::addChild(const DescriptorPtr& child) -{ - DescriptorErrorContext ctx(_errorReporter, "dumpdb", _line); - - DatabaseDescriptorPtr db = DatabaseDescriptorPtr::dynamicCast(child); - DumpDescriptorPtr dump = DumpDescriptorPtr::dynamicCast(child); - - if(db) - { - if(_database) - { - _errorReporter->error("only one <database> element can be specified"); - } - else - { - _database = db; - _children.push_back(db); - } - } - else if(dump) - { - string name = dump->typeName(); - DumpMap::iterator p = _info->dumpMap.find(name); - if(p != _info->dumpMap.end()) - { - _errorReporter->error("<dump> descriptor for `" + name + "' specified more than once"); - } - _info->dumpMap.insert(DumpMap::value_type(name, dump)); - - _children.push_back(dump); - } - else - { - _errorReporter->error("invalid child element"); - } -} - -void -FreezeScript::DumpDBDescriptor::validate() -{ - DescriptorErrorContext ctx(_errorReporter, "dumpdb", _line); - - if(!_database) - { - _errorReporter->error("no <database> element specified"); - } - - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->validate(); - } -} - -void -FreezeScript::DumpDBDescriptor::execute(const SymbolTablePtr&, ExecuteInfo*) -{ - assert(false); -} - -void -FreezeScript::DumpDBDescriptor::dump(const Ice::CommunicatorPtr& communicator, Db* db, DbTxn* txn, const string& facet) -{ - _info->communicator = communicator; - _info->db = db; - _info->txn = txn; - _info->facet = facet; - - try - { - _database->execute(0, _info); - } - catch(...) - { - _info->communicator = 0; - _info->db = 0; - _info->txn = 0; - throw; - } - - _info->communicator = 0; - _info->db = 0; - _info->txn = 0; -} - -// -// SymbolTableI -// -FreezeScript::SymbolTableI::SymbolTableI(const DataFactoryPtr& factory, const Slice::UnitPtr& unit, - const ErrorReporterPtr& errorReporter, ExecuteInfo* info, - const SymbolTablePtr& parent) : - _factory(factory), _unit(unit), _errorReporter(errorReporter), _info(info), _parent(parent) -{ -} - -void -FreezeScript::SymbolTableI::add(const string& name, const DataPtr& data) -{ - DataMap::const_iterator p = _dataMap.find(name); - if(p != _dataMap.end()) - { - _errorReporter->error("`" + name + "' is already defined"); - } - - _dataMap.insert(DataMap::value_type(name, data)); -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::getValue(const EntityNodePtr& entity) const -{ - EntityVisitor visitor(const_cast<SymbolTableI*>(this)); - entity->visit(visitor); - DataPtr result = visitor.getCurrent(); - if(!result) - { - ostringstream ostr; - ostr << "invalid entity `" << entity << "'"; - _errorReporter->error(ostr.str()); - } - - return result; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::getConstantValue(const string& name) const -{ - DataMap::const_iterator p = _constantCache.find(name); - if(p != _constantCache.end()) - { - return p->second; - } - - if(_parent) - { - return _parent->getConstantValue(name); - } - - Slice::ContainedList l = _unit->findContents(name); - if(l.empty()) - { - _errorReporter->error("unknown constant `" + name + "'"); - } - - Slice::EnumeratorPtr e = Slice::EnumeratorPtr::dynamicCast(l.front()); - Slice::ConstPtr c = Slice::ConstPtr::dynamicCast(l.front()); - if(!e && !c) - { - _errorReporter->error("`" + name + "' does not refer to a Slice constant or enumerator"); - } - - DataPtr result; - - if(c) - { - Slice::TypePtr type = c->type(); - string value = c->value(); - Slice::BuiltinPtr b = Slice::BuiltinPtr::dynamicCast(type); - if(b) - { - switch(b->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - { - Ice::Long n; - if(!IceUtilInternal::stringToInt64(value, n)) - { - assert(false); - } - result = _factory->createInteger(n, true); - break; - } - - case Slice::Builtin::KindBool: - { - result = _factory->createBoolean(value == "true", true); - break; - } - - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - double v = strtod(value.c_str(), 0); - result = _factory->createDouble(v, true); - break; - } - - case Slice::Builtin::KindString: - { - result = _factory->createString(value, true); - break; - } - - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } - } - else - { - Slice::EnumPtr en = Slice::EnumPtr::dynamicCast(type); - assert(en); - Slice::EnumeratorList el = en->getEnumerators(); - for(Slice::EnumeratorList::iterator q = el.begin(); q != el.end(); ++q) - { - if((*q)->name() == value) - { - e = *q; - break; - } - } - assert(e); - } - } - - if(!result) - { - assert(e); - result = _factory->create(e->type(), true); - EnumDataPtr ed = EnumDataPtr::dynamicCast(result); - assert(ed); - ed->setValueAsString(e->name()); - } - - // - // Cache the value. - // - const_cast<DataMap&>(_constantCache).insert(DataMap::value_type(name, result)); - - return result; -} - -FreezeScript::SymbolTablePtr -FreezeScript::SymbolTableI::createChild() -{ - return new SymbolTableI(_factory, _unit, _errorReporter, _info, this); -} - -Slice::TypePtr -FreezeScript::SymbolTableI::lookupType(const string& name) -{ - Slice::TypeList l = _unit->lookupType(name, false); - Slice::TypePtr result; - if(!l.empty()) - { - result = l.front(); - } - return result; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::invokeFunction(const string& name, const DataPtr& target, const DataList& args) -{ - if(target) - { - DictionaryDataPtr targetDict = DictionaryDataPtr::dynamicCast(target); - if(targetDict && name == "containsKey") - { - if(args.size() != 1) - { - _errorReporter->error("containsKey() requires one argument"); - } - Slice::DictionaryPtr dictType = Slice::DictionaryPtr::dynamicCast(targetDict->getType()); - assert(dictType); - DataPtr key = _factory->create(dictType->keyType(), false); - AssignVisitor visitor(args[0], _factory, _errorReporter, false); - key->visit(visitor); - DataPtr value = targetDict->getElement(key); - return _factory->createBoolean(value ? true : false, false); - } - - DataPtr result; - if(invokeMemberFunction(name, target, args, result, _factory, _errorReporter)) - { - return result; - } - - _errorReporter->error("unknown function `" + name + "' invoked on type " + typeToString(target->getType())); - } - else - { - // - // Global function. - // - DataPtr result; - if(invokeGlobalFunction(_info->communicator, name, args, result, _factory, _errorReporter)) - { - return result; - } - else - { - _errorReporter->error("unknown global function `" + name + "'"); - } - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::findValue(const string& name) const -{ - DataMap::const_iterator p = _dataMap.find(name); - if(p != _dataMap.end()) - { - return p->second; - } - - if(_parent) - { - SymbolTableIPtr parentI = SymbolTableIPtr::dynamicCast(_parent); - assert(parentI); - return parentI->findValue(name); - } - - return 0; -} - -FreezeScript::SymbolTableI::EntityVisitor::EntityVisitor(SymbolTableI* table) : - _table(table), _error(false) -{ -} - -void -FreezeScript::SymbolTableI::EntityVisitor::visitIdentifier(const string& name) -{ - if(!_error) - { - if(!_current) - { - _current = _table->findValue(name); - } - else - { - _current = _current->getMember(name); - } - - if(!_current) - { - _error = true; - } - } -} - -void -FreezeScript::SymbolTableI::EntityVisitor::visitElement(const NodePtr& value) -{ - if(!_error) - { - assert(_current); - - DataPtr val = value->evaluate(_table); - _current = _current->getElement(val); - - if(!_current) - { - _error = true; - } - } -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::EntityVisitor::getCurrent() const -{ - return _current; -} - -// -// DumpVisitor -// -FreezeScript::DumpVisitor::DumpVisitor(const DataFactoryPtr& factory, const Slice::UnitPtr& unit, - const ErrorReporterPtr& errorReporter, ExecuteInfo* info) : - _factory(factory), _unit(unit), _errorReporter(errorReporter), _info(info) -{ -} - -void -FreezeScript::DumpVisitor::visitBoolean(const BooleanDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitInteger(const IntegerDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitDouble(const DoubleDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitString(const StringDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitProxy(const ProxyDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitStruct(const StructDataPtr& data) -{ - if(dump(data)) - { - DataMemberMap& members = data->getMembers(); - for(DataMemberMap::iterator p = members.begin(); p != members.end(); ++p) - { - p->second->visit(*this); - } - } -} - -void -FreezeScript::DumpVisitor::visitSequence(const SequenceDataPtr& data) -{ - if(dump(data)) - { - DataList& elements = data->getElements(); - for(DataList::iterator p = elements.begin(); p != elements.end(); ++p) - { - (*p)->visit(*this); - } - } -} - -void -FreezeScript::DumpVisitor::visitEnum(const EnumDataPtr& data) -{ - dump(data); -} - -void -FreezeScript::DumpVisitor::visitDictionary(const DictionaryDataPtr& data) -{ - if(dump(data)) - { - DataMap& elements = data->getElements(); - for(DataMap::iterator p = elements.begin(); p != elements.end(); ++p) - { - p->first->visit(*this); - p->second->visit(*this); - } - } -} - -void -FreezeScript::DumpVisitor::visitObject(const ObjectRefPtr& data) -{ - if(dump(data)) - { - ObjectDataPtr value = data->getValue(); - if(value) - { - set<const ObjectData*>::iterator p = _objectHistory.find(value.get()); - if(p == _objectHistory.end()) - { - _objectHistory.insert(value.get()); - DataMemberMap& members = value->getMembers(); - for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q) - { - q->second->visit(*this); - } - } - } - } -} - -bool -FreezeScript::DumpVisitor::dump(const DataPtr& data) -{ - bool result = true; - ObjectRefPtr obj = ObjectRefPtr::dynamicCast(data); - if(obj && obj->getValue()) - { - // - // When the value is an object, attempt to find a <dump> descriptor for the - // object's actual type. If no descriptor is found, attempt to find a - // descriptor for the object's base types (including Ice::Object). - // - ObjectDataPtr objData = obj->getValue(); - Slice::TypePtr cls = objData->getType(); // Actual type - bool checkContents = true; - while(cls) - { - string type = typeToString(cls); - bool base = true; - DumpMap::const_iterator p = _info->dumpMap.find(type); - if(p != _info->dumpMap.end()) - { - SymbolTablePtr sym = new SymbolTableI(_factory, _unit, _errorReporter, _info, _info->symbolTable); - sym->add("value", objData); - p->second->execute(sym, _info); - base = p->second->base(); - if(checkContents) - { - result = p->second->contents(); - checkContents = false; - } - } - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(cls); - cls = 0; - if(base && decl) - { - Slice::ClassDefPtr def = decl->definition(); - assert(def); - Slice::ClassList bases = def->bases(); - if(!bases.empty() && !bases.front()->isInterface()) - { - cls = bases.front()->declaration(); - } - else - { - cls = _unit->builtin(Slice::Builtin::KindObject); - } - } - } - } - else - { - string typeName = typeToString(data->getType()); - DumpMap::iterator p = _info->dumpMap.find(typeName); - if(p != _info->dumpMap.end()) - { - SymbolTablePtr st = new SymbolTableI(_factory, _unit, _errorReporter, _info, _info->symbolTable); - st->add("value", data); - p->second->execute(st, _info); - result = p->second->contents(); - } - - } - - return result; -} diff --git a/cpp/src/FreezeScript/DumpDescriptors.h b/cpp/src/FreezeScript/DumpDescriptors.h deleted file mode 100644 index abbd06b4e0b..00000000000 --- a/cpp/src/FreezeScript/DumpDescriptors.h +++ /dev/null @@ -1,306 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_DUMP_DESCRIPTORS_H -#define FREEZE_SCRIPT_DUMP_DESCRIPTORS_H - -#include <FreezeScript/Parser.h> -#include <IceXML/Parser.h> - -class Db; -class DbTxn; - -namespace FreezeScript -{ - -class Descriptor; -typedef IceUtil::Handle<Descriptor> DescriptorPtr; - -struct ExecuteInfo; - -class Descriptor : virtual public IceUtil::SimpleShared -{ -public: - - virtual ~Descriptor(); - - virtual DescriptorPtr parent() const; - virtual void addChild(const DescriptorPtr&) = 0; - virtual void validate() = 0; - virtual void execute(const SymbolTablePtr&, ExecuteInfo*) = 0; - -protected: - - Descriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&); - - NodePtr parse(const std::string&) const; - - Slice::TypePtr findType(const Slice::UnitPtr&, const std::string&); - - DescriptorPtr _parent; - int _line; - DataFactoryPtr _factory; - ErrorReporterPtr _errorReporter; -}; - -class SetDescriptor : public Descriptor -{ -public: - - SetDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - EntityNodePtr _target; - NodePtr _value; - std::string _valueStr; - NodePtr _length; - std::string _lengthStr; - bool _convert; -}; - -class DefineDescriptor : public Descriptor -{ -public: - - DefineDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, const Slice::UnitPtr&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - std::string _name; - Slice::TypePtr _type; - NodePtr _value; - std::string _valueStr; - bool _convert; -}; - -class AddDescriptor : public Descriptor -{ -public: - - AddDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - EntityNodePtr _target; - NodePtr _key; - std::string _keyStr; - NodePtr _index; - std::string _indexStr; - NodePtr _value; - std::string _valueStr; - bool _convert; -}; - -class RemoveDescriptor : public Descriptor -{ -public: - - RemoveDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - EntityNodePtr _target; - NodePtr _key; - std::string _keyStr; - NodePtr _index; - std::string _indexStr; -}; - -class FailDescriptor : public Descriptor -{ -public: - - FailDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - NodePtr _test; - std::string _testStr; - std::string _message; -}; - -class EchoDescriptor : public Descriptor -{ -public: - - EchoDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, std::ostream&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - std::ostream& _os; - std::string _message; - NodePtr _value; - std::string _valueStr; -}; - -class ExecutableContainerDescriptor : virtual public Descriptor -{ -public: - - ExecutableContainerDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, const std::string&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -protected: - - std::vector<DescriptorPtr> _children; - -private: - - std::string _name; -}; - -class IfDescriptor : public ExecutableContainerDescriptor -{ -public: - - IfDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, const IceXML::Attributes&); - - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - NodePtr _test; - std::string _testStr; -}; - -class IterateDescriptor : public ExecutableContainerDescriptor -{ -public: - - IterateDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&); - - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - EntityNodePtr _target; - std::string _key; - std::string _value; - std::string _element; - std::string _index; -}; - -class DumpDescriptor : public ExecutableContainerDescriptor -{ -public: - - DumpDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, const Slice::UnitPtr&); - - Slice::TypePtr type() const; - std::string typeName() const; - bool base() const; - bool contents() const; - -private: - - Slice::TypePtr _type; - bool _base; - bool _contents; -}; -typedef IceUtil::Handle<DumpDescriptor> DumpDescriptorPtr; - -class RecordDescriptor : public ExecutableContainerDescriptor -{ -public: - - RecordDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, const Slice::UnitPtr&, - const FreezeScript::ObjectFactoryPtr&); - - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - Slice::UnitPtr _unit; - FreezeScript::ObjectFactoryPtr _objectFactory; -}; -typedef IceUtil::Handle<RecordDescriptor> RecordDescriptorPtr; - -class DatabaseDescriptor : public ExecutableContainerDescriptor -{ -public: - - DatabaseDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&, - const IceXML::Attributes&, const Slice::UnitPtr&); - - virtual void addChild(const DescriptorPtr&); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - -private: - - Slice::UnitPtr _unit; - Slice::TypePtr _key; - Slice::TypePtr _value; - RecordDescriptorPtr _record; -}; -typedef IceUtil::Handle<DatabaseDescriptor> DatabaseDescriptorPtr; - -class DumpDBDescriptor : public Descriptor -{ -public: - - DumpDBDescriptor(int, const DataFactoryPtr&, const ErrorReporterPtr&, const IceXML::Attributes&, - const Slice::UnitPtr&); - ~DumpDBDescriptor(); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&, ExecuteInfo*); - - void dump(const Ice::CommunicatorPtr&, Db*, DbTxn*, const std::string&); - -private: - - Slice::UnitPtr _unit; - DatabaseDescriptorPtr _database; - std::vector<DescriptorPtr> _children; - ExecuteInfo* _info; -}; -typedef IceUtil::Handle<DumpDBDescriptor> DumpDBDescriptorPtr; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Error.cpp b/cpp/src/FreezeScript/Error.cpp deleted file mode 100644 index ba4c6d48de3..00000000000 --- a/cpp/src/FreezeScript/Error.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Error.h> -#include <FreezeScript/Exception.h> -#include <FreezeScript/Util.h> - -using namespace std; - -// -// ErrorReporter -// -FreezeScript::ErrorReporter::ErrorReporter(ostream& out, bool suppress) : - _out(out), _suppress(suppress) -{ -} - -ostream& -FreezeScript::ErrorReporter::stream() const -{ - return _out; -} - -void -FreezeScript::ErrorReporter::warning(const string& msg) -{ - ostringstream ostr; - if(!_descName.empty()) - { - ostr << "warning in <" << _descName << "> descriptor, line " << _descLine << ": " << msg << endl; - } - else - { - ostr << "warning: " << msg << endl; - } - string warn = ostr.str(); - if(_suppress) - { - map<string, bool>::iterator p = _warningHistory.find(warn); - if(p != _warningHistory.end()) - { - return; - } - _warningHistory.insert(map<string, bool>::value_type(warn, true)); - } - _out << warn; -} - -void -FreezeScript::ErrorReporter::error(const string& msg) -{ - ostringstream ostr; - if(!_descName.empty()) - { - ostr << "error in <" << _descName << "> descriptor, line " << _descLine << ": " << msg << endl; - } - else - { - ostr << "error: " << msg << endl; - } - throw FailureException(__FILE__, __LINE__, ostr.str()); -} - -void -FreezeScript::ErrorReporter::typeMismatchError(const Slice::TypePtr& expected, const Slice::TypePtr& received, - bool fatal) -{ - ostringstream ostr; - ostr << "type mismatch: expected " << typeToString(expected) << " but received " << typeToString(received); - - if(fatal) - { - error(ostr.str()); - } - else - { - warning(ostr.str()); - } -} - -void -FreezeScript::ErrorReporter::conversionError(const string& value, const Slice::TypePtr& type, bool fatal) -{ - ostringstream ostr; - ostr << "unable to convert `" << value << "' to " << typeToString(type); - - if(fatal) - { - error(ostr.str()); - } - else - { - warning(ostr.str()); - } -} - -void -FreezeScript::ErrorReporter::rangeError(const string& value, const Slice::TypePtr& type, bool fatal) -{ - ostringstream ostr; - ostr << "value `" << value << "' is out of range for type " << typeToString(type); - - if(fatal) - { - error(ostr.str()); - } - else - { - warning(ostr.str()); - } -} - -void -FreezeScript::ErrorReporter::expressionSyntaxError(const string& msg) -{ - assert(!_expression.empty()); - ostringstream ostr; - ostr << "syntax error in expression `" << _expression << "': " << msg; - error(ostr.str()); -} - -void -FreezeScript::ErrorReporter::descriptorError(const string& msg, int line) -{ - ostringstream ostr; - ostr << "XML error on line " << line << ":" << endl << msg; - error(ostr.str()); -} - -void -FreezeScript::ErrorReporter::setDescriptor(const string& name, int line) -{ - _descName = name; - _descLine = line; -} - -void -FreezeScript::ErrorReporter::getDescriptor(string& name, int& line) -{ - name = _descName; - line = _descLine; -} - -void -FreezeScript::ErrorReporter::clearDescriptor() -{ - _descName.clear(); -} - -void -FreezeScript::ErrorReporter::setExpression(const string& expr) -{ - _expression = expr; -} - -void -FreezeScript::ErrorReporter::clearExpression() -{ - _expression.clear(); -} - -// -// DescriptorErrorContext -// -FreezeScript::DescriptorErrorContext::DescriptorErrorContext(const ErrorReporterPtr& errorReporter, const string& name, - int line) : - _errorReporter(errorReporter) -{ - // - // Save the existing descriptor information before changing it. - // - _errorReporter->getDescriptor(_name, _line); - _errorReporter->setDescriptor(name, line); -} - -FreezeScript::DescriptorErrorContext::~DescriptorErrorContext() -{ - // - // Restore the original descriptor information. - // - _errorReporter->setDescriptor(_name, _line); -} diff --git a/cpp/src/FreezeScript/Error.h b/cpp/src/FreezeScript/Error.h deleted file mode 100644 index 353ed067402..00000000000 --- a/cpp/src/FreezeScript/Error.h +++ /dev/null @@ -1,68 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_ERROR_H -#define FREEZE_SCRIPT_ERROR_H - -#include <Slice/Parser.h> - -namespace FreezeScript -{ - -class ErrorReporter : public IceUtil::SimpleShared -{ -public: - - ErrorReporter(std::ostream&, bool); - - std::ostream& stream() const; - - void warning(const std::string&); - void error(const std::string&); - void typeMismatchError(const Slice::TypePtr&, const Slice::TypePtr&, bool); - void conversionError(const std::string&, const Slice::TypePtr&, bool); - void rangeError(const std::string&, const Slice::TypePtr&, bool); - void expressionSyntaxError(const std::string&); - void descriptorError(const std::string&, int); - - void setDescriptor(const std::string&, int); - void getDescriptor(std::string&, int&); - void clearDescriptor(); - - void setExpression(const std::string&); - void clearExpression(); - -private: - - std::ostream& _out; - bool _suppress; - std::map<std::string, bool> _warningHistory; - std::string _descName; - int _descLine; - std::string _expression; -}; -typedef IceUtil::Handle<ErrorReporter> ErrorReporterPtr; - -class DescriptorErrorContext -{ -public: - - DescriptorErrorContext(const ErrorReporterPtr&, const std::string&, int); - ~DescriptorErrorContext(); - -private: - - ErrorReporterPtr _errorReporter; - std::string _name; - int _line; -}; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Exception.cpp b/cpp/src/FreezeScript/Exception.cpp deleted file mode 100644 index 1d1f2efbbe9..00000000000 --- a/cpp/src/FreezeScript/Exception.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Exception.h> - -using namespace std; - -// -// FailureException -// -FreezeScript::FailureException::FailureException(const char* file, int line, const string& reason) : - IceUtil::Exception(file, line), _reason(reason) -{ -} - -FreezeScript::FailureException::~FailureException() throw() -{ -} - -const char* FreezeScript::FailureException::_name = "FreezeScript::FailureException"; - -string -FreezeScript::FailureException::ice_name() const -{ - return _name; -} - -void -FreezeScript::FailureException::ice_print(ostream& out) const -{ - ::IceUtil::Exception::ice_print(out); - out << ":\nerror occurred during transformation"; // TODO - if(!_reason.empty()) - { - out << ":\n" << _reason; - } -} - -FreezeScript::FailureException* -FreezeScript::FailureException::ice_clone() const -{ - return new FailureException(ice_file(), ice_line(), _reason); -} - -void -FreezeScript::FailureException::ice_throw() const -{ - throw *this; -} - -string -FreezeScript::FailureException::reason() const -{ - return _reason; -} diff --git a/cpp/src/FreezeScript/Exception.h b/cpp/src/FreezeScript/Exception.h deleted file mode 100644 index 6f8007c1c5a..00000000000 --- a/cpp/src/FreezeScript/Exception.h +++ /dev/null @@ -1,39 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_EXCEPTION_H -#define FREEZE_SCRIPT_EXCEPTION_H - -#include <IceUtil/Exception.h> - -namespace FreezeScript -{ - -class FailureException : public IceUtil::Exception -{ -public: - - FailureException(const char*, int, const std::string&); - virtual ~FailureException() throw(); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual FailureException* ice_clone() const; - virtual void ice_throw() const; - - std::string reason() const; - -private: - - std::string _reason; - static const char* _name; -}; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Functions.cpp b/cpp/src/FreezeScript/Functions.cpp deleted file mode 100644 index 4670ee4f1c8..00000000000 --- a/cpp/src/FreezeScript/Functions.cpp +++ /dev/null @@ -1,346 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Functions.h> -#include <FreezeScript/Util.h> -#include <IceUtil/UUID.h> -#include <IceUtil/StringUtil.h> - -using namespace std; - -bool -FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, const string& name, const DataList& args, - DataPtr& result, const DataFactoryPtr& factory, - const ErrorReporterPtr& errorReporter) -{ - // - // Global function. - // - if(name == "typeOf") - { - if(args.size() != 1) - { - errorReporter->error("typeOf() requires one argument"); - } - result = factory->createString(typeToString(args.front()->getType()), false); - return true; - } - else if(name == "generateUUID") - { - if(args.size() != 0) - { - errorReporter->error("generateUUID() accepts no arguments"); - } - result = factory->createString(IceUtil::generateUUID(), false); - return true; - } - else if(name == "stringToIdentity") - { - StringDataPtr str; - if(args.size() > 0) - { - str = StringDataPtr::dynamicCast(args.front()); - } - if(args.size() != 1 || !str) - { - errorReporter->error("stringToIdentity() requires a string argument"); - } - - // - // Parse the identity string. - // - string idstr = str->stringValue(); - Ice::Identity id; - try - { - id = communicator->stringToIdentity(idstr); - } - catch(const Ice::IdentityParseException& ex) - { - errorReporter->error("error in stringToIdentity():\n" + ex.str); - } - - // - // Create a data representation of Ice::Identity. - // - Slice::UnitPtr unit = str->getType()->unit(); - Slice::TypeList l = unit->lookupType("::Ice::Identity", false); - assert(!l.empty()); - DataPtr identity = factory->create(l.front(), false); - StringDataPtr member; - member = StringDataPtr::dynamicCast(identity->getMember("name")); - assert(member); - member->setValue(id.name); - member = StringDataPtr::dynamicCast(identity->getMember("category")); - assert(member); - member->setValue(id.category); - result = identity; - return true; - } - else if(name == "identityToString") - { - StructDataPtr identity; - if(args.size() > 0) - { - identity = StructDataPtr::dynamicCast(args.front()); - } - if(identity) - { - Slice::TypePtr argType = identity->getType(); - Slice::StructPtr st = Slice::StructPtr::dynamicCast(argType); - if(!st || st->scoped() != "::Ice::Identity") - { - identity = 0; - } - } - if(args.size() != 1 || !identity) - { - errorReporter->error("identityToString() requires a argument of type ::Ice::Identity"); - } - - // - // Compose the identity. - // - Ice::Identity id; - StringDataPtr member; - member = StringDataPtr::dynamicCast(identity->getMember("name")); - assert(member); - id.name = member->stringValue(); - member = StringDataPtr::dynamicCast(identity->getMember("category")); - assert(member); - id.category = member->stringValue(); - - result = factory->createString(communicator->identityToString(id), false); - return true; - } - else if(name == "stringToProxy") - { - StringDataPtr str; - if(args.size() > 0) - { - str = StringDataPtr::dynamicCast(args.front()); - } - if(args.size() != 1 || !str) - { - errorReporter->error("stringToProxy() requires a string argument"); - } - - // - // Parse the proxy; - // - string sprx = str->stringValue(); - Ice::ObjectPrx prx; - try - { - prx = factory->getCommunicator()->stringToProxy(sprx); - } - catch(const Ice::ProxyParseException& ex) - { - errorReporter->error("error in stringToProxy():\n" + ex.str); - } - - Slice::UnitPtr unit = str->getType()->unit(); - ProxyDataPtr p = - ProxyDataPtr::dynamicCast(factory->create(unit->builtin(Slice::Builtin::KindObjectProxy), false)); - p->setValue(prx); - result = p; - return true; - } - else if(name == "proxyToString") - { - ProxyDataPtr prx; - if(args.size() > 0) - { - prx = ProxyDataPtr::dynamicCast(args.front()); - } - if(args.size() != 1 || !prx) - { - errorReporter->error("proxyToString() requires a proxy argument"); - } - - result = factory->createString(prx->toString(), false); - return true; - } - else if(name == "lowercase") - { - StringDataPtr str; - if(args.size() > 0) - { - str = StringDataPtr::dynamicCast(args.front()); - } - if(args.size() != 1 || !str) - { - errorReporter->error("lowercase() requires a string argument"); - } - string val = IceUtilInternal::toLower(str->stringValue()); - result = factory->createString(val, false); - return true; - } - - return false; -} - -bool -FreezeScript::invokeMemberFunction(const string& name, const DataPtr& target, const DataList& args, DataPtr& result, - const DataFactoryPtr& factory, const ErrorReporterPtr& errorReporter) -{ - // - // string - // - StringDataPtr targetStr = StringDataPtr::dynamicCast(target); - if(targetStr) - { - if(name == "find") - { - StringDataPtr argData; - IntegerDataPtr startData; - if(args.size() > 0) - { - argData = StringDataPtr::dynamicCast(args[0]); - } - if(args.size() > 1) - { - startData = IntegerDataPtr::dynamicCast(args[1]); - } - if(args.size() == 0 || args.size() > 2 || !argData || (args.size() == 2 && !startData)) - { - errorReporter->error("invalid arguments to find(string str[, int len])"); - } - string targ = targetStr->stringValue(); - string arg = argData->stringValue(); - string::size_type pos; - if(startData) - { - string::size_type start = static_cast<string::size_type>(startData->integerValue()); - pos = targ.find(arg, start); - } - else - { - pos = targ.find(arg); - } - result = factory->createInteger(pos == string::npos ? -1 : static_cast<Ice::Long>(pos), false); - return true; - } - else if(name == "substr") - { - IntegerDataPtr startData; - IntegerDataPtr lenData; - if(args.size() > 0) - { - startData = IntegerDataPtr::dynamicCast(args[0]); - } - if(args.size() > 1) - { - lenData = IntegerDataPtr::dynamicCast(args[1]); - } - if(args.size() == 0 || args.size() > 2 || !startData || (args.size() == 2 && !lenData)) - { - errorReporter->error("invalid arguments to substr(int start[, int len])"); - } - string targ = targetStr->stringValue(); - string::size_type start = static_cast<string::size_type>(startData->integerValue()); - string::size_type len = string::npos; - if(lenData) - { - len = static_cast<string::size_type>(lenData->integerValue()); - } - if(start > targ.size()) - { - ostringstream ostr; - ostr << "substr() starting position (" << start << ") is greater than string length (" - << targ.size() << ")"; - errorReporter->error(ostr.str()); - } - result = factory->createString(targ.substr(start, len), false); - return true; - } - else if(name == "replace") - { - IntegerDataPtr startData; - IntegerDataPtr lenData; - StringDataPtr strData; - if(args.size() == 3) - { - startData = IntegerDataPtr::dynamicCast(args[0]); - lenData = IntegerDataPtr::dynamicCast(args[1]); - strData = StringDataPtr::dynamicCast(args[2]); - } - if(args.size() != 3 || !startData || !lenData || !strData) - { - errorReporter->error("invalid arguments to replace(int start, int len, string val)"); - } - string targ = targetStr->stringValue(); - string::size_type start = static_cast<string::size_type>(startData->integerValue()); - string::size_type len = static_cast<string::size_type>(lenData->integerValue()); - string str = strData->stringValue(); - if(start > targ.size()) - { - ostringstream ostr; - ostr << "replace() starting position (" << start << ") is greater than string length (" - << targ.size() << ")"; - errorReporter->error(ostr.str()); - } - result = factory->createString(targ.replace(start, len, str), false); - return true; - } - - return false; - } - - // - // Object - // - ObjectRefPtr targetObj = ObjectRefPtr::dynamicCast(target); - if(targetObj) - { - if(name == "ice_isA") - { - ObjectDataPtr value = targetObj->getValue(); - if(!value) - { - errorReporter->error("ice_isA() invoked on nil object"); - } - StringDataPtr str; - if(args.size() > 0) - { - str = StringDataPtr::dynamicCast(args.front()); - } - if(args.size() != 1 || !str) - { - errorReporter->error("invalid arguments to ice_isA(string id)"); - } - - string id = str->stringValue(); - if(id == "::Ice::Object") - { - result = factory->createBoolean(true, false); - return true; - } - - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(value->getType()); - if(!decl) - { - // - // Ice::Object - // - result = factory->createBoolean(false, false); - return true; - } - - Slice::ClassDefPtr def = decl->definition(); - assert(def); - result = factory->createBoolean(def->isA(id), false); - return true; - } - - return false; - } - - return false; -} diff --git a/cpp/src/FreezeScript/Functions.h b/cpp/src/FreezeScript/Functions.h deleted file mode 100644 index 9b4860fb6f2..00000000000 --- a/cpp/src/FreezeScript/Functions.h +++ /dev/null @@ -1,26 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_FUNCTIONS_H -#define FREEZE_SCRIPT_FUNCTIONS_H - -#include <FreezeScript/Data.h> - -namespace FreezeScript -{ - -bool invokeGlobalFunction(const Ice::CommunicatorPtr&, const std::string&, const DataList&, DataPtr&, - const DataFactoryPtr&, const ErrorReporterPtr&); - -bool invokeMemberFunction(const std::string&, const DataPtr&, const DataList&, DataPtr&, const DataFactoryPtr&, - const ErrorReporterPtr&); - -} - -#endif diff --git a/cpp/src/FreezeScript/Grammar.cpp b/cpp/src/FreezeScript/Grammar.cpp deleted file mode 100644 index e3e79cb8910..00000000000 --- a/cpp/src/FreezeScript/Grammar.cpp +++ /dev/null @@ -1,2051 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */ - -/* 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.4.1" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* Substitute the variable and function names. */ -#define yyparse freeze_script_parse -#define yylex freeze_script_lex -#define yyerror freeze_script_error -#define yylval freeze_script_lval -#define yychar freeze_script_char -#define yydebug freeze_script_debug -#define yynerrs freeze_script_nerrs - - -/* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 1 "../FreezeScript/Grammar.y" - - -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/GrammarUtil.h> - -#ifdef _MSC_VER -// I get these warnings from some bison versions: -// warning C4102: 'yyoverflowlab' : unreferenced label -# pragma warning( disable : 4102 ) -// warning C4065: switch statement contains 'default' but no 'case' labels -# pragma warning( disable : 4065 ) -#endif - -// -// Avoid old style cast warnings in generated grammar -// -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -using namespace std; -using namespace FreezeScript; - -void -freeze_script_error(const char* s) -{ - // yacc and recent versions of Bison use "syntax error" instead - // of "parse error". - - if(strcmp(s, "parse error") == 0) - { - parseErrorReporter->expressionSyntaxError("syntax error"); - } - else - { - parseErrorReporter->expressionSyntaxError(s); - } -} - - - -/* Line 189 of yacc.c */ -#line 131 "Grammar.tab.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#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 - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_AND = 258, - TOK_OR = 259, - TOK_NOT = 260, - TOK_ADD = 261, - TOK_SUB = 262, - TOK_MUL = 263, - TOK_DIV = 264, - TOK_MOD = 265, - TOK_LPAREN = 266, - TOK_RPAREN = 267, - TOK_LBRACKET = 268, - TOK_RBRACKET = 269, - TOK_LESS_THAN = 270, - TOK_GREATER_THAN = 271, - TOK_LESS_EQUAL = 272, - TOK_GREATER_EQUAL = 273, - TOK_EQUAL = 274, - TOK_NEQ = 275, - TOK_TRUE = 276, - TOK_FALSE = 277, - TOK_NIL = 278, - TOK_SCOPE_DELIMITER = 279, - TOK_IDENTIFIER = 280, - TOK_STRING_LITERAL = 281, - TOK_INTEGER_LITERAL = 282, - TOK_FLOATING_POINT_LITERAL = 283, - UNARY_OP = 284 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Line 264 of yacc.c */ -#line 202 "Grammar.tab.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 <stddef.h> /* 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 <libintl.h> /* 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 yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#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 <alloca.h> /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include <malloc.h> /* 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 <stdlib.h> /* 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 <stdlib.h> /* 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 YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* 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)) \ - + 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_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 24 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 111 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 32 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 9 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 39 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 65 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 284 - -#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, - 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, 31, 2, 30, 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, 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, 23, 24, - 25, 26, 27, 28, 29 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 7, 11, 15, 19, 23, 27, - 31, 35, 39, 43, 47, 51, 55, 59, 61, 65, - 68, 71, 73, 75, 77, 79, 81, 83, 85, 89, - 91, 93, 98, 102, 104, 109, 113, 115, 116, 120 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 33, 0, -1, 34, -1, 35, -1, 35, 15, 35, - -1, 35, 16, 35, -1, 35, 17, 35, -1, 35, - 18, 35, -1, 35, 19, 35, -1, 35, 20, 35, - -1, 35, 4, 35, -1, 35, 3, 35, -1, 35, - 8, 35, -1, 35, 9, 35, -1, 35, 10, 35, - -1, 35, 6, 35, -1, 35, 7, 35, -1, 36, - -1, 11, 34, 12, -1, 7, 36, -1, 5, 36, - -1, 27, -1, 28, -1, 26, -1, 21, -1, 22, - -1, 23, -1, 37, -1, 37, 30, 38, -1, 38, - -1, 40, -1, 37, 13, 34, 14, -1, 37, 30, - 25, -1, 25, -1, 25, 11, 39, 12, -1, 39, - 31, 34, -1, 34, -1, -1, 40, 24, 25, -1, - 24, 25, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 91, 91, 100, 109, 113, 117, 121, 125, 129, - 133, 137, 141, 145, 149, 153, 157, 161, 170, 174, - 178, 182, 188, 194, 200, 204, 208, 212, 216, 225, - 229, 240, 247, 256, 267, 280, 287, 294, 302, 311 -}; -#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", "TOK_AND", "TOK_OR", "TOK_NOT", - "TOK_ADD", "TOK_SUB", "TOK_MUL", "TOK_DIV", "TOK_MOD", "TOK_LPAREN", - "TOK_RPAREN", "TOK_LBRACKET", "TOK_RBRACKET", "TOK_LESS_THAN", - "TOK_GREATER_THAN", "TOK_LESS_EQUAL", "TOK_GREATER_EQUAL", "TOK_EQUAL", - "TOK_NEQ", "TOK_TRUE", "TOK_FALSE", "TOK_NIL", "TOK_SCOPE_DELIMITER", - "TOK_IDENTIFIER", "TOK_STRING_LITERAL", "TOK_INTEGER_LITERAL", - "TOK_FLOATING_POINT_LITERAL", "UNARY_OP", "'.'", "','", "$accept", - "start", "expr", "binary", "unary", "entity", "function", "arg_list", - "constant", 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, 278, 279, 280, 281, 282, 283, 284, - 46, 44 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 32, 33, 34, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 37, 37, 37, 38, 39, 39, 39, 40, 40 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 1, 3, 2, - 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, - 1, 4, 3, 1, 4, 3, 1, 0, 3, 2 -}; - -/* 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[] = -{ - 0, 0, 0, 0, 24, 25, 26, 0, 33, 23, - 21, 22, 0, 2, 3, 17, 27, 29, 30, 20, - 19, 0, 39, 37, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 18, 36, 0, 11, 10, 15, 16, 12, 13, - 14, 4, 5, 6, 7, 8, 9, 0, 32, 28, - 38, 34, 0, 31, 35 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 12, 13, 14, 15, 16, 17, 43, 18 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -20 -static const yytype_int8 yypact[] = -{ - 0, 0, 0, 0, -20, -20, -20, -19, 1, -20, - -20, -20, 13, -20, 30, -20, -12, -20, -10, -20, - -20, 3, -20, 0, -20, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, - -8, -20, -20, -2, 63, 48, -6, -6, -20, -20, - -20, 78, 78, 78, 78, 78, 78, 5, 1, -20, - -20, -20, 0, -20, -20 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -20, -20, -3, 74, 7, -20, -7, -20, -20 -}; - -/* 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_int8 yytable[] = -{ - 21, 38, 29, 30, 31, 1, 22, 2, 19, 20, - 61, 3, 23, 24, 40, 41, 58, 60, 39, 63, - 42, 4, 5, 6, 7, 8, 9, 10, 11, 62, - 0, 0, 59, 25, 26, 57, 27, 28, 29, 30, - 31, 0, 0, 0, 0, 32, 33, 34, 35, 36, - 37, 25, 0, 0, 27, 28, 29, 30, 31, 64, - 0, 0, 0, 32, 33, 34, 35, 36, 37, 27, - 28, 29, 30, 31, 0, 0, 0, 0, 32, 33, - 34, 35, 36, 37, 27, 28, 29, 30, 31, 0, - 0, 0, 0, -1, -1, -1, -1, -1, -1, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56 -}; - -static const yytype_int8 yycheck[] = -{ - 3, 13, 8, 9, 10, 5, 25, 7, 1, 2, - 12, 11, 11, 0, 24, 12, 25, 25, 30, 14, - 23, 21, 22, 23, 24, 25, 26, 27, 28, 31, - -1, -1, 39, 3, 4, 38, 6, 7, 8, 9, - 10, -1, -1, -1, -1, 15, 16, 17, 18, 19, - 20, 3, -1, -1, 6, 7, 8, 9, 10, 62, - -1, -1, -1, 15, 16, 17, 18, 19, 20, 6, - 7, 8, 9, 10, -1, -1, -1, -1, 15, 16, - 17, 18, 19, 20, 6, 7, 8, 9, 10, -1, - -1, -1, -1, 15, 16, 17, 18, 19, 20, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 5, 7, 11, 21, 22, 23, 24, 25, 26, - 27, 28, 33, 34, 35, 36, 37, 38, 40, 36, - 36, 34, 25, 11, 0, 3, 4, 6, 7, 8, - 9, 10, 15, 16, 17, 18, 19, 20, 13, 30, - 24, 12, 34, 39, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 34, 25, 38, - 25, 12, 31, 14, 34 -}; - -#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 (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, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* 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); \ - 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) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (!yyvaluep) - return; -# 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) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - 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 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - 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, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#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++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} 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) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - 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 (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#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 (void) -#else -int -yyparse () - -#endif -#endif -{ -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - 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; - - 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; - - /* 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), - &yystacksize); - - 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_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + 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)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead 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; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - 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]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: - -/* Line 1455 of yacc.c */ -#line 92 "../FreezeScript/Grammar.y" - { - parseResult = (yyvsp[(1) - (1)]); -;} - break; - - case 3: - -/* Line 1455 of yacc.c */ -#line 101 "../FreezeScript/Grammar.y" - { - (yyval) = (yyvsp[(1) - (1)]); -;} - break; - - case 4: - -/* Line 1455 of yacc.c */ -#line 110 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpLess, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 5: - -/* Line 1455 of yacc.c */ -#line 114 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpGreater, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 6: - -/* Line 1455 of yacc.c */ -#line 118 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpLessEq, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 7: - -/* Line 1455 of yacc.c */ -#line 122 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpGrEq, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 8: - -/* Line 1455 of yacc.c */ -#line 126 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpEq, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 9: - -/* Line 1455 of yacc.c */ -#line 130 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpNotEq, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 10: - -/* Line 1455 of yacc.c */ -#line 134 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpOr, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 11: - -/* Line 1455 of yacc.c */ -#line 138 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpAnd, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 12: - -/* Line 1455 of yacc.c */ -#line 142 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpMul, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 13: - -/* Line 1455 of yacc.c */ -#line 146 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpDiv, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 14: - -/* Line 1455 of yacc.c */ -#line 150 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpMod, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 15: - -/* Line 1455 of yacc.c */ -#line 154 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpAdd, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 16: - -/* Line 1455 of yacc.c */ -#line 158 "../FreezeScript/Grammar.y" - { - (yyval) = new BinaryNode(BinOpSub, parseDataFactory, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); -;} - break; - - case 17: - -/* Line 1455 of yacc.c */ -#line 162 "../FreezeScript/Grammar.y" - { - (yyval) = (yyvsp[(1) - (1)]); -;} - break; - - case 18: - -/* Line 1455 of yacc.c */ -#line 171 "../FreezeScript/Grammar.y" - { - (yyval) = (yyvsp[(2) - (3)]); -;} - break; - - case 19: - -/* Line 1455 of yacc.c */ -#line 175 "../FreezeScript/Grammar.y" - { - (yyval) = new UnaryNode(UnaryOpNeg, parseDataFactory, (yyvsp[(2) - (2)])); -;} - break; - - case 20: - -/* Line 1455 of yacc.c */ -#line 179 "../FreezeScript/Grammar.y" - { - (yyval) = new UnaryNode(UnaryOpNot, parseDataFactory, (yyvsp[(2) - (2)])); -;} - break; - - case 21: - -/* Line 1455 of yacc.c */ -#line 183 "../FreezeScript/Grammar.y" - { - IntegerTokPtr intVal = IntegerTokPtr::dynamicCast((yyvsp[(1) - (1)])); - assert(intVal); - (yyval) = new DataNode(parseDataFactory->createInteger(intVal->v, true)); -;} - break; - - case 22: - -/* Line 1455 of yacc.c */ -#line 189 "../FreezeScript/Grammar.y" - { - FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast((yyvsp[(1) - (1)])); - assert(floatVal); - (yyval) = new DataNode(parseDataFactory->createDouble(floatVal->v, true)); -;} - break; - - case 23: - -/* Line 1455 of yacc.c */ -#line 195 "../FreezeScript/Grammar.y" - { - StringTokPtr stringVal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); - assert(stringVal); - (yyval) = new DataNode(parseDataFactory->createString(stringVal->v, true)); -;} - break; - - case 24: - -/* Line 1455 of yacc.c */ -#line 201 "../FreezeScript/Grammar.y" - { - (yyval) = new DataNode(parseDataFactory->createBoolean(true, true)); -;} - break; - - case 25: - -/* Line 1455 of yacc.c */ -#line 205 "../FreezeScript/Grammar.y" - { - (yyval) = new DataNode(parseDataFactory->createBoolean(false, true)); -;} - break; - - case 26: - -/* Line 1455 of yacc.c */ -#line 209 "../FreezeScript/Grammar.y" - { - (yyval) = new DataNode(parseDataFactory->createNil(true)); -;} - break; - - case 27: - -/* Line 1455 of yacc.c */ -#line 213 "../FreezeScript/Grammar.y" - { - (yyval) = (yyvsp[(1) - (1)]); -;} - break; - - case 28: - -/* Line 1455 of yacc.c */ -#line 217 "../FreezeScript/Grammar.y" - { - EntityNodePtr entity = EntityNodePtr::dynamicCast((yyvsp[(1) - (3)])); - assert(entity); - FunctionNodePtr func = FunctionNodePtr::dynamicCast((yyvsp[(3) - (3)])); - assert(func); - func->setTarget(entity); - (yyval) = (yyvsp[(3) - (3)]); -;} - break; - - case 29: - -/* Line 1455 of yacc.c */ -#line 226 "../FreezeScript/Grammar.y" - { - (yyval) = (yyvsp[(1) - (1)]); -;} - break; - - case 30: - -/* Line 1455 of yacc.c */ -#line 230 "../FreezeScript/Grammar.y" - { - StringTokPtr stringVal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); - assert(stringVal); - (yyval) = new ConstantNode(stringVal->v); -;} - break; - - case 31: - -/* Line 1455 of yacc.c */ -#line 241 "../FreezeScript/Grammar.y" - { - EntityNodePtr entity = EntityNodePtr::dynamicCast((yyvsp[(1) - (4)])); - assert(entity); - entity->append(new ElementNode((yyvsp[(3) - (4)]))); - (yyval) = (yyvsp[(1) - (4)]); -;} - break; - - case 32: - -/* Line 1455 of yacc.c */ -#line 248 "../FreezeScript/Grammar.y" - { - StringTokPtr stringVal = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); - assert(stringVal); - EntityNodePtr entity = EntityNodePtr::dynamicCast((yyvsp[(1) - (3)])); - assert(entity); - entity->append(new IdentNode(stringVal->v)); - (yyval) = (yyvsp[(1) - (3)]); -;} - break; - - case 33: - -/* Line 1455 of yacc.c */ -#line 257 "../FreezeScript/Grammar.y" - { - StringTokPtr stringVal = StringTokPtr::dynamicCast((yyvsp[(1) - (1)])); - assert(stringVal); - (yyval) = new IdentNode(stringVal->v); -;} - break; - - case 34: - -/* Line 1455 of yacc.c */ -#line 268 "../FreezeScript/Grammar.y" - { - StringTokPtr func = StringTokPtr::dynamicCast((yyvsp[(1) - (4)])); - assert(func); - NodeListTokPtr args = NodeListTokPtr::dynamicCast((yyvsp[(3) - (4)])); - assert(args); - (yyval) = new FunctionNode(func->v, args->v); -;} - break; - - case 35: - -/* Line 1455 of yacc.c */ -#line 281 "../FreezeScript/Grammar.y" - { - NodeListTokPtr l = NodeListTokPtr::dynamicCast((yyvsp[(1) - (3)])); - assert(l); - l->v.push_back((yyvsp[(3) - (3)])); - (yyval) = (yyvsp[(1) - (3)]); -;} - break; - - case 36: - -/* Line 1455 of yacc.c */ -#line 288 "../FreezeScript/Grammar.y" - { - NodeListTokPtr result = new NodeListTok; - result->v.push_back((yyvsp[(1) - (1)])); - (yyval) = result; -;} - break; - - case 37: - -/* Line 1455 of yacc.c */ -#line 294 "../FreezeScript/Grammar.y" - { - (yyval) = new NodeListTok; -;} - break; - - case 38: - -/* Line 1455 of yacc.c */ -#line 303 "../FreezeScript/Grammar.y" - { - StringTokPtr stringVal = StringTokPtr::dynamicCast((yyvsp[(1) - (3)])); - assert(stringVal); - StringTokPtr idVal = StringTokPtr::dynamicCast((yyvsp[(3) - (3)])); - assert(idVal); - stringVal->v.append("::" + idVal->v); - (yyval) = (yyvsp[(1) - (3)]); -;} - break; - - case 39: - -/* Line 1455 of yacc.c */ -#line 312 "../FreezeScript/Grammar.y" - { - StringTokPtr idVal = StringTokPtr::dynamicCast((yyvsp[(2) - (2)])); - assert(idVal); - StringTokPtr stringVal = new StringTok; - stringVal->v.append("::" + idVal->v); - (yyval) = stringVal; -;} - break; - - - -/* Line 1455 of yacc.c */ -#line 1838 "Grammar.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* 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 (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 (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead 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); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead 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; - - /* 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; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - - /* 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; - -#if !defined(yyoverflow) || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* 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); - 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); -} - - - -/* Line 1675 of yacc.c */ -#line 321 "../FreezeScript/Grammar.y" - - diff --git a/cpp/src/FreezeScript/Grammar.h b/cpp/src/FreezeScript/Grammar.h deleted file mode 100644 index ae561a72f12..00000000000 --- a/cpp/src/FreezeScript/Grammar.h +++ /dev/null @@ -1,83 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */ - -/* 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 { - TOK_AND = 258, - TOK_OR = 259, - TOK_NOT = 260, - TOK_ADD = 261, - TOK_SUB = 262, - TOK_MUL = 263, - TOK_DIV = 264, - TOK_MOD = 265, - TOK_LPAREN = 266, - TOK_RPAREN = 267, - TOK_LBRACKET = 268, - TOK_RBRACKET = 269, - TOK_LESS_THAN = 270, - TOK_GREATER_THAN = 271, - TOK_LESS_EQUAL = 272, - TOK_GREATER_EQUAL = 273, - TOK_EQUAL = 274, - TOK_NEQ = 275, - TOK_TRUE = 276, - TOK_FALSE = 277, - TOK_NIL = 278, - TOK_SCOPE_DELIMITER = 279, - TOK_IDENTIFIER = 280, - TOK_STRING_LITERAL = 281, - TOK_INTEGER_LITERAL = 282, - TOK_FLOATING_POINT_LITERAL = 283, - UNARY_OP = 284 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - - - diff --git a/cpp/src/FreezeScript/Grammar.y b/cpp/src/FreezeScript/Grammar.y deleted file mode 100644 index 3db0052ca88..00000000000 --- a/cpp/src/FreezeScript/Grammar.y +++ /dev/null @@ -1,321 +0,0 @@ -%{ - -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/GrammarUtil.h> - -#ifdef _MSC_VER -// I get these warnings from some bison versions: -// warning C4102: 'yyoverflowlab' : unreferenced label -# pragma warning( disable : 4102 ) -// warning C4065: switch statement contains 'default' but no 'case' labels -# pragma warning( disable : 4065 ) -#endif - -// -// Avoid old style cast warnings in generated grammar -// -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wold-style-cast" -#endif - -using namespace std; -using namespace FreezeScript; - -void -freeze_script_error(const char* s) -{ - // yacc and recent versions of Bison use "syntax error" instead - // of "parse error". - - if(strcmp(s, "parse error") == 0) - { - parseErrorReporter->expressionSyntaxError("syntax error"); - } - else - { - parseErrorReporter->expressionSyntaxError(s); - } -} - -%} - -%pure_parser - -%token TOK_AND -%token TOK_OR -%token TOK_NOT -%token TOK_ADD -%token TOK_SUB -%token TOK_MUL -%token TOK_DIV -%token TOK_MOD -%token TOK_LPAREN -%token TOK_RPAREN -%token TOK_LBRACKET -%token TOK_RBRACKET -%token TOK_LESS_THAN -%token TOK_GREATER_THAN -%token TOK_LESS_EQUAL -%token TOK_GREATER_EQUAL -%token TOK_EQUAL -%token TOK_NEQ -%token TOK_TRUE -%token TOK_FALSE -%token TOK_NIL -%token TOK_SCOPE_DELIMITER -%token TOK_IDENTIFIER -%token TOK_STRING_LITERAL -%token TOK_INTEGER_LITERAL -%token TOK_FLOATING_POINT_LITERAL - -%left TOK_OR -%left TOK_AND -%nonassoc TOK_LESS_THAN TOK_GREATER_THAN TOK_LESS_EQUAL TOK_GREATER_EQUAL TOK_EQUAL TOK_NEQ -%left TOK_ADD TOK_SUB -%left TOK_MUL TOK_DIV TOK_MOD -%right UNARY_OP - -%% - -// ---------------------------------------------------------------------- -start -// ---------------------------------------------------------------------- -: expr -{ - parseResult = $1; -} -; - -// ---------------------------------------------------------------------- -expr -// ---------------------------------------------------------------------- -: binary -{ - $$ = $1; -} -; - -// ---------------------------------------------------------------------- -binary -// ---------------------------------------------------------------------- -: binary TOK_LESS_THAN binary -{ - $$ = new BinaryNode(BinOpLess, parseDataFactory, $1, $3); -} -| binary TOK_GREATER_THAN binary -{ - $$ = new BinaryNode(BinOpGreater, parseDataFactory, $1, $3); -} -| binary TOK_LESS_EQUAL binary -{ - $$ = new BinaryNode(BinOpLessEq, parseDataFactory, $1, $3); -} -| binary TOK_GREATER_EQUAL binary -{ - $$ = new BinaryNode(BinOpGrEq, parseDataFactory, $1, $3); -} -| binary TOK_EQUAL binary -{ - $$ = new BinaryNode(BinOpEq, parseDataFactory, $1, $3); -} -| binary TOK_NEQ binary -{ - $$ = new BinaryNode(BinOpNotEq, parseDataFactory, $1, $3); -} -| binary TOK_OR binary -{ - $$ = new BinaryNode(BinOpOr, parseDataFactory, $1, $3); -} -| binary TOK_AND binary -{ - $$ = new BinaryNode(BinOpAnd, parseDataFactory, $1, $3); -} -| binary TOK_MUL binary -{ - $$ = new BinaryNode(BinOpMul, parseDataFactory, $1, $3); -} -| binary TOK_DIV binary -{ - $$ = new BinaryNode(BinOpDiv, parseDataFactory, $1, $3); -} -| binary TOK_MOD binary -{ - $$ = new BinaryNode(BinOpMod, parseDataFactory, $1, $3); -} -| binary TOK_ADD binary -{ - $$ = new BinaryNode(BinOpAdd, parseDataFactory, $1, $3); -} -| binary TOK_SUB binary -{ - $$ = new BinaryNode(BinOpSub, parseDataFactory, $1, $3); -} -| unary -{ - $$ = $1; -} -; - -// ---------------------------------------------------------------------- -unary -// ---------------------------------------------------------------------- -: TOK_LPAREN expr TOK_RPAREN -{ - $$ = $2; -} -| TOK_SUB unary %prec UNARY_OP -{ - $$ = new UnaryNode(UnaryOpNeg, parseDataFactory, $2); -} -| TOK_NOT unary %prec UNARY_OP -{ - $$ = new UnaryNode(UnaryOpNot, parseDataFactory, $2); -} -| TOK_INTEGER_LITERAL -{ - IntegerTokPtr intVal = IntegerTokPtr::dynamicCast($1); - assert(intVal); - $$ = new DataNode(parseDataFactory->createInteger(intVal->v, true)); -} -| TOK_FLOATING_POINT_LITERAL -{ - FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast($1); - assert(floatVal); - $$ = new DataNode(parseDataFactory->createDouble(floatVal->v, true)); -} -| TOK_STRING_LITERAL -{ - StringTokPtr stringVal = StringTokPtr::dynamicCast($1); - assert(stringVal); - $$ = new DataNode(parseDataFactory->createString(stringVal->v, true)); -} -| TOK_TRUE -{ - $$ = new DataNode(parseDataFactory->createBoolean(true, true)); -} -| TOK_FALSE -{ - $$ = new DataNode(parseDataFactory->createBoolean(false, true)); -} -| TOK_NIL -{ - $$ = new DataNode(parseDataFactory->createNil(true)); -} -| entity -{ - $$ = $1; -} -| entity '.' function -{ - EntityNodePtr entity = EntityNodePtr::dynamicCast($1); - assert(entity); - FunctionNodePtr func = FunctionNodePtr::dynamicCast($3); - assert(func); - func->setTarget(entity); - $$ = $3; -} -| function -{ - $$ = $1; -} -| constant -{ - StringTokPtr stringVal = StringTokPtr::dynamicCast($1); - assert(stringVal); - $$ = new ConstantNode(stringVal->v); -} -; - -// ---------------------------------------------------------------------- -entity -// ---------------------------------------------------------------------- -: entity TOK_LBRACKET expr TOK_RBRACKET -{ - EntityNodePtr entity = EntityNodePtr::dynamicCast($1); - assert(entity); - entity->append(new ElementNode($3)); - $$ = $1; -} -| entity '.' TOK_IDENTIFIER -{ - StringTokPtr stringVal = StringTokPtr::dynamicCast($3); - assert(stringVal); - EntityNodePtr entity = EntityNodePtr::dynamicCast($1); - assert(entity); - entity->append(new IdentNode(stringVal->v)); - $$ = $1; -} -| TOK_IDENTIFIER -{ - StringTokPtr stringVal = StringTokPtr::dynamicCast($1); - assert(stringVal); - $$ = new IdentNode(stringVal->v); -} -; - -// ---------------------------------------------------------------------- -function -// ---------------------------------------------------------------------- -: TOK_IDENTIFIER TOK_LPAREN arg_list TOK_RPAREN -{ - StringTokPtr func = StringTokPtr::dynamicCast($1); - assert(func); - NodeListTokPtr args = NodeListTokPtr::dynamicCast($3); - assert(args); - $$ = new FunctionNode(func->v, args->v); -} -; - -// ---------------------------------------------------------------------- -arg_list -// ---------------------------------------------------------------------- -: arg_list ',' expr -{ - NodeListTokPtr l = NodeListTokPtr::dynamicCast($1); - assert(l); - l->v.push_back($3); - $$ = $1; -} -| expr -{ - NodeListTokPtr result = new NodeListTok; - result->v.push_back($1); - $$ = result; -} -| -{ - $$ = new NodeListTok; -} -; - -// ---------------------------------------------------------------------- -constant -// ---------------------------------------------------------------------- -: constant TOK_SCOPE_DELIMITER TOK_IDENTIFIER -{ - StringTokPtr stringVal = StringTokPtr::dynamicCast($1); - assert(stringVal); - StringTokPtr idVal = StringTokPtr::dynamicCast($3); - assert(idVal); - stringVal->v.append("::" + idVal->v); - $$ = $1; -} -| TOK_SCOPE_DELIMITER TOK_IDENTIFIER -{ - StringTokPtr idVal = StringTokPtr::dynamicCast($2); - assert(idVal); - StringTokPtr stringVal = new StringTok; - stringVal->v.append("::" + idVal->v); - $$ = stringVal; -} -; - -%% diff --git a/cpp/src/FreezeScript/GrammarUtil.h b/cpp/src/FreezeScript/GrammarUtil.h deleted file mode 100644 index 5605bc34c70..00000000000 --- a/cpp/src/FreezeScript/GrammarUtil.h +++ /dev/null @@ -1,136 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_GRAMMAR_UTIL_H -#define FREEZE_SCRIPT_GRAMMAR_UTIL_H - -#include <FreezeScript/Parser.h> - -namespace FreezeScript -{ - -extern DataFactoryPtr parseDataFactory; -extern ErrorReporterPtr parseErrorReporter; -extern NodePtr parseResult; -extern int parseLine; - -int getInput(char*, int); - -class StringTok; -class IdentifierTok; -class BoolTok; -class IntegerTok; -class FloatingTok; -class NodeListTok; - -typedef ::IceUtil::Handle<StringTok> StringTokPtr; -typedef ::IceUtil::Handle<IdentifierTok> IdentifierTokPtr; -typedef ::IceUtil::Handle<BoolTok> BoolTokPtr; -typedef ::IceUtil::Handle<IntegerTok> IntegerTokPtr; -typedef ::IceUtil::Handle<FloatingTok> FloatingTokPtr; -typedef ::IceUtil::Handle<NodeListTok> NodeListTokPtr; - -// ---------------------------------------------------------------------- -// Token -// ---------------------------------------------------------------------- - -class Token : public Node -{ -public: - - Token() { } - virtual DataPtr evaluate(const SymbolTablePtr&) { return 0; } - virtual void print(std::ostream&) const {} -}; - -// ---------------------------------------------------------------------- -// StringTok -// ---------------------------------------------------------------------- - -class StringTok : public Token -{ -public: - - StringTok() { } - - std::string v; -}; - -// ---------------------------------------------------------------------- -// BoolTok -// ---------------------------------------------------------------------- - -class BoolTok : public Token -{ -public: - - BoolTok() { } - bool v; -}; - -// ---------------------------------------------------------------------- -// IntegerTok -// ---------------------------------------------------------------------- - -class IntegerTok : public Token -{ -public: - - IntegerTok() { } - IceUtil::Int64 v; -}; - -// ---------------------------------------------------------------------- -// FloatingTok -// ---------------------------------------------------------------------- - -class FloatingTok : public Token -{ -public: - - FloatingTok() { } - double v; -}; - -class NodeListTok : public Token -{ -public: - - NodeListTok() { } - NodeList v; -}; - -} // End of namespace FreezeScript - -// -// Stuff for flex and bison -// - -#define YYSTYPE FreezeScript::NodePtr -#define YY_DECL int freeze_script_lex(YYSTYPE* yylvalp) -YY_DECL; -int freeze_script_parse(); - -// -// I must set the initial stack depth to the maximum stack depth to -// disable bison stack resizing. The bison stack resizing routines use -// simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, -// assignment operator, etc. -// -#define YYMAXDEPTH 10000 -#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. - -// -// Newer bison versions allow to disable stack resizing by defining -// yyoverflow. -// -#define yyoverflow(a, b, c, d, e, f) freeze_script_error(a) - -#endif diff --git a/cpp/src/FreezeScript/Makefile b/cpp/src/FreezeScript/Makefile deleted file mode 100644 index cd25fd9f481..00000000000 --- a/cpp/src/FreezeScript/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -top_srcdir = ../.. - -TRANSFORMDB = $(bindir)/transformdb -DUMPDB = $(bindir)/dumpdb - -TARGETS = $(TRANSFORMDB) $(DUMPDB) - -COMMON_OBJS = AssignVisitor.o \ - Data.o \ - Error.o \ - Exception.o \ - Functions.o \ - Parser.o \ - Print.o \ - Scanner.o \ - Util.o \ - Grammar.o - -TRANSFORM_OBJS = TransformAnalyzer.o \ - TransformVisitor.o \ - Transformer.o \ - transformdb.o - -DUMP_OBJS = DumpDescriptors.o \ - DumpDB.o - -OBJS = $(COMMON_OBJS) $(TRANSFORM_OBJS) $(DUMP_OBJS) - -HDIR = $(headerdir)/FreezeScript - -RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) - -include $(top_srcdir)/config/Make.rules - -CPPFLAGS := -I.. $(CPPFLAGS) $(DB_FLAGS) -BISONFLAGS := --name-prefix "freeze_script_" $(BISONFLAGS) - -$(TRANSFORMDB): $(TRANSFORM_OBJS) $(COMMON_OBJS) - rm -f $@ - $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(TRANSFORM_OBJS) $(COMMON_OBJS) -lSlice $(EXPAT_RPATH_LINK) -lIceXML $(DB_RPATH_LINK) -lFreeze $(LIBS) $(DB_LIBS) - -$(DUMPDB): $(DUMP_OBJS) $(COMMON_OBJS) - rm -f $@ - $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(DUMP_OBJS) $(COMMON_OBJS) -lSlice $(EXPAT_RPATH_LINK) -lIceXML $(DB_RPATH_LINK) -lFreeze $(LIBS) $(DB_LIBS) - -install:: all - $(call installprogram,$(TRANSFORMDB),$(DESTDIR)$(install_bindir)) - $(call installdata,$(top_srcdir)/../man/man1/transformdb.1,$(DESTDIR)$(install_mandir)) - $(call installprogram,$(DUMPDB),$(DESTDIR)$(install_bindir)) - $(call installdata,$(top_srcdir)/../man/man1/dumpdb.1,$(DESTDIR)$(install_mandir)) diff --git a/cpp/src/FreezeScript/Makefile.mak b/cpp/src/FreezeScript/Makefile.mak deleted file mode 100644 index 6743beb4dc4..00000000000 --- a/cpp/src/FreezeScript/Makefile.mak +++ /dev/null @@ -1,90 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -top_srcdir = ..\.. - -TRANSFORMDB = $(top_srcdir)\bin\transformdb.exe -DUMPDB = $(top_srcdir)\bin\dumpdb.exe - -TARGETS = $(TRANSFORMDB) $(DUMPDB) - -BISON_FLEX_OBJS = .\Grammar.obj \ - .\Scanner.obj - -COMMON_OBJS = .\AssignVisitor.obj \ - .\Data.obj \ - .\Error.obj \ - .\Functions.obj \ - .\Exception.obj \ - .\Parser.obj \ - .\Print.obj \ - .\Util.obj \ - $(BISON_FLEX_OBJS) - -TRANSFORM_OBJS = .\TransformAnalyzer.obj \ - .\TransformVisitor.obj \ - .\Transformer.obj \ - .\transformdb.obj - -DUMP_OBJS = .\DumpDescriptors.obj \ - .\DumpDB.obj - -OBJS = $(COMMON_OBJS) $(TRANSFORM_OBJS) $(DUMP_OBJS) - -HDIR = $(headerdir)\FreezeScript - -!include $(top_srcdir)/config/Make.rules.mak - -$(OBJS) : $(DB_NUPKG) - -CPPFLAGS = -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN $(DB_CPPFLAGS) -BISONFLAGS = --name-prefix "freeze_script_" $(BISONFLAGS) - -LINKWITH = $(LIBS) $(DB_LIBS) - -!if "$(GENERATE_PDB)" == "yes" -TPDBFLAGS = /pdb:$(TRANSFORMDB:.exe=.pdb) -DPDBFLAGS = /pdb:$(DUMPDB:.exe=.pdb) -!endif - -TRES_FILE = TransformDB.res -DRES_FILE = DumpDB.res - -$(TRANSFORMDB): $(TRANSFORM_OBJS) $(COMMON_OBJS) TransformDB.res - $(LINK) $(LD_EXEFLAGS) $(DB_LDFLAGS) $(TPDBFLAGS) $(TRANSFORM_OBJS) $(COMMON_OBJS) $(SETARGV) $(PREOUT)$@ \ - $(PRELIBS)$(LINKWITH) $(TRES_FILE) - @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ - $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest - @if defined SIGN_CERTIFICATE echo ^ ^ ^ Signing $@ && \ - signtool sign /f "$(SIGN_CERTIFICATE)" /p $(SIGN_PASSWORD) /t $(SIGN_TIMESTAMPSERVER) $@ - -$(DUMPDB): $(DUMP_OBJS) $(COMMON_OBJS) DumpDB.res - $(LINK) $(LD_EXEFLAGS) $(DB_LDFLAGS) $(DPDBFLAGS) $(DUMP_OBJS) $(COMMON_OBJS) $(SETARGV) $(PREOUT)$@ \ - $(PRELIBS)$(LINKWITH) $(DRES_FILE) - @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ - $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest - @if defined SIGN_CERTIFICATE echo ^ ^ ^ Signing $@ && \ - signtool sign /f "$(SIGN_CERTIFICATE)" /p $(SIGN_PASSWORD) /t $(SIGN_TIMESTAMPSERVER) $@ - -clean:: - -del /q $(TRANSFORMDB:.exe=.*) - -del /q $(DUMPDB:.exe=.*) - -del /q TransformDB.res DumpDB.res - -install:: all - copy $(TRANSFORMDB) "$(install_bindir)" - copy $(DUMPDB) "$(install_bindir)" - -!if "$(GENERATE_PDB)" == "yes" - -install:: all - copy $(TRANSFORMDB:.exe=.pdb) "$(install_bindir)" - copy $(DUMPDB:.exe=.pdb) "$(install_bindir)" - -!endif diff --git a/cpp/src/FreezeScript/Parser.cpp b/cpp/src/FreezeScript/Parser.cpp deleted file mode 100644 index f5fbe129ae3..00000000000 --- a/cpp/src/FreezeScript/Parser.cpp +++ /dev/null @@ -1,728 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Parser.h> -#include <FreezeScript/GrammarUtil.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> - -using namespace std; - -namespace FreezeScript -{ - -class EntityNodePrinter : public EntityNodeVisitor -{ -public: - - EntityNodePrinter(ostream& os) : - _os(os), _first(true) - { - } - - virtual void - visitIdentifier(const std::string& name) - { - if(_first) - { - _first = false; - } - else - { - _os << '.'; - } - _os << name; - } - - virtual void - visitElement(const NodePtr& value) - { - assert(!_first); - _os << '['; - value->print(_os); - _os << ']'; - } - -private: - - ostream& _os; - bool _first; -}; - -} // End of namespace FreezeScript - -// -// Globals required by the Bison grammar. -// -FreezeScript::DataFactoryPtr FreezeScript::parseDataFactory; -FreezeScript::ErrorReporterPtr FreezeScript::parseErrorReporter; -FreezeScript::NodePtr FreezeScript::parseResult; -int FreezeScript::parseLine; - -namespace -{ - -string _input; -string::size_type _pos; - -IceUtil::Mutex* _parserMutex = 0; - -class Init -{ -public: - - Init() - { - _parserMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete _parserMutex; - _parserMutex = 0; - } -}; - -Init init; - -} - -// -// parseExpression -// -FreezeScript::NodePtr -FreezeScript::parseExpression(const string& expr, const DataFactoryPtr& factory, const ErrorReporterPtr& errorReporter) -{ - // - // The bison grammar is not thread-safe. - // - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_parserMutex); - - parseDataFactory = factory; - parseErrorReporter = errorReporter; - parseLine = 1; - - parseErrorReporter->setExpression(expr); - - _input = expr; - _pos = 0; - - int status = freeze_script_parse(); - if(status != 0) - { - parseResult = 0; - } - - parseErrorReporter->clearExpression(); - parseErrorReporter = 0; - - return parseResult; -} - -// -// getInput supplies characters to the lexical scanner. -// -int -FreezeScript::getInput(char* buf, int /*maxSize*/) -{ - if(_pos < _input.length()) - { - buf[0] = _input[_pos]; - _pos++; - return 1; - } - else - { - return 0; - } -} - -// -// EvaluateException -// -FreezeScript::EvaluateException::EvaluateException(const char* file, int line, const string& reason) : - IceUtil::Exception(file, line), _reason(reason) -{ -} - -FreezeScript::EvaluateException::~EvaluateException() throw() -{ -} - -const char* FreezeScript::EvaluateException::_name = "FreezeScript::EvaluateException"; - -string -FreezeScript::EvaluateException::ice_name() const -{ - return _name; -} - -void -FreezeScript::EvaluateException::ice_print(ostream& out) const -{ - Ice::Exception::ice_print(out); - out << ":\nerror occurred while evaluating expression"; - if(!_reason.empty()) - { - out << ":\n" << _reason; - } -} - -FreezeScript::EvaluateException* -FreezeScript::EvaluateException::ice_clone() const -{ - return new EvaluateException(ice_file(), ice_line(), _reason); -} - -void -FreezeScript::EvaluateException::ice_throw() const -{ - throw *this; -} - -string -FreezeScript::EvaluateException::reason() const -{ - return _reason; -} - -// -// SymbolTable -// -FreezeScript::SymbolTable::~SymbolTable() -{ -} - -// -// Node -// -FreezeScript::Node::~Node() -{ -} - -// -// BinaryNode -// -FreezeScript::BinaryNode::BinaryNode(BinaryOperator op, const DataFactoryPtr& factory, const NodePtr& left, - const NodePtr& right) : - _op(op), _factory(factory), _left(left), _right(right) -{ -} - -FreezeScript::DataPtr -FreezeScript::BinaryNode::evaluate(const SymbolTablePtr& st) -{ - DataPtr result; - - switch(_op) - { - case BinOpOr: - { - DataPtr leftValue = _left->evaluate(st); - if(leftValue->booleanValue()) - { - result = leftValue; - } - else - { - result = _right->evaluate(st); - } - break; - } - - case BinOpAnd: - { - DataPtr leftValue = _left->evaluate(st); - if(!leftValue->booleanValue()) - { - result = leftValue; - } - else - { - result = _right->evaluate(st); - } - break; - } - - case BinOpMul: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue); - IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue); - if(ileft && iright) - { - result = _factory->createInteger(leftValue->integerValue() * rightValue->integerValue(), true); - } - else - { - result = _factory->createDouble(leftValue->doubleValue(true) * rightValue->doubleValue(true), true); - } - break; - } - - case BinOpDiv: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue); - IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue); - if(ileft && iright) - { - result = _factory->createInteger(leftValue->integerValue() / rightValue->integerValue(), true); - } - else - { - result = _factory->createDouble(leftValue->doubleValue(true) / rightValue->doubleValue(true), true); - } - break; - } - - case BinOpMod: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - result = _factory->createInteger(leftValue->integerValue() % rightValue->integerValue(), true); - break; - } - - case BinOpAdd: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - StringDataPtr sleft = StringDataPtr::dynamicCast(leftValue); - StringDataPtr sright = StringDataPtr::dynamicCast(rightValue); - IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue); - IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue); - if(sleft || sright) - { - if(sleft && sright) - { - result = _factory->createString(leftValue->stringValue() + rightValue->stringValue(), true); - } - else - { - _factory->getErrorReporter()->error("string concatenation requires two string arguments"); - } - } - else if(ileft && iright) - { - result = _factory->createInteger(leftValue->integerValue() + rightValue->integerValue(), true); - } - else - { - result = _factory->createDouble(leftValue->doubleValue(true) + rightValue->doubleValue(true), true); - } - break; - } - - case BinOpSub: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue); - IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue); - if(ileft && iright) - { - result = _factory->createInteger(leftValue->integerValue() - rightValue->integerValue(), true); - } - else - { - result = _factory->createDouble(leftValue->doubleValue(true) - rightValue->doubleValue(true), true); - } - break; - } - - case BinOpLess: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = leftValue < rightValue; - result = _factory->createBoolean(b, true); - break; - } - - case BinOpGreater: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = (leftValue < rightValue) || (leftValue == rightValue); - result = _factory->createBoolean(!b, true); - break; - } - - case BinOpLessEq: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = (leftValue < rightValue) || (leftValue == rightValue); - result = _factory->createBoolean(b, true); - break; - } - - case BinOpGrEq: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = leftValue < rightValue; - result = _factory->createBoolean(!b, true); - break; - } - - case BinOpEq: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = leftValue == rightValue; - result = _factory->createBoolean(b, true); - break; - } - - case BinOpNotEq: - { - DataPtr leftValue = _left->evaluate(st); - DataPtr rightValue = _right->evaluate(st); - bool b = leftValue == rightValue; - result = _factory->createBoolean(!b, true); - break; - } - } - - if(!result) - { - throw EvaluateException(__FILE__, __LINE__, "invalid operands to operator " + opToString(_op)); - } - - return result; -} - -void -FreezeScript::BinaryNode::print(ostream& os) const -{ - os << opToString(_op) << ": left="; - _left->print(os); - os << ", right="; - _right->print(os); -} - -string -FreezeScript::BinaryNode::opToString(BinaryOperator op) -{ - switch(op) - { - case BinOpOr: - return "OR"; - - case BinOpAnd: - return "AND"; - - case BinOpMul: - return "*"; - - case BinOpDiv: - return "/"; - - case BinOpMod: - return "%"; - - case BinOpAdd: - return "+"; - - case BinOpSub: - return "-"; - - case BinOpLess: - return "<"; - - case BinOpGreater: - return ">"; - - case BinOpLessEq: - return "<="; - - case BinOpGrEq: - return ">="; - - case BinOpEq: - return "=="; - - case BinOpNotEq: - return "!="; - } - - assert(false); - return string(); -} - -// -// UnaryNode -// -FreezeScript::UnaryNode::UnaryNode(UnaryOperator op, const DataFactoryPtr& factory, const NodePtr& right) : - _op(op), _factory(factory), _right(right) -{ -} - -FreezeScript::DataPtr -FreezeScript::UnaryNode::evaluate(const SymbolTablePtr& st) -{ - DataPtr result; - - switch(_op) - { - case UnaryOpNeg: - { - DataPtr rightValue = _right->evaluate(st); - IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue); - if(iright) - { - result = _factory->createInteger(-rightValue->integerValue(), true); - } - else - { - result = _factory->createDouble(-rightValue->doubleValue(), true); - } - break; - } - - case UnaryOpNot: - { - DataPtr rightValue = _right->evaluate(st); - result = _factory->createBoolean(!rightValue->booleanValue(), true); - break; - } - } - - if(!result) - { - throw EvaluateException(__FILE__, __LINE__, "invalid operand to operator " + opToString(_op)); - } - - return result; -} - -void -FreezeScript::UnaryNode::print(ostream& os) const -{ - os << opToString(_op) << ": right="; - _right->print(os); -} - -string -FreezeScript::UnaryNode::opToString(UnaryOperator op) -{ - switch(op) - { - case UnaryOpNeg: - return "-"; - - case UnaryOpNot: - return "!"; - } - - assert(false); - return string(); -} - -// -// DataNode -// -FreezeScript::DataNode::DataNode(const DataPtr& data) : - _data(data) -{ -} - -FreezeScript::DataPtr -FreezeScript::DataNode::evaluate(const SymbolTablePtr&) -{ - return _data; -} - -void -FreezeScript::DataNode::print(ostream& /*os*/) const -{ - // TODO - //_data->print(os); -} - -// -// EntityNodeVisitor -// -FreezeScript::EntityNodeVisitor::~EntityNodeVisitor() -{ -} - -// -// EntityNode -// -FreezeScript::DataPtr -FreezeScript::EntityNode::evaluate(const SymbolTablePtr& st) -{ - DataPtr result = st->getValue(this); - if(!result) - { - ostringstream ostr; - print(ostr); - throw EvaluateException(__FILE__, __LINE__, "unknown entity `" + ostr.str() + "'"); - } - return result; -} - -void -FreezeScript::EntityNode::print(ostream& os) const -{ - EntityNodePrinter printer(os); - visit(printer); -} - -void -FreezeScript::EntityNode::append(const EntityNodePtr& next) -{ - if(_next) - { - _next->append(next); - } - else - { - _next = next; - } -} - -// -// IdentNode -// -FreezeScript::IdentNode::IdentNode(const string& value) : - _value(value) -{ -} - -string -FreezeScript::IdentNode::getValue() const -{ - return _value; -} - -void -FreezeScript::IdentNode::visit(EntityNodeVisitor& visitor) const -{ - visitor.visitIdentifier(_value); - if(_next) - { - _next->visit(visitor); - } -} - -// -// ElementNode -// -FreezeScript::ElementNode::ElementNode(const NodePtr& value) : - _value(value) -{ -} - -FreezeScript::NodePtr -FreezeScript::ElementNode::getValue() const -{ - return _value; -} - -void -FreezeScript::ElementNode::visit(EntityNodeVisitor& visitor) const -{ - visitor.visitElement(_value); - if(_next) - { - _next->visit(visitor); - } -} - -// -// FunctionNode -// -FreezeScript::FunctionNode::FunctionNode(const string& name, const NodeList& args) : - _name(name), _args(args) -{ -} - -FreezeScript::DataPtr -FreezeScript::FunctionNode::evaluate(const SymbolTablePtr& st) -{ - DataPtr target; - if(_target) - { - target = _target->evaluate(st); - } - DataList args; - for(NodeList::iterator p = _args.begin(); p != _args.end(); ++p) - { - args.push_back((*p)->evaluate(st)); - } - return st->invokeFunction(_name, target, args); -} - -void -FreezeScript::FunctionNode::print(ostream& os) const -{ - if(_target) - { - _target->print(os); - os << '.'; - } - os << _name << '('; - for(NodeList::const_iterator p = _args.begin(); p != _args.end(); ++p) - { - if(p != _args.begin()) - { - os << ", "; - } - (*p)->print(os); - } - os << ')'; -} - -void -FreezeScript::FunctionNode::setTarget(const EntityNodePtr& target) -{ - _target = target; -} - -// -// ConstantNode -// -FreezeScript::ConstantNode::ConstantNode(const string& value) : - _value(value) -{ -} - -FreezeScript::DataPtr -FreezeScript::ConstantNode::evaluate(const SymbolTablePtr& st) -{ - DataPtr result = st->getConstantValue(_value); - if(!result) - { - throw EvaluateException(__FILE__, __LINE__, "unknown constant `" + _value + "'"); - } - return result; -} - -void -FreezeScript::ConstantNode::print(ostream& os) const -{ - os << _value; -} - -// -// Stream insertion for an entity node. -// -ostream& -operator<<(ostream& os, const FreezeScript::EntityNodePtr& entity) -{ - FreezeScript::EntityNodePrinter printer(os); - entity->visit(printer); - return os; -} diff --git a/cpp/src/FreezeScript/Parser.h b/cpp/src/FreezeScript/Parser.h deleted file mode 100644 index 213d615022f..00000000000 --- a/cpp/src/FreezeScript/Parser.h +++ /dev/null @@ -1,251 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_PARSER_H -#define FREEZE_SCRIPT_PARSER_H - -#include <FreezeScript/Data.h> - -namespace FreezeScript -{ - -class SymbolTable; -typedef IceUtil::Handle<SymbolTable> SymbolTablePtr; - -class Node; -typedef IceUtil::Handle<Node> NodePtr; - -typedef std::vector<NodePtr> NodeList; - -class EntityNode; -typedef IceUtil::Handle<EntityNode> EntityNodePtr; - -// -// parseExpression parses the given expression and returns the root node of the parse tree. -// -NodePtr parseExpression(const std::string&, const DataFactoryPtr&, const ErrorReporterPtr&); - -// -// EvaluateException is raised by Node::evaluate(). -// -class EvaluateException : public IceUtil::Exception -{ -public: - - EvaluateException(const char*, int, const std::string&); - virtual ~EvaluateException() throw(); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual EvaluateException* ice_clone() const; - virtual void ice_throw() const; - - std::string reason() const; - -private: - - std::string _reason; - static const char* _name; -}; - -// -// SymbolTable is an interface for the lookup operations required by node evaluation. -// -class SymbolTable : public IceUtil::SimpleShared -{ -public: - - virtual ~SymbolTable(); - - virtual void add(const std::string&, const DataPtr&) = 0; - - virtual DataPtr getValue(const EntityNodePtr&) const = 0; - - virtual DataPtr getConstantValue(const std::string&) const = 0; - - virtual SymbolTablePtr createChild() = 0; - - virtual Slice::TypePtr lookupType(const std::string&) = 0; - - virtual DataPtr invokeFunction(const std::string&, const DataPtr&, const DataList&) = 0; -}; - -class Node : public IceUtil::SimpleShared -{ -public: - - virtual ~Node(); - - virtual DataPtr evaluate(const SymbolTablePtr&) = 0; - - virtual void print(std::ostream&) const = 0; -}; - -enum BinaryOperator -{ - BinOpOr, BinOpAnd, - BinOpMul, BinOpDiv, BinOpMod, - BinOpAdd, BinOpSub, - BinOpLess, BinOpGreater, BinOpLessEq, BinOpGrEq, BinOpEq, BinOpNotEq -}; - -class BinaryNode : public Node -{ -public: - - BinaryNode(BinaryOperator, const DataFactoryPtr&, const NodePtr&, const NodePtr&); - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - -private: - - static std::string opToString(BinaryOperator); - - BinaryOperator _op; - DataFactoryPtr _factory; - NodePtr _left; - NodePtr _right; -}; - -enum UnaryOperator { UnaryOpNeg, UnaryOpNot }; - -class UnaryNode : public Node -{ -public: - - UnaryNode(UnaryOperator, const DataFactoryPtr&, const NodePtr&); - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - -private: - - static std::string opToString(UnaryOperator); - - UnaryOperator _op; - DataFactoryPtr _factory; - NodePtr _right; -}; - -class DataNode : public Node -{ -public: - - DataNode(const DataPtr&); - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - -private: - - DataPtr _data; -}; - -class EntityNodeVisitor -{ -public: - - virtual ~EntityNodeVisitor(); - - virtual void visitIdentifier(const std::string&) = 0; - virtual void visitElement(const NodePtr&) = 0; -}; - -class EntityNode : public Node -{ -public: - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - - virtual void visit(EntityNodeVisitor&) const = 0; - - void append(const EntityNodePtr&); - -protected: - - EntityNodePtr _next; -}; - -class IdentNode : public EntityNode -{ -public: - - IdentNode(const std::string&); - - virtual void visit(EntityNodeVisitor&) const; - - std::string getValue() const; - -private: - - std::string _value; -}; -typedef IceUtil::Handle<IdentNode> IdentNodePtr; - -class ElementNode : public EntityNode -{ -public: - - ElementNode(const NodePtr&); - - virtual void visit(EntityNodeVisitor&) const; - - NodePtr getValue() const; - -private: - - NodePtr _value; -}; -typedef IceUtil::Handle<ElementNode> ElementNodePtr; - -class FunctionNode : public Node -{ -public: - - FunctionNode(const std::string&, const NodeList&); - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - - void setTarget(const EntityNodePtr&); - -private: - - std::string _name; - NodeList _args; - EntityNodePtr _target; -}; -typedef IceUtil::Handle<FunctionNode> FunctionNodePtr; - -class ConstantNode : public Node -{ -public: - - ConstantNode(const std::string&); - - virtual DataPtr evaluate(const SymbolTablePtr&); - - virtual void print(std::ostream&) const; - -private: - - std::string _value; -}; - -} // End of namespace FreezeScript - -std::ostream& operator<<(std::ostream&, const FreezeScript::EntityNodePtr&); - -#endif diff --git a/cpp/src/FreezeScript/Print.cpp b/cpp/src/FreezeScript/Print.cpp deleted file mode 100644 index 7709301e12f..00000000000 --- a/cpp/src/FreezeScript/Print.cpp +++ /dev/null @@ -1,233 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Print.h> -#include <FreezeScript/Util.h> -#include <IceUtil/OutputUtil.h> - -using namespace std; -using namespace IceUtil; -using namespace IceUtilInternal; - -namespace FreezeScript -{ - -class PrintVisitor : public DataVisitor -{ -public: - - PrintVisitor(ostream&); - ~PrintVisitor(); - - virtual void visitBoolean(const BooleanDataPtr&); - virtual void visitInteger(const IntegerDataPtr&); - virtual void visitDouble(const DoubleDataPtr&); - virtual void visitString(const StringDataPtr&); - virtual void visitProxy(const ProxyDataPtr&); - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitEnum(const EnumDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); - -private: - - void printObjectMembers(const Slice::ClassDefPtr&, const DataMemberMap&); - - IceUtilInternal::Output _out; - typedef map<const ObjectData*, int> ObjectHistoryMap; - ObjectHistoryMap _objectHistory; - int _objectCount; -}; - -} // End of namespace FreezeScript - -// -// printData -// -void -FreezeScript::printData(const DataPtr& data, ostream& os) -{ - PrintVisitor visitor(os); - data->visit(visitor); -} - -// -// PrintVisitor -// -FreezeScript::PrintVisitor::PrintVisitor(ostream& os) : - _out(os), _objectCount(0) -{ -} - -FreezeScript::PrintVisitor::~PrintVisitor() -{ -} - -void -FreezeScript::PrintVisitor::visitBoolean(const BooleanDataPtr& data) -{ - _out << "bool(" << data->toString() << ")"; -} - -void -FreezeScript::PrintVisitor::visitInteger(const IntegerDataPtr& data) -{ - _out << typeToString(data->getType()) << "(" << data->toString() << ")"; -} - -void -FreezeScript::PrintVisitor::visitDouble(const DoubleDataPtr& data) -{ - _out << typeToString(data->getType()) << "(" << data->toString() << ")"; -} - -void -FreezeScript::PrintVisitor::visitString(const StringDataPtr& data) -{ - _out << "'" << data->toString() << "'"; -} - -void -FreezeScript::PrintVisitor::visitProxy(const ProxyDataPtr& data) -{ - string str = data->toString(); - _out << typeToString(data->getType()) << '(' << (str.empty() ? string("nil") : str) << ')'; -} - -void -FreezeScript::PrintVisitor::visitStruct(const StructDataPtr& data) -{ - Slice::StructPtr type = Slice::StructPtr::dynamicCast(data->getType()); - assert(type); - _out << "struct " << typeToString(type); - _out << sb; - // - // Print members in order of declaration. - // - Slice::DataMemberList l = type->dataMembers(); - DataMemberMap members = data->getMembers(); - for(Slice::DataMemberList::const_iterator p = l.begin(); p != l.end(); ++p) - { - DataMemberMap::const_iterator q = members.find((*p)->name()); - assert(q != members.end()); - _out << nl; - _out << q->first << " = "; - q->second->visit(*this); - } - _out << eb; -} - -void -FreezeScript::PrintVisitor::visitSequence(const SequenceDataPtr& data) -{ - DataList& elements = data->getElements(); - _out << "sequence " << typeToString(data->getType()) << " (size = " << elements.size() << ")"; - _out << sb; - Ice::Int i = 0; - for(DataList::const_iterator p = elements.begin(); p != elements.end(); ++p, ++i) - { - _out << nl << "[" << i << "] = "; - (*p)->visit(*this); - } - _out << eb; -} - -void -FreezeScript::PrintVisitor::visitEnum(const EnumDataPtr& data) -{ - _out << typeToString(data->getType()) << "(" << data->toString() << ")"; -} - -void -FreezeScript::PrintVisitor::visitDictionary(const DictionaryDataPtr& data) -{ - DataMap& map = data->getElements(); - _out << "dictionary " << typeToString(data->getType()) << " (size = " << map.size() << ")"; - _out << sb; - for(DataMap::const_iterator p = map.begin(); p != map.end(); ++p) - { - _out << nl; - p->first->visit(*this); - _out << " => "; - p->second->visit(*this); - } - _out << eb; -} - -void -FreezeScript::PrintVisitor::visitObject(const ObjectRefPtr& data) -{ - ObjectDataPtr value = data->getValue(); - if(!value) - { - _out << typeToString(data->getType()) << "(nil)"; - } - else - { - Slice::TypePtr type = value->getType(); - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(type); // May be nil for Ice::Object - - _out << "class " << typeToString(type); - ObjectHistoryMap::iterator p = _objectHistory.find(value.get()); - if(p != _objectHistory.end()) - { - ostringstream ostr; - ostr << " (object #" << p->second << ")"; - _out << ostr.str(); - } - else - { - _objectHistory.insert(ObjectHistoryMap::value_type(value.get(), _objectCount)); - ostringstream ostr; - ostr << " (object #" << _objectCount << ")"; - _out << ostr.str(); - _objectCount++; - _out << sb; - - DataMemberMap members = value->getMembers(); - - // - // If Ice::Object had any members, this is where we would print them. - // - - if(decl) - { - Slice::ClassDefPtr def = decl->definition(); - assert(def); - printObjectMembers(def, members); - } - - _out << eb; - } - } -} - -void -FreezeScript::PrintVisitor::printObjectMembers(const Slice::ClassDefPtr& type, const DataMemberMap& members) -{ - Slice::ClassList bases = type->bases(); - if(!bases.empty() && !bases.front()->isAbstract()) - { - printObjectMembers(bases.front(), members); - } - - // - // Print members in order of declaration. - // - Slice::DataMemberList l = type->dataMembers(); - for(Slice::DataMemberList::const_iterator p = l.begin(); p != l.end(); ++p) - { - DataMemberMap::const_iterator q = members.find((*p)->name()); - assert(q != members.end()); - _out << nl; - _out << q->first << " = "; - q->second->visit(*this); - } -} diff --git a/cpp/src/FreezeScript/Print.h b/cpp/src/FreezeScript/Print.h deleted file mode 100644 index 0ce50cadea4..00000000000 --- a/cpp/src/FreezeScript/Print.h +++ /dev/null @@ -1,22 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_PRINT_H -#define FREEZE_SCRIPT_PRINT_H - -#include <FreezeScript/Data.h> - -namespace FreezeScript -{ - -void printData(const DataPtr&, std::ostream&); - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Scanner.cpp b/cpp/src/FreezeScript/Scanner.cpp deleted file mode 100644 index 35aa5e2e5c6..00000000000 --- a/cpp/src/FreezeScript/Scanner.cpp +++ /dev/null @@ -1,2253 +0,0 @@ -#include <IceUtil/ScannerConfig.h> -#line 2 "lex.yy.c" - -#line 4 "lex.yy.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define yy_create_buffer freeze_script__create_buffer -#define yy_delete_buffer freeze_script__delete_buffer -#define yy_flex_debug freeze_script__flex_debug -#define yy_init_buffer freeze_script__init_buffer -#define yy_flush_buffer freeze_script__flush_buffer -#define yy_load_buffer_state freeze_script__load_buffer_state -#define yy_switch_to_buffer freeze_script__switch_to_buffer -#define yyin freeze_script_in -#define yyleng freeze_script_leng -#define yylex freeze_script_lex -#define yylineno freeze_script_lineno -#define yyout freeze_script_out -#define yyrestart freeze_script_restart -#define yytext freeze_script_text -#define yywrap freeze_script_wrap -#define yyalloc freeze_script_alloc -#define yyrealloc freeze_script_realloc -#define yyfree freeze_script_free - -#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 <stdio.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have <inttypes.h>. 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 <inttypes.h> -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) - -/* 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 (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 (((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 freeze_script_restart(freeze_script_in ) - -#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 - -extern int freeze_script_leng; - -extern FILE *freeze_script_in, *freeze_script_out; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up freeze_script_text. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up freeze_script_text again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#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 freeze_script_restart()), so that the user can continue scanning by - * just pointing freeze_script_in at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* 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 ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(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 (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when freeze_script_text is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int freeze_script_leng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow freeze_script_wrap()'s to do buffer switches - * instead of setting up a fresh freeze_script_in. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void freeze_script_restart (FILE *input_file ); -void freeze_script__switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE freeze_script__create_buffer (FILE *file,int size ); -void freeze_script__delete_buffer (YY_BUFFER_STATE b ); -void freeze_script__flush_buffer (YY_BUFFER_STATE b ); -void freeze_script_push_buffer_state (YY_BUFFER_STATE new_buffer ); -void freeze_script_pop_buffer_state (void ); - -static void freeze_script_ensure_buffer_stack (void ); -static void freeze_script__load_buffer_state (void ); -static void freeze_script__init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER freeze_script__flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE freeze_script__scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE freeze_script__scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE freeze_script__scan_bytes (yyconst char *bytes,int len ); - -void *freeze_script_alloc (yy_size_t ); -void *freeze_script_realloc (void *,yy_size_t ); -void freeze_script_free (void * ); - -#define yy_new_buffer freeze_script__create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - freeze_script_ensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - freeze_script__create_buffer(freeze_script_in,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - freeze_script_ensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - freeze_script__create_buffer(freeze_script_in,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define freeze_script_wrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -FILE *freeze_script_in = (FILE *) 0, *freeze_script_out = (FILE *) 0; - -typedef int yy_state_type; - -extern int freeze_script_lineno; - -int freeze_script_lineno = 1; - -extern char *freeze_script_text; -#define yytext_ptr freeze_script_text - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up freeze_script_text. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - freeze_script_leng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 -/* 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_accept[51] = - { 0, - 0, 0, 27, 25, 8, 8, 25, 4, 19, 5, - 20, 21, 17, 15, 16, 25, 18, 6, 6, 25, - 9, 25, 10, 3, 22, 23, 14, 0, 6, 6, - 7, 2, 1, 7, 6, 0, 0, 24, 11, 13, - 12, 3, 0, 7, 0, 7, 6, 0, 7, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 1, 1, 6, 1, 7, 8, - 9, 10, 11, 1, 12, 13, 14, 15, 16, 16, - 16, 16, 16, 16, 16, 17, 17, 18, 1, 19, - 20, 21, 1, 1, 22, 22, 22, 22, 23, 24, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 26, 1, 27, 1, 25, 1, 22, 22, 22, 22, - - 28, 24, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 29, - 25, 25, 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, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[30] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 1, 1, 3, 3, 3, 1, 1, 1, - 1, 4, 4, 4, 5, 1, 1, 4, 5 - } ; - -static yyconst flex_int16_t yy_base[55] = - { 0, - 0, 0, 72, 104, 104, 104, 51, 104, 104, 104, - 104, 104, 104, 17, 22, 25, 33, 35, 30, 44, - 29, 24, 16, 0, 104, 104, 104, 38, 0, 0, - 50, 104, 104, 0, 2, 45, 0, 104, 104, 104, - 104, 0, 49, 104, 53, 60, 0, 64, 70, 104, - 92, 96, 97, 100 - } ; - -static yyconst flex_int16_t yy_def[55] = - { 0, - 50, 1, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 18, 50, - 50, 50, 50, 51, 50, 50, 50, 50, 18, 19, - 50, 50, 50, 31, 18, 52, 53, 50, 50, 50, - 50, 51, 54, 50, 50, 50, 53, 50, 50, 0, - 50, 50, 50, 50 - } ; - -static yyconst flex_int16_t yy_nxt[134] = - { 0, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, - 23, 24, 24, 24, 24, 25, 26, 24, 24, 28, - 50, 29, 30, 30, 28, 41, 29, 30, 30, 31, - 31, 31, 32, 40, 30, 30, 33, 34, 39, 35, - 35, 30, 31, 31, 31, 45, 45, 36, 50, 48, - 48, 38, 36, 37, 31, 31, 31, 46, 46, 46, - 27, 50, 43, 44, 46, 46, 46, 43, 49, 49, - 49, 50, 50, 44, 49, 49, 49, 50, 50, 50, - 50, 50, 50, 44, 42, 42, 42, 46, 46, 47, - - 47, 49, 49, 3, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50 - } ; - -static yyconst flex_int16_t yy_chk[134] = - { 0, - 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, 14, - 35, 14, 14, 14, 15, 23, 15, 15, 15, 16, - 16, 16, 17, 22, 19, 19, 17, 18, 21, 18, - 18, 18, 28, 28, 28, 36, 36, 18, 19, 43, - 43, 20, 18, 18, 31, 31, 31, 45, 45, 45, - 7, 3, 31, 31, 46, 46, 46, 31, 48, 48, - 48, 0, 0, 46, 49, 49, 49, 0, 0, 0, - 0, 0, 0, 49, 51, 51, 51, 52, 52, 53, - - 53, 54, 54, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int freeze_script__flex_debug; -int freeze_script__flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *freeze_script_text; -#line 1 "Scanner.l" -#line 2 "Scanner.l" - -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/GrammarUtil.h> // Before Grammar.h, so that YYSTYPE is defined -#include <FreezeScript/Grammar.h> -#include <IceUtil/InputUtil.h> - -#include <stdlib.h> -#include <math.h> - -#include <map> - -#if defined(_MSC_VER) && defined(ICE_64) -// -// '=' : conversion from 'size_t' to 'int', possible loss of data -// The result of fread() is a size_t and gets inserted into an int -// -# pragma warning( 4 : 4267 ) -// -// 'initializing' : conversion from '__int64' to 'int', possible loss of data -// Puts a pointer-difference into an int -// -# pragma warning( 4 : 4244 ) -#endif - -#ifdef _MSC_VER -# ifdef freeze_script_wrap -# undef freeze_script_wrap -# define freeze_script_wrap() 1 -# endif -# define YY_NO_UNISTD_H -#endif - -#ifdef __SUNPRO_CC -# ifdef freeze_script_wrap -# undef freeze_script_wrap -# define freeze_script_wrap() 1 -# endif -# ifdef ICE_64 -# pragma error_messages(off,truncwarn) -# endif -#endif - -using namespace std; -using namespace FreezeScript; - -namespace FreezeScript -{ - -typedef map<string, int> KeywordMap; -static KeywordMap keywordMap; - -void initScanner(); -int checkKeyword(const string&); -StringTokPtr parseString(char); - -} - -#define YY_USER_INIT initScanner(); - -#define YY_INPUT(buf, result, max_size) { result = getInput(buf, max_size); } -#line 585 "lex.yy.c" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include <unistd.h> -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int freeze_script_lex_destroy (void ); - -int freeze_script_get_debug (void ); - -void freeze_script_set_debug (int debug_flag ); - -YY_EXTRA_TYPE freeze_script_get_extra (void ); - -void freeze_script_set_extra (YY_EXTRA_TYPE user_defined ); - -FILE *freeze_script_get_in (void ); - -void freeze_script_set_in (FILE * in_str ); - -FILE *freeze_script_get_out (void ); - -void freeze_script_set_out (FILE * out_str ); - -int freeze_script_get_leng (void ); - -char *freeze_script_get_text (void ); - -int freeze_script_get_lineno (void ); - -void freeze_script_set_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int freeze_script_wrap (void ); -#else -extern int freeze_script_wrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* 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 do { if (fwrite( freeze_script_text, freeze_script_leng, 1, freeze_script_out )) {} } while (0) -#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 = '*'; \ - unsigned n; \ - for ( n = 0; n < max_size && \ - (c = getc( freeze_script_in )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( freeze_script_in ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, freeze_script_in))==0 && ferror(freeze_script_in)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(freeze_script_in); \ - } \ - }\ -\ - -#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 ) -#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 freeze_script_lex (void); - -#define YY_DECL int freeze_script_lex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after freeze_script_text and freeze_script_leng - * 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 \ - 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; - -#line 83 "Scanner.l" - - -#line 770 "lex.yy.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! freeze_script_in ) - freeze_script_in = stdin; - - if ( ! freeze_script_out ) - freeze_script_out = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - freeze_script_ensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - freeze_script__create_buffer(freeze_script_in,YY_BUF_SIZE ); - } - - freeze_script__load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of freeze_script_text. */ - *yy_cp = (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 = (yy_start); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = 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 >= 51 ) - 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 != 50 ); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 85 "Scanner.l" -{ - // C++-style comment - int c; - do - { - c = yyinput(); - if(c == '\n') - { - parseLine++; - } - } - while(c != '\n' && c != EOF); -} - YY_BREAK -case 2: -YY_RULE_SETUP -#line 99 "Scanner.l" -{ - // C-style comment - while(true) - { - int c = yyinput(); - if(c == '\n') - { - parseLine++; - } - else if(c == '*') - { - int next = yyinput(); - if(next == '/') - { - break; - } - else - { - unput(next); - } - } - else if(c == EOF) - { - parseErrorReporter->expressionSyntaxError("EOF in comment"); - break; - } - } -} - YY_BREAK -case 3: -YY_RULE_SETUP -#line 128 "Scanner.l" -{ - StringTokPtr ident = new StringTok; - ident->v = freeze_script_text; - *yylvalp = ident; - return checkKeyword(ident->v); -} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 135 "Scanner.l" -{ - StringTokPtr str = parseString('"'); - *yylvalp = str; - return TOK_STRING_LITERAL; -} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 141 "Scanner.l" -{ - StringTokPtr str = parseString('\''); - *yylvalp = str; - return TOK_STRING_LITERAL; -} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 147 "Scanner.l" -{ - IntegerTokPtr itp = new IntegerTok; - *yylvalp = itp; - if(!IceUtilInternal::stringToInt64(string(freeze_script_text), itp->v)) - { - assert(itp->v != 0); - string msg = "integer constant `"; - msg += freeze_script_text; - msg += "' out of range"; - parseErrorReporter->expressionSyntaxError(msg); - } - return TOK_INTEGER_LITERAL; -} - YY_BREAK -case 7: -YY_RULE_SETUP -#line 161 "Scanner.l" -{ - errno = 0; - FloatingTokPtr ftp = new FloatingTok; - *yylvalp = ftp; - string literal(freeze_script_text); - char lastChar = literal[literal.size() - 1]; - if(lastChar == 'f' || lastChar == 'F') - { - literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix - } - ftp->v = strtod(literal.c_str(), 0); - if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE) - { - string msg = "floating-point constant `"; - msg += freeze_script_text; - msg += "' too large (overflow)"; - parseErrorReporter->expressionSyntaxError(msg); - } - else if(ftp->v == 0 && errno == ERANGE) - { - string msg = "floating-point constant `"; - msg += freeze_script_text; - msg += "' too small (underflow)"; - parseErrorReporter->expressionSyntaxError(msg); - } - return TOK_FLOATING_POINT_LITERAL; -} - YY_BREAK -case 8: -/* rule 8 can match eol */ -YY_RULE_SETUP -#line 189 "Scanner.l" -{ - // Igore white-space - - if(freeze_script_text[0] == '\n') - { - parseLine++; - } -} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 198 "Scanner.l" -return TOK_LESS_THAN; - YY_BREAK -case 10: -YY_RULE_SETUP -#line 199 "Scanner.l" -return TOK_GREATER_THAN; - YY_BREAK -case 11: -YY_RULE_SETUP -#line 200 "Scanner.l" -return TOK_LESS_EQUAL; - YY_BREAK -case 12: -YY_RULE_SETUP -#line 201 "Scanner.l" -return TOK_GREATER_EQUAL; - YY_BREAK -case 13: -YY_RULE_SETUP -#line 202 "Scanner.l" -return TOK_EQUAL; - YY_BREAK -case 14: -YY_RULE_SETUP -#line 203 "Scanner.l" -return TOK_NEQ; - YY_BREAK -case 15: -YY_RULE_SETUP -#line 204 "Scanner.l" -return TOK_ADD; - YY_BREAK -case 16: -YY_RULE_SETUP -#line 205 "Scanner.l" -return TOK_SUB; - YY_BREAK -case 17: -YY_RULE_SETUP -#line 206 "Scanner.l" -return TOK_MUL; - YY_BREAK -case 18: -YY_RULE_SETUP -#line 207 "Scanner.l" -return TOK_DIV; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 208 "Scanner.l" -return TOK_MOD; - YY_BREAK -case 20: -YY_RULE_SETUP -#line 209 "Scanner.l" -return TOK_LPAREN; - YY_BREAK -case 21: -YY_RULE_SETUP -#line 210 "Scanner.l" -return TOK_RPAREN; - YY_BREAK -case 22: -YY_RULE_SETUP -#line 211 "Scanner.l" -return TOK_LBRACKET; - YY_BREAK -case 23: -YY_RULE_SETUP -#line 212 "Scanner.l" -return TOK_RBRACKET; - YY_BREAK -case 24: -YY_RULE_SETUP -#line 213 "Scanner.l" -return TOK_SCOPE_DELIMITER; - YY_BREAK -case 25: -YY_RULE_SETUP -#line 215 "Scanner.l" -{ - return freeze_script_text[0]; -} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 219 "Scanner.l" -ECHO; - YY_BREAK -#line 1079 "lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (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 freeze_script_in at a new source and called - * freeze_script_lex(). 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. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = freeze_script_in; - 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 ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* 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 ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( freeze_script_wrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * freeze_script_text, 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. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (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 freeze_script_lex */ - -/* 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 (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(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 ( (yy_c_buf_p) - (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) ((yy_c_buf_p) - (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 = (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. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - freeze_script_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - 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]), - (yy_n_chars), (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - freeze_script_restart(freeze_script_in ); - } - - 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) ((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 = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) freeze_script_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (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 (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = 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 >= 51 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - 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 ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = 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 >= 51 ) - 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 == 50); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up freeze_script_text */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(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 ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - 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. */ - freeze_script_restart(freeze_script_in ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( freeze_script_wrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve freeze_script_text */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void freeze_script_restart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - freeze_script_ensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - freeze_script__create_buffer(freeze_script_in,YY_BUF_SIZE ); - } - - freeze_script__init_buffer(YY_CURRENT_BUFFER,input_file ); - freeze_script__load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void freeze_script__switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * freeze_script_pop_buffer_state(); - * freeze_script_push_buffer_state(new_buffer); - */ - freeze_script_ensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - freeze_script__load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (freeze_script_wrap()) processing, but the only time this flag - * is looked at is after freeze_script_wrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void freeze_script__load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - freeze_script_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(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. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE freeze_script__create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) freeze_script_alloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script__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 *) freeze_script_alloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script__create_buffer()" ); - - b->yy_is_our_buffer = 1; - - freeze_script__init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with freeze_script__create_buffer() - * - */ - void freeze_script__delete_buffer (YY_BUFFER_STATE b ) -{ - - 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 ) - freeze_script_free((void *) b->yy_ch_buf ); - - freeze_script_free((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a freeze_script_restart() or at EOF. - */ - static void freeze_script__init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - freeze_script__flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then freeze_script__init_buffer was _probably_ - * called from freeze_script_restart() 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. - * - */ - void freeze_script__flush_buffer (YY_BUFFER_STATE b ) -{ - 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 ) - freeze_script__load_buffer_state( ); -} - -/** 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. - * - */ -void freeze_script_push_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - freeze_script_ensure_buffer_stack(); - - /* This block is copied from freeze_script__switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from freeze_script__switch_to_buffer. */ - freeze_script__load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void freeze_script_pop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - freeze_script__delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - freeze_script__load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void freeze_script_ensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(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; - (yy_buffer_stack) = (struct yy_buffer_state**)freeze_script_alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script_ensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)freeze_script_realloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script_ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (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 - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE freeze_script__scan_buffer (char * base, yy_size_t size ) -{ - 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) freeze_script_alloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script__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; - - freeze_script__switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to freeze_script_lex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * freeze_script__scan_bytes() instead. - */ -YY_BUFFER_STATE freeze_script__scan_string (yyconst char * yystr ) -{ - - return freeze_script__scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to freeze_script_lex() 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. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE freeze_script__scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - 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 *) freeze_script_alloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in freeze_script__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 = freeze_script__scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in freeze_script__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; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (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 freeze_script_text. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - freeze_script_text[freeze_script_leng] = (yy_hold_char); \ - (yy_c_buf_p) = freeze_script_text + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - freeze_script_leng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int freeze_script_get_lineno (void) -{ - - return freeze_script_lineno; -} - -/** Get the input stream. - * - */ -FILE *freeze_script_get_in (void) -{ - return freeze_script_in; -} - -/** Get the output stream. - * - */ -FILE *freeze_script_get_out (void) -{ - return freeze_script_out; -} - -/** Get the length of the current token. - * - */ -int freeze_script_get_leng (void) -{ - return freeze_script_leng; -} - -/** Get the current token. - * - */ - -char *freeze_script_get_text (void) -{ - return freeze_script_text; -} - -/** Set the current line number. - * @param line_number - * - */ -void freeze_script_set_lineno (int line_number ) -{ - - freeze_script_lineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see freeze_script__switch_to_buffer - */ -void freeze_script_set_in (FILE * in_str ) -{ - freeze_script_in = in_str ; -} - -void freeze_script_set_out (FILE * out_str ) -{ - freeze_script_out = out_str ; -} - -int freeze_script_get_debug (void) -{ - return freeze_script__flex_debug; -} - -void freeze_script_set_debug (int bdebug ) -{ - freeze_script__flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from freeze_script_lex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - freeze_script_in = stdin; - freeze_script_out = stdout; -#else - freeze_script_in = (FILE *) 0; - freeze_script_out = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * freeze_script_lex_init() - */ - return 0; -} - -/* freeze_script_lex_destroy is for both reentrant and non-reentrant scanners. */ -int freeze_script_lex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - freeze_script__delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - freeze_script_pop_buffer_state(); - } - - /* Destroy the stack itself. */ - freeze_script_free((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * freeze_script_lex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - 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 ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *freeze_script_alloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *freeze_script_realloc (void * ptr, yy_size_t size ) -{ - /* 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 freeze_script_free (void * ptr ) -{ - free( (char *) ptr ); /* see freeze_script_realloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 219 "Scanner.l" - - - -namespace FreezeScript -{ - -void -initScanner() -{ - keywordMap["true"] = TOK_TRUE; - keywordMap["false"] = TOK_FALSE; - keywordMap["and"] = TOK_AND; - keywordMap["or"] = TOK_OR; - keywordMap["not"] = TOK_NOT; - keywordMap["nil"] = TOK_NIL; -} - -int -checkKeyword(const string& id) -{ - KeywordMap::const_iterator pos = keywordMap.find(id); - if(pos != keywordMap.end()) - { - return pos->second; - } - return TOK_IDENTIFIER; -} - -StringTokPtr -parseString(char start) -{ - StringTokPtr str = new StringTok; - while(true) - { - char c = static_cast<char>(yyinput()); - if(c == start) - { - break; - } - else if(c == EOF) - { - parseErrorReporter->expressionSyntaxError("EOF in string"); - break; - } - else if(c == '\n') - { - parseErrorReporter->expressionSyntaxError("newline in string"); - } - else if(c == '\\') - { - char next = static_cast<char>(yyinput()); - switch(next) - { - case '\\': - case '"': - case '\'': - { - str->v += next; - break; - } - - case 'n': - { - str->v += '\n'; - break; - } - - case 'r': - { - str->v += '\r'; - break; - } - - case 't': - { - str->v += '\t'; - break; - } - - case 'v': - { - str->v += '\v'; - break; - } - - case 'f': - { - str->v += '\f'; - break; - } - - case 'a': - { - str->v += '\a'; - break; - } - - case 'b': - { - str->v += '\b'; - break; - } - - case '?': - { - str->v += '\?'; - break; - } - - case '0': - case '1': - case '2': - case '3': - { - static string octalDigits = "01234567"; - unsigned short us = next - '0'; - if(octalDigits.find_first_of(next = static_cast<char>(yyinput())) != string::npos) - { - us = us * 8 + next - '0'; - if(octalDigits.find_first_of(next = static_cast<char>(yyinput())) != string::npos) - { - us = us * 8 + next - '0'; - } - else - { - unput(next); - } - } - else - { - unput(next); - } - str->v += static_cast<char>(us); - break; - } - case 'x': - { - IceUtil::Int64 ull = 0; - while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput())))) - { - ull *= 16; - if(isdigit(static_cast<unsigned char>(next))) - { - ull += next - '0'; - } - else if(islower(static_cast<unsigned char>(next))) - { - ull += next - 'a' + 10; - } - else - { - ull += next - 'A' + 10; - } - } - unput(next); - str->v += static_cast<char>(ull); - break; - } - - // TODO: add universal character names - - default: - { - str->v += c; - unput(next); - } - } - } - else - { - str->v += c; - } - } - - return str; -} - -} // End of namespace FreezeScript - diff --git a/cpp/src/FreezeScript/Scanner.l b/cpp/src/FreezeScript/Scanner.l deleted file mode 100644 index 0b1d3bac0e9..00000000000 --- a/cpp/src/FreezeScript/Scanner.l +++ /dev/null @@ -1,395 +0,0 @@ -%{ - -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/GrammarUtil.h> // Before Grammar.h, so that YYSTYPE is defined -#include <FreezeScript/Grammar.h> -#include <IceUtil/InputUtil.h> - -#include <stdlib.h> -#include <math.h> - -#include <map> - -#if defined(_MSC_VER) && defined(ICE_64) -// -// '=' : conversion from 'size_t' to 'int', possible loss of data -// The result of fread() is a size_t and gets inserted into an int -// -# pragma warning( 4 : 4267 ) -// -// 'initializing' : conversion from '__int64' to 'int', possible loss of data -// Puts a pointer-difference into an int -// -# pragma warning( 4 : 4244 ) -#endif - -#ifdef _MSC_VER -# ifdef freeze_script_wrap -# undef freeze_script_wrap -# define freeze_script_wrap() 1 -# endif -# define YY_NO_UNISTD_H -#endif - -#ifdef __SUNPRO_CC -# ifdef freeze_script_wrap -# undef freeze_script_wrap -# define freeze_script_wrap() 1 -# endif -# ifdef ICE_64 -# pragma error_messages(off,truncwarn) -# endif -#endif - -using namespace std; -using namespace FreezeScript; - -namespace FreezeScript -{ - -typedef map<string, int> KeywordMap; -static KeywordMap keywordMap; - -void initScanner(); -int checkKeyword(const string&); -StringTokPtr parseString(char); - -} - -#define YY_USER_INIT initScanner(); - -#define YY_INPUT(buf, result, max_size) { result = getInput(buf, max_size); } -%} - -%option noyywrap -%option never-interactive -%option prefix="freeze_script_" -%option outfile="lex.yy.c" - -identifier [[:alpha:]_][[:alnum:]_]* -integer_constant (\+|-)?((0[0-7]+)|(0x[[:xdigit:]]+)|([[:digit:]]+)) -fractional_constant (\+|-)?(([[:digit:]]*\.[[:digit:]]+)|([[:digit:]]+\.)) -exponent_part (e|E)(\+|-)?[[:digit:]]+ -floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?[[:digit:]]+{exponent_part}))[fF]? - -%% - -"//" { - // C++-style comment - int c; - do - { - c = yyinput(); - if(c == '\n') - { - parseLine++; - } - } - while(c != '\n' && c != EOF); -} - -"/*" { - // C-style comment - while(true) - { - int c = yyinput(); - if(c == '\n') - { - parseLine++; - } - else if(c == '*') - { - int next = yyinput(); - if(next == '/') - { - break; - } - else - { - unput(next); - } - } - else if(c == EOF) - { - parseErrorReporter->expressionSyntaxError("EOF in comment"); - break; - } - } -} - -{identifier} { - StringTokPtr ident = new StringTok; - ident->v = yytext; - *yylvalp = ident; - return checkKeyword(ident->v); -} - -\" { - StringTokPtr str = parseString('"'); - *yylvalp = str; - return TOK_STRING_LITERAL; -} - -\' { - StringTokPtr str = parseString('\''); - *yylvalp = str; - return TOK_STRING_LITERAL; -} - -{integer_constant} { - IntegerTokPtr itp = new IntegerTok; - *yylvalp = itp; - if(!IceUtilInternal::stringToInt64(string(yytext), itp->v)) - { - assert(itp->v != 0); - string msg = "integer constant `"; - msg += yytext; - msg += "' out of range"; - parseErrorReporter->expressionSyntaxError(msg); - } - return TOK_INTEGER_LITERAL; -} - -{floating_literal} { - errno = 0; - FloatingTokPtr ftp = new FloatingTok; - *yylvalp = ftp; - string literal(yytext); - char lastChar = literal[literal.size() - 1]; - if(lastChar == 'f' || lastChar == 'F') - { - literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix - } - ftp->v = strtod(literal.c_str(), 0); - if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE) - { - string msg = "floating-point constant `"; - msg += yytext; - msg += "' too large (overflow)"; - parseErrorReporter->expressionSyntaxError(msg); - } - else if(ftp->v == 0 && errno == ERANGE) - { - string msg = "floating-point constant `"; - msg += yytext; - msg += "' too small (underflow)"; - parseErrorReporter->expressionSyntaxError(msg); - } - return TOK_FLOATING_POINT_LITERAL; -} - -[[:space:]] { - // Igore white-space - - if(yytext[0] == '\n') - { - parseLine++; - } -} - -"<" return TOK_LESS_THAN; -">" return TOK_GREATER_THAN; -"<=" return TOK_LESS_EQUAL; -">=" return TOK_GREATER_EQUAL; -"==" return TOK_EQUAL; -"!=" return TOK_NEQ; -"+" return TOK_ADD; -"-" return TOK_SUB; -"*" return TOK_MUL; -"/" return TOK_DIV; -"%" return TOK_MOD; -"(" return TOK_LPAREN; -")" return TOK_RPAREN; -"[" return TOK_LBRACKET; -"]" return TOK_RBRACKET; -"::" return TOK_SCOPE_DELIMITER; - -. { - return yytext[0]; -} - -%% - -namespace FreezeScript -{ - -void -initScanner() -{ - keywordMap["true"] = TOK_TRUE; - keywordMap["false"] = TOK_FALSE; - keywordMap["and"] = TOK_AND; - keywordMap["or"] = TOK_OR; - keywordMap["not"] = TOK_NOT; - keywordMap["nil"] = TOK_NIL; -} - -int -checkKeyword(const string& id) -{ - KeywordMap::const_iterator pos = keywordMap.find(id); - if(pos != keywordMap.end()) - { - return pos->second; - } - return TOK_IDENTIFIER; -} - -StringTokPtr -parseString(char start) -{ - StringTokPtr str = new StringTok; - while(true) - { - char c = static_cast<char>(yyinput()); - if(c == start) - { - break; - } - else if(c == EOF) - { - parseErrorReporter->expressionSyntaxError("EOF in string"); - break; - } - else if(c == '\n') - { - parseErrorReporter->expressionSyntaxError("newline in string"); - } - else if(c == '\\') - { - char next = static_cast<char>(yyinput()); - switch(next) - { - case '\\': - case '"': - case '\'': - { - str->v += next; - break; - } - - case 'n': - { - str->v += '\n'; - break; - } - - case 'r': - { - str->v += '\r'; - break; - } - - case 't': - { - str->v += '\t'; - break; - } - - case 'v': - { - str->v += '\v'; - break; - } - - case 'f': - { - str->v += '\f'; - break; - } - - case 'a': - { - str->v += '\a'; - break; - } - - case 'b': - { - str->v += '\b'; - break; - } - - case '?': - { - str->v += '\?'; - break; - } - - case '0': - case '1': - case '2': - case '3': - { - static string octalDigits = "01234567"; - unsigned short us = next - '0'; - if(octalDigits.find_first_of(next = static_cast<char>(yyinput())) != string::npos) - { - us = us * 8 + next - '0'; - if(octalDigits.find_first_of(next = static_cast<char>(yyinput())) != string::npos) - { - us = us * 8 + next - '0'; - } - else - { - unput(next); - } - } - else - { - unput(next); - } - str->v += static_cast<char>(us); - break; - } - case 'x': - { - IceUtil::Int64 ull = 0; - while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput())))) - { - ull *= 16; - if(isdigit(static_cast<unsigned char>(next))) - { - ull += next - '0'; - } - else if(islower(static_cast<unsigned char>(next))) - { - ull += next - 'a' + 10; - } - else - { - ull += next - 'A' + 10; - } - } - unput(next); - str->v += static_cast<char>(ull); - break; - } - - // TODO: add universal character names - - default: - { - str->v += c; - unput(next); - } - } - } - else - { - str->v += c; - } - } - - return str; -} - -} // End of namespace FreezeScript diff --git a/cpp/src/FreezeScript/TransformAnalyzer.cpp b/cpp/src/FreezeScript/TransformAnalyzer.cpp deleted file mode 100644 index e1c9776e128..00000000000 --- a/cpp/src/FreezeScript/TransformAnalyzer.cpp +++ /dev/null @@ -1,1236 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/TransformAnalyzer.h> -#include <FreezeScript/Util.h> -#include <IceUtil/OutputUtil.h> -#include <map> - -using namespace std; -using namespace Slice; -using namespace IceUtil; -using namespace IceUtilInternal; - -namespace FreezeScript -{ - -// -// AnalyzeTransformVisitor visits the old definitions and compares them with -// the new definitions. -// -class AnalyzeTransformVisitor : public ParserVisitor -{ -public: - - AnalyzeTransformVisitor(XMLOutput&, const UnitPtr&, bool, vector<string>&, vector<string>&); - - void addDatabase(const string&, const TypePtr&, const TypePtr&, const TypePtr&, const TypePtr&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - virtual void visitEnum(const EnumPtr&); - -private: - - void compareMembers(const DataMemberList&, const DataMemberList&); - void compareTypes(const string&, const TypePtr&, const TypePtr&); - void typeChange(const string&, const TypePtr&, const TypePtr&); - bool checkClasses(const ClassDeclPtr&, const ClassDeclPtr&); - - XMLOutput& _out; - UnitPtr _newUnit; - bool _ignoreTypeChanges; - vector<string>& _missingTypes; - vector<string>& _errors; -}; - -// -// InitVisitor visits the new definitions to find any that are not present -// in the old definitions, and generates init elements for them. -// -class AnalyzeInitVisitor : public ParserVisitor -{ -public: - - AnalyzeInitVisitor(XMLOutput&, const UnitPtr&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitStructStart(const StructPtr&); - virtual void visitSequence(const SequencePtr&); - virtual void visitDictionary(const DictionaryPtr&); - virtual void visitEnum(const EnumPtr&); - -private: - - void typeChange(const TypePtr&, const string&, const string&); - - XMLOutput& _out; - UnitPtr _oldUnit; -}; - -} - -//////////////////////////////////// -// AnalyzeTransformVisitor -//////////////////////////////////// - -FreezeScript::AnalyzeTransformVisitor::AnalyzeTransformVisitor(XMLOutput& out, const UnitPtr& newUnit, - bool ignoreTypeChanges, vector<string>& missingTypes, - vector<string>& errors) : - _out(out), _newUnit(newUnit), _ignoreTypeChanges(ignoreTypeChanges), _missingTypes(missingTypes), _errors(errors) -{ -} - -void -FreezeScript::AnalyzeTransformVisitor::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey, - const TypePtr& oldValue, const TypePtr& newValue) -{ - _out << "\n"; - _out << se("database"); - - if(!name.empty()) - { - _out << attr("name", name); - } - - string oldKeyName = oldKey ? typeToString(oldKey) : string("UNKNOWN"); - string newKeyName = newKey ? typeToString(newKey) : string("UNKNOWN"); - if(oldKeyName == newKeyName) - { - _out << attr("key", oldKeyName); - } - else - { - _out << attr("key", oldKeyName + "," + newKeyName); - } - - string oldValueName = oldValue ? typeToString(oldValue) : string("UNKNOWN"); - string newValueName = newValue ? typeToString(newValue) : string("UNKNOWN"); - if(oldValueName == newValueName) - { - _out << attr("value", oldValueName); - } - else - { - _out << attr("value", oldValueName + "," + newValueName); - } - - _out << se("record"); - if(oldKey && newKey) - { - compareTypes("database key", oldKey, newKey); - } - if(oldValue && newValue) - { - compareTypes("database value", oldValue, newValue); - } - _out << ee; - - _out << ee; -} - -bool -FreezeScript::AnalyzeTransformVisitor::visitClassDefStart(const ClassDefPtr& v) -{ - if(v->isInterface() || v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return false; - } - - TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - _missingTypes.push_back(scoped); - return false; - } - - // - // Allow transforming from class to struct. - // - ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front()); - StructPtr newStruct = StructPtr::dynamicCast(l.front()); - if(!newStruct && (!decl || decl->isInterface())) - { - if(!_ignoreTypeChanges) - { - typeChange(scoped, v->declaration(), l.front()); - } - return false; - } - - ClassDefPtr newClass; - if(decl) - { - newClass = decl->definition(); - if(!newClass) - { - _missingTypes.push_back(scoped); - return false; - } - } - - DataMemberList oldMembers, newMembers; - - if(newClass) - { - oldMembers = v->dataMembers(); - newMembers = newClass->dataMembers(); - } - else - { - oldMembers = v->allDataMembers(); - newMembers = newStruct->dataMembers(); - } - - _out.newline(); - _out.newline(); - if(newStruct) - { - _out << "<!-- struct " << scoped << " -->"; - } - else - { - _out << "<!-- class " << scoped << " -->"; - } - _out << se("transform") << attr("type", scoped); - - compareMembers(oldMembers, newMembers); - - _out << ee; - - return false; -} - -bool -FreezeScript::AnalyzeTransformVisitor::visitStructStart(const StructPtr& v) -{ - if(v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return false; - } - - TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - _missingTypes.push_back(scoped); - return false; - } - - // - // Allow transforming from struct to class. - // - StructPtr newStruct = StructPtr::dynamicCast(l.front()); - ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front()); - ClassDefPtr newClass; - if(decl) - { - newClass = decl->definition(); - if(!newClass) - { - _missingTypes.push_back(scoped); - return false; - } - } - else if(!newStruct) - { - if(!_ignoreTypeChanges) - { - typeChange(scoped, v, l.front()); - } - return false; - } - - _out.newline(); - _out.newline(); - if(newClass) - { - _out << "<!-- class " << scoped << " -->"; - } - else - { - _out << "<!-- struct " << scoped << " -->"; - } - _out << se("transform") << attr("type", scoped); - - DataMemberList oldMembers, newMembers; - - if(newClass) - { - oldMembers = v->dataMembers(); - newMembers = newClass->allDataMembers(); - } - else - { - oldMembers = v->dataMembers(); - newMembers = newStruct->dataMembers(); - } - - compareMembers(oldMembers, newMembers); - - _out << ee; - - return false; -} - -void -FreezeScript::AnalyzeTransformVisitor::visitSequence(const SequencePtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - _missingTypes.push_back(scoped); - return; - } - - SequencePtr newSeq = SequencePtr::dynamicCast(l.front()); - if(!newSeq) - { - if(!_ignoreTypeChanges) - { - typeChange(scoped, v, l.front()); - } - return; - } - - _out.newline(); - _out.newline(); - _out << "<!-- sequence " << scoped << " -->"; - _out << se("transform") << attr("type", scoped); - - compareTypes(scoped + " sequence type", v->type(), newSeq->type()); - - _out << ee; -} - -void -FreezeScript::AnalyzeTransformVisitor::visitDictionary(const DictionaryPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - _missingTypes.push_back(scoped); - return; - } - - DictionaryPtr newDict = DictionaryPtr::dynamicCast(l.front()); - if(!newDict) - { - if(!_ignoreTypeChanges) - { - typeChange(scoped, v, l.front()); - } - return; - } - - _out.newline(); - _out.newline(); - _out << "<!-- dictionary " << scoped << " -->"; - _out << se("transform") << attr("type", scoped); - - compareTypes(scoped + " key type", v->keyType(), newDict->keyType()); - compareTypes(scoped + " value type", v->valueType(), newDict->valueType()); - - _out << ee; -} - -void -FreezeScript::AnalyzeTransformVisitor::visitEnum(const EnumPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - if(ignoreType(scoped)) - { - return; - } - - TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - _missingTypes.push_back(scoped); - return; - } - - EnumPtr newEnum = EnumPtr::dynamicCast(l.front()); - if(!newEnum) - { - if(!_ignoreTypeChanges) - { - typeChange(scoped, v, l.front()); - } - return; - } - - map<string, int> m; - { - Slice::EnumeratorList enumerators = newEnum->getEnumerators(); - int i = 0; - for(Slice::EnumeratorList::iterator p = enumerators.begin(); p != enumerators.end(); ++p, ++i) - { - m.insert(map<string, int>::value_type((*p)->name(), i)); - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- enum " << scoped << " -->"; - _out << se("transform") << attr("type", scoped); - - Slice::EnumeratorList enumerators = v->getEnumerators(); - int i = 0; - for(Slice::EnumeratorList::iterator p = enumerators.begin(); p != enumerators.end(); ++p, ++i) - { - map<string, int>::const_iterator q = m.find((*p)->name()); - if(q == m.end()) - { - _out.newline(); - _out << "<!-- NOTICE: enumerator `" << (*p)->name() << "' has been removed -->"; - } - else if(q->second != i) - { - _out.newline(); - _out << "<!-- NOTICE: enumerator `" << (*p)->name() << "' has changed position -->"; - } - } - - _out << ee; -} - -void -FreezeScript::AnalyzeTransformVisitor::compareMembers(const DataMemberList& oldMembers, - const DataMemberList& newMembers) -{ - map<string, DataMemberPtr> oldMap, newMap; - - for(DataMemberList::const_iterator p = oldMembers.begin(); p != oldMembers.end(); ++p) - { - oldMap.insert(pair<string, DataMemberPtr>((*p)->name(), *p)); - } - - for(DataMemberList::const_iterator p = newMembers.begin(); p != newMembers.end(); ++p) - { - newMap.insert(pair<string, DataMemberPtr>((*p)->name(), *p)); - } - - for(DataMemberList::const_iterator p = oldMembers.begin(); p != oldMembers.end(); ++p) - { - string name = (*p)->name(); - map<string, DataMemberPtr>::iterator q = newMap.find(name); - if(q == newMap.end()) - { - _out.newline(); - _out << "<!-- NOTICE: " << name << " has been removed -->"; - } - else - { - TypePtr oldType = (*p)->type(); - TypePtr newType = q->second->type(); - compareTypes(name, oldType, newType); - - // - // Remove this entry from the map to indicate that we've - // already seen it. - // - newMap.erase(q); - } - } - - // - // Iterate over the remaining entries in newMap. These represent - // members that were added in the new definition. - // - for(map<string, DataMemberPtr>::iterator q = newMap.begin(); q != newMap.end(); ++q) - { - _out.newline(); - _out << "<!-- NOTICE: " << q->first << " has been added -->"; - } -} - -void -FreezeScript::AnalyzeTransformVisitor::compareTypes(const string& desc, const TypePtr& oldType, const TypePtr& newType) -{ - assert(!oldType->isLocal()); - if(newType->isLocal()) - { - ostringstream ostr; - ostr << desc << " has changed to a local type"; - _errors.push_back(ostr.str()); - return; - } - - BuiltinPtr b = BuiltinPtr::dynamicCast(oldType); - if(b) - { - BuiltinPtr newb = BuiltinPtr::dynamicCast(newType); - switch(b->kind()) - { - case Builtin::KindByte: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindString: - { - return; - } - case Builtin::KindBool: - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindBool: - { - if(newb && (newb->kind() == Builtin::KindBool || newb->kind() == Builtin::KindString)) - { - return; - } - - break; - } - case Builtin::KindShort: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindString: - { - return; - } - case Builtin::KindBool: - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindInt: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindString: - { - return; - } - case Builtin::KindBool: - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindLong: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindString: - { - return; - } - case Builtin::KindBool: - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindFloat: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindString: - { - return; - } - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindBool: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindDouble: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindString: - { - return; - } - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindBool: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - break; - } - case Builtin::KindString: - { - if(newb) - { - switch(newb->kind()) - { - case Builtin::KindByte: - case Builtin::KindBool: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - case Builtin::KindFloat: - case Builtin::KindDouble: - case Builtin::KindString: - case Builtin::KindObjectProxy: - { - return; - } - case Builtin::KindObject: - case Builtin::KindLocalObject: - { - break; - } - } - - break; - } - - if(EnumPtr::dynamicCast(newType)) - { - return; - } - - if(ProxyPtr::dynamicCast(newType)) - { - return; - } - - break; - } - case Builtin::KindObject: - { - // - // Allow change from Object to class. Validation has to - // be done during transformation, when the actual type of - // an instance can be compared for compatibility with the - // new type. - // - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(newType); - if(cl || (newb && newb->kind() == Builtin::KindObject)) - { - return; - } - - break; - } - case Builtin::KindObjectProxy: - { - ProxyPtr p = ProxyPtr::dynamicCast(newType); - if(p || (newb && newb->kind() == Builtin::KindObjectProxy) || (newb && newb->kind() == Builtin::KindString)) - { - return; - } - - break; - } - case Builtin::KindLocalObject: - { - assert(false); - break; - } - } - - typeChange(desc, oldType, newType); - return; - } - - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(oldType); - if(cl) - { - if(!cl->definition()) - { - _errors.push_back("class " + cl->scoped() + " declared but not defined"); - return; - } - - // - // Allow target type of Object. - // - BuiltinPtr newb = BuiltinPtr::dynamicCast(newType); - if(newb && newb->kind() == Builtin::KindObject) - { - return; - } - - // - // Allow target type of struct. - // - if(StructPtr::dynamicCast(newType)) - { - return; - } - - ClassDeclPtr newcl = ClassDeclPtr::dynamicCast(newType); - if(newcl) - { - if(!newcl->definition()) - { - _errors.push_back("class " + newcl->scoped() + " declared but not defined"); - return; - } - - if(checkClasses(cl, newcl)) - { - return; - } - } - - typeChange(desc, oldType, newType); - return; - } - - StructPtr s = StructPtr::dynamicCast(oldType); - if(s) - { - StructPtr news = StructPtr::dynamicCast(newType); - if(news && s->scoped() == news->scoped()) - { - return; - } - - // - // Allow target type of class. - // - if(ClassDeclPtr::dynamicCast(newType)) - { - return; - } - - typeChange(desc, oldType, newType); - return; - } - - ProxyPtr proxy = ProxyPtr::dynamicCast(oldType); - if(proxy) - { - // - // Allow target type of Object* and string. - // - BuiltinPtr newb = BuiltinPtr::dynamicCast(newType); - if(newb && (newb->kind() == Builtin::KindObjectProxy || newb->kind() == Builtin::KindString)) - { - return; - } - - ProxyPtr newProxy = ProxyPtr::dynamicCast(newType); - if(newProxy && checkClasses(proxy->_class(), newProxy->_class())) - { - return; - } - - typeChange(desc, oldType, newType); - return; - } - - DictionaryPtr dict = DictionaryPtr::dynamicCast(oldType); - if(dict) - { - DictionaryPtr newDict = DictionaryPtr::dynamicCast(newType); - if(newDict && dict->scoped() == newDict->scoped()) - { - return; - } - - typeChange(desc, oldType, newType); - return; - } - - SequencePtr seq = SequencePtr::dynamicCast(oldType); - if(seq) - { - SequencePtr newSeq = SequencePtr::dynamicCast(newType); - if(newSeq && seq->scoped() == newSeq->scoped()) - { - return; - } - - typeChange(desc, oldType, newType); - return; - } - - EnumPtr en = EnumPtr::dynamicCast(oldType); - if(en) - { - EnumPtr newen = EnumPtr::dynamicCast(newType); - BuiltinPtr newb = BuiltinPtr::dynamicCast(newType); - if((newen && en->scoped() == newen->scoped()) || (newb && newb->kind() == Builtin::KindString)) - { - return; - } - - typeChange(desc, oldType, newType); - return; - } - - assert(false); -} - -void -FreezeScript::AnalyzeTransformVisitor::typeChange(const string& desc, const TypePtr& t1, const TypePtr& t2) -{ - BuiltinPtr b1 = BuiltinPtr::dynamicCast(t1); - BuiltinPtr b2 = BuiltinPtr::dynamicCast(t2); - ContainedPtr c1 = ContainedPtr::dynamicCast(t1); - ContainedPtr c2 = ContainedPtr::dynamicCast(t2); - ProxyPtr p1 = ProxyPtr::dynamicCast(t1); - ProxyPtr p2 = ProxyPtr::dynamicCast(t2); - - if(_ignoreTypeChanges) - { - _out.newline(); - _out << "<!-- NOTICE: " << desc << " has changed from "; - if(b1) - { - _out << b1->kindAsString(); - } - else if(p1) - { - _out << p1->_class()->scoped() << '*'; - } - else - { - assert(c1); - _out << c1->kindOf() << ' ' << c1->scoped(); - } - _out << " to "; - if(b2) - { - _out << b2->kindAsString(); - } - else if(p2) - { - _out << p2->_class()->scoped() << '*'; - } - else - { - assert(c2); - _out << c2->kindOf() << ' ' << c2->scoped(); - } - _out << " -->"; - } - else - { - ostringstream ostr; - ostr << "unsupported type change in " << desc << " from "; - if(b1) - { - ostr << b1->kindAsString(); - } - else if(p1) - { - ostr << p1->_class()->scoped() << '*'; - } - else - { - assert(c1); - ostr << c1->kindOf() << ' ' << c1->scoped(); - } - ostr << " to "; - if(b2) - { - ostr << b2->kindAsString(); - } - else if(p2) - { - ostr << p2->_class()->scoped() << '*'; - } - else - { - assert(c2); - ostr << c2->kindOf() << ' ' << c2->scoped(); - } - _errors.push_back(ostr.str()); - } -} - -bool -FreezeScript::AnalyzeTransformVisitor::checkClasses(const ClassDeclPtr& from, const ClassDeclPtr& to) -{ - string fromScoped = from->scoped(); - string toScoped = to->scoped(); - - if(fromScoped == toScoped) - { - return true; - } - - // - // The types don't match, so check them for compatibility. Specifically, - // look up the old type id in the new Slice and see if it has the target - // type as a base class. - // - TypeList l = to->unit()->lookupTypeNoBuiltin(from->scoped(), false); - if(!l.empty()) - { - ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front()); - if(decl) - { - ClassDefPtr def = decl->definition(); - if(def) - { - ClassList bases = def->allBases(); - for(ClassList::iterator p = bases.begin(); p != bases.end(); ++p) - { - if((*p)->scoped() == toScoped) - { - return true; - } - } - } - } - } - - return false; -} - -//////////////////////////////////// -// InitVisitor -//////////////////////////////////// - -FreezeScript::AnalyzeInitVisitor::AnalyzeInitVisitor(XMLOutput& out, const UnitPtr& oldUnit) : - _out(out), _oldUnit(oldUnit) -{ -} - -bool -FreezeScript::AnalyzeInitVisitor::visitClassDefStart(const ClassDefPtr& v) -{ - if(v->isInterface() || v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false); - if(!l.empty()) - { - ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front()); - if(!decl || decl->isInterface()) - { - typeChange(l.front(), scoped, "class"); - } - else - { - return false; - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- class " << scoped << " -->"; - _out << se("init") << attr("type", scoped); - _out << ee; - - return false; -} - -bool -FreezeScript::AnalyzeInitVisitor::visitStructStart(const StructPtr& v) -{ - if(v->isLocal()) - { - return false; - } - - string scoped = v->scoped(); - TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false); - if(!l.empty()) - { - StructPtr s = StructPtr::dynamicCast(l.front()); - if(!s) - { - typeChange(l.front(), scoped, "struct"); - } - else - { - return false; - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- struct " << scoped << " -->"; - _out << se("init") << attr("type", scoped); - _out << ee; - - return false; -} - -void -FreezeScript::AnalyzeInitVisitor::visitSequence(const SequencePtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false); - if(!l.empty()) - { - SequencePtr s = SequencePtr::dynamicCast(l.front()); - if(!s) - { - typeChange(l.front(), scoped, "sequence"); - } - else - { - return; - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- sequence " << scoped << " -->"; - _out << se("init") << attr("type", scoped); - _out << ee; -} - -void -FreezeScript::AnalyzeInitVisitor::visitDictionary(const DictionaryPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false); - if(!l.empty()) - { - DictionaryPtr d = DictionaryPtr::dynamicCast(l.front()); - if(!d) - { - typeChange(l.front(), scoped, "dictionary"); - } - else - { - return; - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- dictionary " << scoped << " -->"; - _out << se("init") << attr("type", scoped); - _out << ee; -} - -void -FreezeScript::AnalyzeInitVisitor::visitEnum(const EnumPtr& v) -{ - if(v->isLocal()) - { - return; - } - - string scoped = v->scoped(); - TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false); - if(!l.empty()) - { - EnumPtr e = EnumPtr::dynamicCast(l.front()); - if(!e) - { - typeChange(l.front(), scoped, "enum"); - } - else - { - return; - } - } - - _out.newline(); - _out.newline(); - _out << "<!-- enum " << scoped << " -->"; - _out << se("init") << attr("type", scoped); - _out << ee; -} - - -void -FreezeScript::AnalyzeInitVisitor::typeChange(const TypePtr& t, const string& scoped, const string& kind) -{ - BuiltinPtr b = BuiltinPtr::dynamicCast(t); - ContainedPtr c = ContainedPtr::dynamicCast(t); - ProxyPtr p = ProxyPtr::dynamicCast(t); - - _out.newline(); - _out.newline(); - _out << "<!-- NOTICE: " << scoped << " has changed from "; - if(b) - { - _out << b->kindAsString(); - } - else if(p) - { - _out << "proxy"; - } - else - { - assert(c); - _out << c->kindOf(); - } - _out << " to " << kind << " -->"; -} - -FreezeScript::TransformAnalyzer::TransformAnalyzer(const UnitPtr& oldUnit, const UnitPtr& newUnit, - bool ignoreTypeChanges, ostream& os, vector<string>& missingTypes, - vector<string>& errors) : - _old(oldUnit), _new(newUnit), _out(os), - _visitor(new AnalyzeTransformVisitor(_out, newUnit, ignoreTypeChanges, missingTypes, errors)) -{ - _out << se("transformdb"); -} - -FreezeScript::TransformAnalyzer::~TransformAnalyzer() -{ - delete _visitor; -} - -void -FreezeScript::TransformAnalyzer::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey, - const TypePtr& oldValue, const TypePtr& newValue) -{ - _visitor->addDatabase(name, oldKey, newKey, oldValue, newValue); -} - -void -FreezeScript::TransformAnalyzer::finish() -{ - _old->visit(_visitor, false); - - AnalyzeInitVisitor initVisitor(_out, _old); - _new->visit(&initVisitor, false); - - _out << ee; - _out << '\n'; -} diff --git a/cpp/src/FreezeScript/TransformAnalyzer.h b/cpp/src/FreezeScript/TransformAnalyzer.h deleted file mode 100644 index 938b04ec1e3..00000000000 --- a/cpp/src/FreezeScript/TransformAnalyzer.h +++ /dev/null @@ -1,44 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_TRANSFORM_ANALYZER_H -#define FREEZE_SCRIPT_TRANSFORM_ANALYZER_H - -#include <Slice/Parser.h> -#include <IceUtil/OutputUtil.h> -#include <ostream> - -namespace FreezeScript -{ - -class AnalyzeTransformVisitor; - -class TransformAnalyzer -{ -public: - - TransformAnalyzer(const Slice::UnitPtr&, const Slice::UnitPtr&, bool, std::ostream&, std::vector<std::string>&, - std::vector<std::string>&); - ~TransformAnalyzer(); - - void addDatabase(const std::string&, const Slice::TypePtr&, const Slice::TypePtr&, const Slice::TypePtr&, - const Slice::TypePtr&); - void finish(); - -private: - - Slice::UnitPtr _old; - Slice::UnitPtr _new; - IceUtilInternal::XMLOutput _out; - AnalyzeTransformVisitor* _visitor; -}; - -} - -#endif diff --git a/cpp/src/FreezeScript/TransformDB.rc b/cpp/src/FreezeScript/TransformDB.rc deleted file mode 100644 index 6211ed2a3c1..00000000000 --- a/cpp/src/FreezeScript/TransformDB.rc +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,7,0,0 - PRODUCTVERSION 3,7,0,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "ZeroC, Inc.\0" - VALUE "FileDescription", "Transform Freeze Database\0" - VALUE "FileVersion", "3.7.0\0" - VALUE "InternalName", "transformdb\0" - VALUE "LegalCopyright", "\251 2003-2015 ZeroC, Inc.\0" - VALUE "OriginalFilename", "transformdb.exe\0" - VALUE "ProductName", "Ice\0" - VALUE "ProductVersion", "3.7.0\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END diff --git a/cpp/src/FreezeScript/TransformVisitor.cpp b/cpp/src/FreezeScript/TransformVisitor.cpp deleted file mode 100644 index fb77a39353f..00000000000 --- a/cpp/src/FreezeScript/TransformVisitor.cpp +++ /dev/null @@ -1,995 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/TransformVisitor.h> -#include <FreezeScript/Util.h> -#include <IceUtil/InputUtil.h> - -using namespace std; - -FreezeScript::TransformVisitor::TransformVisitor(const DataPtr& src, const TransformInfoPtr& info, - const string& context) : - _src(src), _info(info), _context(context) -{ - assert(_info); -} - -void -FreezeScript::TransformVisitor::visitBoolean(const BooleanDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - BooleanDataPtr b = BooleanDataPtr::dynamicCast(_src); - if(b) - { - dest->setValue(b->getValue()); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - string v = s->getValue(); - if(v == "true") - { - dest->setValue(true); - } - else if(v == "false") - { - dest->setValue(false); - } - else - { - conversionError(type, _src->getType(), v); - } - } - else - { - typeMismatchError(type, _src->getType()); - } - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitInteger(const IntegerDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - IntegerDataPtr i = IntegerDataPtr::dynamicCast(_src); - if(i) - { - dest->setValue(i->getValue(), false); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - string str = s->getValue(); - Ice::Long value; - if(IceUtilInternal::stringToInt64(str, value)) - { - dest->setValue(value, false); - } - else - { - conversionError(type, _src->getType(), str); - } - } - else - { - typeMismatchError(type, _src->getType()); - } - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitDouble(const DoubleDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - DoubleDataPtr d = DoubleDataPtr::dynamicCast(_src); - if(d) - { - dest->setValue(d->doubleValue()); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - string str = s->stringValue(); - const char* start = str.c_str(); - char* end; - double v = strtod(start, &end); - if(errno == ERANGE) - { - rangeError(str, type); - } - else - { - while(*end) - { - if(!isspace(static_cast<unsigned char>(*end))) - { - conversionError(type, _src->getType(), str); - return; - } - end++; - } - if(!*end) - { - dest->setValue(v); - } - } - } - else - { - typeMismatchError(type, _src->getType()); - } - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitString(const StringDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - BooleanDataPtr b = BooleanDataPtr::dynamicCast(_src); - IntegerDataPtr i = IntegerDataPtr::dynamicCast(_src); - DoubleDataPtr d = DoubleDataPtr::dynamicCast(_src); - EnumDataPtr e = EnumDataPtr::dynamicCast(_src); - ProxyDataPtr p = ProxyDataPtr::dynamicCast(_src); - if(s || b || i || d || e || p) - { - dest->setValue(_src->toString()); - } - else - { - typeMismatchError(type, _src->getType()); - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitProxy(const ProxyDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - ProxyDataPtr p = ProxyDataPtr::dynamicCast(_src); - if(p) - { - dest->setValue(p->getValue()); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - dest->setValue(s->getValue(), false); - } - else - { - typeMismatchError(type, _src->getType()); - } - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitStruct(const StructDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - // - // Support struct->struct and class->struct transforms. - // - StructDataPtr s = StructDataPtr::dynamicCast(_src); - ObjectRefPtr obj = ObjectRefPtr::dynamicCast(_src); - if((s || obj) && isCompatible(type, _src->getType())) - { - // - // Transform members with the same name. - // - DataMemberMap srcMap = s ? s->getMembers() : obj->getValue()->getMembers(); - DataMemberMap destMap = dest->getMembers(); - string typeName = typeToString(type); - for(DataMemberMap::iterator p = destMap.begin(); p != destMap.end(); ++p) - { - DataMemberMap::iterator q = srcMap.find(p->first); - if(q != srcMap.end()) - { - string context = typeName + " member " + p->first + " value"; - TransformVisitor v(q->second, _info, context); - p->second->visit(v); - } - } - } - else - { - typeMismatchError(type, _src->getType()); - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitSequence(const SequenceDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - SequenceDataPtr s = SequenceDataPtr::dynamicCast(_src); - if(s && isCompatible(type, _src->getType())) - { - DataList& srcElements = s->getElements(); - DataList destElements; - Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(type); - assert(seqType); - Slice::TypePtr elemType = seqType->type(); - string typeName = typeToString(type); - for(DataList::const_iterator p = srcElements.begin(); p != srcElements.end(); ++p) - { - DataPtr element = _info->getDataFactory()->create(elemType, false); - Destroyer<DataPtr> elementDestroyer(element); - try - { - TransformVisitor v(*p, _info, typeName + " element"); - element->visit(v); - destElements.push_back(element); - elementDestroyer.release(); - } - catch(const ClassNotFoundException& ex) - { - // - // If transformation of the sequence element fails because a class - // could not be found, then we invoke purgeObjects() to determine - // whether we should ignore the situation (and remove the element - // from the sequence) or raise the exception again. - // - if(!_info->purgeObjects()) - { - throw; - } - warning("purging element of sequence " + typeToString(type) + - " due to missing class type " + ex.id); - } - } - DataList& l = dest->getElements(); - l.swap(destElements); - } - else - { - typeMismatchError(type, _src->getType()); - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitEnum(const EnumDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - string name; - EnumDataPtr e = EnumDataPtr::dynamicCast(_src); - if(e && isCompatible(type, _src->getType())) - { - name = e->toString(); - } - else - { - StringDataPtr s = StringDataPtr::dynamicCast(_src); - if(s) - { - name = s->getValue(); - } - else - { - typeMismatchError(type, _src->getType()); - return; - } - } - - if(!dest->setValueAsString(name)) - { - conversionError(type, _src->getType(), name); - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitDictionary(const DictionaryDataPtr& dest) -{ - Slice::TypePtr type = dest->getType(); - if(_info->doDefaultTransform(type)) - { - DictionaryDataPtr d = DictionaryDataPtr::dynamicCast(_src); - if(d && isCompatible(type, _src->getType())) - { - DataMap& srcMap = d->getElements(); - DataMap destMap; - Slice::DictionaryPtr dictType = Slice::DictionaryPtr::dynamicCast(type); - assert(dictType); - Slice::TypePtr keyType = dictType->keyType(); - Slice::TypePtr valueType = dictType->valueType(); - string typeName = typeToString(type); - for(DataMap::const_iterator p = srcMap.begin(); p != srcMap.end(); ++p) - { - DataPtr key = _info->getDataFactory()->create(keyType, false); - Destroyer<DataPtr> keyDestroyer(key); - DataPtr value = _info->getDataFactory()->create(valueType, false); - Destroyer<DataPtr> valueDestroyer(value); - - TransformVisitor keyVisitor(p->first, _info, typeName + " key"); - key->visit(keyVisitor); - - try - { - TransformVisitor valueVisitor(p->second, _info, typeName + " value"); - value->visit(valueVisitor); - } - catch(const ClassNotFoundException& ex) - { - // - // If transformation of the dictionary value fails because a class - // could not be found, then we invoke purgeObjects() to determine - // whether we should ignore the situation (and remove the element - // from the dictionary) or raise the exception again. - // - if(!_info->purgeObjects()) - { - throw; - } - warning("purging element of dictionary " + typeToString(dictType) + " due to missing class type " + - ex.id); - continue; - } - - DataMap::const_iterator q = destMap.find(key); - if(q != destMap.end()) - { - warning("duplicate dictionary key in " + typeToString(dictType)); - } - else - { - destMap.insert(DataMap::value_type(key, value)); - keyDestroyer.release(); - valueDestroyer.release(); - } - } - DataMap& m = dest->getElements(); - m.swap(destMap); - } - else - { - typeMismatchError(type, _src->getType()); - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::visitObject(const ObjectRefPtr& dest) -{ - // - // Support struct->class and class->class transforms. - // - Slice::TypePtr type = dest->getType(); - ObjectRefPtr src = ObjectRefPtr::dynamicCast(_src); - StructDataPtr s = StructDataPtr::dynamicCast(_src); - if(!src && !s) - { - typeMismatchError(type, _src->getType()); - } - else if(_info->doDefaultTransform(type)) - { - if(src) - { - // - // class->class transform - // - ObjectDataPtr srcValue = src->getValue(); - Slice::TypePtr srcType = src->getType(); - if(!srcValue) - { - // - // Allow a nil value from type Object. - // - if(Slice::BuiltinPtr::dynamicCast(srcType) || isCompatible(type, srcType)) - { - dest->setValue(0); - } - else - { - typeMismatchError(type, srcType); - } - } - else - { - Slice::TypePtr srcValueType = srcValue->getType(); - if(isCompatible(type, srcValueType)) - { - // - // If the types are in the same Slice unit, then we can simply - // copy the reference. Otherwise, we check the object map to - // see if an equivalent object has already been created, and - // if not, then we have to create one. - // - if(type->unit().get() == srcValueType->unit().get()) - { - dest->setValue(srcValue); - } - else - { - ObjectDataMap& objectDataMap = _info->getObjectDataMap(); - ObjectDataMap::iterator p = objectDataMap.find(srcValue.get()); - if(p != objectDataMap.end() && p->second) - { - dest->setValue(p->second); - } - else - { - // - // If the type has been renamed, we need to get its equivalent - // in the new Slice definitions. - // - Slice::TypePtr newType = _info->getRenamedType(srcValueType); - if(!newType) - { - string name = typeToString(srcValueType); - Slice::TypeList l = type->unit()->lookupType(name, false); - if(l.empty()) - { - throw ClassNotFoundException(name); - } - newType = l.front(); - } - - // - // Use createObject() so that an initializer is invoked if necessary. - // - DataPtr newObj = _info->getDataFactory()->createObject(newType, false); - ObjectRefPtr newRef = ObjectRefPtr::dynamicCast(newObj); - assert(newRef); - - ObjectDataPtr newValue = newRef->getValue(); - try - { - transformObject(newValue, srcValue); - } - catch(...) - { - newObj->destroy(); - throw; - } - - dest->setValue(newValue); - newObj->destroy(); - } - } - } - else - { - typeMismatchError(type, srcValueType); - } - } - } - else - { - // - // struct->class transform - // - Slice::TypePtr srcType = _src->getType(); - if(isCompatible(type, srcType)) - { - // - // If the type has been renamed, we need to get its equivalent - // in the new Slice definitions. - // - Slice::TypePtr newType = _info->getRenamedType(srcType); - if(!newType) - { - string name = typeToString(srcType); - Slice::TypeList l = type->unit()->lookupType(name, false); - if(l.empty()) - { - throw ClassNotFoundException(name); - } - newType = l.front(); - } - - // - // Use createObject() so that an initializer is invoked if necessary. - // - DataPtr newObj = _info->getDataFactory()->createObject(newType, false); - ObjectRefPtr newRef = ObjectRefPtr::dynamicCast(newObj); - assert(newRef); - - ObjectDataPtr newValue = newRef->getValue(); - try - { - // - // Transform members with the same name. - // - DataMemberMap srcMap = s->getMembers(); - DataMemberMap destMap = newValue->getMembers(); - string typeName = typeToString(type); - for(DataMemberMap::iterator p = destMap.begin(); p != destMap.end(); ++p) - { - DataMemberMap::iterator q = srcMap.find(p->first); - if(q != srcMap.end()) - { - string context = typeName + " member " + p->first + " value"; - TransformVisitor v(q->second, _info, context); - p->second->visit(v); - } - } - } - catch(...) - { - newObj->destroy(); - throw; - } - - dest->setValue(newValue); - newObj->destroy(); - } - else - { - typeMismatchError(type, srcType); - } - } - } - _info->executeCustomTransform(dest, _src); -} - -void -FreezeScript::TransformVisitor::transformObject(const ObjectDataPtr& dest, const ObjectDataPtr& src) -{ - // - // The source object must be present in the object map (we currently don't support - // transforming two ObjectData instances from the same Slice unit - this transform - // would be handled by-reference at the ObjectRef level). We must update the object - // map before transforming members in order to handle cycles. - // - ObjectDataMap& objectDataMap = _info->getObjectDataMap(); - ObjectDataMap::iterator p = objectDataMap.find(src.get()); - assert(p != objectDataMap.end()); - assert(p->second == 0); - objectDataMap.erase(p); - objectDataMap.insert(ObjectDataMap::value_type(src.get(), dest)); - p = objectDataMap.find(src.get()); - - try - { - // - // Transform members with the same name. - // - DataMemberMap srcMap = src->getMembers(); - DataMemberMap destMap = dest->getMembers(); - string typeName = typeToString(dest->getType()); - for(DataMemberMap::iterator p = destMap.begin(); p != destMap.end(); ++p) - { - DataMemberMap::iterator q = srcMap.find(p->first); - if(q != srcMap.end()) - { - string context = typeName + " member " + p->first + " value"; - TransformVisitor v(q->second, _info, context); - p->second->visit(v); - } - } - } - catch(...) - { - objectDataMap.erase(p); - -#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) - objectDataMap.insert(ObjectDataMap::value_type(src.get(), static_cast<ObjectDataPtr>(nullptr))); -#else - objectDataMap.insert(ObjectDataMap::value_type(src.get(), 0)); -#endif - throw; - } -} - -bool -FreezeScript::TransformVisitor::checkRename(const Slice::TypePtr& dest, const Slice::TypePtr& src) -{ - if(dest->unit().get() != src->unit().get()) - { - Slice::TypePtr t = _info->getRenamedType(src); - return t.get() == dest.get(); - } - - return false; -} - -bool -FreezeScript::TransformVisitor::isCompatible(const Slice::TypePtr& dest, const Slice::TypePtr& src) -{ - Slice::BuiltinPtr b1 = Slice::BuiltinPtr::dynamicCast(dest); - if(b1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - switch(b1->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindString: - { - return true; - } - case Slice::Builtin::KindBool: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - } - - return false; - } - case Slice::Builtin::KindBool: - { - if(b2 && (b2->kind() == Slice::Builtin::KindBool || b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - { - return true; - } - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - } - - return false; - } - case Slice::Builtin::KindString: - { - if(b2) - { - switch(b2->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindBool: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - case Slice::Builtin::KindString: - case Slice::Builtin::KindObjectProxy: - { - return true; - } - case Slice::Builtin::KindObject: - case Slice::Builtin::KindLocalObject: - { - return false; - } - } - - return false; - } - else if(Slice::EnumPtr::dynamicCast(src)) - { - return true; - } - else if(Slice::ProxyPtr::dynamicCast(src)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindObject: - { - // - // Allow transformation from Object to class. Validation has to - // be done during transformation, when the actual type of - // an instance can be compared for compatibility with the - // new type. - // - Slice::ClassDeclPtr cl = Slice::ClassDeclPtr::dynamicCast(src); - if(cl || (b2 && b2->kind() == Slice::Builtin::KindObject)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindObjectProxy: - { - Slice::ProxyPtr p = Slice::ProxyPtr::dynamicCast(src); - if(p || (b2 && b2->kind() == Slice::Builtin::KindObjectProxy) || - (b2 && b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - return false; - } - case Slice::Builtin::KindLocalObject: - { - assert(false); - return false; - } - } - - assert(false); - } - - Slice::ClassDeclPtr cl1 = Slice::ClassDeclPtr::dynamicCast(dest); - if(cl1) - { - Slice::ClassDeclPtr cl2 = Slice::ClassDeclPtr::dynamicCast(src); - if(cl2 && checkClasses(cl1, cl2)) - { - return true; - } - - Slice::StructPtr s2 = Slice::StructPtr::dynamicCast(src); - if(s2) - { - if(checkRename(dest, src)) - { - return true; - } - - if(s2 && cl1->scoped() == s2->scoped()) - { - return true; - } - } - - return false; - } - - Slice::StructPtr s1 = Slice::StructPtr::dynamicCast(dest); - if(s1) - { - if(checkRename(dest, src)) - { - return true; - } - - Slice::StructPtr s2 = Slice::StructPtr::dynamicCast(src); - Slice::ClassDeclPtr cl2 = Slice::ClassDeclPtr::dynamicCast(src); - if((s2 && s1->scoped() == s2->scoped()) || (cl2 && s1->scoped() == cl2->scoped())) - { - return true; - } - - return false; - } - - Slice::ProxyPtr p1 = Slice::ProxyPtr::dynamicCast(dest); - if(p1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - if(b2 && (b2->kind() == Slice::Builtin::KindObjectProxy || b2->kind() == Slice::Builtin::KindString)) - { - return true; - } - - Slice::ProxyPtr p2 = Slice::ProxyPtr::dynamicCast(src); - if(p2 && checkClasses(p1->_class(), p2->_class())) - { - return true; - } - - return false; - } - - Slice::DictionaryPtr d1 = Slice::DictionaryPtr::dynamicCast(dest); - if(d1) - { - Slice::DictionaryPtr d2 = Slice::DictionaryPtr::dynamicCast(src); - if(d2) - { - return isCompatible(d1->keyType(), d2->keyType()) && - isCompatible(d1->valueType(), d2->valueType()); - } - - return false; - } - - Slice::SequencePtr seq1 = Slice::SequencePtr::dynamicCast(dest); - if(seq1) - { - Slice::SequencePtr seq2 = Slice::SequencePtr::dynamicCast(src); - if(seq2) - { - return isCompatible(seq1->type(), seq2->type()); - } - - return false; - } - - Slice::EnumPtr e1 = Slice::EnumPtr::dynamicCast(dest); - if(e1) - { - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(src); - if(b2 && b2->kind() == Slice::Builtin::KindString) - { - return true; - } - - if(checkRename(dest, src)) - { - return true; - } - - Slice::EnumPtr e2 = Slice::EnumPtr::dynamicCast(src); - if(e2 && e1->scoped() == e2->scoped()) - { - return true; - } - - return false; - } - - assert(false); - return false; -} - -bool -FreezeScript::TransformVisitor::checkClasses(const Slice::ClassDeclPtr& dest, const Slice::ClassDeclPtr& src) -{ - // - // Here are the rules for verifying class compatibility: - // - // 1. If the type ids are the same, assume they are compatible. - // 2. If the source type has been renamed, then check its equivalent new definition for compatibility. - // 3. Otherwise, the types are only compatible if they are defined in the same Slice unit, and if the - // destination type is a base type of the source type. - // - string s1 = dest->scoped(); - string s2 = src->scoped(); - if(s1 == s2) - { - return true; - } - else - { - Slice::TypePtr t = _info->getRenamedType(src); - Slice::ClassDeclPtr s = Slice::ClassDeclPtr::dynamicCast(t); - if(s) - { - return checkClasses(dest, s); - } - - if(dest->unit().get() != src->unit().get()) - { - Slice::TypeList l = dest->unit()->lookupTypeNoBuiltin(s2, false); - if(l.empty()) - { - _info->getErrorReporter()->error("class " + s2 + " not found in new Slice definitions"); - } - s = Slice::ClassDeclPtr::dynamicCast(l.front()); - } - else - { - s = src; - } - - if(s) - { - Slice::ClassDefPtr def = s->definition(); - if(!def) - { - _info->getErrorReporter()->error("class " + s2 + " declared but not defined"); - } - return def->isA(s1); - } - } - - return false; -} - -void -FreezeScript::TransformVisitor::typeMismatchError(const Slice::TypePtr& dest, const Slice::TypePtr& src) -{ - ostringstream ostr; - ostr << "unable to transform"; - if(!_context.empty()) - { - ostr << ' ' << _context; - } - ostr << " from " << typeToString(src) << " to " << typeToString(dest); - warning(ostr.str()); -} - -void -FreezeScript::TransformVisitor::conversionError(const Slice::TypePtr& dest, const Slice::TypePtr& src, - const string& value) -{ - ostringstream ostr; - ostr << "unable to convert"; - if(!_context.empty()) - { - ostr << ' ' << _context; - } - ostr << " `" << value << "' from " << typeToString(src) << " to " << typeToString(dest); - warning(ostr.str()); -} - -void -FreezeScript::TransformVisitor::rangeError(const string& value, const Slice::TypePtr& type) -{ - ostringstream ostr; - if(!_context.empty()) - { - ostr << _context << ' '; - } - ostr << "`" << value << "' is out of range for type " << typeToString(type); - warning(ostr.str()); -} - -void -FreezeScript::TransformVisitor::warning(const string& msg) -{ - _info->getErrorReporter()->warning(msg); -} diff --git a/cpp/src/FreezeScript/TransformVisitor.h b/cpp/src/FreezeScript/TransformVisitor.h deleted file mode 100644 index 724f4b42b0a..00000000000 --- a/cpp/src/FreezeScript/TransformVisitor.h +++ /dev/null @@ -1,120 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_TRANSFORM_VISITOR_H -#define FREEZE_SCRIPT_TRANSFORM_VISITOR_H - -#include <FreezeScript/Data.h> - -namespace FreezeScript -{ - -// -// ObjectDataMap associates old instances of ObjectData to their -// transformed equivalents. -// -typedef std::map<const ObjectData*, ObjectDataPtr> ObjectDataMap; - -// -// TransformInfo supplies information required by TransformVisitor. -// -class TransformInfo : public IceUtil::SimpleShared -{ -public: - - virtual ~TransformInfo() {} - - // - // Get data factory. - // - virtual DataFactoryPtr getDataFactory() = 0; - - // - // Get error reporter. - // - virtual ErrorReporterPtr getErrorReporter() = 0; - - // - // Indicates whether the default transformation should be performed. - // - virtual bool doDefaultTransform(const Slice::TypePtr&) = 0; - - // - // Indicates whether a base class transformation should be performed. - // - virtual bool doBaseTransform(const Slice::ClassDefPtr&) = 0; - - // - // Given an old type, return the equivalent new type if the type - // has been renamed. - // - virtual Slice::TypePtr getRenamedType(const Slice::TypePtr&) = 0; - - // - // Execute the custom transformation for the given old and new Data values. - // - virtual void executeCustomTransform(const DataPtr&, const DataPtr&) = 0; - - // - // The facet name of the database (evictor only). - // - virtual std::string facetName() = 0; - - // - // Indicates whether objects should be removed if no class definition is found. - // - virtual bool purgeObjects() = 0; - - // - // Associates old object instances with their transformed equivalents. - // - virtual ObjectDataMap& getObjectDataMap() = 0; -}; -typedef IceUtil::Handle<TransformInfo> TransformInfoPtr; - -// -// TransformVisitor is used to visit a destination Data value and -// preserve as much information as possible from the source Data value. -// -class TransformVisitor : public DataVisitor -{ -public: - - TransformVisitor(const DataPtr&, const TransformInfoPtr&, const std::string& = std::string()); - - virtual void visitBoolean(const BooleanDataPtr&); - virtual void visitInteger(const IntegerDataPtr&); - virtual void visitDouble(const DoubleDataPtr&); - virtual void visitString(const StringDataPtr&); - virtual void visitProxy(const ProxyDataPtr&); - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitEnum(const EnumDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); - -private: - - void transformObject(const ObjectDataPtr&, const ObjectDataPtr&); - bool checkRename(const Slice::TypePtr&, const Slice::TypePtr&); - bool isCompatible(const Slice::TypePtr&, const Slice::TypePtr&); - bool checkClasses(const Slice::ClassDeclPtr&, const Slice::ClassDeclPtr&); - void typeMismatchError(const Slice::TypePtr&, const Slice::TypePtr&); - void conversionError(const Slice::TypePtr&, const Slice::TypePtr&, const std::string&); - void rangeError(const std::string&, const Slice::TypePtr&); - void warning(const std::string&); - - DataPtr _src; - TransformInfoPtr _info; - std::string _context; // Provides additional detail for use in warning messages. -}; - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Transformer.cpp b/cpp/src/FreezeScript/Transformer.cpp deleted file mode 100644 index e6fc8f66c19..00000000000 --- a/cpp/src/FreezeScript/Transformer.cpp +++ /dev/null @@ -1,3044 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Transformer.h> -#include <FreezeScript/Parser.h> -#include <FreezeScript/TransformVisitor.h> -#include <FreezeScript/AssignVisitor.h> -#include <FreezeScript/Print.h> -#include <FreezeScript/Functions.h> -#include <FreezeScript/Exception.h> -#include <FreezeScript/Util.h> -#include <Freeze/Catalog.h> -#include <Freeze/Initialize.h> -#include <IceXML/Parser.h> -#include <IceUtil/InputUtil.h> -#include <db_cxx.h> -#include <climits> - -using namespace std; - -namespace FreezeScript -{ - -class DeleteRecordException {}; - -class Descriptor; -typedef IceUtil::Handle<Descriptor> DescriptorPtr; - -class InitDescriptor; -typedef IceUtil::Handle<InitDescriptor> InitDescriptorPtr; - -class TransformDescriptor; -typedef IceUtil::Handle<TransformDescriptor> TransformDescriptorPtr; - -class TransformDataFactory; -typedef IceUtil::Handle<TransformDataFactory> TransformDataFactoryPtr; - -typedef map<string, TransformDescriptorPtr> TransformMap; -typedef map<string, Slice::TypePtr> RenameMap; - -// -// TransformInfoI -// -struct TransformInfoI : public TransformInfo -{ - virtual DataFactoryPtr getDataFactory(); - virtual ErrorReporterPtr getErrorReporter(); - virtual bool doDefaultTransform(const Slice::TypePtr&); - virtual bool doBaseTransform(const Slice::ClassDefPtr&); - virtual Slice::TypePtr getRenamedType(const Slice::TypePtr&); - virtual void executeCustomTransform(const DataPtr&, const DataPtr&); - virtual string facetName(); - virtual bool purgeObjects(); - virtual ObjectDataMap& getObjectDataMap(); - - Ice::CommunicatorPtr communicator; - FreezeScript::ObjectFactoryPtr objectFactory; - Slice::UnitPtr oldUnit; - Slice::UnitPtr newUnit; - Db* oldDb; - Db* newDb; - DbTxn* newDbTxn; - - // - // Connection to the new environment; not null only if we want to write into the catalog - // - Freeze::ConnectionPtr connection; - string newDbName; - - string facet; - bool purge; - ErrorReporterPtr errorReporter; - TransformDataFactoryPtr factory; - SymbolTablePtr symbolTable; - Slice::TypePtr oldKeyType; - Slice::TypePtr oldValueType; - Slice::TypePtr newKeyType; - Slice::TypePtr newValueType; - TransformMap transformMap; - RenameMap renameMap; - ObjectDataMap objectDataMap; -}; -typedef IceUtil::Handle<TransformInfoI> TransformInfoIPtr; - -// -// TransformDataFactory -// -class TransformDataFactory : public DataFactory -{ -public: - - TransformDataFactory(const Ice::CommunicatorPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&); - - void addInitDescriptor(const InitDescriptorPtr&); - void disableInitializers(); - void enableInitializers(); - -protected: - - virtual void initialize(const DataPtr&); - -private: - - typedef map<string, InitDescriptorPtr> InitMap; - InitMap _initMap; - bool _enabled; -}; - -// -// Descriptor -// -class Descriptor : public IceUtil::SimpleShared -{ -public: - - virtual ~Descriptor(); - - virtual DescriptorPtr parent() const; - virtual void addChild(const DescriptorPtr&) = 0; - virtual void validate() = 0; - virtual void execute(const SymbolTablePtr&) = 0; - -protected: - - Descriptor(const DescriptorPtr&, int, const TransformInfoIPtr&); - - NodePtr parse(const string&) const; - - Slice::TypePtr findType(const Slice::UnitPtr&, const string&); - - DescriptorPtr _parent; - int _line; - TransformInfoIPtr _info; -}; - -// -// SetDescriptor -// -class SetDescriptor : public Descriptor -{ -public: - - SetDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - EntityNodePtr _target; - NodePtr _value; - string _valueStr; - string _type; - NodePtr _length; - string _lengthStr; - bool _convert; -}; - -// -// DefineDescriptor -// -class DefineDescriptor : public Descriptor -{ -public: - - DefineDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - string _name; - NodePtr _value; - string _valueStr; - Slice::TypePtr _type; - bool _convert; -}; - -// -// AddDescriptor -// -class AddDescriptor : public Descriptor -{ -public: - - AddDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - EntityNodePtr _target; - NodePtr _key; - string _keyStr; - NodePtr _index; - string _indexStr; - NodePtr _value; - string _valueStr; - string _type; - bool _convert; -}; - -// -// RemoveDescriptor -// -class RemoveDescriptor : public Descriptor -{ -public: - - RemoveDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - EntityNodePtr _target; - NodePtr _key; - string _keyStr; - NodePtr _index; - string _indexStr; -}; - -// -// DeleteDescriptor -// -class DeleteDescriptor : public Descriptor -{ -public: - - DeleteDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); -}; - -// -// FailDescriptor -// -class FailDescriptor : public Descriptor -{ -public: - - FailDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - NodePtr _test; - string _testStr; - string _message; -}; - -// -// EchoDescriptor -// -class EchoDescriptor : public Descriptor -{ -public: - - EchoDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - string _message; - NodePtr _value; - string _valueStr; -}; - -// -// ExecutableContainerDescriptor -// -class ExecutableContainerDescriptor : public Descriptor -{ -public: - - ExecutableContainerDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&, - const string&); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -protected: - - vector<DescriptorPtr> _children; - -private: - - string _name; -}; - -// -// IfDescriptor -// -class IfDescriptor : public ExecutableContainerDescriptor -{ -public: - - IfDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void execute(const SymbolTablePtr&); - -private: - - NodePtr _test; - string _testStr; -}; - -// -// IterateDescriptor -// -class IterateDescriptor : public ExecutableContainerDescriptor -{ -public: - - IterateDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void execute(const SymbolTablePtr&); - -private: - - EntityNodePtr _target; - string _key; - string _value; - string _element; - string _index; -}; - -// -// TransformDescriptor -// -class TransformDescriptor : public ExecutableContainerDescriptor -{ -public: - - TransformDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - Slice::TypePtr type() const; - string typeName() const; - Slice::TypePtr renameType() const; - string renameTypeName() const; - bool doDefaultTransform() const; - bool doBaseTransform() const; - -private: - - bool _default; - bool _base; - Slice::TypePtr _newType; - Slice::TypePtr _renameType; -}; -typedef IceUtil::Handle<TransformDescriptor> TransformDescriptorPtr; - -// -// InitDescriptor -// -class InitDescriptor : public ExecutableContainerDescriptor -{ -public: - - InitDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - void initialize(const DataPtr&); - - string typeName() const; - -private: - - Slice::TypePtr _type; -}; - -// -// RecordDescriptor -// -class RecordDescriptor : public ExecutableContainerDescriptor -{ -public: - - RecordDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void execute(const SymbolTablePtr&); - -private: - - void transformRecord(const Ice::ByteSeq&, const Ice::ByteSeq&, Ice::ByteSeq&, Ice::ByteSeq&); - - Slice::UnitPtr _old; - Slice::UnitPtr _new; -}; -typedef IceUtil::Handle<RecordDescriptor> RecordDescriptorPtr; - -// -// DatabaseDescriptor -// -class DatabaseDescriptor : public ExecutableContainerDescriptor -{ -public: - - DatabaseDescriptor(const DescriptorPtr&, int, const TransformInfoIPtr&, const IceXML::Attributes&); - - virtual void addChild(const DescriptorPtr&); - virtual void execute(const SymbolTablePtr&); - - string name() const; - -private: - - string _name; - string _oldKeyName; - string _oldValueName; - string _newKeyName; - string _newValueName; - RecordDescriptorPtr _record; -}; -typedef IceUtil::Handle<DatabaseDescriptor> DatabaseDescriptorPtr; - -// -// TransformDBDescriptor -// -class TransformDBDescriptor : public Descriptor -{ -public: - - TransformDBDescriptor(int, const TransformInfoIPtr&, const IceXML::Attributes&); - ~TransformDBDescriptor(); - - virtual void addChild(const DescriptorPtr&); - virtual void validate(); - virtual void execute(const SymbolTablePtr&); - -private: - - map<string, DatabaseDescriptorPtr> _databases; - vector<DescriptorPtr> _children; -}; -typedef IceUtil::Handle<TransformDBDescriptor> TransformDBDescriptorPtr; - -// -// SymbolTableI -// -class SymbolTableI : public SymbolTable -{ -public: - - SymbolTableI(const TransformInfoIPtr&, const SymbolTablePtr& = SymbolTablePtr()); - - virtual void add(const string&, const DataPtr&); - - virtual DataPtr getValue(const EntityNodePtr&) const; - - virtual DataPtr getConstantValue(const string&) const; - - virtual SymbolTablePtr createChild(); - - virtual Slice::TypePtr lookupType(const string&); - - virtual DataPtr invokeFunction(const string&, const DataPtr&, const DataList&); - -private: - - DataPtr findValue(const string&) const; - - class EntityVisitor : public EntityNodeVisitor - { - public: - - EntityVisitor(SymbolTableI*); - - virtual void visitIdentifier(const string&); - virtual void visitElement(const NodePtr&); - - DataPtr getCurrent() const; - - private: - - SymbolTableI* _table; - DataPtr _current; - bool _error; - }; - - friend class EntityVisitor; - - TransformInfoIPtr _info; - SymbolTablePtr _parent; - typedef map<string, DataPtr> DataMap; - DataMap _dataMap; - DataMap _constantCache; -}; -typedef IceUtil::Handle<SymbolTableI> SymbolTableIPtr; - -// -// ObjectVisitor -// -class ObjectVisitor : public DataVisitor -{ -public: - - ObjectVisitor(ObjectDataMap&); - - virtual void visitStruct(const StructDataPtr&); - virtual void visitSequence(const SequenceDataPtr&); - virtual void visitDictionary(const DictionaryDataPtr&); - virtual void visitObject(const ObjectRefPtr&); - -private: - - ObjectDataMap& _map; -}; - -// -// DescriptorHandler -// -class DescriptorHandler : public IceXML::Handler -{ -public: - - DescriptorHandler(const TransformInfoIPtr&); - - virtual void startElement(const string&, const IceXML::Attributes&, int, int); - virtual void endElement(const string&, int, int); - virtual void characters(const string&, int, int); - virtual void error(const string&, int, int); - - TransformDBDescriptorPtr descriptor() const; - -private: - - TransformInfoIPtr _info; - DescriptorPtr _current; - TransformDBDescriptorPtr _descriptor; -}; - -void assignOrTransform(const DataPtr&, const DataPtr&, bool, const TransformInfoPtr&); - -} // End of namespace FreezeScript - -// -// TransformDataFactory -// -FreezeScript::TransformDataFactory::TransformDataFactory(const Ice::CommunicatorPtr& communicator, - const Slice::UnitPtr& unit, - const ErrorReporterPtr& errorReporter) : - DataFactory(communicator, unit, errorReporter), _enabled(true) -{ -} - -void -FreezeScript::TransformDataFactory::addInitDescriptor(const InitDescriptorPtr& init) -{ - string typeName = init->typeName(); - assert(_initMap.find(typeName) == _initMap.end()); - _initMap.insert(InitMap::value_type(typeName, init)); -} - -void -FreezeScript::TransformDataFactory::initialize(const DataPtr& data) -{ - if(_enabled) - { - string typeName = typeToString(data->getType()); - InitMap::iterator p = _initMap.find(typeName); - if(p != _initMap.end()) - { - p->second->initialize(data); - } - } -} - -void -FreezeScript::TransformDataFactory::disableInitializers() -{ - _enabled = false; -} - -void -FreezeScript::TransformDataFactory::enableInitializers() -{ - _enabled = true; -} - -// -// Descriptor -// -FreezeScript::Descriptor::Descriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info) : - _parent(parent), _line(line), _info(info) -{ -} - -FreezeScript::Descriptor::~Descriptor() -{ -} - -FreezeScript::DescriptorPtr -FreezeScript::Descriptor::parent() const -{ - return _parent; -} - -FreezeScript::NodePtr -FreezeScript::Descriptor::parse(const string& expr) const -{ - return parseExpression(expr, _info->factory, _info->errorReporter); -} - -Slice::TypePtr -FreezeScript::Descriptor::findType(const Slice::UnitPtr& u, const string& type) -{ - Slice::TypeList l; - - l = u->lookupType(type, false); - if(l.empty()) - { - _info->errorReporter->error("unknown type `" + type + "'"); - } - - return l.front(); -} - -// -// SetDescriptor -// -FreezeScript::SetDescriptor::SetDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - DescriptorErrorContext ctx(_info->errorReporter, "set", _line); - - IceXML::Attributes::const_iterator p; - - string target; - p = attributes.find("target"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("type"); - if(p != attributes.end()) - { - _type = p->second; - } - - p = attributes.find("length"); - if(p != attributes.end()) - { - _lengthStr = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - if(!_valueStr.empty() && !_type.empty()) - { - _info->errorReporter->error("attributes `value' and 'type' are mutually exclusive"); - } - - if(_valueStr.empty() && _type.empty() && _lengthStr.empty()) - { - _info->errorReporter->error("requires a value for attributes `value', 'type' or 'length'"); - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _info->errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } - - if(!_lengthStr.empty()) - { - _length = parse(_lengthStr); - } -} - -void -FreezeScript::SetDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "set", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::SetDescriptor::validate() -{ -} - -void -FreezeScript::SetDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "set", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - Destroyer<DataPtr> valueDestroyer; - if(!_type.empty()) - { - assert(!value); - Slice::TypePtr type = sym->lookupType(_type); - if(!type) - { - _info->errorReporter->error("type `" + _type + "' not found"); - } - value = _info->factory->createObject(type, false); - valueDestroyer.set(value); - } - - DataPtr length; - if(_length) - { - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a sequence"); - } - - try - { - length = _length->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of length `" + _lengthStr + "' failed:\n" + ex.reason()); - } - - DataList& elements = seq->getElements(); - Ice::Long l = length->integerValue(); - if(l < 0 || l > INT_MAX) - { - _info->errorReporter->error("sequence length " + length->toString() + " is out of range"); - } - - DataList::size_type len = static_cast<DataList::size_type>(l); - if(len < elements.size()) - { - for(DataList::size_type i = len; i < elements.size(); ++i) - { - elements[i]->destroy(); - } - elements.resize(len); - } - else if(len > elements.size()) - { - Slice::SequencePtr seqType = Slice::SequencePtr::dynamicCast(seq->getType()); - assert(seqType); - Slice::TypePtr elemType = seqType->type(); - for(DataList::size_type i = elements.size(); i < len; ++i) - { - DataPtr v = _info->factory->create(elemType, false); - if(value) - { - assignOrTransform(v, value, _convert, _info); - } - elements.push_back(v); - } - } - } - else - { - assignOrTransform(data, value, _convert, _info); - } -} - -// -// DefineDescriptor -// -FreezeScript::DefineDescriptor::DefineDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - DescriptorErrorContext ctx(_info->errorReporter, "define", _line); - - IceXML::Attributes::const_iterator p; - - p = attributes.find("name"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `name' is missing"); - } - _name = p->second; - - p = attributes.find("type"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `type' is missing"); - } - if(p->second.find("::New") != string::npos) - { - Slice::TypeList l = _info->newUnit->lookupType(p->second.substr(5), false); - if(l.empty()) - { - _info->errorReporter->error("type `" + p->second + "' not found"); - } - _type = l.front(); - } - else if(p->second.find("::Old") != string::npos) - { - Slice::TypeList l = _info->oldUnit->lookupType(p->second.substr(5), false); - if(l.empty()) - { - _info->errorReporter->error("type `" + p->second + "' not found"); - } - _type = l.front(); - } - else - { - Slice::TypeList l = _info->newUnit->lookupType(p->second, false); - if(l.empty()) - { - _info->errorReporter->error("type `" + p->second + "' not found"); - } - _type = l.front(); - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::DefineDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "define", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::DefineDescriptor::validate() -{ -} - -void -FreezeScript::DefineDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "define", _line); - - DataPtr data = _info->factory->create(_type, false); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - if(value) - { - assignOrTransform(data, value, _convert, _info); - } - - sym->add(_name, data); -} - -// -// AddDescriptor -// -FreezeScript::AddDescriptor::AddDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - DescriptorErrorContext ctx(_info->errorReporter, "add", _line); - - IceXML::Attributes::const_iterator p; - - string target; - p = attributes.find("target"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _keyStr = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _indexStr = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - p = attributes.find("type"); - if(p != attributes.end()) - { - _type = p->second; - } - - p = attributes.find("convert"); - if(p != attributes.end()) - { - _convert = p->second == "true"; - } - - if(!_keyStr.empty() && !_indexStr.empty()) - { - _info->errorReporter->error("attributes `key' and `index' are mutually exclusive"); - } - - if(_keyStr.empty() && _indexStr.empty()) - { - _info->errorReporter->error("one of attributes `key' or `index' is required"); - } - - if(!_valueStr.empty() && !_type.empty()) - { - _info->errorReporter->error("attributes `value' and `type' are mutually exclusive"); - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _info->errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } - - if(!_keyStr.empty()) - { - _key = parse(_keyStr); - } - - if(!_indexStr.empty()) - { - _index = parse(_indexStr); - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::AddDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "add", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::AddDescriptor::validate() -{ -} - -void -FreezeScript::AddDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "add", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - if(_key) - { - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - if(!dict) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a dictionary"); - } - - Slice::DictionaryPtr type = Slice::DictionaryPtr::dynamicCast(dict->getType()); - assert(type); - - DataPtr key; - Destroyer<DataPtr> keyDestroyer; - try - { - DataPtr v = _key->evaluate(sym); - key = _info->factory->create(type->keyType(), false); - keyDestroyer.set(key); - assignOrTransform(key, v, _convert, _info); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of key `" + _keyStr + "' failed:\n" + ex.reason()); - } - - if(dict->getElement(key)) - { - ostringstream ostr; - printData(key, ostr); - _info->errorReporter->error("key " + ostr.str() + " already exists in dictionary"); - } - - DataPtr elem = _info->factory->create(type->valueType(), false); - Destroyer<DataPtr> elemDestroyer(elem); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - Destroyer<DataPtr> valueDestroyer; - if(!_type.empty()) - { - assert(!value); - Slice::TypePtr type = sym->lookupType(_type); - if(!type) - { - _info->errorReporter->error("type `" + _type + "' not found"); - } - value = _info->factory->createObject(type, false); - valueDestroyer.set(value); - } - - if(value) - { - assignOrTransform(elem, value, _convert, _info); - } - DataMap& map = dict->getElements(); - map.insert(DataMap::value_type(key, elem)); - keyDestroyer.release(); - elemDestroyer.release(); - } - else - { - assert(_index); - - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a sequence"); - } - - Slice::SequencePtr type = Slice::SequencePtr::dynamicCast(seq->getType()); - assert(type); - - DataPtr index; - Destroyer<DataPtr> indexDestroyer; - try - { - index = _index->evaluate(sym); - indexDestroyer.set(index); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of index `" + _indexStr + "' failed:\n" + ex.reason()); - } - - DataList& elements = seq->getElements(); - Ice::Long l = index->integerValue(); - DataList::size_type i = static_cast<DataList::size_type>(l); - if(l < 0 || l > INT_MAX || i > elements.size()) - { - _info->errorReporter->error("sequence index " + index->toString() + " is out of range"); - } - - DataPtr elem = _info->factory->create(type->type(), false); - Destroyer<DataPtr> elemDestroyer(elem); - - DataPtr value; - if(_value) - { - try - { - value = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - } - - Destroyer<DataPtr> valueDestroyer; - if(!_type.empty()) - { - assert(!value); - Slice::TypePtr type = sym->lookupType(_type); - if(!type) - { - _info->errorReporter->error("type `" + _type + "' not found"); - } - value = _info->factory->createObject(type, false); - valueDestroyer.set(value); - } - - if(value) - { - assignOrTransform(elem, value, _convert, _info); - } - - elements.insert(elements.begin() + i, elem); - indexDestroyer.release(); - elemDestroyer.release(); - } -} - -// -// RemoveDescriptor -// -FreezeScript::RemoveDescriptor::RemoveDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - DescriptorErrorContext ctx(_info->errorReporter, "remove", _line); - - IceXML::Attributes::const_iterator p; - - string target; - p = attributes.find("target"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _keyStr = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _indexStr = p->second; - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _info->errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } - - if(!_keyStr.empty() && !_indexStr.empty()) - { - _info->errorReporter->error("attributes `key' and `index' are mutually exclusive"); - } - - if(_keyStr.empty() && _indexStr.empty()) - { - _info->errorReporter->error("one of attributes `key' or `index' is required"); - } - - if(!_keyStr.empty()) - { - _key = parse(_keyStr); - } - - if(!_indexStr.empty()) - { - _index = parse(_indexStr); - } -} - -void -FreezeScript::RemoveDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "remove", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::RemoveDescriptor::validate() -{ -} - -void -FreezeScript::RemoveDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "remove", _line); - - DataPtr data = sym->getValue(_target); - if(data->readOnly()) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' cannot be modified"); - } - - if(_key) - { - DataPtr key; - try - { - key = _key->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of key `" + _keyStr + "' failed:\n" + ex.reason()); - } - - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - if(!dict) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a dictionary"); - } - - DataMap& map = dict->getElements(); - DataMap::iterator p = map.find(key); - if(p != map.end()) - { - p->first->destroy(); - p->second->destroy(); - map.erase(p); - } - } - else - { - assert(_index); - - DataPtr index; - try - { - index = _index->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of index `" + _indexStr + "' failed:\n" + ex.reason()); - } - - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!seq) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a sequence"); - } - - DataList& elements = seq->getElements(); - Ice::Long l = index->integerValue(); - DataList::size_type i = static_cast<DataList::size_type>(l); - if(l < 0 || l > INT_MAX || i >= elements.size()) - { - _info->errorReporter->error("sequence index " + index->toString() + " is out of range"); - } - - elements[i]->destroy(); - elements.erase(elements.begin() + i); - } -} - -// -// DeleteDescriptor -// -FreezeScript::DeleteDescriptor::DeleteDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes&) : - Descriptor(parent, line, info) -{ -} - -void -FreezeScript::DeleteDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "delete", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::DeleteDescriptor::validate() -{ -} - -void -FreezeScript::DeleteDescriptor::execute(const SymbolTablePtr&) -{ - throw DeleteRecordException(); -} - -// -// FailDescriptor -// -FreezeScript::FailDescriptor::FailDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - IceXML::Attributes::const_iterator p; - - p = attributes.find("test"); - if(p != attributes.end()) - { - _testStr = p->second; - } - - p = attributes.find("message"); - if(p != attributes.end()) - { - _message = p->second; - } - - if(!_testStr.empty()) - { - _test = parse(_testStr); - } - - if(_message.empty()) - { - ostringstream ostr; - ostr << "<fail> executed at line " << line << endl; - _message = ostr.str(); - } -} - -void -FreezeScript::FailDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "fail", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::FailDescriptor::validate() -{ -} - -void -FreezeScript::FailDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "fail", _line); - - if(_test) - { - try - { - DataPtr b = _test->evaluate(sym); - BooleanDataPtr bd = BooleanDataPtr::dynamicCast(b); - if(!bd) - { - _info->errorReporter->error("expression `" + _testStr + "' does not evaluate to a boolean"); - } - if(!bd->booleanValue()) - { - return; - } - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of expression `" + _testStr + "' failed:\n" + ex.reason()); - } - } - - throw FailureException(__FILE__, __LINE__, _message); -} - -// -// EchoDescriptor -// -FreezeScript::EchoDescriptor::EchoDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - Descriptor(parent, line, info) -{ - IceXML::Attributes::const_iterator p; - - p = attributes.find("message"); - if(p != attributes.end()) - { - _message = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _valueStr = p->second; - } - - if(!_valueStr.empty()) - { - _value = parse(_valueStr); - } -} - -void -FreezeScript::EchoDescriptor::addChild(const DescriptorPtr&) -{ - DescriptorErrorContext ctx(_info->errorReporter, "echo", _line); - _info->errorReporter->error("child elements are not supported"); -} - -void -FreezeScript::EchoDescriptor::validate() -{ -} - -void -FreezeScript::EchoDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "echo", _line); - - ostream& out = _info->errorReporter->stream(); - - if(!_message.empty()) - { - out << _message; - } - - if(_value) - { - DataPtr v; - try - { - v = _value->evaluate(sym); - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of value `" + _valueStr + "' failed:\n" + ex.reason()); - } - printData(v, out); - } - - out << endl; -} - -// -// ExecutableContainerDescriptor -// -FreezeScript::ExecutableContainerDescriptor::ExecutableContainerDescriptor(const DescriptorPtr& parent, int line, - const TransformInfoIPtr& info, - const IceXML::Attributes&, - const string& name) : - Descriptor(parent, line, info), _name(name) -{ -} - -void -FreezeScript::ExecutableContainerDescriptor::addChild(const DescriptorPtr& child) -{ - _children.push_back(child); -} - -void -FreezeScript::ExecutableContainerDescriptor::validate() -{ - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->validate(); - } -} - -void -FreezeScript::ExecutableContainerDescriptor::execute(const SymbolTablePtr& sym) -{ - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->execute(sym); - } -} - -// -// IfDescriptor -// -FreezeScript::IfDescriptor::IfDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "if") -{ - DescriptorErrorContext ctx(_info->errorReporter, "if", _line); - - IceXML::Attributes::const_iterator p = attributes.find("test"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `test' is missing"); - } - _testStr = p->second; - - _test = parse(_testStr); -} - -void -FreezeScript::IfDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "if", _line); - - try - { - DataPtr b = _test->evaluate(sym); - BooleanDataPtr bd = BooleanDataPtr::dynamicCast(b); - if(!bd) - { - _info->errorReporter->error("expression `" + _testStr + "' does not evaluate to a boolean"); - } - if(bd->booleanValue()) - { - ExecutableContainerDescriptor::execute(sym); - } - } - catch(const EvaluateException& ex) - { - _info->errorReporter->error("evaluation of conditional expression `" + _testStr + "' failed:\n" + ex.reason()); - } -} - -// -// IterateDescriptor -// -FreezeScript::IterateDescriptor::IterateDescriptor(const DescriptorPtr& parent, int line, - const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "iterate") -{ - DescriptorErrorContext ctx(_info->errorReporter, "iterate", _line); - - IceXML::Attributes::const_iterator p; - string target; - - p = attributes.find("target"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `target' is missing"); - } - target = p->second; - - p = attributes.find("key"); - if(p != attributes.end()) - { - _key = p->second; - } - - p = attributes.find("value"); - if(p != attributes.end()) - { - _value = p->second; - } - - p = attributes.find("element"); - if(p != attributes.end()) - { - _element = p->second; - } - - p = attributes.find("index"); - if(p != attributes.end()) - { - _index = p->second; - } - - NodePtr node = parse(target); - _target = EntityNodePtr::dynamicCast(node); - if(!_target) - { - _info->errorReporter->error("`target' attribute is not an entity: `" + target + "'"); - } -} - -void -FreezeScript::IterateDescriptor::execute(const SymbolTablePtr& sym) -{ - DescriptorErrorContext ctx(_info->errorReporter, "iterate", _line); - - DataPtr data = sym->getValue(_target); - - DictionaryDataPtr dict = DictionaryDataPtr::dynamicCast(data); - SequenceDataPtr seq = SequenceDataPtr::dynamicCast(data); - if(!dict && !seq) - { - ostringstream ostr; - ostr << _target; - _info->errorReporter->error("target `" + ostr.str() + "' is not a dictionary or sequence"); - } - - if(dict) - { - if(!_element.empty()) - { - _info->errorReporter->error("attribute `element' specified for dictionary target"); - } - if(!_index.empty()) - { - _info->errorReporter->error("attribute `index' specified for dictionary target"); - } - - string key = _key; - if(key.empty()) - { - key = "key"; - } - - string value = _value; - if(value.empty()) - { - value = "value"; - } - - DataMap& map = dict->getElements(); - for(DataMap::iterator p = map.begin(); p != map.end(); ++p) - { - SymbolTablePtr elemSym = sym->createChild(); - elemSym->add(key, p->first); - elemSym->add(value, p->second); - ExecutableContainerDescriptor::execute(elemSym); - } - } - else - { - if(!_key.empty()) - { - _info->errorReporter->error("attribute `key' specified for sequence target"); - } - if(!_value.empty()) - { - _info->errorReporter->error("attribute `value' specified for sequence target"); - } - - string element = _element; - if(element.empty()) - { - element = "elem"; - } - - string index = _index; - if(index.empty()) - { - index = "i"; - } - - // - // NOTE: Don't use iterator to traverse vector because child descriptors might remove elements. - // - DataList& l = seq->getElements(); - DataList::size_type i = 0; - while(i < l.size()) - { - SymbolTablePtr elemSym = sym->createChild(); - elemSym->add(element, l[i]); - elemSym->add(index, _info->factory->createInteger(i, true)); - ExecutableContainerDescriptor::execute(elemSym); - ++i; - } - } -} - -// -// TransformDescriptor -// -FreezeScript::TransformDescriptor::TransformDescriptor(const DescriptorPtr& parent, int line, - const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "transform"), _default(true), _base(true) -{ - DescriptorErrorContext ctx(_info->errorReporter, "transform", _line); - - IceXML::Attributes::const_iterator p; - - string type, rename; - - p = attributes.find("type"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `type' is missing"); - } - type = p->second; - - p = attributes.find("default"); - if(p != attributes.end()) - { - if(p->second == "false") - { - _default = false; - } - } - - p = attributes.find("base"); - if(p != attributes.end()) - { - if(p->second == "false") - { - _base = false; - } - } - - p = attributes.find("rename"); - if(p != attributes.end()) - { - rename = p->second; - } - - Slice::TypeList l; - - l = _info->newUnit->lookupType(type, false); - if(l.empty()) - { - _info->errorReporter->error("unable to find type `" + type + "' in new Slice definitions"); - } - else - { - _newType = l.front(); - } - - if(!rename.empty()) - { - l = _info->oldUnit->lookupType(rename, false); - if(l.empty()) - { - _info->errorReporter->error("unable to find type `" + rename + "' in old Slice definitions"); - } - _renameType = l.front(); - } -} - -Slice::TypePtr -FreezeScript::TransformDescriptor::type() const -{ - return _newType; -} - -string -FreezeScript::TransformDescriptor::typeName() const -{ - return typeToString(_newType); -} - -Slice::TypePtr -FreezeScript::TransformDescriptor::renameType() const -{ - return _renameType; -} - -string -FreezeScript::TransformDescriptor::renameTypeName() const -{ - string result; - if(_renameType) - { - result = typeToString(_renameType); - } - return result; -} - -bool -FreezeScript::TransformDescriptor::doDefaultTransform() const -{ - return _default; -} - -bool -FreezeScript::TransformDescriptor::doBaseTransform() const -{ - return _base; -} - -// -// InitDescriptor -// -FreezeScript::InitDescriptor::InitDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "init") -{ - DescriptorErrorContext ctx(_info->errorReporter, "init", _line); - - IceXML::Attributes::const_iterator p = attributes.find("type"); - - string type; - - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `type' is missing"); - } - type = p->second; - - Slice::TypeList l = _info->newUnit->lookupType(type, false); - if(l.empty()) - { - _info->errorReporter->error("unable to find type `" + type + "' in new Slice definitions"); - } - else - { - _type = l.front(); - } -} - -void -FreezeScript::InitDescriptor::initialize(const DataPtr& data) -{ - SymbolTablePtr sym = new SymbolTableI(_info, _info->symbolTable); - sym->add("value", data); - execute(sym); -} - -string -FreezeScript::InitDescriptor::typeName() const -{ - return typeToString(_type); -} - -// -// RecordDescriptor -// -FreezeScript::RecordDescriptor::RecordDescriptor(const DescriptorPtr& parent, int line, const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "record") -{ -} - -void -FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& /*sym*/) -{ - // - // Temporarily add an object factory. - // - _info->objectFactory->activate(_info->factory, _info->oldUnit); - - // - // Iterate over the database. - // - Dbc* dbc = 0; - _info->oldDb->cursor(0, &dbc, 0); - try - { - Dbt dbKey, dbValue; - while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) - { - Ice::ByteSeq inKeyBytes; - inKeyBytes.resize(dbKey.get_size()); - memcpy(&inKeyBytes[0], dbKey.get_data(), dbKey.get_size()); - - Ice::ByteSeq inValueBytes; - inValueBytes.resize(dbValue.get_size()); - memcpy(&inValueBytes[0], dbValue.get_data(), dbValue.get_size()); - - try - { - Ice::ByteSeq outKeyBytes, outValueBytes; - transformRecord(inKeyBytes, inValueBytes, outKeyBytes, outValueBytes); - Dbt dbNewKey(&outKeyBytes[0], static_cast<unsigned>(outKeyBytes.size())), - dbNewValue(&outValueBytes[0], static_cast<unsigned>(outValueBytes.size())); - if(_info->newDb->put(_info->newDbTxn, &dbNewKey, &dbNewValue, DB_NOOVERWRITE) == DB_KEYEXIST) - { - _info->errorReporter->error("duplicate key encountered"); - } - } - catch(const DeleteRecordException&) - { - // The record is deleted simply by not adding it to the new database. - } - catch(const ClassNotFoundException& ex) - { - if(!_info->purge) - { - _info->errorReporter->error("class " + ex.id + " not found in new Slice definitions"); - } - else - { - // The record is deleted simply by not adding it to the new database. - _info->errorReporter->warning("purging database record due to missing class type " + ex.id); - } - } - } - } - catch(...) - { - if(dbc) - { - dbc->close(); - } - _info->objectFactory->deactivate(); - throw; - } - - if(dbc) - { - dbc->close(); - } - _info->objectFactory->deactivate(); -} - -void -FreezeScript::RecordDescriptor::transformRecord(const Ice::ByteSeq& inKeyBytes, - const Ice::ByteSeq& inValueBytes, - Ice::ByteSeq& outKeyBytes, - Ice::ByteSeq& outValueBytes) -{ - Ice::InputStreamPtr inKey = Ice::wrapInputStream(_info->communicator, inKeyBytes); - Ice::InputStreamPtr inValue = Ice::wrapInputStream(_info->communicator, inValueBytes); - inValue->startEncapsulation(); - - Ice::OutputStreamPtr outKey = Ice::createOutputStream(_info->communicator); - Ice::OutputStreamPtr outValue = Ice::createOutputStream(_info->communicator); - outValue->startEncapsulation(); - - // - // Create data representations of the old key and value types. - // - _info->factory->disableInitializers(); - DataPtr oldKeyData = _info->factory->create(_info->oldKeyType, true); - Destroyer<DataPtr> oldKeyDataDestroyer(oldKeyData); - DataPtr oldValueData = _info->factory->create(_info->oldValueType, true); - Destroyer<DataPtr> oldValueDataDestroyer(oldValueData); - - // - // Unmarshal the old key and value. - // - oldKeyData->unmarshal(inKey); - oldValueData->unmarshal(inValue); - _info->objectDataMap.clear(); - if(_info->oldValueType->usesClasses()) - { - inValue->readPendingObjects(); - ObjectVisitor visitor(_info->objectDataMap); - oldValueData->visit(visitor); - } - _info->factory->enableInitializers(); - - // - // Create data representations of the new key and value types. - // - DataPtr newKeyData = _info->factory->create(_info->newKeyType, false); - Destroyer<DataPtr> newKeyDataDestroyer(newKeyData); - DataPtr newValueData = _info->factory->create(_info->newValueType, false); - Destroyer<DataPtr> newValueDataDestroyer(newValueData); - DataPtr facetData = _info->factory->createString(_info->facet, true); - Destroyer<DataPtr> facetDataDestroyer(facetData); - - // - // Copy the data from the old key and value to the new key and value, if possible. - // - TransformVisitor keyVisitor(oldKeyData, _info); - newKeyData->visit(keyVisitor); - TransformVisitor valueVisitor(oldValueData, _info); - newValueData->visit(valueVisitor); - - if(!_children.empty()) - { - // - // Execute the child descriptors. - // - // TODO: Revisit identifiers. - // - SymbolTablePtr st = new SymbolTableI(_info, _info->symbolTable); - st->add("oldkey", oldKeyData); - st->add("newkey", newKeyData); - st->add("oldvalue", oldValueData); - st->add("newvalue", newValueData); - st->add("facet", facetData); - ExecutableContainerDescriptor::execute(st); - } - - newKeyData->marshal(outKey); - newValueData->marshal(outValue); - - outKey->finished(outKeyBytes); - - if(_info->newValueType->usesClasses()) - { - outValue->writePendingObjects(); - } - outValue->endEncapsulation(); - outValue->finished(outValueBytes); -} - -// -// DatabaseDescriptor -// -FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent, int line, - const TransformInfoIPtr& info, - const IceXML::Attributes& attributes) : - ExecutableContainerDescriptor(parent, line, info, attributes, "database") -{ - DescriptorErrorContext ctx(_info->errorReporter, "database", _line); - - IceXML::Attributes::const_iterator p; - - p = attributes.find("name"); - if(p != attributes.end()) - { - _name = p->second; - } - - p = attributes.find("key"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `key' is missing"); - } - string keyTypes = p->second; - - p = attributes.find("value"); - if(p == attributes.end()) - { - _info->errorReporter->error("required attribute `value' is missing"); - } - string valueTypes = p->second; - - string::size_type pos; - - pos = keyTypes.find(','); - if(pos == 0 || pos == keyTypes.size()) - { - _info->errorReporter->error("invalid key type specification `" + keyTypes +"'"); - } - if(pos == string::npos) - { - _oldKeyName = keyTypes; - _newKeyName = keyTypes; - } - else - { - _oldKeyName = keyTypes.substr(0, pos); - _newKeyName = keyTypes.substr(pos + 1); - } - - pos = valueTypes.find(','); - if(pos == 0 || pos == valueTypes.size()) - { - _info->errorReporter->error("invalid value type specification `" + valueTypes +"'"); - } - if(pos == string::npos) - { - _oldValueName = valueTypes; - _newValueName = valueTypes; - } - else - { - _oldValueName = valueTypes.substr(0, pos); - _newValueName = valueTypes.substr(pos + 1); - } -} - -void -FreezeScript::DatabaseDescriptor::addChild(const DescriptorPtr& child) -{ - DescriptorErrorContext ctx(_info->errorReporter, "database", _line); - - RecordDescriptorPtr rec = RecordDescriptorPtr::dynamicCast(child); - if(rec) - { - if(_record) - { - _info->errorReporter->error("only one <record> element can be specified"); - } - _record = rec; - } - - ExecutableContainerDescriptor::addChild(child); -} - -void -FreezeScript::DatabaseDescriptor::execute(const SymbolTablePtr& st) -{ - DescriptorErrorContext ctx(_info->errorReporter, "database", _line); - - // - // Look up the Slice definitions for the key and value types. - // - _info->oldKeyType = findType(_info->oldUnit, _oldKeyName); - _info->newKeyType = findType(_info->newUnit, _newKeyName); - _info->oldValueType = findType(_info->oldUnit, _oldValueName); - _info->newValueType = findType(_info->newUnit, _newValueName); - - if(_info->connection != 0) - { - Freeze::Catalog catalog(_info->connection, Freeze::catalogName()); - Freeze::CatalogData catalogData; - catalogData.evictor = false; - catalogData.key = _info->newKeyType->typeId(); - catalogData.value = _info->newValueType->typeId(); - catalog.put(Freeze::Catalog::value_type(_info->newDbName, catalogData)); - } - - // - // TODO: it looks like _info is not destroyed before the new dbEnv is closed. - // - _info->connection = 0; - - ExecutableContainerDescriptor::execute(st); -} - -string -FreezeScript::DatabaseDescriptor::name() const -{ - return _name; -} - -// -// TransformDBDescriptor -// -FreezeScript::TransformDBDescriptor::TransformDBDescriptor(int line, const TransformInfoIPtr& info, - const IceXML::Attributes&) : - Descriptor(0, line, info) -{ -} - -FreezeScript::TransformDBDescriptor::~TransformDBDescriptor() -{ -} - -void -FreezeScript::TransformDBDescriptor::addChild(const DescriptorPtr& child) -{ - DescriptorErrorContext ctx(_info->errorReporter, "transformdb", _line); - - DatabaseDescriptorPtr db = DatabaseDescriptorPtr::dynamicCast(child); - TransformDescriptorPtr transform = TransformDescriptorPtr::dynamicCast(child); - InitDescriptorPtr init = InitDescriptorPtr::dynamicCast(child); - - if(db) - { - string name = db->name(); - map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(name); - if(p != _databases.end()) - { - if(name.empty()) - { - _info->errorReporter->error("duplicate <database> element"); - } - else - { - _info->errorReporter->error(string("duplicate <database> element for ") + name); - } - } - else - { - _databases[name] = db; - _children.push_back(db); - } - } - else if(transform) - { - string name = transform->typeName(); - TransformMap::iterator p = _info->transformMap.find(name); - if(p != _info->transformMap.end()) - { - _info->errorReporter->error("transform `" + name + "' specified more than once"); - } - _info->transformMap.insert(TransformMap::value_type(name, transform)); - - string renameTypeName = transform->renameTypeName(); - if(!renameTypeName.empty()) - { - RenameMap::iterator q = _info->renameMap.find(renameTypeName); - if(q != _info->renameMap.end()) - { - _info->errorReporter->error("multiple transform descriptors specify the rename value `" + - renameTypeName + "'"); - } - _info->renameMap.insert(RenameMap::value_type(renameTypeName, transform->type())); - } - - _children.push_back(transform); - } - else if(init) - { - _info->factory->addInitDescriptor(init); - _children.push_back(init); - } - else - { - _info->errorReporter->error("invalid child element"); - } -} - -void -FreezeScript::TransformDBDescriptor::validate() -{ - DescriptorErrorContext ctx(_info->errorReporter, "transformdb", _line); - - if(_databases.empty()) - { - _info->errorReporter->error("no <database> element defined"); - } - - for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p) - { - (*p)->validate(); - } -} - -void -FreezeScript::TransformDBDescriptor::execute(const SymbolTablePtr& sym) -{ - map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(_info->newDbName); - if(p == _databases.end()) - { - p = _databases.find(""); - } - - if(p == _databases.end()) - { - _info->errorReporter->error("no <database> element found for `" + _info->newDbName + "'"); - } - - p->second->execute(sym); -} - -// -// SymbolTableI -// -FreezeScript::SymbolTableI::SymbolTableI(const TransformInfoIPtr& info, const SymbolTablePtr& parent) : - _info(info), _parent(parent) -{ -} - -void -FreezeScript::SymbolTableI::add(const string& name, const DataPtr& data) -{ - DataMap::const_iterator p = _dataMap.find(name); - if(p != _dataMap.end()) - { - _info->errorReporter->error("`" + name + "' is already defined"); - } - - _dataMap.insert(DataMap::value_type(name, data)); -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::getValue(const EntityNodePtr& entity) const -{ - EntityVisitor visitor(const_cast<SymbolTableI*>(this)); - entity->visit(visitor); - DataPtr result = visitor.getCurrent(); - if(!result) - { - ostringstream ostr; - ostr << "invalid entity `" << entity << "'"; - _info->errorReporter->error(ostr.str()); - } - - return result; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::getConstantValue(const string& name) const -{ - string::size_type pos; - Slice::UnitPtr unit; - string key; - - DataMap::const_iterator p = _constantCache.find(name); - if(p != _constantCache.end()) - { - return p->second; - } - - if(_parent) - { - return _parent->getConstantValue(name); - } - - // - // Name must start with "::Old" or "::New" to indicate the Slice unit. - // - pos = name.find("::Old"); - if(pos == 0) - { - if(name.length() > 5) - { - key = name.substr(5); - unit = _info->oldUnit; - } - } - else - { - pos = name.find("::New"); - if(pos == 0) - { - if(name.length() > 5) - { - key = name.substr(5); - unit = _info->newUnit; - } - } - } - - if(key.empty()) - { - _info->errorReporter->error("invalid constant name `" + name + "'"); - } - - Slice::ContainedList l = unit->findContents(key); - if(l.empty()) - { - _info->errorReporter->error("unknown constant `" + name + "'"); - } - - Slice::EnumeratorPtr e = Slice::EnumeratorPtr::dynamicCast(l.front()); - Slice::ConstPtr c = Slice::ConstPtr::dynamicCast(l.front()); - if(!e && !c) - { - _info->errorReporter->error("`" + name + "' does not refer to a Slice constant or enumerator"); - } - - DataPtr result; - - if(c) - { - Slice::TypePtr type = c->type(); - string value = c->value(); - Slice::BuiltinPtr b = Slice::BuiltinPtr::dynamicCast(type); - if(b) - { - switch(b->kind()) - { - case Slice::Builtin::KindByte: - case Slice::Builtin::KindShort: - case Slice::Builtin::KindInt: - case Slice::Builtin::KindLong: - { - Ice::Long n; - if(!IceUtilInternal::stringToInt64(value, n)) - { - assert(false); - } - result = _info->factory->createInteger(n, true); - break; - } - - case Slice::Builtin::KindBool: - { - result = _info->factory->createBoolean(value == "true", true); - break; - } - - case Slice::Builtin::KindFloat: - case Slice::Builtin::KindDouble: - { - double v = strtod(value.c_str(), 0); - result = _info->factory->createDouble(v, true); - break; - } - - case Slice::Builtin::KindString: - { - result = _info->factory->createString(value, true); - break; - } - - case Slice::Builtin::KindObject: - case Slice::Builtin::KindObjectProxy: - case Slice::Builtin::KindLocalObject: - assert(false); - } - } - else - { - Slice::EnumPtr en = Slice::EnumPtr::dynamicCast(type); - assert(en); - Slice::EnumeratorList el = en->getEnumerators(); - for(Slice::EnumeratorList::iterator q = el.begin(); q != el.end(); ++q) - { - if((*q)->name() == value) - { - e = *q; - break; - } - } - assert(e); - } - } - - if(!result) - { - assert(e); - result = _info->factory->create(e->type(), true); - EnumDataPtr ed = EnumDataPtr::dynamicCast(result); - assert(ed); - ed->setValueAsString(e->name()); - } - - // - // Cache the value. - // - const_cast<DataMap&>(_constantCache).insert(DataMap::value_type(name, result)); - - return result; -} - -FreezeScript::SymbolTablePtr -FreezeScript::SymbolTableI::createChild() -{ - return new SymbolTableI(_info, this); -} - -Slice::TypePtr -FreezeScript::SymbolTableI::lookupType(const string& name) -{ - Slice::TypeList l = _info->newUnit->lookupType(name, false); - Slice::TypePtr result; - if(!l.empty()) - { - result = l.front(); - } - return result; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::invokeFunction(const string& name, const DataPtr& target, const DataList& args) -{ - if(target) - { - DictionaryDataPtr targetDict = DictionaryDataPtr::dynamicCast(target); - if(targetDict && name == "containsKey") - { - if(args.size() != 1) - { - _info->errorReporter->error("containsKey() requires one argument"); - } - Slice::DictionaryPtr dictType = Slice::DictionaryPtr::dynamicCast(targetDict->getType()); - assert(dictType); - DataPtr key = _info->factory->create(dictType->keyType(), false); - assignOrTransform(key, args[0], false, _info); - DataPtr value = targetDict->getElement(key); - return _info->factory->createBoolean(value ? true : false, false); - } - - DataPtr result; - if(invokeMemberFunction(name, target, args, result, _info->factory, _info->errorReporter)) - { - return result; - } - - _info->errorReporter->error("unknown function `" + name + "' invoked on type " + - typeToString(target->getType())); - } - else - { - // - // Global function. - // - DataPtr result; - if(invokeGlobalFunction(_info->communicator, name, args, result, _info->factory, _info->errorReporter)) - { - return result; - } - else - { - _info->errorReporter->error("unknown global function `" + name + "'"); - } - } - - return 0; -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::findValue(const string& name) const -{ - DataMap::const_iterator p = _dataMap.find(name); - if(p != _dataMap.end()) - { - return p->second; - } - - if(_parent) - { - SymbolTableIPtr parentI = SymbolTableIPtr::dynamicCast(_parent); - assert(parentI); - return parentI->findValue(name); - } - - return 0; -} - -FreezeScript::SymbolTableI::EntityVisitor::EntityVisitor(SymbolTableI* table) : - _table(table), _error(false) -{ -} - -void -FreezeScript::SymbolTableI::EntityVisitor::visitIdentifier(const string& name) -{ - if(!_error) - { - if(!_current) - { - _current = _table->findValue(name); - } - else - { - _current = _current->getMember(name); - } - - if(!_current) - { - _error = true; - } - } -} - -void -FreezeScript::SymbolTableI::EntityVisitor::visitElement(const NodePtr& value) -{ - if(!_error) - { - assert(_current); - - DataPtr val = value->evaluate(_table); - _current = _current->getElement(val); - - if(!_current) - { - _error = true; - } - } -} - -FreezeScript::DataPtr -FreezeScript::SymbolTableI::EntityVisitor::getCurrent() const -{ - return _current; -} - -// -// ObjectVisitor -// -FreezeScript::ObjectVisitor::ObjectVisitor(ObjectDataMap& objectDataMap) : - _map(objectDataMap) -{ -} - -void -FreezeScript::ObjectVisitor::visitStruct(const StructDataPtr& data) -{ - Slice::TypePtr type = data->getType(); - if(type->usesClasses()) - { - DataMemberMap& members = data->getMembers(); - for(DataMemberMap::iterator p = members.begin(); p != members.end(); ++p) - { - p->second->visit(*this); - } - } -} - -void -FreezeScript::ObjectVisitor::visitSequence(const SequenceDataPtr& data) -{ - Slice::TypePtr type = data->getType(); - if(type->usesClasses()) - { - DataList& elements = data->getElements(); - for(DataList::iterator p = elements.begin(); p != elements.end(); ++p) - { - (*p)->visit(*this); - } - } -} - -void -FreezeScript::ObjectVisitor::visitDictionary(const DictionaryDataPtr& data) -{ - Slice::TypePtr type = data->getType(); - if(type->usesClasses()) - { - DataMap& elements = data->getElements(); - for(DataMap::iterator p = elements.begin(); p != elements.end(); ++p) - { - // - // NOTE: There's no need to visit the key. - // - p->second->visit(*this); - } - } -} - -void -FreezeScript::ObjectVisitor::visitObject(const ObjectRefPtr& data) -{ - ObjectDataPtr value = data->getValue(); - if(value) - { - ObjectDataMap::iterator p = _map.find(value.get()); - if(p == _map.end()) - { -#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) - _map.insert(ObjectDataMap::value_type(value.get(), static_cast<ObjectDataPtr>(nullptr))); -#else - _map.insert(ObjectDataMap::value_type(value.get(), 0)); -#endif - DataMemberMap& members = value->getMembers(); - for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q) - { - q->second->visit(*this); - } - } - } -} - -// -// TransformInfoI -// -FreezeScript::DataFactoryPtr -FreezeScript::TransformInfoI::getDataFactory() -{ - return factory; -} - -FreezeScript::ErrorReporterPtr -FreezeScript::TransformInfoI::getErrorReporter() -{ - return errorReporter; -} - -bool -FreezeScript::TransformInfoI::doDefaultTransform(const Slice::TypePtr& type) -{ - TransformMap::const_iterator p = transformMap.find(typeToString(type)); - if(p != transformMap.end()) - { - return p->second->doDefaultTransform(); - } - return true; -} - -bool -FreezeScript::TransformInfoI::doBaseTransform(const Slice::ClassDefPtr& type) -{ - TransformMap::const_iterator p = transformMap.find(type->scoped()); - if(p != transformMap.end()) - { - return p->second->doBaseTransform(); - } - return true; -} - -Slice::TypePtr -FreezeScript::TransformInfoI::getRenamedType(const Slice::TypePtr& old) -{ - RenameMap::iterator p = renameMap.find(typeToString(old)); - if(p != renameMap.end()) - { - return p->second; - } - return 0; -} - -void -FreezeScript::TransformInfoI::executeCustomTransform(const DataPtr& dest, const DataPtr& src) -{ - // - // Execute the type's transform (if any). Non-nil objects need special consideration, - // for two reasons: - // - // 1. The dest and src arguments are ObjectRef instances whose getType() - // function returns the formal type, which may not match the actual type - // if inheritance is being used. Therefore, we need to look for the - // transform of the actual type of the object. - // - // 2. It's not sufficient to execute only the transform for the actual type; - // the transform descriptors for base types must also be executed (if not - // explicitly precluded). - // - // The algorithm goes like this: - // - // 1. If a transform exists for the actual type, execute it. - // 2. If the transform doesn't exist, or if it does exist and does not preclude - // the execution of the base transform, then obtain the base type. If the - // type has no user-defined base class, use Object. - // 3. If a base type was found and a transform exists for the base type, execute it. - // 4. Repeat step 2. - // - ObjectRefPtr obj = ObjectRefPtr::dynamicCast(dest); - if(obj && obj->getValue()) - { - ObjectDataPtr data = obj->getValue(); - Slice::TypePtr cls = data->getType(); // Actual type: may be Builtin (Object) or ClassDecl - bool transformBase = true; - while(cls) - { - string type = typeToString(cls); - TransformMap::const_iterator p = transformMap.find(type); - if(p != transformMap.end()) - { - SymbolTablePtr sym = new SymbolTableI(this, symbolTable); - sym->add("new", dest); - sym->add("old", src); - p->second->execute(sym); - transformBase = p->second->doBaseTransform(); - } - Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(cls); - cls = 0; - if(transformBase && decl) - { - Slice::ClassDefPtr def = decl->definition(); - assert(def); - Slice::ClassList bases = def->bases(); - if(!bases.empty() && !bases.front()->isInterface()) - { - cls = bases.front()->declaration(); - } - else - { - cls = newUnit->builtin(Slice::Builtin::KindObject); - } - } - } - } - else - { - string type = typeToString(dest->getType()); - TransformMap::const_iterator p = transformMap.find(type); - if(p != transformMap.end()) - { - SymbolTablePtr sym = new SymbolTableI(this, symbolTable); - sym->add("new", dest); - sym->add("old", src); - p->second->execute(sym); - } - } -} - -string -FreezeScript::TransformInfoI::facetName() -{ - return facet; -} - -bool -FreezeScript::TransformInfoI::purgeObjects() -{ - return purge; -} - -FreezeScript::ObjectDataMap& -FreezeScript::TransformInfoI::getObjectDataMap() -{ - return objectDataMap; -} - -// -// DescriptorHandler -// -FreezeScript::DescriptorHandler::DescriptorHandler(const TransformInfoIPtr& info) : - _info(info) -{ -} - -void -FreezeScript::DescriptorHandler::startElement(const string& name, const IceXML::Attributes& attributes, int line, - int /*column*/) -{ - DescriptorPtr d; - - if(name == "transformdb") - { - if(_current) - { - _info->errorReporter->descriptorError("<transformdb> must be the top-level element", line); - } - - _descriptor = new TransformDBDescriptor(line, _info, attributes); - d = _descriptor; - } - else if(name == "database") - { - if(!_current) - { - _info->errorReporter->descriptorError("<database> must be a child of <transformdb>", line); - } - - d = new DatabaseDescriptor(_current, line, _info, attributes); - } - else if(name == "record") - { - if(!_current) - { - _info->errorReporter->descriptorError("<record> must be a child of <database>", line); - } - - d = new RecordDescriptor(_current, line, _info, attributes); - } - else if(name == "transform") - { - if(!_current) - { - _info->errorReporter->descriptorError("<transform> must be a child of <transformdb>", line); - } - - d = new TransformDescriptor(_current, line, _info, attributes); - } - else if(name == "init") - { - if(!_current) - { - _info->errorReporter->descriptorError("<init> must be a child of <transformdb>", line); - } - - d = new InitDescriptor(_current, line, _info, attributes); - } - else if(name == "set") - { - if(!_current) - { - _info->errorReporter->descriptorError("<set> cannot be a top-level element", line); - } - - d = new SetDescriptor(_current, line, _info, attributes); - } - else if(name == "define") - { - if(!_current) - { - _info->errorReporter->descriptorError("<define> cannot be a top-level element", line); - } - - d = new DefineDescriptor(_current, line, _info, attributes); - } - else if(name == "add") - { - if(!_current) - { - _info->errorReporter->descriptorError("<add> cannot be a top-level element", line); - } - - d = new AddDescriptor(_current, line, _info, attributes); - } - else if(name == "remove") - { - if(!_current) - { - _info->errorReporter->descriptorError("<remove> cannot be a top-level element", line); - } - - d = new RemoveDescriptor(_current, line, _info, attributes); - } - else if(name == "delete") - { - if(!_current) - { - _info->errorReporter->descriptorError("<delete> cannot be a top-level element", line); - } - - d = new DeleteDescriptor(_current, line, _info, attributes); - } - else if(name == "fail") - { - if(!_current) - { - _info->errorReporter->descriptorError("<fail> cannot be a top-level element", line); - } - - d = new FailDescriptor(_current, line, _info, attributes); - } - else if(name == "echo") - { - if(!_current) - { - _info->errorReporter->descriptorError("<echo> cannot be a top-level element", line); - } - - d = new EchoDescriptor(_current, line, _info, attributes); - } - else if(name == "if") - { - if(!_current) - { - _info->errorReporter->descriptorError("<if> cannot be a top-level element", line); - } - - d = new IfDescriptor(_current, line, _info, attributes); - } - else if(name == "iterate") - { - if(!_current) - { - _info->errorReporter->descriptorError("<iterate> cannot be a top-level element", line); - } - - d = new IterateDescriptor(_current, line, _info, attributes); - } - else - { - _info->errorReporter->descriptorError("unknown descriptor `" + name + "'", line); - } - - if(_current) - { - _current->addChild(d); - } - _current = d; -} - -void -FreezeScript::DescriptorHandler::endElement(const string&, int, int) -{ - assert(_current); - _current = _current->parent(); -} - -void -FreezeScript::DescriptorHandler::characters(const string&, int, int) -{ -} - -void -FreezeScript::DescriptorHandler::error(const string& msg, int line, int) -{ - _info->errorReporter->descriptorError(msg, line); -} - -FreezeScript::TransformDBDescriptorPtr -FreezeScript::DescriptorHandler::descriptor() const -{ - return _descriptor; -} - -// -// assignOrTransform -// -void -FreezeScript::assignOrTransform(const DataPtr& dest, const DataPtr& src, bool convert, const TransformInfoPtr& info) -{ - Slice::TypePtr destType = dest->getType(); - Slice::TypePtr srcType = src->getType(); - Slice::BuiltinPtr b1 = Slice::BuiltinPtr::dynamicCast(destType); - Slice::BuiltinPtr b2 = Slice::BuiltinPtr::dynamicCast(srcType); - - if(!b1 && !b2 && dest->getType()->unit().get() != src->getType()->unit().get()) - { - TransformVisitor v(src, info); - dest->visit(v); - } - else - { - AssignVisitor v(src, info->getDataFactory(), info->getErrorReporter(), convert); - dest->visit(v); - } -} - -void -FreezeScript::transformDatabase(const Ice::CommunicatorPtr& communicator, - const FreezeScript::ObjectFactoryPtr& objectFactory, - const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit, - Db* oldDb, Db* newDb, DbTxn* newDbTxn, const Freeze::ConnectionPtr& connection, - const string& newDbName, const string& facetName, bool purgeObjects, ostream& errors, - bool suppress, istream& is) -{ - - TransformInfoIPtr info = new TransformInfoI; - info->communicator = communicator; - info->objectFactory = objectFactory; - info->oldUnit = oldUnit; - info->newUnit = newUnit; - info->oldDb = oldDb; - info->newDb = newDb; - info->newDbTxn = newDbTxn; - info->connection = connection; - info->newDbName = newDbName; - info->facet = facetName; - info->purge = purgeObjects; - info->errorReporter = new ErrorReporter(errors, suppress); - info->factory = new TransformDataFactory(communicator, newUnit, info->errorReporter); - info->symbolTable = new SymbolTableI(info); - - try - { - DescriptorHandler dh(info); - IceXML::Parser::parse(is, dh); - TransformDBDescriptorPtr descriptor = dh.descriptor(); - descriptor->validate(); - descriptor->execute(info->symbolTable); - } - catch(const IceXML::ParserException& ex) - { - info->errorReporter->error(ex.reason()); - } -} diff --git a/cpp/src/FreezeScript/Transformer.h b/cpp/src/FreezeScript/Transformer.h deleted file mode 100644 index 71eee136c04..00000000000 --- a/cpp/src/FreezeScript/Transformer.h +++ /dev/null @@ -1,33 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_TRANSFORMER_H -#define FREEZE_SCRIPT_TRANSFORMER_H - -#include <Ice/Ice.h> -#include <Slice/Parser.h> -#include <Freeze/Connection.h> -#include <FreezeScript/Data.h> - -class Db; -class DbTxn; - -namespace FreezeScript -{ - -void -transformDatabase(const Ice::CommunicatorPtr&, - const FreezeScript::ObjectFactoryPtr& objectFactory, - const Slice::UnitPtr&, const Slice::UnitPtr&, - Db*, Db*, DbTxn*, const Freeze::ConnectionPtr&, const std::string&, const std::string&, bool, - std::ostream&, bool, std::istream&); - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp deleted file mode 100644 index 941b9cf9b76..00000000000 --- a/cpp/src/FreezeScript/Util.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Util.h> -#include <FreezeScript/Exception.h> -#include <Freeze/Catalog.h> -#include <Freeze/Connection.h> -#include <Freeze/Initialize.h> -#include <Slice/Preprocessor.h> -#include <db_cxx.h> -#include <sys/stat.h> - -using namespace std; -using namespace Slice; - -string -FreezeScript::typeToString(const TypePtr& type) -{ - BuiltinPtr b = BuiltinPtr::dynamicCast(type); - ContainedPtr c = ContainedPtr::dynamicCast(type); - if(b) - { - return b->kindAsString(); - } - else if(c) - { - return c->scoped(); - } - else - { - ProxyPtr p = ProxyPtr::dynamicCast(type); - assert(p); - return p->_class()->scoped() + "*"; - } -} - -bool -FreezeScript::ignoreType(const string& type) -{ - // - // Suppress descriptors for the following pre-defined types. Must be kept in ascending alphabetical order. - // - static const string ignoreTypeList[] = - { - "::Freeze::ObjectRecord", - "::Freeze::Statistics", - "::Ice::Identity" - }; - - return binary_search(&ignoreTypeList[0], &ignoreTypeList[sizeof(ignoreTypeList) / sizeof(*ignoreTypeList)], type); -} - -void -FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& u) -{ - Slice::TypeList l; - Slice::ContainedList c; - - // - // Create the Ice module if necessary. - // - c = u->lookupContained("Ice", false); - Slice::ModulePtr ice; - if(c.empty()) - { - ice = u->createModule("Ice"); - } - else - { - ice = Slice::ModulePtr::dynamicCast(c.front()); - if(!ice) - { - throw FailureException(__FILE__, __LINE__, "the symbol `::Ice' is defined in Slice but is not a module"); - } - } - - // - // Create the Slice definition for Ice::Identity if it doesn't exist. - // - string scoped = "::Ice::Identity"; - l = u->lookupTypeNoBuiltin(scoped, false); - Slice::StructPtr identity; - if(l.empty()) - { - identity = ice->createStruct("Identity", false); - Slice::TypePtr str = u->builtin(Slice::Builtin::KindString); - identity->createDataMember("name", str, false, 0, 0, "", ""); - identity->createDataMember("category", str, false, 0, 0, "", ""); - } - else - { - identity = Slice::StructPtr::dynamicCast(l.front()); - if(!identity) - { - throw FailureException(__FILE__, __LINE__, - "the symbol `::Ice::Identity' is defined in Slice but is not a struct"); - } - } - - // - // Create the Freeze module if necessary. - // - c = u->lookupContained("Freeze", false); - Slice::ModulePtr freeze; - if(c.empty()) - { - freeze = u->createModule("Freeze"); - } - else - { - freeze = Slice::ModulePtr::dynamicCast(c.front()); - if(!freeze) - { - throw FailureException(__FILE__, __LINE__, - "the symbol `::Freeze' is defined in Slice but is not a module"); - } - } - - // - // Create the Slice definition for Freeze::Statistics if it doesn't exist. - // - scoped = "::Freeze::Statistics"; - l = u->lookupTypeNoBuiltin(scoped, false); - Slice::StructPtr stats; - if(l.empty()) - { - stats = freeze->createStruct("Statistics", false); - Slice::TypePtr tl = u->builtin(Slice::Builtin::KindLong); - stats->createDataMember("creationTime", tl, false, 0, 0, "", ""); - stats->createDataMember("lastSaveTime", tl, false, 0, 0, "", ""); - stats->createDataMember("avgSaveTime", tl, false, 0, 0, "", ""); - } - else - { - stats = Slice::StructPtr::dynamicCast(l.front()); - if(!stats) - { - throw FailureException(__FILE__, __LINE__, "the symbol `::Freeze::Statistics' is defined in " - "Slice but is not a struct"); - } - } - - // - // Create the Slice definition for Freeze::ObjectRecord if it doesn't exist. - // - scoped = "::Freeze::ObjectRecord"; - l = u->lookupTypeNoBuiltin(scoped, false); - if(l.empty()) - { - Slice::StructPtr rec = freeze->createStruct("ObjectRecord", false); - Slice::TypePtr obj = u->builtin(Slice::Builtin::KindObject); - rec->createDataMember("servant", obj, false, 0, 0, "", ""); - rec->createDataMember("stats", stats, false, 0, 0, "", ""); - } - else - { - if(!Slice::StructPtr::dynamicCast(l.front())) - { - throw FailureException(__FILE__, __LINE__, "the symbol `::Freeze::ObjectRecord' is defined in " - "Slice but is not a struct"); - } - } -} - -bool -FreezeScript::parseSlice(const string& n, const Slice::UnitPtr& u, const vector<string>& files, - const vector<string>& cppArgs, bool debug, const std::string& extraArgs) -{ - // - // Parse the Slice files. - // - for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p) - { - PreprocessorPtr icecpp = Preprocessor::create(n, *p, cppArgs); - - FILE* cppHandle = icecpp->preprocess(false, extraArgs); - - if(cppHandle == 0) - { - return false; - } - - int status = u->parse(*p, cppHandle, debug); - - if(!icecpp->close()) - { - return false; - } - - if(status != EXIT_SUCCESS) - { - return false; - } - } - - u->mergeModules(); - - return true; -} - -FreezeScript::CatalogDataMap -FreezeScript::readCatalog(const Ice::CommunicatorPtr& communicator, const string& dbEnvName) -{ - CatalogDataMap result; - - DbEnv dbEnv(0); - try - { -#ifdef _WIN32 - // - // Berkeley DB may use a different C++ runtime. - // - dbEnv.set_alloc(::malloc, ::realloc, ::free); -#endif - - // - // Open the database environment. - // - { - u_int32_t flags = DB_THREAD | DB_CREATE | DB_INIT_TXN | DB_INIT_MPOOL; - dbEnv.open(dbEnvName.c_str(), flags, 0); - } - - Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, dbEnvName, dbEnv); - Freeze::Catalog catalog(connection, Freeze::catalogName()); - for(Freeze::Catalog::const_iterator p = catalog.begin(); p != catalog.end(); ++p) - { - result.insert(make_pair(p->first, p->second)); - } - } - catch(const DbException& ex) - { - dbEnv.close(0); - throw FailureException(__FILE__, __LINE__, string("database error: ") + ex.what()); - } - catch(const IceUtil::FileLockException&) - { - dbEnv.close(0); - throw FailureException(__FILE__, __LINE__, "environment `" + dbEnvName + "' is locked"); - } - catch(...) - { - dbEnv.close(0); - throw; - } - - dbEnv.close(0); - - return result; -} - -string -FreezeScript::CompactIdResolverI::resolve(Ice::Int id) const -{ - string type; - map<Ice::Int, string>::const_iterator p = _ids.find(id); - if(p != _ids.end()) - { - type = p->second; - } - return type; -} - -void -FreezeScript::CompactIdResolverI::add(Ice::Int id, const string& type) -{ -#ifndef NDEBUG - map<Ice::Int, string>::const_iterator p = _ids.find(id); -#else - _ids.find(id); -#endif - assert(p == _ids.end()); - - _ids[id] = type; -} - -void -FreezeScript::collectCompactIds(const UnitPtr& unit, const FreezeScript::CompactIdResolverIPtr& r) -{ - class Visitor : public ParserVisitor - { - public: - - Visitor(const FreezeScript::CompactIdResolverIPtr& resolver) : _r(resolver) - { - } - - virtual bool visitClassDefStart(const ClassDefPtr& p) - { - if(p->compactId() != -1) - { - _r->add(p->compactId(), p->scoped()); - } - return true; - } - - FreezeScript::CompactIdResolverIPtr _r; - }; - - Visitor v(r); - unit->visit(&v, false); -} diff --git a/cpp/src/FreezeScript/Util.h b/cpp/src/FreezeScript/Util.h deleted file mode 100644 index 71d07988602..00000000000 --- a/cpp/src/FreezeScript/Util.h +++ /dev/null @@ -1,83 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef FREEZE_SCRIPT_UTIL_H -#define FREEZE_SCRIPT_UTIL_H - -#include <Slice/Parser.h> -#include <Ice/Initialize.h> -#include <Freeze/CatalogData.h> - -namespace FreezeScript -{ - -template<class T> -class Destroyer -{ -public: - - Destroyer() {} - Destroyer(T p) : _p(p) {} - ~Destroyer() - { - if(_p) - { - _p->destroy(); - } - } - - void set(T p) - { - if(_p) - { - _p->destroy(); - } - _p = p; - } - - void release() - { - _p = 0; - } - -private: - - T _p; -}; - -std::string typeName(const Slice::TypePtr&); -std::string typeToString(const Slice::TypePtr&); -bool ignoreType(const std::string&); -void createEvictorSliceTypes(const Slice::UnitPtr&); -bool parseSlice(const std::string&, const Slice::UnitPtr&, const std::vector<std::string>&, - const std::vector<std::string>&, bool, const std::string&); - -typedef std::map<std::string, Freeze::CatalogData> CatalogDataMap; - -CatalogDataMap readCatalog(const Ice::CommunicatorPtr&, const std::string&); - -class CompactIdResolverI : public Ice::CompactIdResolver -{ -public: - - virtual std::string resolve(Ice::Int) const; - - void add(Ice::Int, const std::string&); - -private: - - std::map<Ice::Int, std::string> _ids; -}; -typedef IceUtil::Handle<CompactIdResolverI> CompactIdResolverIPtr; - -void collectCompactIds(const Slice::UnitPtr&, const CompactIdResolverIPtr&); - -} // End of namespace FreezeScript - -#endif diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp deleted file mode 100644 index d260ef0a7f6..00000000000 --- a/cpp/src/FreezeScript/transformdb.cpp +++ /dev/null @@ -1,1022 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <FreezeScript/Transformer.h> -#include <FreezeScript/TransformAnalyzer.h> -#include <FreezeScript/Exception.h> -#include <FreezeScript/Util.h> -#include <Freeze/Initialize.h> -#include <Freeze/Transaction.h> -#include <Freeze/Catalog.h> -#include <IceUtil/Options.h> -#include <IceUtil/FileUtil.h> -#include <db_cxx.h> -#include <sys/stat.h> -#include <algorithm> - -using namespace std; - -#ifdef _WIN32 -# define FREEZE_SCRIPT_DB_MODE 0 -#else -# define FREEZE_SCRIPT_DB_MODE (S_IRUSR | S_IWUSR) -#endif - -static void -usage(const std::string& n) -{ - cerr << "Usage:\n"; - cerr << "\n"; - cerr << n << " -o FILE [-i] [slice-options] [type-options]\n"; - cerr << " Generates descriptors in FILE for a database.\n"; - cerr << "\n"; - cerr << n << " -o FILE [-i] [slice-options] DBENV\n"; - cerr << " Generates descriptors in FILE for all databases in the environment DBENV.\n"; - cerr << "\n"; - cerr << n << " [options] [slice-options] [type-options] DBENV DB NEWDBENV\n"; - cerr << " Transform the database DB in the environment DBENV. A database of the\n"; - cerr << " same name is created in the environment NEWDBENV.\n"; - cerr << "\n"; - cerr << n << " [options] [slice-options] DBENV NEWDBENV\n"; - cerr << " Transform all databases from the environment DBENV into the\n"; - cerr << " environment NEWDBENV.\n"; - cerr << "\n"; - cerr << - "Slice Options:\n" - "-DNAME Define NAME as 1.\n" - "-DNAME=DEF Define NAME as DEF.\n" - "-UNAME Remove any definition for NAME.\n" - "-d, --debug Print debug messages.\n" - "--underscore Permit underscores in Slice identifiers.\n" - "--include-old DIR Put DIR in the include file search path for old Slice\n" - " definitions.\n" - "--include-new DIR Put DIR in the include file search path for new Slice\n" - " definitions.\n" - "--old SLICE Load old Slice definitions from the file SLICE.\n" - "--new SLICE Load new Slice definitions from the file SLICE.\n" - ; - cerr << "\n"; - cerr << - "Type Options:\n" - "-e Indicates the database is an Evictor database.\n" - "--key TYPE[,TYPE] Specifies the Slice types of the database key. If the\n" - " type names have not changed, only one needs to be\n" - " specified. Otherwise, the type names are specified as\n" - " old-type,new-type.\n" - "--value TYPE[,TYPE] Specifies the Slice types of the database value. If the\n" - " type names have not changed, only one needs to be\n" - " specified. Otherwise, the type names are specified as\n" - " old-type,new-type.\n" - ; - cerr << "\n"; - cerr << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-i Ignore incompatible type changes.\n" - "-p Purge objects whose types no longer exist.\n" - "-c Use catastrophic recovery on the old database environment.\n" - "-w Suppress duplicate warnings during migration.\n" - "-f FILE Execute the transformation descriptors in the file FILE.\n" - ; -} - -static Slice::TypePtr -findType(const Slice::UnitPtr& u, const string& type) -{ - Slice::TypeList l; - - string t; - if(type == "::Ice::Object") - { - t = "Object"; - } - else if(type == "::Ice::Object*") - { - t = "Object*"; - } - else - { - t = type; - } - - l = u->lookupType(t, false); - if(l.empty()) - { - return 0; - } - - return l.front(); -} - -static void -transformDb(bool evictor, const Ice::CommunicatorPtr& communicator, - const FreezeScript::ObjectFactoryPtr& objectFactory, - DbEnv& dbEnv, DbEnv& dbEnvNew, const string& dbName, - const Freeze::ConnectionPtr& connectionNew, vector<Db*>& dbs, - const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit, - DbTxn* txnNew, bool purgeObjects, bool suppress, string descriptors) -{ - if(evictor) - { - // - // The evictor database file contains multiple databases. We must first - // determine the names of those databases, ignoring any whose names - // begin with "$index:". Each database represents a separate facet, with - // the facet name used as the database name. The database named "$default" - // represents the main object. - // - vector<string> dbNames; - { - Db db(&dbEnv, 0); - db.open(0, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0); - Dbt dbKey, dbValue; - dbKey.set_flags(DB_DBT_MALLOC); - dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); - - Dbc* dbc = 0; - db.cursor(0, &dbc, 0); - - while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) - { - string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size()); - if(s.find("$index:") != 0) - { - dbNames.push_back(s); - } - free(dbKey.get_data()); - } - - dbc->close(); - db.close(0); - } - - // - // Transform each database. We must delay closing the new databases - // until after the transaction is committed or aborted. - // - for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p) - { - string name = p->c_str(); - - Db db(&dbEnv, 0); - db.open(0, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); - - Db* dbNew = new Db(&dbEnvNew, 0); - dbs.push_back(dbNew); - dbNew->open(txnNew, dbName.c_str(), name.c_str(), DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE); - - // - // Execute the transformation descriptors. - // - istringstream istr(descriptors); - string facet = (name == "$default" ? string("") : name); - FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, 0, - dbName, facet, purgeObjects, cerr, suppress, istr); - - db.close(0); - } - - Freeze::Catalog catalogNew(connectionNew, Freeze::catalogName()); - Freeze::CatalogData catalogData = { true, "::Ice::Identity", "Object" }; - catalogNew.put(Freeze::Catalog::value_type(dbName, catalogData)); - } - else - { - // - // Transform a map database. - // - Db db(&dbEnv, 0); - db.open(0, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); - - Db* dbNew = new Db(&dbEnvNew, 0); - dbs.push_back(dbNew); - dbNew->open(txnNew, dbName.c_str(), 0, DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE); - - // - // Execute the transformation descriptors. - // - istringstream istr(descriptors); - FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, - connectionNew, dbName, "", purgeObjects, cerr, suppress, istr); - - db.close(0); - } -} - -static int -run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator, - const FreezeScript::CompactIdResolverIPtr& resolver) -{ - vector<string> oldCppArgs; - vector<string> newCppArgs; - bool debug; - bool ice = true; // Needs to be true in order to create default definitions. - bool underscore; - string outputFile; - bool ignoreTypeChanges; - bool purgeObjects; - bool catastrophicRecover; - bool suppress; - string inputFile; - vector<string> oldSlice; - vector<string> newSlice; - bool evictor; - string keyTypeNames; - string valueTypeNames; - string dbEnvName, dbName, dbEnvNameNew; - bool allDb = false; - - IceUtilInternal::Options opts; - opts.addOpt("h", "help"); - opts.addOpt("v", "version"); - opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("d", "debug"); - opts.addOpt("", "underscore"); - opts.addOpt("o", "", IceUtilInternal::Options::NeedArg); - opts.addOpt("i"); - opts.addOpt("p"); - opts.addOpt("c"); - opts.addOpt("w"); - opts.addOpt("f", "", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "include-old", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("", "include-new", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("", "old", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("", "new", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("a"); - opts.addOpt("e"); - opts.addOpt("", "key", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "value", IceUtilInternal::Options::NeedArg); - - const string appName = originalArgs[0]; - vector<string> args; - try - { - args = opts.parse(originalArgs); - } - catch(const IceUtilInternal::BadOptException& e) - { - cerr << appName << ": " << e.reason << endl; - usage(appName); - return EXIT_FAILURE; - } - - if(opts.isSet("help")) - { - usage(appName); - return EXIT_SUCCESS; - } - if(opts.isSet("version")) - { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - if(opts.isSet("D")) - { - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - oldCppArgs.push_back("-D" + *i); - newCppArgs.push_back("-D" + *i); - } - } - if(opts.isSet("U")) - { - vector<string> optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - oldCppArgs.push_back("-U" + *i); - newCppArgs.push_back("-U" + *i); - } - } - debug = opts.isSet("debug"); - - underscore = opts.isSet("underscore"); - - if(opts.isSet("o")) - { - outputFile = opts.optArg("o"); - } - ignoreTypeChanges = opts.isSet("i"); - purgeObjects = opts.isSet("p"); - catastrophicRecover = opts.isSet("c"); - suppress = opts.isSet("w"); - - if(opts.isSet("f")) - { - inputFile = opts.optArg("f"); - } - if(opts.isSet("include-old")) - { - vector<string> optargs = opts.argVec("include-old"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - oldCppArgs.push_back("-I" + *i); - } - } - if(opts.isSet("include-new")) - { - vector<string> optargs = opts.argVec("include-new"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - newCppArgs.push_back("-I" + *i); - } - } - if(opts.isSet("old")) - { - vector<string> optargs = opts.argVec("old"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - oldSlice.push_back(*i); - } - } - if(opts.isSet("new")) - { - vector<string> optargs = opts.argVec("new"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - newSlice.push_back(*i); - } - } - evictor = opts.isSet("e"); - if(opts.isSet("key")) - { - keyTypeNames = opts.optArg("key"); - } - if(opts.isSet("value")) - { - valueTypeNames = opts.optArg("value"); - } - - if(outputFile.empty()) - { - if(args.size() == 2) - { - allDb = true; - } - else if(args.size() != 3) - { - usage(appName); - return EXIT_FAILURE; - } - } - else - { - if(args.size() == 1) - { - allDb = true; - } - else if(args.size() != 0) - { - usage(appName); - return EXIT_FAILURE; - } - } - - if(allDb && (!keyTypeNames.empty() || !valueTypeNames.empty())) - { - usage(appName); - return EXIT_FAILURE; - } - - if(inputFile.empty() && !allDb && !evictor && (keyTypeNames.empty() || valueTypeNames.empty())) - { - usage(appName); - return EXIT_FAILURE; - } - - if(args.size() > 0) - { - dbEnvName = args[0]; - } - if(args.size() > 1) - { - if(allDb) - { - dbEnvNameNew = args[1]; - } - else - { - dbName = args[1]; - } - } - if(args.size() > 2) - { - dbEnvNameNew = args[2]; - } - if(args.size() > 3) - { - cerr << appName << ": too many arguments" << endl; - usage(appName); - return EXIT_FAILURE; - } - - // - // Freeze creates a lock file by default to prevent multiple processes from opening - // the same database environment simultaneously. In the case of a read-only program - // such as transformdb, however, we still want to be able to open the environment despite - // the lock. This assumes of course that the other process has opened the environment - // with DbPrivate=0. If DbPrivate=0 is also set for dumpdb, we disable the lock. - // - if(!catastrophicRecover && outputFile.empty()) - { - Ice::PropertiesPtr props = communicator->getProperties(); - string prefix = "Freeze.DbEnv." + args[0]; - if(props->getPropertyAsIntWithDefault(prefix + ".DbPrivate", 1) <= 0) - { - props->setProperty(prefix + ".LockFile", "0"); - } - } - - Slice::UnitPtr oldUnit = Slice::Unit::createUnit(true, true, ice, underscore); - FreezeScript::Destroyer<Slice::UnitPtr> oldD(oldUnit); - if(!FreezeScript::parseSlice(appName, oldUnit, oldSlice, oldCppArgs, debug, "-D__TRANSFORMDB__")) - { - return EXIT_FAILURE; - } - - FreezeScript::collectCompactIds(oldUnit, resolver); - - Slice::UnitPtr newUnit = Slice::Unit::createUnit(true, true, ice, underscore); - FreezeScript::Destroyer<Slice::UnitPtr> newD(newUnit); - if(!FreezeScript::parseSlice(appName, newUnit, newSlice, newCppArgs, debug, "-D__TRANSFORMDB__")) - { - return EXIT_FAILURE; - } - - // - // Install the evictor types in the Slice units. - // - FreezeScript::createEvictorSliceTypes(oldUnit); - FreezeScript::createEvictorSliceTypes(newUnit); - - // - // Read the catalog if necessary. - // - FreezeScript::CatalogDataMap catalog; - if(allDb) - { - try - { - catalog = FreezeScript::readCatalog(communicator, dbEnvName); - } - catch(const FreezeScript::FailureException& ex) - { - cerr << appName << ": " << ex.reason() << endl; - return EXIT_FAILURE; - } - if(catalog.empty()) - { - cerr << appName << ": no databases in environment `" << dbEnvName << "'" << endl; - return EXIT_FAILURE; - } - } - - // - // If no input file was provided, then we need to analyze the Slice types. - // - string descriptors; - - if(inputFile.empty()) - { - ostringstream out; - vector<string> missingTypes; - vector<string> analyzeErrors; - - FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors); - - const string evictorKeyName = "::Ice::Identity"; - const string oldEvictorValueName = "::Freeze::ObjectRecord"; - const string newEvictorValueName = "Object"; - - if(allDb) - { - // - // Add a <database> element for each database in the catalog. - // - for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p) - { - string keyName, valueName; - - if(p->second.evictor) - { - keyName = p->second.key; - valueName = p->second.value; - - if(keyName.empty()) - { - keyName = evictorKeyName; - } - if(valueName.empty()) - { - valueName = oldEvictorValueName; - } - } - else - { - keyName = p->second.key; - valueName = p->second.value; - } - - // - // Look up the key and value types in the old and new Slice definitions. - // - Slice::TypePtr oldKeyType = findType(oldUnit, keyName); - if(!oldKeyType) - { - cerr << appName << ": type `" << keyName << "' from database `" << p->first - << "' not found in old Slice definitions" << endl; - } - Slice::TypePtr newKeyType = findType(newUnit, keyName); - if(!newKeyType) - { - cerr << appName << ": type `" << keyName << "' from database `" << p->first - << "' not found in new Slice definitions" << endl; - } - Slice::TypePtr oldValueType = findType(oldUnit, valueName); - if(!oldValueType) - { - cerr << appName << ": type `" << valueName << "' from database `" << p->first - << "' not found in old Slice definitions" << endl; - } - - Slice::TypePtr newValueType; - if(p->second.evictor) - { - // - // The new evictor does not keep stats - // - newValueType = findType(newUnit, newEvictorValueName); - } - else - { - newValueType = findType(newUnit, valueName); - } - - if(!newValueType) - { - cerr << appName << ": type `" << valueName << "' from database `" << p->first - << "' not found in new Slice definitions" << endl; - } - - // - // If we are generating an output file, we do not consider a missing type to be - // an error. Since the type information comes from the catalog of the old - // environment, it's possible that the key or value types are not present in - // the new Slice definitions. Rather than abort at this point, we simply emit - // a partially-defined <database> element that must be edited by the user. - // - // If we are not generating an output file, we have to stop now. - // - if(outputFile.empty() && (!oldKeyType || !newKeyType || !oldValueType || !newValueType)) - { - return EXIT_FAILURE; - } - - analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType); - } - } - else - { - string oldKeyName, newKeyName, oldValueName, newValueName; - - string::size_type pos; - - if(!evictor && (keyTypeNames.empty() || valueTypeNames.empty())) - { - usage(appName); - return EXIT_FAILURE; - } - - if(!keyTypeNames.empty()) - { - pos = keyTypeNames.find(','); - if(pos == 0 || pos == keyTypeNames.size()) - { - usage(appName); - return EXIT_FAILURE; - } - if(pos == string::npos) - { - oldKeyName = keyTypeNames; - newKeyName = keyTypeNames; - } - else - { - oldKeyName = keyTypeNames.substr(0, pos); - newKeyName = keyTypeNames.substr(pos + 1); - } - } - - if(!valueTypeNames.empty()) - { - pos = valueTypeNames.find(','); - if(pos == 0 || pos == valueTypeNames.size()) - { - usage(appName); - return EXIT_FAILURE; - } - if(pos == string::npos) - { - oldValueName = valueTypeNames; - newValueName = valueTypeNames; - } - else - { - oldValueName = valueTypeNames.substr(0, pos); - newValueName = valueTypeNames.substr(pos + 1); - } - } - - if(evictor) - { - if(oldKeyName.empty()) - { - oldKeyName = evictorKeyName; - } - if(newKeyName.empty()) - { - newKeyName = evictorKeyName; - } - if(oldValueName.empty()) - { - oldValueName = newEvictorValueName; - } - if(newValueName.empty()) - { - newValueName = newEvictorValueName; - } - } - - // - // Look up the key and value types in the old and new Slice definitions. - // - Slice::TypePtr oldKeyType = findType(oldUnit, oldKeyName); - if(!oldKeyType) - { - cerr << appName << ": type `" << oldKeyName << "' not found in old Slice definitions" << endl; - } - Slice::TypePtr newKeyType = findType(newUnit, newKeyName); - if(!newKeyType) - { - cerr << appName << ": type `" << newKeyName << "' not found in new Slice definitions" << endl; - } - Slice::TypePtr oldValueType = findType(oldUnit, oldValueName); - if(!oldValueType) - { - cerr << appName << ": type `" << oldValueName << "' not found in old Slice definitions" << endl; - } - Slice::TypePtr newValueType = findType(newUnit, newValueName); - if(!newValueType) - { - cerr << appName << ": type `" << newValueName << "' not found in new Slice definitions" << endl; - } - - // - // Stop now if any of the types could not be found. - // - if(!oldKeyType || !newKeyType || !oldValueType || !newValueType) - { - return EXIT_FAILURE; - } - - analyzer.addDatabase("", oldKeyType, newKeyType, oldValueType, newValueType); - } - - analyzer.finish(); - - if(!analyzeErrors.empty()) - { - for(vector<string>::const_iterator p = analyzeErrors.begin(); p != analyzeErrors.end(); ++p) - { - cerr << appName << ": " << *p << endl; - } - } - - if(!missingTypes.empty()) - { - sort(missingTypes.begin(), missingTypes.end()); - unique(missingTypes.begin(), missingTypes.end()); - if(!analyzeErrors.empty()) - { - cerr << endl; - } - cerr << "The following types had no matching definitions in the new Slice:" << endl; - for(vector<string>::const_iterator p = missingTypes.begin(); p != missingTypes.end(); ++p) - { - cerr << " " << *p << endl; - } - } - - if(!analyzeErrors.empty()) - { - return EXIT_FAILURE; - } - - descriptors = out.str(); - - if(!outputFile.empty()) - { - IceUtilInternal::ofstream of(outputFile); - if(!of.good()) - { - cerr << appName << ": unable to open file `" << outputFile << "'" << endl; - return EXIT_FAILURE; - } - of << descriptors; - of.close(); - return EXIT_SUCCESS; - } - } - else - { - // - // Read the input file. - // - IceUtilInternal::ifstream in(inputFile); - char buff[1024]; - while(true) - { - in.read(buff, 1024); - descriptors.append(buff, static_cast<size_t>(in.gcount())); - if(in.gcount() < 1024) - { - break; - } - } - in.close(); - } - - if(dbEnvName == dbEnvNameNew) - { - cerr << appName << ": database environment names must be different" << endl; - return EXIT_FAILURE; - } - - FreezeScript::ObjectFactoryPtr objectFactory = new FreezeScript::ObjectFactory; - communicator->addObjectFactory(objectFactory, ""); - - // - // Transform the database. - // - DbEnv dbEnv(0); - DbEnv dbEnvNew(0); - Freeze::TransactionPtr txNew; - Freeze::ConnectionPtr connection; - Freeze::ConnectionPtr connectionNew; - vector<Db*> dbs; - int status = EXIT_SUCCESS; - try - { -#ifdef _WIN32 - // - // Berkeley DB may use a different C++ runtime. - // - dbEnv.set_alloc(::malloc, ::realloc, ::free); - dbEnvNew.set_alloc(::malloc, ::realloc, ::free); -#endif - - // - // Open the old database environment. Use DB_RECOVER_FATAL if -c is specified. - // No transaction is created for the old environment. - // - // DB_THREAD is for compatibility with Freeze (the catalog) - // - { - u_int32_t flags = DB_THREAD | DB_CREATE | DB_INIT_TXN | DB_INIT_MPOOL; - if(catastrophicRecover) - { - flags |= DB_INIT_LOG | DB_RECOVER_FATAL; - } - dbEnv.open(dbEnvName.c_str(), flags, FREEZE_SCRIPT_DB_MODE); - } - - // - // We're creating a connection just to make sure the database environment - // isn't locked. - // - connection = Freeze::createConnection(communicator, dbEnvName, dbEnv); - - // - // Open the new database environment and start a transaction. - // - // - // DB_THREAD is for compatibility with Freeze (the catalog) - // - { - u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER | DB_CREATE | DB_THREAD; - dbEnvNew.open(dbEnvNameNew.c_str(), flags, FREEZE_SCRIPT_DB_MODE); - } - - // - // TODO: handle properly DbHome config (currently it will break if it's set for the new env) - // - - // - // Open the catalog of the new environment, and start a transaction. - // - connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew); - txNew = connectionNew->beginTransaction(); - DbTxn* txnNew = Freeze::getTxn(txNew); - - if(allDb) - { - // - // Transform all databases in the old catalog. - // - for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p) - { - transformDb(p->second.evictor, communicator, objectFactory, dbEnv, dbEnvNew, p->first, connectionNew, - dbs, oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors); - } - } - else - { - transformDb(evictor, communicator, objectFactory, dbEnv, dbEnvNew, dbName, connectionNew, dbs, - oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors); - } - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - status = EXIT_FAILURE; - } - catch(const IceUtil::FileLockException&) - { - cerr << appName << ": error: database environment is locked" << endl; - status = EXIT_FAILURE; - } - catch(...) - { - try - { - if(txNew != 0) - { - txNew->rollback(); - txNew = 0; - } - if(connectionNew) - { - connectionNew->close(); - connectionNew = 0; - } - if(connection) - { - connection->close(); - connection = 0; - } - for(vector<Db*>::iterator p = dbs.begin(); p != dbs.end(); ++p) - { - Db* db = *p; - db->close(0); - delete db; - } - try - { - dbEnv.close(0); - } - catch(const DbException&) - { - } - try - { - dbEnvNew.close(0); - } - catch(const DbException&) - { - } - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - } - throw; - } - - if(txNew != 0) - { - try - { - if(status == EXIT_FAILURE) - { - txNew->rollback(); - } - else - { - txNew->commit(); - - // - // Checkpoint to migrate changes from the log to the database(s). - // - dbEnvNew.txn_checkpoint(0, 0, DB_FORCE); - } - - for(vector<Db*>::iterator p = dbs.begin(); p != dbs.end(); ++p) - { - Db* db = *p; - db->close(0); - delete db; - } - } - catch(const DbException& ex) - { - cerr << appName << ": database error: " << ex.what() << endl; - status = EXIT_FAILURE; - } - } - // Clear the transaction before closing the database environment. - txNew = 0; - - if(connectionNew) - { - connectionNew->close(); - connectionNew = 0; - } - - if(connection) - { - connection->close(); - connection = 0; - } - - try - { - dbEnv.close(0); - } - catch(const DbException&) - { - } - - try - { - dbEnvNew.close(0); - } - catch(const DbException&) - { - } - - return status; -} - -#ifdef _WIN32 - -int -wmain(int argc, wchar_t* argv[]) - -#else - -int -main(int argc, char* argv[]) -#endif -{ - Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); - assert(args.size() > 0); - const string appName = args[0]; - - Ice::InitializationData initData; - FreezeScript::CompactIdResolverIPtr resolver = new FreezeScript::CompactIdResolverI; - initData.compactIdResolver = resolver; - - Ice::CommunicatorPtr communicator; - int status = EXIT_SUCCESS; - try - { - communicator = Ice::initialize(args, initData); - status = run(args, communicator, resolver); - } - catch(const FreezeScript::FailureException& ex) - { - string reason = ex.reason(); - cerr << appName << ": " << reason; - if(reason[reason.size() - 1] != '\n') - { - cerr << endl; - } - status = EXIT_FAILURE; - } - catch(const std::exception& ex) - { - cerr << appName << ": " << ex.what() << endl; - status = EXIT_FAILURE; - } - catch(...) - { - cerr << appName << ": unknown exception" << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - communicator->destroy(); - } - - return status; -} - |