Beispiel #1
0
        /// <summary>
        /// Converts a generic value to a strongly typed value
        /// </summary>
        /// <param name="value">The value to convert</param>
        /// <param name="schema">The schema of the value</param>
        /// <returns>The strongly typed vlaue</returns>
        private T _valueAs <T>(GenericValue value)
        {
            var schema = Value <T> .Schema;
            var stream = value.Provider.CreateStream(value, schema);

            return(Value <T> .Loader(stream));
        }
Beispiel #2
0
        public int Execute()
        {
            ExecutionEngine executionEngine = (ExecutionEngine)_input.GetVMModuleArtifact();
            Value           mainFunc        = executionEngine.FindFunction(_job._entry);

            if (!mainFunc.IsValid)
            {
                throw Diagnostics.ThrowError($"Unable to find '{_job._entry}' function in VM modules");
            }

            GenericValue[] args = new GenericValue[_job._argsToPass.Count];
            for (int i = 0, iend = _job._argsToPass.Count; i < iend; ++i)
            {
                args[i] = _toolchain.CreateIntGenericValue(_job._argsToPass[i]);
            }

            using GenericValue retVal = executionEngine.RunFunction(mainFunc, args);

            foreach (GenericValue arg in args)
            {
                arg.Dispose();
            }

            return((int)retVal.IntValue(true));
        }
Beispiel #3
0
 public ListOfSelectionCriteriaType(PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, RelationSpecifierType relationSpecifier, GenericValue comparisonValue)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.RelationSpecifier  = relationSpecifier;
     this.ComparisonValue    = comparisonValue;
 }
 public AddListElementRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue listOfElements)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ListOfElements = listOfElements;
 }
 public AddListElementRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue listOfElements)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ListOfElements     = listOfElements;
 }
Beispiel #6
0
 public ReadPropertyAck(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
 }
Beispiel #7
0
 public ReadPropertyAck(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue propertyValue)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue      = propertyValue;
 }
Beispiel #8
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue value, Option<uint> priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value = value;
     this.Priority = priority;
 }
 public IntegratorVariable(NxtRobot owner, int noOfSamples, Variable yVar, Variable xVar = null)
 {
     Enabled = true;
     // set owner
     Owner = owner;
     // set number of samples to hold
     NoOfSamples = noOfSamples;
     // set independant variable if not 'sample count'
     XVar = xVar;
     // set dependant/measured variable
     YVar = yVar;
     // initialize 'x' and 'y' stacks for sampled values
     XVarValues = new Stack <int>(NoOfSamples);
     YVarValues = new Stack <int>(NoOfSamples);
     // update name of object to describe the interpolation
     if (XVar != null)
     {
         Name = "Distance of '" + YVar.Name + "' over distance of  '" + XVar.Name + "' over last " + NoOfSamples + " samples.";
     }
     else
     {
         Name = "Distance of '" + YVar.Name + "' over last " + NoOfSamples + " samples.";
     }
     // create value obj with appropriate min and max limits
     Value = new GenericValue(YVar.Value.MinimumAllowableValue, yVar.Value.MaximumAllowableValue * NoOfSamples, YVar.Value.Units);
 }
Beispiel #10
0
 /// <summary>
 /// Attempts to interpret a TaggedGenericType instance as
 /// a specific type
 /// </summary>
 /// <param name="value">The value to interpet</param>
 /// <param name="schema">The type to interpret as</param>
 /// <param name="output">The output type</param>
 /// <returns>True if the interpretation succeeds, false otherwise</returns>
 public IValueStream CreateStream(GenericValue value, ISchema schema)
 {
     var tagged = (TaggedGenericValue)value;
     MemoryStream ms = new MemoryStream(tagged.tag, tagged.offset, tagged.end - tagged.offset);
     TagReader reader = new TagReader(ms);
     TagReaderStream stream = new TagReaderStream(reader, schema);
     return stream;
 }
Beispiel #11
0
 public Variable(string name, GenericValue value, NxtRobot owner)
 {
     Enabled = true;
     Name    = name;
     _value  = value;
     value.ValueHasBeenUpdated += InformOfValueChange;
     Owner = owner;
 }
 public DeviceObjectPropertyValue(ObjectId deviceIdentifier, ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> arrayIndex, GenericValue value)
 {
     this.DeviceIdentifier   = deviceIdentifier;
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.ArrayIndex         = arrayIndex;
     this.Value = value;
 }
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue, Option<byte> priority)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
     this.Priority = priority;
 }
