/// <summary> /// Provides the callable that is called by this expression /// </summary> /// <param name="namable"></param> /// <returns></returns> public override ICallable getCalled(InterpretationContext context) { ICallable retVal = null; Call calledFunction = Called as Call; if (calledFunction != null) { retVal = Called.GetValue(context) as ICallable; } else { retVal = Called.getCalled(context); if (retVal == null) { Types.Range range = Called.GetExpressionType() as Types.Range; if (range != null) { retVal = range.CastFunction; } if (retVal == null) { retVal = Called.GetValue(context) as ICallable; } } } return(retVal); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public Cast(Types.Range range) : base(range.EFSSystem, range.Name) { Range = range; Value = (Parameter)Generated.acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.AnyType; Value.setFather(this); FormalParameters.Add(Value); }
/// <summary> /// Provides the ICallable that is statically defined /// </summary> public virtual ICallable getStaticCallable() { ICallable retVal = Ref as ICallable; if (retVal == null) { Types.Range range = Ref as Types.Range; if (range != null) { retVal = range.CastFunction; } } return(retVal); }
public ICallable getCalled(InterpretationContext context) { ICallable retVal = getReference(context) as ICallable; if (retVal == null) { Types.Range range = GetDesignatorType() as Types.Range; if (range != null) { retVal = range.CastFunction; } } return(retVal); }
/// <summary> /// Indicates if the type is double /// </summary> /// <param name="root"></param> /// <param name="expression"></param> /// <param name="parameter"></param> public bool IsDouble() { bool retVal = false; Types.Range range = this as Types.Range; if (range != null) { retVal = range.getPrecision() == Generated.acceptor.PrecisionEnum.aDoublePrecision; } else { retVal = this == EFSSystem.DoubleType; } return(retVal); }
/// <summary> /// Fills the given structure with the values provided from the database /// </summary> /// <param name="aNameSpace">Namespace of the structure</param> /// <param name="fields">Fields to be copied into the structure</param> /// <param name="index">Index (of fields list) from which we have to start copying</param> /// <param name="aStructure">The structure to be filled</param> private void FillStructure(Types.NameSpace aNameSpace, ArrayList fields, ref int index, Values.StructureValue aStructure) { int j = 0; for (int i = index; i < fields.Count; i++) { Tests.DBElements.DBField field = fields[i] as Tests.DBElements.DBField; KeyValuePair <string, Variables.IVariable> pair = aStructure.SubVariables.ElementAt(j); Variables.IVariable variable = pair.Value; if (variable.Name.StartsWith(field.Variable)) // we use StartsWith and not Equals because we can have N_ITER_1 and N_ITER { if (variable.Type is Types.Enum) { Types.Enum type = variable.Type as Types.Enum; foreach (DataDictionary.Constants.EnumValue enumValue in type.Values) { int value = Int32.Parse(enumValue.getValue()); if (value == field.Value) { variable.Value = enumValue; j++; break; } } } else if (variable.Type is Types.Range) { Types.Range type = variable.Type as Types.Range; variable.Value = new Values.IntValue(type, (decimal)field.Value); j++; } else { throw new Exception("Unhandled variable type"); } if (field.Variable.Equals("N_ITER")) // we have to create a sequence { KeyValuePair <string, Variables.IVariable> sequencePair = aStructure.SubVariables.ElementAt(j); Variables.IVariable sequenceVariable = sequencePair.Value; Types.Collection collectionType = (Types.Collection)EFSSystem.findType(aNameSpace, sequenceVariable.TypeName); Values.ListValue sequence = new Values.ListValue(collectionType, new List <Values.IValue>()); for (int k = 0; k < field.Value; k++) { Types.Structure structureType = (Types.Structure)EFSSystem.findType(aNameSpace, sequence.CollectionType.Type.FullName); Values.StructureValue structureValue = new Values.StructureValue(structureType, structureType.NameSpace); FillStructure(aNameSpace, fields, ref index, structureValue); sequence.Val.Add(structureValue); } sequenceVariable.Value = sequence; j++; } } // if all the fields of the structue are filled, we terminated if (j == aStructure.SubVariables.Count) { index = i; break; } } }