aboutsummaryrefslogtreecommitdiff
path: root/main/coclmain.icl
blob: 18cee66d20888e1801c6cfb65dc6eefa41994081 (plain) (blame)
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
implementation module coclmain

CoclMainVersion :== 0

import StdEnv
import ArgEnv
import Version
import set_return_code

import compile

// coclMain :: ![{#Char}] !*World -> *World
// testArgs world
coclMain :== coclMainWithVersionCheck CoclMainVersionCurrent CoclMainVersionLatestDef CoclMainVersionLatestImp

CoclMainVersionCurrent
	:==	0x02000205
CoclMainVersionLatestDef
	:==	0x02000205
CoclMainVersionLatestImp
	:==	0x02000205

checkVersion :: VersionsCompatability *File -> (!Bool, !*File)
checkVersion VersionsAreCompatible errorFile
	=	(True, errorFile)
checkVersion VersionObservedIsTooNew errorFile
	#	errorFile
			=	fwrites "[Coclmain] the library is too new\n" errorFile
	=	(False, errorFile)
checkVersion VersionObservedIsTooOld errorFile
	#	errorFile
			=	fwrites "[Coclmain] the library is too old\n" errorFile
	=	(False, errorFile)

coclMainWithVersionCheck :: !Int !Int !Int ![{#Char}] !*World -> *World
// currentVersion latestDefVersion latestImpVersion testArgs world
coclMainWithVersionCheck  currentVersion latestDefVersion latestImpVersion testArgs world
	# observedVersion =
		{	versionCurrent
				=	CoclMainVersionCurrent
		,	versionOldestDefinition
				=	CoclMainVersionLatestDef
		,	versionOldestImplementation
				=	CoclMainVersionLatestImp
		}
	  expectedVersion =
		{	versionCurrent
				=	currentVersion
		,	versionOldestDefinition
				=	latestDefVersion
		,	versionOldestImplementation
				=	latestImpVersion
		}
	| not (fst (checkVersion (versionCompare expectedVersion observedVersion) stderr))
		=	set_return_code (-1) world
	# (success, world)
		=	accFiles (\files0 -> let (r,cache,files)=compile commandArgs empty_cache files0 in (r,files)) world
	=	set_return_code (if success 0(-1)) world
	where
		commandArgs
			=	if (length realArgs == 0) testArgs realArgs
		realArgs
			=	tl [arg \\ arg <-: getCommandLine]