Beispiel #14
0
 public Variable(string name, GenericValue value, NxtRobot owner)
 {
     Enabled = true;
     Name    = name;
     Value   = value;
     value.ValueHasBeenUpdated += _ValueHasBeenUpdated;
     Owner = owner;
 }
 public DeviceObjectPropertyValue(ObjectId deviceIdentifier, ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> arrayIndex, GenericValue value)
 {
     this.DeviceIdentifier = deviceIdentifier;
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.ArrayIndex = arrayIndex;
     this.Value = value;
 }
        /// <summary>
        /// Attempts to interpret a TaggedGenericType instance as
        /// a specific type
        /// </summary>
        /// <param name="value">The value to interpet</param>
        /// <param name="schema">The type to interpret as</param>
        /// <param name="output">The output type</param>
        /// <returns>True if the interpretation succeeds, false otherwise</returns>
        public IValueStream CreateStream(GenericValue value, ISchema schema)
        {
            var             tagged = (TaggedGenericValue)value;
            MemoryStream    ms     = new MemoryStream(tagged.tag, tagged.offset, tagged.end - tagged.offset);
            TagReader       reader = new TagReader(ms);
            TagReaderStream stream = new TagReaderStream(reader, schema);

            return(stream);
        }
Beispiel #17
0
 public ActionCommand(Option<ObjectId> deviceIdentifier, ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue, Option<uint> priority, Option<uint> postDelay, bool quitOnFailure, bool writeSuccessful)
 {
     this.DeviceIdentifier = deviceIdentifier;
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
     this.Priority = priority;
     this.PostDelay = postDelay;
     this.QuitOnFailure = quitOnFailure;
     this.WriteSuccessful = writeSuccessful;
 }
