DynamoDS/Dynamo — pull request #1680 by ke-yu (2014-05-21 02:19:42+00:00)
Title: Opdata unify

Hi Luke, I've to send pull request because it accumulates too many changes scattered in too many files.

This pull request is about unifying ```opdata``` and ```opdata_d```, and also contains a lot of code cleanup work.

1. ```opdata_d``` is removed from ```StackValue``` struct. To access double value, should call ```StackValue.RawDoubleValue```, which internally will do trivial bit conversion to cast ```opdata``` to double. ```StackValue.RawIntegerValue``` and ```StackValue.RawBooleanValue``` are added accordingly to get different type of raw values from ```StackValue```. Ideally all directly ```opdata``` accesses should be replaced with ```StackValue.RawIntegerValue``` or ```StackValue.RawBooleanValue``` so that we could easily change ```StackValue``` implementation without touching a bunch of files. This cleanup work will be done in the near future.
2. Move most extension functions defined in ```StackUtils``` class to ```StackValue```. They are:
* Type checker functions like ```StackUtils.IsString()```, ```StackUtils.IsNull()``` and so on.
* Type conversion functions like ```StackUtils.AsInt()```, ```StackUtils.AsDouble()``` and ```StackUtils.AsBoolean()```, they are moved to ```StackValue.ToInteger()```, ```StackValue.ToDouble()```,```StackValue.ToBoolean()```.
* ```StackUtils.Equals()```
3. Replace direct type checking for ```StackValue``` with type checking functions. For example, replace ```AddressType.BlockIndex == opdata.optype``` with ```opdata.IsBlockIndex()```. It makes the code more succinct and easier to understand. It also makes the further optimization be easier.
4. Remove ```StackValue.ShadowClone()```. As ```StackValue``` is a struct, all copy operations by default will create an new instance on stack.
5. Remove verbose namespaces in some long expression. For example, replace ```ProtoCore.DSASM.Constants.kInvalidIndex``` with ```Constants.kInvalidIndex```.