コード例 #1
0
ファイル: ChelaModule.cs プロジェクト: ronsaldo/chela
        public Structure GetAssociatedClass(IChelaType type)
        {
            if(type.IsArray())
                return arrayClass;

            Structure ret;
            if(associatedClass.TryGetValue(type, out ret))
                return ret;
            else
                return null;
        }
コード例 #2
0
ファイル: ChelaModule.cs プロジェクト: ronsaldo/chela
        private void RegisterAnonTypeLeaf(IChelaType type, bool registered)
        {
            // Make sure lower types are registered.
            if(!registered)
                RegisterType(type);

            if(type.IsReference())
            {
                ReferenceType refType = (ReferenceType)type;
                RegisterAnonTypeLeaf(refType.GetReferencedType());
            }
            else if(type.IsPointer())
            {
                PointerType pointerType = (PointerType)type;
                RegisterAnonTypeLeaf(pointerType.GetPointedType());
            }
            else if(type.IsConstant())
            {
                ConstantType constType = (ConstantType)type;
                RegisterAnonTypeLeaf(constType.GetValueType());
            }
            else if(type.IsArray())
            {
                ArrayType arrayType = (ArrayType)type;
                RegisterAnonTypeLeaf(arrayType.GetValueType());
            }
            else if(type.IsVector())
            {
                VectorType vectorType = (VectorType)type;
                RegisterAnonTypeLeaf(vectorType.GetPrimitiveType());
            }
            else if(type.IsMatrix())
            {
                MatrixType matrixType = (MatrixType)type;
                RegisterAnonTypeLeaf(matrixType.GetPrimitiveType());
            }
            else if(type.IsFunction())
            {
                FunctionType functionType = (FunctionType)type;

                // Register the return type.
                RegisterAnonTypeLeaf(functionType.GetReturnType());

                // Register the function arguments.
                for(int i = 0; i < functionType.GetArgumentCount(); ++i)
                    RegisterAnonTypeLeaf(functionType.GetArgument(i));
            }
            else if(type.IsPlaceHolderType())
            {
                // Register the base types.
                PlaceHolderType placeholder = (PlaceHolderType)type;
                for(int i = 0; i < placeholder.GetBaseCount(); ++i)
                    RegisterMember(placeholder.GetBase(i));
            }
            else if(type.IsPrimitive())
            {
                // Do nothing.
            }
            else if(type.IsTypeInstance())
            {
                StructureInstance instance = (StructureInstance)type;
                instance.PrepareSerialization();
                RegisterMember(instance);
            }
            else
            {
                // Found a leaf.
                ScopeMember member = (ScopeMember)type;
                RegisterMember(member);
            }
        }