aboutsummaryrefslogtreecommitdiff
path: root/frontend/syntax.icl
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/syntax.icl')
-rw-r--r--frontend/syntax.icl57
1 files changed, 34 insertions, 23 deletions
diff --git a/frontend/syntax.icl b/frontend/syntax.icl
index 1e9ad0b..55d7f7b 100644
--- a/frontend/syntax.icl
+++ b/frontend/syntax.icl
@@ -30,9 +30,18 @@ where toString {import_module} = toString import_module
, ste_previous :: SymbolTableEntry
}
+:: FunctionOrMacroIndex = FunctionOrIclMacroIndex !Int | DclMacroIndex /*module_n*/ !Int /*macro_n_in_module*/ !Int;
+
+instance == FunctionOrMacroIndex
+ where
+ (==) (FunctionOrIclMacroIndex f1) (FunctionOrIclMacroIndex f2) = f1==f2
+ (==) (DclMacroIndex m1 f1) (DclMacroIndex m2 f2) = m1==m2 && f1==f2
+ (==) _ _ = False
+
:: STE_BoundTypeVariable = { stv_count :: !Int, stv_attribute :: !TypeAttribute, stv_info_ptr :: !TypeVarInfoPtr }
-:: STE_Kind = STE_FunctionOrMacro ![Index]
+:: STE_Kind = STE_FunctionOrMacro ![FunctionOrMacroIndex]
+ | STE_DclMacroOrLocalMacroFunction ![FunctionOrMacroIndex]
| STE_Type
| STE_Constructor
| STE_Selector ![Global Index]
@@ -53,7 +62,7 @@ where toString {import_module} = toString import_module
| STE_DictType !CheckedTypeDef
| STE_DictCons !ConsDef
| STE_DictField !SelectorDef
- | STE_Called ![Index] /* used during macro expansion to indicate that this function is called */
+ | STE_Called ![FunctionOrMacroIndex] /* used during macro expansion to indicate that this function is called */
| STE_ExplImpSymbol !Int
| STE_ExplImpComponentNrs ![ComponentNrAndIndex] ![Declaration]
| STE_BelongingSymbol !Int
@@ -97,11 +106,12 @@ where toString {import_module} = toString import_module
| TypeSpec !AType
| EmptyRhs !BITVECT
-:: CollectedDefinitions instance_kind macro_defs =
+:: CollectedDefinitions instance_kind def_macros =
{ def_types :: ![TypeDef TypeRhs]
, def_constructors :: ![ConsDef]
, def_selectors :: ![SelectorDef]
- , def_macros :: !macro_defs
+ , def_macros :: ![FunDef]
+ , def_macro_indices :: !IndexRange
, def_classes :: ![ClassDef]
, def_members :: ![MemberDef]
, def_generics :: ![GenericDef] // AA
@@ -123,13 +133,13 @@ where toString {import_module} = toString import_module
:: Index :== Int
NoIndex :== -1
-
:: Level :== Int
NotALevel :== -1
:: CollectedLocalDefs =
{ loc_functions :: !IndexRange
, loc_nodes :: ![NodeDef ParsedExpr]
+ , loc_in_icl_module :: !Bool // False for local functions in macros in dcl modules, otherwise True
}
:: NodeDef dst =
@@ -162,8 +172,6 @@ cIsNotAFunction :== False
:: FunKind = FK_Function !Bool | FK_Macro | FK_Caf | FK_Unknown
-:: DefOrImpFunKind = FK_DefFunction !Bool| FK_ImpFunction !Bool | FK_DefMacro | FK_ImpMacro | FK_ImpCaf | FK_DefOrImpUnknown
-
cNameNotLocationDependent :== False
cNameLocationDependent :== True
@@ -421,10 +429,7 @@ where
, fv_count :: !Int
}
-:: FunCall =
- { fc_level :: !Level
- , fc_index :: !Index
- }
+:: FunCall = FunCall !Index !Level | MacroCall !Index !Index Level;
/* Sjaak 19-3-2001 ... */
@@ -467,8 +472,8 @@ FI_HasTypeSpec :== 2 // whether the function has u user defined type
:: FunctionBody = ParsedBody ![ParsedBody]
| CheckedBody !CheckedBody
/* The next three constructors are used during macro expansion (module transform) */
- | PartioningMacro
- | PartioningFunction !CheckedBody !Int
+ | PartitioningMacro
+ | PartitioningFunction !CheckedBody !Int
| RhsMacroBody !CheckedBody
/* macro expansion the transforms a CheckedBody into a TransformedBody */
| TransformedBody !TransformedBody
@@ -488,9 +493,8 @@ FI_HasTypeSpec :== 2 // whether the function has u user defined type
, fun_body :: !FunctionBody
, fun_type :: !Optional SymbolType
, fun_pos :: !Position
- , fun_kind :: !DefOrImpFunKind
+ , fun_kind :: !FunKind
, fun_lifted :: !Int
-// , fun_type_ptr :: !TypeVarInfoPtr
, fun_info :: !FunInfo
}
@@ -521,7 +525,7 @@ pIsSafe :== True
| AP_WildCard !OptionalVariable
| AP_Empty !Ident
-:: AP_Kind = APK_Constructor !Index | APK_Macro
+:: AP_Kind = APK_Constructor !Index | APK_Macro !Bool // is_dcl_macro
:: VarInfo = VI_Empty | VI_Type !AType !(Optional CoercionPosition) | VI_FAType ![ATypeVar] !AType !(Optional CoercionPosition) |
VI_Occurrence !Occurrence | VI_UsedVar !Ident |
@@ -607,13 +611,14 @@ cNotVarNumber :== -1
:: SymbKind = SK_Unknown
| SK_Function !(Global Index)
+ | SK_IclMacro !Index
| SK_LocalMacroFunction !Index
+ | SK_DclMacro !(Global Index)
+ | SK_LocalDclMacroFunction !(Global Index)
| SK_OverloadedFunction !(Global Index)
- | SK_Generic !(Global Index) !TypeKind // AA
- | SK_Constructor !(Global Index)
- | SK_Macro !(Global Index)
-// | SK_RecordSelector !(Global Index)
| SK_GeneratedFunction !FunctionInfoPtr !Index
+ | SK_Constructor !(Global Index)
+ | SK_Generic !(Global Index) !TypeKind
| SK_TypeCode
// MW2 moved some type definitions
@@ -1464,9 +1469,11 @@ where
(<<<) file symb=:{symb_kind = SK_Function symb_index }
= file <<< symb.symb_name <<< '@' <<< symb_index
(<<<) file symb=:{symb_kind = SK_LocalMacroFunction symb_index }
- = file <<< symb.symb_name <<< '@' <<< symb_index
+ = file <<< symb.symb_name <<< "[lm]@" <<< symb_index
(<<<) file symb=:{symb_kind = SK_GeneratedFunction _ symb_index }
- = file <<< symb.symb_name <<< '@' <<< symb_index
+ = file <<< symb.symb_name <<< "[g]@" <<< symb_index
+ (<<<) file symb=:{symb_kind = SK_LocalDclMacroFunction symb_index }
+ = file <<< symb.symb_name <<< "[ldm]@" <<< symb_index
(<<<) file symb=:{symb_kind = SK_OverloadedFunction symb_index }
= file <<< symb.symb_name <<< "[o]@" <<< symb_index
(<<<) file symb
@@ -1758,6 +1765,8 @@ where
(<<<) file {fun_symb,fun_body=NoBody,fun_type=Yes type} = file // <<< type <<< '\n'
<<< fun_symb <<< '.' <<< "Array function\n"
+ (<<<) file {fun_symb} = file <<< fun_symb <<< "???" <<< '\n'
+
instance <<< FunctionBody
where
(<<<) file (ParsedBody bodies) = file <<< bodies
@@ -1769,8 +1778,10 @@ where
instance <<< FunCall
where
- (<<<) file { fc_level,fc_index }
+ (<<<) file (FunCall fc_index fc_level)
= file <<< fc_index <<< '.' <<< fc_level
+ (<<<) file (MacroCall module_index fc_index fc_level)
+ = file <<< "MacroCall "<<< module_index <<<" "<<<fc_index <<< '.' <<< fc_level
instance <<< FreeVar
where