Beispiel #18
0
        public IJoinOperation JoinOperationFactory(ActivityContext context)
        {
            InArgument   expr_06 = this.Operand;
            object       obj     = (expr_06 != null) ? expr_06.Get(context) : null;
            GenericValue value;

            if ((value = (obj as GenericValue)) != (GenericValue)null)
            {
                obj = GenericValue.GetRawValue(value);
            }
            if (this.Operator == JoinOperator.EQ)
            {
                return(new EqualsOperation
                {
                    Operand = obj
                });
            }
            if (this.Operator == JoinOperator.NOTEQ)
            {
                return(new NotEqualsOperation
                {
                    Operand = obj
                });
            }
            IComparable operand = obj as IComparable;

            switch (this.Operator)
            {
            //case JoinOperator.LT:
            //    return new LessThanOperation
            //    {
            //        Operand = operand
            //    };
            //case JoinOperator.GT:
            //    return new GreaterThanOperation
            //    {
            //        Operand = operand
            //    };
            //case JoinOperator.LTE:
            //    return new LessThanOrEqualOperation
            //    {
            //        Operand = operand
            //    };
            //case JoinOperator.GTE:
            //    return new GreaterThanOrEqualOperation
            //    {
            //        Operand = operand
            //    };
            default:
                return(null);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Writes a generic value to the stream
        /// </summary>
        /// <param name="value">The value to write</param>
        /// <param name="tag">The wrapper tag number, or 255 for no wrapper tag</param>
        public void WriteGeneric(GenericValue value, byte tag = 255)
        {
            var tvalue = value as TaggedGenericValue;

            if (tvalue == null)
            {
                throw new Exception("Can only write TaggedGenericValue instances");
            }

            _writeTypeHeader(tag, TagType.Open);
            _writer.Write(tvalue.tag, 0, tvalue.tag.Length);
            _writeTypeHeader(tag, TagType.Close);
        }
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (value != null && value.GetType().IsAssignableFrom(destinationType))
            {
                return(value);
            }
            GenericValue genericValue = (GenericValue)value;

            if (genericValue != null as GenericValue && genericValue.RawValue != null && genericValue.RawValue.GetType().IsAssignableFrom(destinationType))
            {
                return(genericValue.RawValue);
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Beispiel #21
0
        public override Value Process(Node n)
        {
            InitTypeMap();

            LLVM.Native.LinkInJIT();
            //LLVM.Native.InitializeNativeTarget(); // Declared in bindings but not exported from the shared library.
            LLVM.Native.InitializeX86TargetInfo();
            LLVM.Native.InitializeX86Target();
            LLVM.Native.InitializeX86TargetMC();

            using (module = new Module("llvm compiler"))
                using (builder = new IRBuilder())
                {
                    execEngine = new ExecutionEngine(module);

                    passManager = new PassManager(module);
                    passManager.AddTargetData(execEngine.GetTargetData());

                    // optimizations
                        #if false
                    passManager.AddBasicAliasAnalysisPass();
                    passManager.AddPromoteMemoryToRegisterPass();
                    passManager.AddInstructionCombiningPass();
                    passManager.AddReassociatePass();
                    passManager.AddGVNPass();
                    passManager.AddCFGSimplificationPass();
                        #endif
                    passManager.Initialize();

                    // main = EmitTestLLVMIR();
                    Value valRet = traverse(n);

                    module.Dump();

                    //	if (valRet.Equals(Value.Null))
                    //		return Value.Null;

                    GenericValue val = execEngine.RunFunction(evalCtx.main, new GenericValue[0]);
                    Console.WriteLine("Evaluated to " + val.ToUInt());
                }

            return(default(Value));
        }
        public static int?GetColumnIndex(this DataTable dt, object argumentValue, bool throwIfNotFound = false)
        {
            int?result = null;

            if (dt == null || argumentValue == null)
            {
                result = null;
            }
            if (argumentValue != null)
            {
                GenericValue value = argumentValue as GenericValue;
                argumentValue = GenericValue.GetRawValue(value);
            }
            int?       num        = argumentValue as int?;
            DataColumn dataColumn = argumentValue as DataColumn;
            string     text       = argumentValue as string;

            text = (string.IsNullOrEmpty(text) ? null : text);
            if (dataColumn != null)
            {
                num = new int?(dt.Columns.IndexOf(dataColumn));
            }
            if (text != null)
            {
                num = new int?(dt.Columns.IndexOf(text));
            }
            if (num.HasValue)
            {
                result = ((num < 0 || dt.Columns.Count <= num) ? null : num);
            }
            if (!result.HasValue & throwIfNotFound)
            {
                string text2 = (argumentValue is string) ?
                               string.Format("ValueNotSetForArgument", "ColumnName") : ((argumentValue is int) ?
                                                                                        string.Format("ValueNotSetForArgument", "ColumnIndex") : string.Format("ValueNotSetForArgument", "Column"));
                text2 = char.ToLowerInvariant(text2[0]).ToString() + text2.Substring(1);
                throw new ArgumentException(text2);
            }
            return(result);
        }
Beispiel #23
0
 public AnyValueWrapper(GenericValue item)
 {
     this.Item = item;
 }
Beispiel #24
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue propertyValue, Option <byte> priority)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue      = propertyValue;
     this.Priority           = priority;
 }
Beispiel #25
0
 public ConstructedValueWrapper(GenericValue item)
 {
     this.Item = item;
 }
Beispiel #26
0
 public static NotificationParameters NewCommandFailure(GenericValue commandValue, StatusFlags statusFlags, GenericValue feedbackValue)
 {
     return(new CommandFailure(commandValue, statusFlags, feedbackValue));
 }
Beispiel #27
0
 public static PriorityValue NewConstructedValue(GenericValue constructedValue)
 {
     return new ConstructedValueWrapper(constructedValue);
 }
        public IFilterOperation FilterOperationFactory(DataTable datatable, ActivityContext context)
        {
            InArgument expr_06 = this.Operand;
            object     obj     = (expr_06 != null) ? expr_06.Get(context) : null;

            if (obj != null)
            {
                GenericValue genericValue = obj as GenericValue;
                obj = GenericValue.GetRawValue(genericValue);
            }
            if (this.Operator == FilterOperator.EQ)
            {
                return(new EqualsOperation
                {
                    Operand = obj
                });
            }
            if (this.Operator == FilterOperator.NOTEQ)
            {
                return(new NotEqualsOperation
                {
                    Operand = obj
                });
            }
            if (this.IsStringOperation)
            {
                string operand = obj as string;
                switch (this.Operator)
                {
                case FilterOperator.EMPTY:
                    return(new IsEmptyOperation());

                case FilterOperator.NOTEMPTY:
                    return(new IsEmptyOperation
                    {
                        IsNegation = true
                    });

                case FilterOperator.STARTSWITH:
                    return(new StartsWithOperation
                    {
                        Operand = operand
                    });

                case FilterOperator.ENDSWITH:
                    return(new EndsWithOperation
                    {
                        Operand = operand
                    });

                case FilterOperator.CONTAINS:
                    return(new ContainsOperation
                    {
                        Operand = operand
                    });

                case FilterOperator.NOTSTARTSWITH:
                    return(new StartsWithOperation
                    {
                        Operand = operand,
                        IsNegation = true
                    });

                case FilterOperator.NOTENDSWITH:
                    return(new EndsWithOperation
                    {
                        Operand = operand,
                        IsNegation = true
                    });

                case FilterOperator.NOTCONTAINS:
                    return(new ContainsOperation
                    {
                        Operand = operand,
                        IsNegation = true
                    });

                default:
                    return(null);
                }
            }
            else
            {
                IComparable operand2 = obj as IComparable;
                switch (this.Operator)
                {
                case FilterOperator.LT:
                    return(new LessThanOperation
                    {
                        Operand = operand2
                    });

                case FilterOperator.GT:
                    return(new GreaterThanOperation
                    {
                        Operand = operand2
                    });

                case FilterOperator.LTE:
                    return(new LessThanOrEqualOperation
                    {
                        Operand = operand2
                    });

                case FilterOperator.GTE:
                    return(new GreaterThanOrEqualOperation
                    {
                        Operand = operand2
                    });

                default:
                    return(null);
                }
            }
        }
Beispiel #29
0
 public TimeValue(Time time, GenericValue value)
 {
     this.Time = time;
     this.Value = value;
 }
 public static NotificationParameters NewCommandFailure(GenericValue commandValue, StatusFlags statusFlags, GenericValue feedbackValue)
 {
     return new CommandFailure(commandValue, statusFlags, feedbackValue);
 }
 //---------------------------------------------------------------------
 public GenericValue(GenericValue src)
 {
     this.value = src.value;
 }
Beispiel #32
0
 /// <summary>
 /// Puts a value into the sink
 /// </summary>
 /// <param name="value">The value to put</param>
 public void PutGeneric(GenericValue value)
 {
     _require(StreamOp.Generic);
     _writer.WriteGeneric(value, _state.Tag);
     _moveNext();
 }
Beispiel #33
0
 /// <summary>
 /// Puts a value into the sink
 /// </summary>
 /// <param name="value">The value to put</param>
 public void PutGeneric(GenericValue value)
 {
     _require(StreamOp.Generic);
     _writer.WriteGeneric(value, _state.Tag);
     _moveNext();
 }
Beispiel #34
0
        /// <summary>
        /// Writes a generic value to the stream
        /// </summary>
        /// <param name="value">The value to write</param>
        /// <param name="tag">The wrapper tag number, or 255 for no wrapper tag</param>
        public void WriteGeneric(GenericValue value, byte tag = 255)
        {
            var tvalue = value as TaggedGenericValue;
            if (tvalue == null)
                throw new Exception("Can only write TaggedGenericValue instances");

            _writeTypeHeader(tag, TagType.Open);
            _writer.Write(tvalue.tag, 0, tvalue.tag.Length);
            _writeTypeHeader(tag, TagType.Close);
        }
Beispiel #35
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue propertyValue)
     : this(objectIdentifier, propertyIdentifier, propertyArrayIndex, propertyValue, Option <byte> .None)
 {
 }
