예제 #1
0
 public ExprSubstitutionNode(
     string optionalName,
     ClassIdentifierWArray optionalType)
 {
     OptionalName = optionalName;
     OptionalType = optionalType;
 }
예제 #2
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="variableType">type of the variable</param>
 /// <param name="variableName">name of the variable</param>
 /// <param name="assignment">expression assigning the initial value, or null if none</param>
 /// <param name="constant">if set to <c>true</c> [constant].</param>
 public CreateVariableDesc(
     ClassIdentifierWArray variableType,
     string variableName,
     ExprNode assignment,
     bool constant)
 {
     VariableType = variableType;
     VariableName = variableName;
     Assignment   = assignment;
     IsConstant   = constant;
 }
예제 #3
0
 public CreateTableColumn(
     string columnName,
     ExprNode optExpression,
     ClassIdentifierWArray optType,
     IList <AnnotationDesc> annotations,
     bool?primaryKey)
 {
     ColumnName    = columnName;
     OptExpression = optExpression;
     OptType       = optType;
     Annotations   = annotations;
     PrimaryKey    = primaryKey;
 }
예제 #4
0
        public override void ToPrecedenceFreeEPL(TextWriter writer)
        {
            writer.Write("cast(");
            ChildNodes[0].ToEPL(writer, ExprPrecedenceEnum.MINIMUM);
            writer.Write(",");
            ClassIdentifierWArray.ToEPL(writer);
            for (var i = 1; i < ChildNodes.Length; i++) {
                writer.Write(",");
                ChildNodes[i].ToEPL(writer, ExprPrecedenceEnum.MINIMUM);
            }

            writer.Write(')');
        }
예제 #5
0
 public static VariableMetaData CompileVariable(
     String variableName,
     String variableModuleName,
     NameAccessModifier variableVisibility,
     String optionalContextName,
     NameAccessModifier? optionalContextVisibility,
     String optionalModuleName,
     ClassIdentifierWArray variableType,
     bool isConstant,
     bool compileTimeConstant,
     Object initializationValue,
     ImportService importService,
     ExtensionClass extensionClass,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     BeanEventTypeFactory beanEventTypeFactory)
 {
     try {
         return GetTypeInfo(
             variableName,
             variableModuleName,
             variableVisibility,
             optionalContextName,
             optionalContextVisibility,
             optionalModuleName,
             variableType,
             false,
             isConstant,
             compileTimeConstant,
             initializationValue,
             importService,
             extensionClass,
             eventBeanTypedEventFactory,
             eventTypeRepositoryPreconfigured,
             beanEventTypeFactory);
     }
     catch (VariableTypeException t) {
         throw new ExprValidationException(t.Message, t);
     }
     catch (Exception t) {
         throw new ExprValidationException("Failed to compile variable '" + variableName + "': " + t.Message, t);
     }
 }
예제 #6
0
        public static void ConfigureVariables(
            VariableRepositoryPreconfigured repo,
            IDictionary<string, ConfigurationCommonVariable> variables,
            ImportService importService,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            foreach (var entry in variables) {
                string variableName = entry.Key.Trim();
                if (repo.GetMetadata(variableName) != null) {
                    continue;
                }

                VariableMetaData meta;
                try {
                    var variableType = ClassIdentifierWArray.ParseSODA(entry.Value.VariableType);
                    meta = GetTypeInfo(
                        variableName,
                        null,
                        NameAccessModifier.PRECONFIGURED,
                        null,
                        null,
                        null,
                        variableType,
                        true,
                        entry.Value.IsConstant,
                        entry.Value.IsConstant,
                        entry.Value.InitializationValue,
                        importService,
                        ExtensionClassEmpty.INSTANCE,
                        eventBeanTypedEventFactory,
                        eventTypeRepositoryPreconfigured,
                        beanEventTypeFactory);
                }
                catch (Exception t) {
                    throw new ConfigurationException("Error configuring variable '" + entry.Key + "': " + t.Message, t);
                }

                repo.AddVariable(entry.Key, meta);
            }
        }
예제 #7
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="classIdentifierWArray">the the name of the type to cast to</param>
 public ExprCastNode(ClassIdentifierWArray classIdentifierWArray)
 {
     ClassIdentifierWArray = classIdentifierWArray;
 }
예제 #8
0
        private static VariableMetaData GetTypeInfo(
            string variableName,
            string variableModuleName,
            NameAccessModifier variableVisibility,
            string optionalContextName,
            NameAccessModifier? optionalContextVisibility,
            string optionalContextModule,
            ClassIdentifierWArray variableTypeWArray,
            bool preconfigured,
            bool constant,
            bool compileTimeConstant,
            object valueAsProvided,
            ImportService importService,
            ExtensionClass extensionClass,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            // Determine the variable type
            var primitiveType = TypeHelper.GetPrimitiveTypeForName(variableTypeWArray.ClassIdentifier);
            var type = TypeHelper.GetTypeForSimpleName(variableTypeWArray.ClassIdentifier).GetBoxedType();
            Type arrayType = null;
            EventType eventType = null;
            if (type == null) {
                if (variableTypeWArray.ClassIdentifier.Equals("object", StringComparison.InvariantCultureIgnoreCase)) {
                    type = TypeHelper.GetArrayType(typeof(object), variableTypeWArray.ArrayDimensions);
                }

                if (type == null) {
                    eventType = eventTypeRepositoryPreconfigured.GetTypeByName(variableTypeWArray.ClassIdentifier);
                    if (eventType != null) {
                        type = eventType.UnderlyingType;
                    }
                }

                ImportException lastException = null;
                if (type == null) {
                    try {
                        type = importService.ResolveClass(variableTypeWArray.ClassIdentifier, false, extensionClass);
                        type = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                    catch (ImportException e) {
                        Log.Debug("Not found '" + type + "': " + e.Message, e);
                        lastException = e;
                        // expected
                    }
                }

                if (type == null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' is not a recognized type",
                        lastException);
                }

                if (variableTypeWArray.ArrayDimensions > 0 && eventType != null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array type as it is an event type",
                        lastException);
                }
            }
            else {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    if (variableTypeWArray.IsArrayOfPrimitive) {
                        if (primitiveType == null) {
                            throw new VariableTypeException(
                                "Cannot create variable '" +
                                variableName +
                                "', type '" +
                                variableTypeWArray.ClassIdentifier +
                                "' is not a primitive type");
                        }

                        arrayType = TypeHelper.GetArrayType(primitiveType, variableTypeWArray.ArrayDimensions);
                    }
                    else {
                        arrayType = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                }
            }

            if (eventType == null &&
                !type.IsBuiltinDataType() &&
                type != typeof(object) &&
                !type.IsArray &&
                !type.IsEnum) {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array, only scalar types can be array");
                }

                eventType = beanEventTypeFactory.GetCreateBeanType(type, false);
            }

            if (arrayType != null) {
                type = arrayType;
            }

            var coerced = GetCoercedValue(valueAsProvided, eventType, variableName, type, eventBeanTypedEventFactory);
            return new VariableMetaData(
                variableName,
                variableModuleName,
                variableVisibility,
                optionalContextName,
                optionalContextVisibility,
                optionalContextModule,
                type,
                eventType,
                preconfigured,
                constant,
                compileTimeConstant,
                coerced,
                true);
        }