Skip to content

built-ins.stx

pdmosses/webdsl-statix/webdslstatix/trans/static-semantics/actions/built-ins.stx

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
module 

imports
  static-semantics/types/built-ins
  static-semantics/webdsl-built-ins
  static-semantics/webdsl-types
  static-semantics/webdsl

rules

   : scope
  declareFunctionIns() :- {             }
    datetime  == datetime(s),
    date      == date(s),
    string    == string(s),
    time      == time(s),
    int       == int(s),
    float     == float(s),
    uuid      == uuid(s),
    void      == VOID(),
    bool      == bool(s),
    object    == object(s),
    url       == url(s),
    entity    == entity(s),

    declareBuiltInFunction(s, "now"     , []               , datetime),
    declareBuiltInFunction(s, "today"   , []               , date),
    declareBuiltInFunction(s, "Date"    , [string, string] , date),
    declareBuiltInFunction(s, "Date"    , [string]         , date),
    declareBuiltInFunction(s, "Time"    , [string, string] , time),
    declareBuiltInFunction(s, "Time"    , [string]         , time),
    declareBuiltInFunction(s, "DateTime", [string, string] , datetime),
    declareBuiltInFunction(s, "DateTime", [string]         , datetime),
    declareBuiltInFunction(s, "random"  , [int, int]       , int),
    declareBuiltInFunction(s, "random"  , [int]            , int),
    declareBuiltInFunction(s, "random"  , []               , float),
    declareBuiltInFunction(s, "url"     , [string]         , url),

    declareBuiltInFunction(s, "randomUUID"     , []      , uuid),
    declareBuiltInFunction(s, "UUIDFromString" , [string], uuid),

    declareBuiltInFunction(s, "getSessionManager", [], definedTypeNoRef(s, "SessionManager")),

    declareBuiltInFunction(s, "cancel"  , [], void),
    declareBuiltInFunction(s, "rollback", [], void),
    declareBuiltInFunction(s, "flush"   , [], void),

    declareBuiltInFunction(s, "getValidationErrorsByName", [string], LIST(string)),

    declareBuiltInFunction(s, "getHttpMethod"          , []      , string),
    declareBuiltInFunction(s, "getRequestParameter"    , [string], string),
    declareBuiltInFunction(s, "getRequestParameterList", [string], LIST(string)),
    declareBuiltInFunction(s, "readRequestBody"        , []      , string),

    declareBuiltInFunction(s, "attribute"          , [string]        , string),
    declareBuiltInFunction(s, "attribute"          , [string, string], string),
    declareBuiltInFunction(s, "hasNotNullAttribute", []              , bool),

    declareBuiltInFunction(s, "message", [string], void),
    declareBuiltInFunction(s, "log"    , [object], void),

    declareBuiltInFunction(s, "assert", [bool], void),
    declareBuiltInFunction(s, "assert", [bool, string], void),
    declareBuiltInFunction(s, "assertEquals", [object, object], void),
    declareBuiltInFunction(s, "assertEquals", [object, object, string], void),
    declareBuiltInFunction(s, "assertNotSame", [object, object], void),
    declareBuiltInFunction(s, "assertNotSame", [object, object, string], void),

    declareBuiltInFunction(s, "loadEntity", [string, uuid], entity).