SaffronDefaultArchitectureImpl.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
James Rauen, June 22, 1988 12:25:39 pm PDT
Last edited by: James Rauen July 11, 1988 11:26:37 am PDT
DIRECTORY
SaffronDefaultArchitecture USING [],
SaffronTargetArchitecture USING [TargetArchitecture, TargetArchitectureBody];
SaffronDefaultArchitectureImpl:
CEDAR
PROGRAM
EXPORTS SaffronDefaultArchitecture
~ BEGIN
OPEN SaffronTargetArchitecture;
DefaultArchitecture:
PUBLIC
PROC
RETURNS [TargetArchitecture] ~
BEGIN
RETURN[
NEW[TargetArchitectureBody ← [
wordSize: 16,
integerSize: 16,
longIntegerSize: 32
]]];
DefaultArchitecture: PUBLIC PROC RETURNS [TargetArchitecture] ~ BEGIN
targetOperations: TargetOperations ← NEW[TargetOperationsRec ← [
MakeIntBase8: MakeIntBase8,
MakeIntBase10: MakeIntBase10,
MakeIntBase16: MakeIntBase16,
IntAdd: IntAdd,
IntSubtract: IntSubtract,
IntMultiply: IntMultiply,
True: True,
False: False,
And: And,
Or: Or,
Not: Not
]];
RETURN[NEW[TargetArchitectureBody ← [
operations: targetOperations
]]];
END;
MakeIntBase8: PROC [r: Rope.ROPE] RETURNS [TargetInt] ~ {
i: INT ← Convert.IntFromRope[r, 8];
RETURN[NEW[INT ← i]];
};
MakeIntBase10: PROC [r: Rope.ROPE] RETURNS [TargetInt] ~ {
i: INT ← Convert.IntFromRope[r, 10];
RETURN[NEW[INT ← i]];
};
MakeIntBase16: PROC [r: Rope.ROPE] RETURNS [TargetInt] ~ {
i: INT ← Convert.IntFromRope[r, 16];
RETURN[NEW[INT ← i]];
};
IntAdd: PROC [a: TargetInt, b: TargetInt] RETURNS [TargetInt] ~ {
aa: REF INT ← NARROW[a];
bb: REF INT ← NARROW[b];
RETURN[NEW[INT ← (aa^ + bb^)]];
};
IntSubtract: PROC [a: TargetInt, b: TargetInt] RETURNS [TargetInt] ~ {
aa: REF INT ← NARROW[a];
bb: REF INT ← NARROW[b];
RETURN[NEW[INT ← (aa^ - bb^)]];
};
IntMultiply: PROC [a: TargetInt, b: TargetInt] RETURNS [TargetInt] ~ {
aa: REF INT ← NARROW[a];
bb: REF INT ← NARROW[b];
RETURN[NEW[INT ← (aa^ * bb^)]];
};
True: PROC RETURNS [TargetBoolean] ~ {
RETURN[NEW[BOOLEAN ← TRUE]];
};
False: PROC RETURNS [TargetBoolean] ~ {
RETURN[NEW[BOOLEAN ← FALSE]];
};
And: PROC [a: TargetBoolean, b: TargetBoolean] RETURNS [TargetBoolean] ~ {
aa: REF BOOLEAN ← NARROW[a];
bb: REF BOOLEAN ← NARROW[b];
RETURN[NEW[BOOLEAN ← (aa^ AND bb^)]];
};
Or: PROC [a: TargetBoolean, b: TargetBoolean] RETURNS [TargetBoolean] ~ {
aa: REF BOOLEAN ← NARROW[a];
bb: REF BOOLEAN ← NARROW[b];
RETURN[NEW[BOOLEAN ← (aa^ OR bb^)]];
};
Not: PROC [a: TargetBoolean] RETURNS [TargetBoolean] ~ {
aa: REF BOOLEAN ← NARROW[a];
RETURN[NEW[BOOLEAN ← (NOT aa^)]];
};
END.