Commit d1f68b96 authored by Ronny Wichers Schreur's avatar Ronny Wichers Schreur

Initial import

parent cc8d6a7e
This diff is collapsed.
#
# Makefile for the Clean Standard Environment
#
#
# make (= make stdenv):
# compiles all modules
#
# make install:
# compiles all modules
# copies files to install directory
#
# make cleanup:
# removes all files in this directory that can be recreated
#
CLEAN_MODULES = \
StdArray StdCharList StdClass StdDebug StdFunc StdList \
StdOrdList StdOverloaded StdTuple _SystemEnum StdEnum StdEnv
SYSTEM_MODULES = \
StdBool StdChar StdFile StdInt StdMisc StdReal \
StdString _SystemArray
ABC_MODULES = \
_system
OBJECT_MODULES = \
_startup
SYSTEM_OBJECT_MODULES = \
_reals crt crti crtn
CLEAN_MODULES_ABC = $(CLEAN_MODULES:%=Clean\ System\ Files/%.abc)
SYSTEM_MODULES_ABC = $(SYSTEM_MODULES:%=Clean\ System\ Files/%.abc)
ABC_MODULES_ABC = $(ABC_MODULES:%=Clean\ System\ Files/%.abc)
CLEAN_MODULES_O = $(CLEAN_MODULES:%=Clean\ System\ Files/%.o)
SYSTEM_MODULES_O = $(SYSTEM_MODULES:%=Clean\ System\ Files/%.o)
ABC_MODULES_O = $(ABC_MODULES:%=Clean\ System\ Files/%.o)
OBJECT_MODULES_O = $(OBJECT_MODULES:%=Clean\ System\ Files/%.o)
SYSTEM_OBJECT_MODULES_O = $(SYSTEM_OBJECT_MODULES:%=Clean\ System\ Files/%.o)
STDENV_FILES = \
$(CLEAN_MODULES:%=%.icl) \
$(CLEAN_MODULES:%=%.dcl) \
$(SYSTEM_MODULES:%=%.dcl) \
$(SYSTEM_MODULES_ABC) \
$(CLEAN_MODULES_ABC) \
$(ABC_MODULES_ABC) \
wait1 \
$(SYSTEM_MODULES_O) \
$(CLEAN_MODULES_O) \
$(ABC_MODULES_O) \
$(OBJECT_MODULES_O) \
$(SYSTEM_OBJECT_MODULES_O)
wait1:
sleep 1
#
# Compile
#
stdenv: $(STDENV_FILES)
#
# Install
#
# the order here is important, because the files will be
# installed in the order given below.
INSTALL_STDENV_FILES = \
$(CLEAN_MODULES:%=$(INSTALL_STDENV_DIR)/%.icl) \
$(CLEAN_MODULES:%=$(INSTALL_STDENV_DIR)/%.dcl) \
$(SYSTEM_MODULES:%=$(INSTALL_STDENV_DIR)/%.dcl) \
$(ABC_MODULES:%=$(INSTALL_STDENV_DIR)/%.dcl) \
$(OBJECT_MODULES:%=$(INSTALL_STDENV_DIR)/%.dcl) \
$(SYSTEM_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.abc) \
$(CLEAN_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.abc) \
$(ABC_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.abc) \
wait2 \
$(SYSTEM_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.o) \
$(CLEAN_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.o) \
$(ABC_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.o) \
$(OBJECT_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.o) \
$(SYSTEM_OBJECT_MODULES:%=$(INSTALL_STDENV_DIR)/Clean\ System\ Files/%.o) \
$(INSTALL_STDENV_DIR)/Clean\ System\ Files/libCleanxv.a
install: stdenv $(INSTALL_STDENV_DIR) $(INSTALL_STDENV_DIR)/Clean\ System\ Files $(INSTALL_STDENV_FILES)
wait2:
sleep 1
$(INSTALL_STDENV_DIR) :
mkdir -p "$@"
$(INSTALL_STDENV_DIR)/Clean\ System\ Files :
mkdir -p "$@"
$(INSTALL_STDENV_DIR)/% : %
cp "$<" "$@"
chmod 644 "$@"
$(INSTALL_STDENV_DIR)/Clean\ System\ Files/libCleanxv.a :
$(RM) $(INSTALL_STDENV_DIR)/Clean\ System\ Files/libCleanxv.a; \
if test -f ../../iolib/libCleanvx.a; \
then ln -fs ../../iolib/libCleanxv.a $(INSTALL_STDENV_DIR)/Clean\ System\ Files/libCleanxv.a; \
else touch ../../libCleanxv.a; ln -fs ../../iolib/libCleanxv.a $(INSTALL_STDENV_DIR)/Clean\ System\ Files/libCleanxv.a; rm ../../libCleanxv.a; \
fi
#
# Cleanup
#
cleanup:
$(RM) $(CLEAN_MODULES_ABC) \
$(RM) $(CLEAN_MODULES_O) \
$(RM) $(SYSTEM_MODULES_O) \
$(RM) $(ABC_MODULES_O)
#
# Commands
#
CLM = clm
CLMFLAGS =
.SUFFIXES: .abc .dcl .icl .o
.icl.abc:
$(CLM) $(CLMFLAGS) -ABC $*
.icl.o:
$(CLM) $(CLMFLAGS) -O `basename "$*" .icl`
.abc.o:
$(CLM) $(CLMFLAGS) -O `basename "$*" .icl`
Clean\ System\ Files/StdArray.o : StdArray.icl StdArray.dcl
$(CLM) -O StdArray
Clean\ System\ Files/StdArray.abc : StdArray.icl StdArray.dcl
$(CLM) -ABC StdArray
Clean\ System\ Files/StdCharList.o : StdCharList.icl StdCharList.dcl
$(CLM) -O StdCharList
Clean\ System\ Files/StdCharList.abc : StdCharList.icl StdCharList.dcl
$(CLM) -ABC StdCharList
Clean\ System\ Files/StdClass.o : StdClass.icl StdClass.dcl
$(CLM) -O StdClass
Clean\ System\ Files/StdClass.abc : StdClass.icl StdClass.dcl
$(CLM) -ABC StdClass
Clean\ System\ Files/StdDebug.o : StdDebug.icl StdDebug.dcl
$(CLM) -O StdDebug
Clean\ System\ Files/StdDebug.abc : StdDebug.icl StdDebug.dcl
$(CLM) -ABC StdDebug
Clean\ System\ Files/StdEnum.o : StdEnum.icl StdEnum.dcl
$(CLM) -O StdEnum
Clean\ System\ Files/StdEnum.abc : StdEnum.icl StdEnum.dcl
$(CLM) -ABC StdEnum
Clean\ System\ Files/StdEnv.o : StdEnv.icl StdEnv.dcl
$(CLM) -O StdEnv
Clean\ System\ Files/StdEnv.abc : StdEnv.icl StdEnv.dcl
$(CLM) -ABC StdEnv
Clean\ System\ Files/StdFunc.o : StdFunc.icl StdFunc.dcl
$(CLM) -O StdFunc
Clean\ System\ Files/StdFunc.abc : StdFunc.icl StdFunc.dcl
$(CLM) -ABC StdFunc
Clean\ System\ Files/StdList.o : StdList.icl StdList.dcl
$(CLM) -O StdList
Clean\ System\ Files/StdList.abc : StdList.icl StdList.dcl
$(CLM) -ABC StdList
Clean\ System\ Files/StdOrdList.o : StdOrdList.icl StdOrdList.dcl
$(CLM) -O StdOrdList
Clean\ System\ Files/StdOrdList.abc : StdOrdList.icl StdOrdList.dcl
$(CLM) -ABC StdOrdList
Clean\ System\ Files/StdOverloaded.o : StdOverloaded.icl StdOverloaded.dcl
$(CLM) -O StdOverloaded
Clean\ System\ Files/StdOverloaded.abc : StdOverloaded.icl StdOverloaded.dcl
$(CLM) -ABC StdOverloaded
Clean\ System\ Files/StdTuple.o : StdTuple.icl StdTuple.dcl
$(CLM) -O StdTuple
Clean\ System\ Files/StdTuple.abc : StdTuple.icl StdTuple.dcl
$(CLM) -ABC StdTuple
Clean\ System\ Files/_SystemEnum.o : _SystemEnum.icl _SystemEnum.dcl
$(CLM) -O _SystemEnum
Clean\ System\ Files/_SystemEnum.abc : _SystemEnum.icl _SystemEnum.dcl
$(CLM) -ABC _SystemEnum
Clean\ System\ Files/StdBool.o : StdBool.dcl Clean\ System\ Files/StdBool.abc
$(CLM) -O StdBool
Clean\ System\ Files/StdChar.o : StdChar.dcl Clean\ System\ Files/StdChar.abc
$(CLM) -O StdChar
Clean\ System\ Files/StdFile.o : StdFile.dcl Clean\ System\ Files/StdFile.abc
$(CLM) -O StdFile
Clean\ System\ Files/StdInt.o : StdInt.dcl Clean\ System\ Files/StdInt.abc
$(CLM) -O StdInt
Clean\ System\ Files/StdMisc.o : StdMisc.dcl Clean\ System\ Files/StdMisc.abc
$(CLM) -O StdMisc
Clean\ System\ Files/StdReal.o : StdReal.dcl Clean\ System\ Files/StdReal.abc
$(CLM) -O StdReal
Clean\ System\ Files/StdString.o : StdString.dcl Clean\ System\ Files/StdString.abc
$(CLM) -O StdString
Clean\ System\ Files/_SystemArray.o : _SystemArray.dcl Clean\ System\ Files/_SystemArray.abc
$(CLM) -O _SystemArray
Clean\ System\ Files/_system.o : Clean\ System\ Files/_system.abc
$(CLM) -O _system
definition module StdArray
import _SystemArray
\ No newline at end of file
implementation module StdArray
system module StdBool
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version 2.0
// Copyright 1998 University of Nijmegen
// ****************************************************************************************
import StdOverloaded
instance == Bool
instance toBool Bool
instance fromBool Bool
instance fromBool {#Char}
// Additional Logical Operators:
not :: !Bool -> Bool // Not arg1
(||) infixr 2 :: !Bool Bool -> Bool // Conditional or of arg1 and arg2
(&&) infixr 3 :: !Bool Bool -> Bool // Conditional and of arg1 and arg2
implementation module StdBool
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version 2.0
// Copyright 1998 University of Nijmegen
// ****************************************************************************************
import StdOverloaded
instance == Bool
where
(==) :: !Bool !Bool -> Bool
(==) a b
= code inline {
eqB
}
instance toBool Bool
where
toBool :: !Bool -> Bool
toBool a
= code inline {
no_op
}
instance toString Bool
where
toString :: !Bool -> {#Char}
toString a
= code inline {
.d 0 1 b
jsr BtoAC
.o 1 0
}
instance fromBool Bool
where
fromBool :: !Bool -> Bool
fromBool a
= code inline {
no_op
}
instance fromBool {#Char}
where
fromBool :: !Bool -> {#Char}
fromBool a
= code inline {
.d 0 1 b
jsr BtoAC
.o 1 0
}
// Logical Operators:
not :: !Bool -> Bool
not a
= code inline {
notB
}
(&&) infixr 3 :: !Bool Bool -> Bool
(&&) a b
= code {
push_b 0
jmp_false l1
pop_b 1
jsr_eval 0
pushB_a 0
pop_a 1
.d 0 1 b
rtn
:l1
pop_a 1
.d 0 1 b
rtn
}
(||) infixr 2 :: !Bool Bool -> Bool
(||) a b
= code {
push_b 0
jmp_true l2
pop_b 1
jsr_eval 0
pushB_a 0
pop_a 1
.d 0 1 b
rtn
:l2
pop_a 1
.d 0 1 b
rtn
}
system module StdChar
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version 2.0
// Copyright 1998 University of Nijmegen
// ****************************************************************************************
import StdOverloaded
instance + Char
instance - Char
instance zero Char
instance one Char
instance == Char
instance < Char
instance toChar Char
instance toChar Int
instance fromChar Int
instance fromChar Char
instance fromChar {#Char}
// Additional conversions:
digitToInt :: !Char -> Int // Convert Digit into Int
toUpper :: !Char -> Char // Convert Char into an uppercase Char
toLower :: !Char -> Char // Convert Char into a lowercase Char
// Tests on Characters:
isUpper :: !Char -> Bool // True if arg1 is an uppercase character
isLower :: !Char -> Bool // True if arg1 is a lowercase character
isAlpha :: !Char -> Bool // True if arg1 is a letter
isAlphanum :: !Char -> Bool // True if arg1 is an alphanumerical character
isDigit :: !Char -> Bool // True if arg1 is a digit
isOctDigit :: !Char -> Bool // True if arg1 is a digit
isHexDigit :: !Char -> Bool // True if arg1 is a digit
isSpace :: !Char -> Bool // True if arg1 is a space, tab etc
isControl :: !Char -> Bool // True if arg1 is a control character
isPrint :: !Char -> Bool // True if arg1 is a printable character
isAscii :: !Char -> Bool // True if arg1 is a 7 bit ASCII character
implementation module StdChar
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version .0
// Copyright 1998 University of Nijmegen
// ****************************************************************************************
import StdOverloaded, StdBool, StdInt, StdClass
instance + Char
where
(+) :: !Char !Char -> Char
(+) a b
= code inline {
addI
ItoC
}
instance - Char
where
(-) :: !Char !Char -> Char
(-) a b
= code inline {
subI
ItoC
}
instance zero Char
where
zero :: Char
zero
= code inline {
pushI 0
ItoC
}
instance one Char
where
one :: Char
one
= code inline {
pushI 1
ItoC
}
instance == Char
where
(==) ::!Char !Char -> Bool
(==) a b
= code inline {
eqC
}
instance < Char
where
(<) ::!Char !Char -> Bool
(<) a b
= code inline {
ltC
}
instance toChar Char
where
toChar::!Char -> Char
toChar a
= code inline {
no_op
}
instance toChar Int
where
toChar :: !Int -> Char
toChar a
= code inline {
ItoC
}
instance fromChar Int
where
fromChar::!Char -> Int
fromChar a
= code inline {
CtoI
}
instance fromChar {#Char}
where
fromChar::!Char -> {#Char}
fromChar a
= code {
CtoAC
}
instance fromChar Char
where
fromChar::!Char -> Char
fromChar a
= code inline {
no_op
}
// Convert Character into:
toUpper::!Char -> Char
toUpper c
| IsLower c = clear_lowercase_bit c
= c
toLower::!Char -> Char
toLower c
| IsUpper c = set_lowercase_bit c
= c
digitToInt ::!Char -> Int
digitToInt c = toInt c - 48 // toInt '0'
// Test on Characters:
IsLower c :== c >= 'a' && c <= 'z'
IsUpper c :== c >= 'A' && c <= 'Z'
IsDigit c :== c >= '0'&& c <= '9'
IsAlpha c :== IsUpper (clear_lowercase_bit c)
clear_lowercase_bit :: !Char -> Char
clear_lowercase_bit c = code inline {
pushI 223
and%
}
set_lowercase_bit :: !Char -> Char
set_lowercase_bit c = code inline {
pushI 32
or%
}
isAscii::!Char -> Bool
isAscii c = toInt c < 128
isControl::!Char -> Bool
isControl c = c < ' ' || c == '\177'
isPrint::!Char -> Bool
isPrint c = c >= ' ' && c <= '~'
isSpace::!Char -> Bool
isSpace c = c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v'
isUpper::!Char -> Bool
isUpper c = IsUpper c
isLower::!Char -> Bool
isLower c = IsLower c
isAlpha::!Char -> Bool
isAlpha c = IsAlpha c
isDigit::!Char -> Bool
isDigit c = IsDigit c
isOctDigit::!Char -> Bool
isOctDigit c = c >= '0' && c <= '7'
isHexDigit::!Char -> Bool
isHexDigit c
# uc = clear_lowercase_bit c
= IsDigit c || (uc>='A' && uc<='F')
isAlphanum::!Char -> Bool
isAlphanum c = IsAlpha c || IsDigit c
definition module StdCharList
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version 2.0
// Copyright 1998 University of Nijmegen
// ****************************************************************************************
cjustify :: !.Int ![.Char] -> .[Char] // Center [Char] in field with width arg1
ljustify :: !.Int ![.Char] -> .[Char] // Left justify [Char] in field with width arg1
rjustify :: !.Int ![.Char] -> [Char] // Right justify [Char] in field with width arg1
flatlines :: ![[u:Char]] -> [u:Char] // Concatenate by adding newlines
mklines :: ![Char] -> [[Char]] // Split in lines removing newlines
spaces :: !.Int -> .[Char] // Make [Char] containing n space characters
implementation module StdCharList
// ****************************************************************************************
// Concurrent Clean Standard Library Module Version 2.0
// Copyright 1995 University of Nijmegen
// ****************************************************************************************
import StdList, StdInt, StdChar
cjustify::!.Int ![.Char] -> .[Char]
cjustify n s = spaces lmargin ++ s ++ spaces rmargin
where
margin = n - length s
lmargin = margin / 2
rmargin = margin - lmargin
ljustify::!.Int ![.Char] -> .[Char]
ljustify n s = s ++ spaces (n - length s)
rjustify::!.Int ![.Char] -> [Char]
rjustify n s = spaces (n - length s ) ++ s
flatlines::![[u:Char]] -> [u:Char]
flatlines [a:x] = a ++ ['\n' : flatlines x]
flatlines [] = []
mklines::![Char] -> [[Char]]
mklines [] = []
mklines [a:x] | a == '\n' = [[]:mklines x]
= [[a:hd result]:tl result]
where
result = case x of
[] -> [[]]
n -> mklines x