Beispiel #36
0
 public static ReadResultType NewPropertyValue(GenericValue propertyValue)
 {
     return new PropertyValueWrapper(propertyValue);
 }
Beispiel #37
0
 public ConstructedValueWrapper(GenericValue item)
 {
     this.Item = item;
 }
Beispiel #38
0
 public static LogDatumType NewAnyValue(GenericValue anyValue)
 {
     return(new AnyValueWrapper(anyValue));
 }
Beispiel #39
0
 public static PriorityValue NewConstructedValue(GenericValue constructedValue)
 {
     return(new ConstructedValueWrapper(constructedValue));
 }
Beispiel #40
0
 public AnyValueWrapper(GenericValue item)
 {
     this.Item = item;
 }
Beispiel #41
0
 public CommandFailure(GenericValue commandValue, StatusFlags statusFlags, GenericValue feedbackValue)
 {
     this.CommandValue  = commandValue;
     this.StatusFlags   = statusFlags;
     this.FeedbackValue = feedbackValue;
 }
Beispiel #42
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue value, Option <uint> priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value    = value;
     this.Priority = priority;
 }
 public ListOfSelectionCriteriaType(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, RelationSpecifierType relationSpecifier, GenericValue comparisonValue)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.RelationSpecifier = relationSpecifier;
     this.ComparisonValue = comparisonValue;
 }
Beispiel #44
0
 public PropertyValueWrapper(GenericValue item)
 {
     this.Item = item;
 }
Beispiel #45
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue)
     : this(objectIdentifier, propertyIdentifier, propertyArrayIndex, propertyValue, Option<byte>.None)
 {
 }
Beispiel #46
0
 internal GenericValue CreateIntGenericValue(int val) =>
 GenericValue.FromInt(_context.Int32Type, (ulong)val, true);
Beispiel #47
0
 public static ReadResultType NewPropertyValue(GenericValue propertyValue)
 {
     return(new PropertyValueWrapper(propertyValue));
 }
Beispiel #48
0
 public static LogDatumType NewAnyValue(GenericValue anyValue)
 {
     return new AnyValueWrapper(anyValue);
 }
 public CommandFailure(GenericValue commandValue, StatusFlags statusFlags, GenericValue feedbackValue)
 {
     this.CommandValue = commandValue;
     this.StatusFlags = statusFlags;
     this.FeedbackValue = feedbackValue;
 }
Beispiel #50
0
 public PropertyValueWrapper(GenericValue item)
 {
     this.Item = item;
 }