|
|
@@ -7,7 +7,7 @@ use num_bigint::BigInt;
|
|
|
use num_traits::One;
|
|
|
use parser::pt;
|
|
|
|
|
|
-struct Prototype {
|
|
|
+pub struct Prototype {
|
|
|
pub builtin: Builtin,
|
|
|
pub namespace: Option<&'static str>,
|
|
|
pub name: &'static str,
|
|
|
@@ -358,6 +358,20 @@ pub fn is_builtin_call(namespace: Option<&str>, fname: &str, ns: &Namespace) ->
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+/// Get the prototype for a builtin. If the prototype has arguments, it is a function else
|
|
|
+/// it is a variable.
|
|
|
+pub fn get_prototype(builtin: Builtin) -> &'static Prototype {
|
|
|
+ if let Some(p) = BUILTIN_FUNCTIONS.iter().find(|p| p.builtin == builtin) {
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+
|
|
|
+ if let Some(p) = BUILTIN_VARIABLE.iter().find(|p| p.builtin == builtin) {
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+
|
|
|
+ panic!("cannot find prototype for {:?}", builtin);
|
|
|
+}
|
|
|
+
|
|
|
/// Does variable name match builtin
|
|
|
pub fn builtin_var(
|
|
|
loc: &pt::Loc,
|