예제 #1
0
        public void Visit(LoadStmt load)
        {
            const string   module         = "<Module>";
            const string   program        = "Program";
            const string   sysFuncs       = "SystemFunctions";
            const string   userFuncs      = "UserFunctions";
            var            foundProgram   = false;
            var            foundSysFuncs  = false;
            var            foundUserFuncs = false;
            TypeDefinition userFuncsType  = null;

            // We load the assembly given by the statement.
            Raise <TypeCheckException> .IfNot(File.Exists(load.Assembly));

            var asmDef = AssemblyDefinition.ReadAssembly(load.Assembly);
            var modDef = asmDef.MainModule;

            // Type loading; in the first pass, we load all types. After that,
            // all field types are loaded: we have to do at least two passes
            // since field types may rely on types declared in the assembly we have to load.
            var loadedTypes = new LinkedList <TypeDefinition>();

            foreach (var typeDef in modDef.Types)
            {
                switch (typeDef.Name)
                {
                case module:
                    continue;

                case program:
                    foundProgram = true;
                    continue;

                case sysFuncs:
                    foundSysFuncs = true;
                    continue;

                case userFuncs:
                    foundUserFuncs = true;
                    userFuncsType  = typeDef;
                    continue;

                default:
                    LoadType(typeDef);
                    loadedTypes.AddLast(typeDef);
                    break;
                }
            }
            // An assembly produced by this language must have
            // a set of predefined types.
            Raise <TypeCheckException> .IfNot(foundProgram && foundSysFuncs && foundUserFuncs, "Invalid assembly");

            foreach (var typeDef in loadedTypes)
            {
                LoadTypeFields(typeDef);
            }

            // Function loading...
            Debug.Assert(userFuncsType != null);
            foreach (var funcDef in userFuncsType.Methods)
            {
                LoadFunc(funcDef);
            }
        }
예제 #2
0
 public void Visit(LoadStmt load)
 {
     Indent();
     _sb.AppendFormat("load({0})\r\n", load.Assembly);
 }
예제 #3
0
 public void Visit(LoadStmt load)
 {
     // Nothing to do here...
 }
예제 #4
0
 public void Visit(LoadStmt load)
 {
     // Nothing to do here...
 }
예제 #5
0
        public void Visit(LoadStmt load)
        {
            const string module = "<Module>";
            const string program = "Program";
            const string sysFuncs = "SystemFunctions";
            const string userFuncs = "UserFunctions";
            var foundProgram = false;
            var foundSysFuncs = false;
            var foundUserFuncs = false;
            TypeDefinition userFuncsType = null;

            // We load the assembly given by the statement.
            Raise<TypeCheckException>.IfNot(File.Exists(load.Assembly));
            var asmDef = AssemblyDefinition.ReadAssembly(load.Assembly);
            var modDef = asmDef.MainModule;

            // Type loading; in the first pass, we load all types. After that,
            // all field types are loaded: we have to do at least two passes
            // since field types may rely on types declared in the assembly we have to load.
            var loadedTypes = new LinkedList<TypeDefinition>();
            foreach (var typeDef in modDef.Types) {
                switch (typeDef.Name) {
                    case module:
                        continue;
                    case program:
                        foundProgram = true;
                        continue;
                    case sysFuncs:
                        foundSysFuncs = true;
                        continue;
                    case userFuncs:
                        foundUserFuncs = true;
                        userFuncsType = typeDef;
                        continue;
                    default:
                        LoadType(typeDef);
                        loadedTypes.AddLast(typeDef);
                        break;
                }
            }
            // An assembly produced by this language must have
            // a set of predefined types.
            Raise<TypeCheckException>.IfNot(foundProgram && foundSysFuncs && foundUserFuncs, "Invalid assembly");
            foreach (var typeDef in loadedTypes) {
                LoadTypeFields(typeDef);
            }

            // Function loading...
            Debug.Assert(userFuncsType != null);
            foreach (var funcDef in userFuncsType.Methods) {
                LoadFunc(funcDef);
            }
        }
예제 #6
0
 public void Visit(LoadStmt load)
 {
     Indent();
     _sb.AppendFormat("load({0})\r\n", load.Assembly);
 }