about summary refs log tree commit diff stats
path: root/503manhattan-line.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-22 21:38:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-22 21:40:03 -0700
commitba4a3c5be70d473479e663be0400b798f88c113d (patch)
treed0e332d7d67302cef5ef31e17152aeaec01b8ab6 /503manhattan-line.mu
parent5c26d765c7b0f263b48fcb5e903c2f284027859b (diff)
downloadmu-ba4a3c5be70d473479e663be0400b798f88c113d.tar.gz
start throwing error on labels too far for /disp8
While I'm doing this I might as well lay out a story I don't seem to
have told before in this commit log.

I translated Mu programs to Linux before I did so to bare metal like I
do in the top-level these days. The translator programs still run from
the linux/ directory. However they don't always have good error
messages. As long as I was translating to Linux this wasn't a huge deal
because I always translated Mu programs using the bootstrap translator
in linux/bootstrap/ -- which has great error messages. However,
linux/bootstrap/ can't build bare-metal programs because boot.subx uses
real-mode instructions that aren't supported. As a hack I created a
script called misc_checks that at least tries to run everything besides
boot.subx -- even though translation can never succeed. If I run it and
get to errors about unknown variables I know everything besides
boot.subx raised no errors.

Having labels too far in /disp8 args is is the single biggest reason we
need the misc_checks hack. Hopefully it's now obsolete.
Diffstat (limited to '503manhattan-line.mu')
0 files changed, 0 insertions, 0 deletions
ison <ben@gbmor.dev> 2019-06-06 01:23:44 -0400 committer Ben Morrison <ben@gbmor.dev> 2019-06-06 01:23:44 -0400 moved initDatabase() to db.go' href='/gbmor/getwtxt/commit/svc/db.go?h=v0.4.8&id=439695f5521924833153852dc84040554e835f11'>439695f ^
a5a32e7 ^


439695f ^


a5a32e7 ^
78f4d8a ^
439695f ^


78f4d8a ^
e9d4a6b ^
439695f ^
439695f ^
439695f ^
1a15258 ^
439695f ^

fdd9bd0 ^








c8fddff ^

fdd9bd0 ^

1a15258 ^
c8fddff ^
e9d4a6b ^
c8fddff ^

930ef34 ^

e9d4a6b ^
c8fddff ^

fdd9bd0 ^
1a15258 ^
c8fddff ^
c8fddff ^
e9d4a6b ^
c8fddff ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                                                      

        
                                             
                               

 








                                                




                      

                                          

                     
                          


                                


                               
                                                         
                                 


                                      
                                 
 
         
 
                    
                

 








                                             

 

                                        
                     
                      
                        

                    

                   
                  

 
                                            
               
                      
                 
                    
 
package svc // import "github.com/getwtxt/getwtxt/svc"

import (
	"github.com/syndtr/goleveldb/leveldb"
	"golang.org/x/sys/unix"
)

// Everything in this file is database-agnostic.
// Functions and types related to specific kinds
// of databases will be in their own respective
// files, such as:
//  - leveldb.go
//  - sqlite.go

// Abstraction to allow several different
// databases to be used interchangeably.
type dbase interface {
	push() error
	pull()
}

// Opens a new connection to the specified
// database, then reads it into memory.
func initDatabase() {
	var db dbase
	confObj.Mu.RLock()
	dbpath := confObj.DBPath
	confObj.Mu.RUnlock()

	switch confObj.DBType {

	case "leveldb":
		lvl, err := leveldb.OpenFile(dbpath, nil)
		errFatal("", err)
		db = &dbLevel{db: lvl}

	case "sqlite":
		db = initSqlite()

	}

	dbChan <- db
	pullDB()
}

// Close the database connection.
func killDB() {
	db := <-dbChan
	switch dbType := db.(type) {
	case *dbLevel:
		errLog("", dbType.db.Close())
	case *dbSqlite:
		errLog("", dbType.db.Close())
	}
}

// Pushes the registry's cache data
// to a local database for safe keeping.
func pushDB() error {
	db := <-dbChan
	err := db.push()
	dbChan <- db

	unix.Sync()

	return err
}

// Reads the database from disk into memory.
func pullDB() {
	db := <-dbChan
	db.pull()
	dbChan <- db
}