mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 00:52:51 -06:00
the compiler now allows + to be used as a floating point addition in the abstract syntax
This commit is contained in:
@@ -131,6 +131,11 @@ compileFun gr arity st vs (Let (x, (_, e1)) e2) h0 bs args =
|
|||||||
let (h1,bs1,arg,is1) = compileLambda gr st vs [] e1 h0 bs
|
let (h1,bs1,arg,is1) = compileLambda gr st vs [] e1 h0 bs
|
||||||
(h2,bs2,is2) = compileFun gr arity st ((x,arg):vs) e2 h1 bs1 args
|
(h2,bs2,is2) = compileFun gr arity st ((x,arg):vs) e2 h1 bs1 args
|
||||||
in (h2,bs2,is1++is2)
|
in (h2,bs2,is1++is2)
|
||||||
|
compileFun gr arity st vs (Glue e1 e2) h0 bs args =
|
||||||
|
let (h1,bs1,arg1,is1) = compileArg gr st vs e1 h0 bs
|
||||||
|
(h2,bs2,arg2,is2) = compileArg gr st vs e2 h1 bs1
|
||||||
|
(st1,is3) = pushArgs st [arg2,arg1]
|
||||||
|
in (h2,bs2,is1++is2++is3++[ADD])
|
||||||
compileFun gr arity st vs e _ _ _ = error (show e)
|
compileFun gr arity st vs e _ _ _ = error (show e)
|
||||||
|
|
||||||
compileArg gr st vs (Q(m,id)) h0 bs =
|
compileArg gr st vs (Q(m,id)) h0 bs =
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ data AExp =
|
|||||||
| ARecType [ALabelling]
|
| ARecType [ALabelling]
|
||||||
| AR [AAssign]
|
| AR [AAssign]
|
||||||
| AP AExp Label Val
|
| AP AExp Label Val
|
||||||
|
| AGlue AExp AExp
|
||||||
| AData Val
|
| AData Val
|
||||||
deriving (Eq,Show)
|
deriving (Eq,Show)
|
||||||
|
|
||||||
@@ -162,6 +163,10 @@ checkExp th tenv@(k,rho,gamma) e ty = do
|
|||||||
P r l -> do (r',cs) <- checkExp th tenv r (VRecType [(l,typ)])
|
P r l -> do (r',cs) <- checkExp th tenv r (VRecType [(l,typ)])
|
||||||
return (AP r' l typ,cs)
|
return (AP r' l typ,cs)
|
||||||
|
|
||||||
|
Glue x y -> do cs1 <- eqVal k valAbsFloat typ
|
||||||
|
(x,cs2) <- checkExp th tenv x typ
|
||||||
|
(y,cs3) <- checkExp th tenv y typ
|
||||||
|
return (AGlue x y,cs1++cs2++cs3)
|
||||||
_ -> checkInferExp th tenv e typ
|
_ -> checkInferExp th tenv e typ
|
||||||
|
|
||||||
checkInferExp :: Theory -> TCEnv -> Exp -> Val -> Err (AExp, [(Val,Val)])
|
checkInferExp :: Theory -> TCEnv -> Exp -> Val -> Err (AExp, [(Val,Val)])
|
||||||
|
|||||||
@@ -136,7 +136,8 @@ typedef enum {
|
|||||||
PGF_INSTR_PUSH = 9,
|
PGF_INSTR_PUSH = 9,
|
||||||
PGF_INSTR_EVAL = 10,
|
PGF_INSTR_EVAL = 10,
|
||||||
PGF_INSTR_DROP = 13,
|
PGF_INSTR_DROP = 13,
|
||||||
PGF_INSTR_FAIL = 14
|
PGF_INSTR_FAIL = 14,
|
||||||
|
PGF_INSTR_ADD = 15
|
||||||
} PgfInstruction;
|
} PgfInstruction;
|
||||||
|
|
||||||
typedef GuSeq PgfConcrs;
|
typedef GuSeq PgfConcrs;
|
||||||
|
|||||||
@@ -1160,6 +1160,11 @@ pgf_jit_function(PgfReader* rdr, PgfAbstr* abstr,
|
|||||||
#endif
|
#endif
|
||||||
jit_jmpi(abstr->eval_gates->mk_const);
|
jit_jmpi(abstr->eval_gates->mk_const);
|
||||||
break;
|
break;
|
||||||
|
case PGF_INSTR_ADD:
|
||||||
|
#ifdef PGF_JIT_DEBUG
|
||||||
|
gu_printf(out, err, "ADD\n");
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gu_impossible();
|
gu_impossible();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ instance Binary Instr where
|
|||||||
put (EVAL (GLOBAL id) (UpdateCall b c)) = putWord8 51 >> put id >> put (b,c)
|
put (EVAL (GLOBAL id) (UpdateCall b c)) = putWord8 51 >> put id >> put (b,c)
|
||||||
put (DROP n l ) = putWord8 52 >> put (n,l)
|
put (DROP n l ) = putWord8 52 >> put (n,l)
|
||||||
put (FAIL ) = putWord8 56
|
put (FAIL ) = putWord8 56
|
||||||
|
put (ADD ) = putWord8 60
|
||||||
|
|
||||||
instance Binary Type where
|
instance Binary Type where
|
||||||
put (DTyp hypos cat exps) = put (hypos,cat,exps)
|
put (DTyp hypos cat exps) = put (hypos,cat,exps)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ data Instr
|
|||||||
| EVAL IVal TailInfo
|
| EVAL IVal TailInfo
|
||||||
| DROP {-# UNPACK #-} !Int {-# UNPACK #-} !CodeLabel
|
| DROP {-# UNPACK #-} !Int {-# UNPACK #-} !CodeLabel
|
||||||
| FAIL
|
| FAIL
|
||||||
|
| ADD
|
||||||
|
|
||||||
data IVal
|
data IVal
|
||||||
= HEAP {-# UNPACK #-} !Int
|
= HEAP {-# UNPACK #-} !Int
|
||||||
@@ -61,6 +62,7 @@ ppInstr (PUSH v) = text "PUSH " <+> ppIVal v
|
|||||||
ppInstr (EVAL v ti) = text "EVAL " <+> ppIVal v <+> ppTailInfo ti
|
ppInstr (EVAL v ti) = text "EVAL " <+> ppIVal v <+> ppTailInfo ti
|
||||||
ppInstr (DROP n l ) = text "DROP " <+> int n <+> ppLabel l
|
ppInstr (DROP n l ) = text "DROP " <+> int n <+> ppLabel l
|
||||||
ppInstr (FAIL ) = text "FAIL"
|
ppInstr (FAIL ) = text "FAIL"
|
||||||
|
ppInstr (ADD ) = text "ADD"
|
||||||
|
|
||||||
ppIVal (HEAP n) = text "hp" <> parens (int n)
|
ppIVal (HEAP n) = text "hp" <> parens (int n)
|
||||||
ppIVal (ARG_VAR n) = text "stk" <> parens (int n)
|
ppIVal (ARG_VAR n) = text "stk" <> parens (int n)
|
||||||
|
|||||||
Reference in New Issue
Block a user