Skip to content

built-ins.stx

pdmosses/webdsl-statix/webdslstatix/trans/static-semantics/entities/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
module 

imports
  static-semantics/types/built-ins

  static-semantics/entities/annotations

  static-semantics/webdsl-entities
  static-semantics/webdsl-built-ins
  static-semantics/webdsl

rules

   : scope
  declareEntityBuiltIns() :- {   }
    new s_object, s_object -DEF-> s,
    new s_ent, s_ent -INHERIT-> s_object,
    declareType(s, "Object", BUILTINTYPE("Object", s_object)),
    declareType(s, "Entity", ENTITY("Entity", s_ent)),
    declareVar(s_ent, "id"       , uuid(s)),
    declareVar(s_ent, "naturalId", string(s)),
    declareVar(s_ent, "version"  , int(s)),
    declareVar(s_ent, "name"     , string(s)), declareAnnotations(s_ent, "name", [OVERRIDABLE(), NAME(), DERIVED()]),
    declareVar(s_ent, "created"  , datetime(s)),
    declareVar(s_ent, "modified" , datetime(s)),
    declareBuiltInFunction(s_ent, "save"  , [], VOID()),
    declareBuiltInFunction(s_ent, "delete", [], VOID()), // TO-DO: not allowed on session entities and global vars
    declareBuiltInFunction(s_object, "toString", [], string(s)),

    new s_sessionmessage, s_sessionmessage -INHERIT-> s_ent,
    declareType(s, "SessionMessage", ENTITY("SessionMessage", s_sessionmessage)),
    declareVar(s_sessionmessage, "text", text(s)),

    new s_sessionmanager, s_sessionmanager -INHERIT-> s_ent,
    declareType(s, "SessionManager", ENTITY("SessionManager", s_sessionmanager)),
    declareVar(s_sessionmanager, "messages"         , ENTITY("SessionMessage", s_sessionmessage)),
    declareVar(s_sessionmanager, "lastUse"          , datetime(s)),
    declareVar(s_sessionmanager, "logsqlMessage"    , text(s)),
    declareVar(s_sessionmanager, "stayLoggedIn"     , bool(s)),
    declareVar(s_sessionmanager, "sessionHasChanges", bool(s)),
    declareVar(s_sessionmanager, "domain"           , string(s)),
    declareVar(s_sessionmanager, "cookieValue"      , uuid(s)).