Package org.openquark.cal.internal.serialization.RecordInputStream

Examples of org.openquark.cal.internal.serialization.RecordInputStream.RecordHeaderInfo


     * @param mti    
     * @param msgLogger the logger to which to log deserialization messages.
     * @throws IOException
     */
    void loadFinal (RecordInputStream s, ModuleTypeInfo mti, CompilerMessageLogger msgLogger) throws IOException {
        RecordHeaderInfo rhi = s.findRecord(TYPE_CONSTRUCTOR_ENTITY_RECORD_TAGS);
        if (rhi == null) {
            throw new IOException ("Unable to find TypeConstructor record.");
        }
        DeserializationHelper.checkSerializationSchema(rhi.getSchema(), serializationSchema, mti.getModuleName(), "TypeConstructor", msgLogger);

        try {
            super.readContent (s, mti, msgLogger);
           
            // QualifiedName
            QualifiedName name = this.getName();
            TypeConstructor builtIn = getBuiltInType(name);
            if (builtIn != null) {
                s.skipRestOfRecord();
                return;
            }
           
            // kindExpr
            kindExpr = KindExpr.load(s, mti.getModuleName(), msgLogger);
           
            // ForeignTypeInfo  
            if (rhi.getRecordTag() == ModuleSerializationTags.FOREIGN_TYPE_CONSTRUCTOR_ENTITY) {
                foreignTypeInfo = ForeignTypeInfo.load(s, mti.getModuleName(), mti.getModule().getForeignClassLoader(), msgLogger);
            }
           
            int nDCs = s.readShortCompressed();
            for (int i = 0; i < nDCs; ++i) {
View Full Code Here


     * @param msgLogger the logger to which to log deserialization messages.
     * @return and instance of FieldName.
     * @throws IOException
     */
    static FieldName load (RecordInputStream s, ModuleName moduleName, CompilerMessageLogger msgLogger) throws IOException {
        RecordHeaderInfo rhi = s.findRecord(FieldNameIO.FIELD_NAME_RECORD_TAGS);
        if (rhi == null) {
            throw new IOException ("Unable to find FieldName record header.");
        }
       
        // Now that we have the record tag load the appropriate type of child.
        switch (rhi.getRecordTag()) {
            case ModuleSerializationTags.FIELD_NAME_ORDINAL:
            {
                return FieldNameIO.loadOrdinalFieldName(s, rhi.getSchema(), moduleName, msgLogger);
            }
           
            case ModuleSerializationTags.FIELD_NAME_TEXTUAL:
            {
                return FieldNameIO.loadTextualFieldName(s, rhi.getSchema(), moduleName, msgLogger);
            }
           
            default:
                throw new IOException("Unexpected record tag " + rhi.getRecordTag() + " encountered while loading FieldName.");
        }
    }
View Full Code Here

     * @param msgLogger the logger to which to log deserialization messages.
     * @return an instance of CoreFunction.
     * @throws IOException
     */
    public static final CoreFunction load (RecordInputStream s, ModuleTypeInfo mti, CompilerMessageLogger msgLogger) throws IOException {
        RecordHeaderInfo rhi = s.findRecord(ModuleSerializationTags.CORE_FUNCTION);
        if (rhi == null) {
            throw new IOException("Unable to find CoreFunction record header.");
        }
        DeserializationHelper.checkSerializationSchema(rhi.getSchema(), serializationSchema, mti.getModuleName(), "CoreFunction", msgLogger);
       
        QualifiedName name = s.readQualifiedName();
        try {
            byte flags = s.readByte();
            boolean aliasOfExists = (flags & 0x01) > 0;
            boolean isTailRecursive = (flags & 0x02) > 0;
            boolean functionCanBeEagerlyEvaluated = (flags &0x04) > 0;
           
            int nArgs = s.readShortCompressed();
            String[] argNames = new String[nArgs];
            for (int i = 0; i < nArgs; ++i) {
                argNames[i] = s.readUTF();
            }
           
            int nBytesForArgFlags = (nArgs + 7) / 8;
            byte[] argFlags = new byte[nBytesForArgFlags];
            for (int i = 0; i < argFlags.length; ++i) {
                argFlags[i] = s.readByte();
            }
           
            boolean[] argStrictness = RecordInputStream.bitArrayToBooleans(argFlags, nArgs);
           
            TypeExpr[] argTypes = new TypeExpr[nArgs];
            for (int i = 0; i < argFlags.length; ++i) {
                argFlags[i] = s.readByte();
            }
            boolean[] typeExistence = RecordInputStream.bitArrayToBooleans(argFlags, nArgs);
            int nArgsPresent = 0;
            for (int i = 0; i < nArgs; ++i) {
                if (typeExistence[i]) {
                    nArgsPresent++;
                }
            }
           
            TypeExpr[] types = TypeExpr.load(s, mti, nArgsPresent+1, msgLogger);
            int iSource = 0;
            // length of type existence is the number of args
            for(int iDest = 0; iDest < nArgs; ++iDest){
                if (typeExistence[iDest]){
                    argTypes[iDest] = types[iSource++];
                }
            }
           
            TypeExpr resultType = types[nArgsPresent];
           
            QualifiedName aliasOf = null;
            if (aliasOfExists) {
                aliasOf = s.readQualifiedName();
            }
           
            long timeStamp = s.readLong();
           
            int nConnectedComponents = s.readShortCompressed();
            Set<String> connectedComponents = new HashSet<String>();
            for (int i = 0; i < nConnectedComponents; ++i) {
                String componentName = s.readUTF();
                connectedComponents.add(componentName);
            }
           
            byte type = s.readByte();
           
            CoreFunction cf = new CoreFunction (name,
                                                argNames,
                                                argStrictness,
                                                argTypes,
                                                resultType,
                                                type,
                                                functionCanBeEagerlyEvaluated,
                                                timeStamp);
           
            cf.setIsTailRecursive(isTailRecursive);
            cf.setAliasOf(aliasOf);
            cf.setStronglyConnectedComponents(connectedComponents);
           
            if (!s.atEndOfRecord()) {
                boolean b = s.readBoolean();
                if (b) {
                    byte typeByte = s.readByte();
                    if (typeByte == LITERAL_TYPE_CHARACTER) {
                        cf.literalValue = Character.valueOf(s.readChar());
                    } else if (typeByte == LITERAL_TYPE_BOOLEAN) {
                        cf.literalValue = Boolean.valueOf(s.readBoolean());
                    } else if (typeByte == LITERAL_TYPE_INTEGER) {
                        cf.literalValue = Integer.valueOf(s.readInt());
                    } else if (typeByte == LITERAL_TYPE_DOUBLE) {
                        cf.literalValue = Double.valueOf(s.readDouble());
                    } else if (typeByte == LITERAL_TYPE_BYTE) {
                        cf.literalValue = Byte.valueOf(s.readByte());
                    } else if (typeByte == LITERAL_TYPE_SHORT) {
                        cf.literalValue = Short.valueOf(s.readShort());
                    } else if (typeByte == LITERAL_TYPE_FLOAT) {
                        cf.literalValue = Float.valueOf(s.readFloat());
                    } else if (typeByte == LITERAL_TYPE_LONG) {
                        cf.literalValue = Long.valueOf(s.readLong());
                    } else if (typeByte == LITERAL_TYPE_STRING) {
                        cf.literalValue = s.readUTF();
                    } else if (typeByte == LITERAL_TYPE_BIG_INTEGER) {
                        String ds = s.readUTF();
                        cf.literalValue = new BigInteger(ds);
                    else {
                        throw new IOException ("Attemp to read unhandled literal value.");
                    }
                   
                }
            }
           
            boolean isForAdjunct = s.readBoolean();
            cf.setForAdjunct(isForAdjunct);
           
            if (rhi.getSchema() >= serializationSchema){
                boolean hadUnsafeCoerce = s.readBoolean();
                if (hadUnsafeCoerce){
                    cf.setHadUnsafeCoerce();
                }
            }
View Full Code Here

     * @param msgLogger the logger to which to log deserialization messages.
     * @throws IOException
     */
    protected void read (RecordInputStream s, ModuleTypeInfo mti, CompilerMessageLogger msgLogger) throws IOException {
        // Load the record header and determine which actual class we are loading.
        RecordHeaderInfo rhi = s.findRecord(ModuleSerializationTags.MACHINE_FUNCTION);
        if (rhi == null) {
            throw new IOException ("Unable to find record header for MachineFunction.");
        }
        if (rhi.getSchema() > serialSchema) {
            throw new IOException("Saved schema is greater than current schema in MachineFunction.");
        }
       
        this.optimized = true;
        this.codeGenerated = true;
View Full Code Here

     * @throws IOException
     */
    protected void readContent (RecordInputStream s, Map<ModuleName, Module> otherModules, CompilerMessageLogger msgLogger) throws IOException {
       
        // At this point we should be at the beginning of the Module record.
        RecordHeaderInfo rhi = s.findRecord(ModuleSerializationTags.MODULE);
        if (rhi == null) {
            throw new IOException ("Unable to find Module record.");
        }
        if (rhi.getSchema() > moduleSerializationSchema) {
            throw new IOException("Saved schema is greather than current schema in Module.");
        }
       
       
        moduleTypeInfo.readContent(s, otherModules, msgLogger);
View Full Code Here

     * @param s
     * @return Set of ModuleName representing the imported modules.
     * @throws IOException
     */
    public static Set<ModuleName> readDependencies (RecordInputStream s) throws IOException {
        RecordHeaderInfo rhi = s.findRecord(ModuleSerializationTags.MODULE_IMPORTS);
        if (rhi == null) {
            throw new IOException ("Unable to find module dependencies record.");
        }
        if (rhi.getSchema() > importSerializationSchema) {
            throw new IOException("Saved schema is greather than current schema in Module.");
        }
        if (rhi.getSchema() < importSerializationSchema) {
            throw new IOException("Saved schema is less than current schema in Module. Earlier import serialization schemas are not supported.");
        }
        /* ModuleName moduleName = */ s.readModuleName();
        int nImports = s.readInt();
        Set<ModuleName> set = new HashSet<ModuleName>();
View Full Code Here

     * @return the module-specific GeneratedCodeInfo.
     * @throws IOException
     */
    public static final GeneratedCodeInfo loadGeneratedCodeInfo(RecordInputStream s) throws IOException {
        // Load the record header and determine which class this is.
        RecordHeaderInfo rhi = s.findRecord(GENERATED_CODE_INFO_RECORD_TAGS);
        if (rhi == null) {
            throw new IOException ("Unable to find module record.");
        }

        if (rhi.getRecordTag() == ModuleSerializationTags.LECC_GENERATED_CODE_INFO) {
            return LECCModule.loadCodeInfo(s, rhi.getSchema())// read the module name and the generated code info.
        } else
            if (rhi.getRecordTag() == ModuleSerializationTags.G_GENERATED_CODE_INFO) {
                throw new IOException ("Loading of g-machine specific compiled modules is not yet supported.");
            } else {
                throw new IOException ("Unexpected record tag found in Module.read: " + rhi.getRecordTag());
            }
    }
View Full Code Here

     */
    public final static Module load (RecordInputStream s, Map<ModuleName, Module> loadedModules, ClassLoader foreignClassLoader,
            GeneratedCodeInfo generatedCodeInfo, CompilerMessageLogger msgLogger) throws IOException {
       
        // Load the record header and determine which class this is.
        RecordHeaderInfo rhi = s.findRecord(MODULE_RECORD_TAGS);
        if (rhi == null) {
            throw new IOException ("Unable to find module record.");
        }
       
        if (rhi.getRecordTag() == ModuleSerializationTags.LECC_MODULE) {
            return LECCModule.load(s, rhi.getSchema(), loadedModules, foreignClassLoader, generatedCodeInfo, msgLogger);
        } else
        if (rhi.getRecordTag() == ModuleSerializationTags.G_MODULE) {
            throw new IOException ("Loading of g-machine specific compiled modules is not yet supported.");
        } else {
            throw new IOException ("Unexpected record tag found in Module.read: " + rhi.getRecordTag());
        }
    }
View Full Code Here

     * @return an instance of Expression
     * @throws IOException
     */
    public static Expression load (RecordInputStream s, ModuleTypeInfo moduleTypeInfo, CompilerMessageLogger msgLogger) throws IOException {

        RecordHeaderInfo rhi = s.findRecord(EXPRESSION_RECORD_TAGS);
        if (rhi == null) {
            throw new IOException("Unable to find Expression record header.");
        }
       
        switch (rhi.getRecordTag()) {
        case ModuleSerializationTags.EXPRESSION_APPL:
            return Appl.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_CAST:
            return Cast.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_DATACONS_SELECTION:
            return DataConsSelection.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_ERROR_INFO:
            return ErrorInfo.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_LET_REC:
            return LetRec.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_LET_NONREC:
            return LetNonRec.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_LITERAL:
            return Literal.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_PACKCONS:
            return PackCons.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_RECORD_CASE:
            return RecordCase.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_RECORD_UPDATE:
            return RecordUpdate.load(s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_RECORD_EXTENSION:
            return RecordExtension.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_RECORD_SELECTION:
            return RecordSelection.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_SWITCH:
            return Switch.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_TAIL_RECURSIVE_CALL:
            return TailRecursiveCall.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        case ModuleSerializationTags.EXPRESSION_VAR:
            return Var.load (s, rhi.getSchema(), moduleTypeInfo, msgLogger);
           
        default:
            throw new IOException ("Unrecognized record tag of " + rhi.getRecordTag() + " for Expression.");
        }
    }
View Full Code Here

         * @param mti
         * @param msgLogger the logger to which to log deserialization messages.
         * @throws IOException
         */
        private void readContent (RecordInputStream s, ModuleTypeInfo mti, CompilerMessageLogger msgLogger) throws IOException {
            RecordHeaderInfo rhi = s.findRecord(ModuleSerializationTags.EXPRESSION_LET);
            if (rhi == null) {
                throw new IOException("Unable to find Expression.Let record header.");
            }
            DeserializationHelper.checkSerializationSchema(rhi.getSchema(), serializationSchema, mti.getModuleName(), "Expression.Let", msgLogger);

            Expression expr = Expression.load (s, mti, msgLogger);
           
            this.body = expr;
           
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.serialization.RecordInputStream.RecordHeaderInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.