aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorStefan Monnier2010-06-13 16:36:17 -0400
committerStefan Monnier2010-06-13 16:36:17 -0400
commitb9598260f96ddc652cd82ab64bbe922ccfc48a29 (patch)
tree2a692a8471de07f2578ea481c99971585def8eda /src/alloc.c
parenta6e8d97c1414230e577d375c27da78c858a5fa75 (diff)
downloademacs-b9598260f96ddc652cd82ab64bbe922ccfc48a29.tar.gz
emacs-b9598260f96ddc652cd82ab64bbe922ccfc48a29.zip
New branch for lexbind, losing all history.
This initial patch is based on 2002-06-27T22:39:10Z!storm@cua.dk of the original lexbind branch.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c76
1 files changed, 69 insertions, 7 deletions
diff --git a/src/alloc.c b/src/alloc.c
index e0f07cc5f5a..a23c688043c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3042,6 +3042,39 @@ See also the function `vector'. */)
3042} 3042}
3043 3043
3044 3044
3045/* Return a new `function vector' containing KIND as the first element,
3046 followed by NUM_NIL_SLOTS nil elements, and further elements copied from
3047 the vector PARAMS of length NUM_PARAMS (so the total length of the
3048 resulting vector is 1 + NUM_NIL_SLOTS + NUM_PARAMS).
3049
3050 If NUM_PARAMS is zero, then PARAMS may be NULL.
3051
3052 A `function vector', a.k.a. `funvec', is a funcallable vector in Emacs Lisp.
3053 See the function `funvec' for more detail. */
3054
3055Lisp_Object
3056make_funvec (kind, num_nil_slots, num_params, params)
3057 Lisp_Object kind;
3058 int num_nil_slots, num_params;
3059 Lisp_Object *params;
3060{
3061 int param_index;
3062 Lisp_Object funvec;
3063
3064 funvec = Fmake_vector (make_number (1 + num_nil_slots + num_params), Qnil);
3065
3066 ASET (funvec, 0, kind);
3067
3068 for (param_index = 0; param_index < num_params; param_index++)
3069 ASET (funvec, 1 + num_nil_slots + param_index, params[param_index]);
3070
3071 XSETPVECTYPE (XVECTOR (funvec), PVEC_FUNVEC);
3072 XSETFUNVEC (funvec, XVECTOR (funvec));
3073
3074 return funvec;
3075}
3076
3077
3045DEFUN ("vector", Fvector, Svector, 0, MANY, 0, 3078DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
3046 doc: /* Return a newly created vector with specified arguments as elements. 3079 doc: /* Return a newly created vector with specified arguments as elements.
3047Any number of arguments, even zero arguments, are allowed. 3080Any number of arguments, even zero arguments, are allowed.
@@ -3063,6 +3096,29 @@ usage: (vector &rest OBJECTS) */)
3063} 3096}
3064 3097
3065 3098
3099DEFUN ("funvec", Ffunvec, Sfunvec, 1, MANY, 0,
3100 doc: /* Return a newly created `function vector' of type KIND.
3101A `function vector', a.k.a. `funvec', is a funcallable vector in Emacs Lisp.
3102KIND indicates the kind of funvec, and determines its behavior when called.
3103The meaning of the remaining arguments depends on KIND. Currently
3104implemented values of KIND, and their meaning, are:
3105
3106 A list -- A byte-compiled function. See `make-byte-code' for the usual
3107 way to create byte-compiled functions.
3108
3109 `curry' -- A curried function. Remaining arguments are a function to
3110 call, and arguments to prepend to user arguments at the
3111 time of the call; see the `curry' function.
3112
3113usage: (funvec KIND &rest PARAMS) */)
3114 (nargs, args)
3115 register int nargs;
3116 Lisp_Object *args;
3117{
3118 return make_funvec (args[0], 0, nargs - 1, args + 1);
3119}
3120
3121
3066DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, 3122DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
3067 doc: /* Create a byte-code object with specified arguments as elements. 3123 doc: /* Create a byte-code object with specified arguments as elements.
3068The arguments should be the arglist, bytecode-string, constant vector, 3124The arguments should be the arglist, bytecode-string, constant vector,
@@ -3078,6 +3134,10 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
3078 register int index; 3134 register int index;
3079 register struct Lisp_Vector *p; 3135 register struct Lisp_Vector *p;
3080 3136
3137 /* Make sure the arg-list is really a list, as that's what's used to
3138 distinguish a byte-compiled object from other funvecs. */
3139 CHECK_LIST (args[0]);
3140
3081 XSETFASTINT (len, nargs); 3141 XSETFASTINT (len, nargs);
3082 if (!NILP (Vpurify_flag)) 3142 if (!NILP (Vpurify_flag))
3083 val = make_pure_vector ((EMACS_INT) nargs); 3143 val = make_pure_vector ((EMACS_INT) nargs);
@@ -3099,8 +3159,8 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
3099 args[index] = Fpurecopy (args[index]); 3159 args[index] = Fpurecopy (args[index]);
3100 p->contents[index] = args[index]; 3160 p->contents[index] = args[index];
3101 } 3161 }
3102 XSETPVECTYPE (p, PVEC_COMPILED); 3162 XSETPVECTYPE (p, PVEC_FUNVEC);
3103 XSETCOMPILED (val, p); 3163 XSETFUNVEC (val, p);
3104 return val; 3164 return val;
3105} 3165}
3106 3166
@@ -3199,6 +3259,7 @@ Its value and function definition are void, and its property list is nil. */)
3199 p->gcmarkbit = 0; 3259 p->gcmarkbit = 0;
3200 p->interned = SYMBOL_UNINTERNED; 3260 p->interned = SYMBOL_UNINTERNED;
3201 p->constant = 0; 3261 p->constant = 0;
3262 p->declared_special = 0;
3202 consing_since_gc += sizeof (struct Lisp_Symbol); 3263 consing_since_gc += sizeof (struct Lisp_Symbol);
3203 symbols_consed++; 3264 symbols_consed++;
3204 return val; 3265 return val;
@@ -4907,7 +4968,7 @@ Does not copy symbols. Copies strings without text properties. */)
4907 obj = make_pure_string (SDATA (obj), SCHARS (obj), 4968 obj = make_pure_string (SDATA (obj), SCHARS (obj),
4908 SBYTES (obj), 4969 SBYTES (obj),
4909 STRING_MULTIBYTE (obj)); 4970 STRING_MULTIBYTE (obj));
4910 else if (COMPILEDP (obj) || VECTORP (obj)) 4971 else if (FUNVECP (obj) || VECTORP (obj))
4911 { 4972 {
4912 register struct Lisp_Vector *vec; 4973 register struct Lisp_Vector *vec;
4913 register int i; 4974 register int i;
@@ -4919,10 +4980,10 @@ Does not copy symbols. Copies strings without text properties. */)
4919 vec = XVECTOR (make_pure_vector (size)); 4980 vec = XVECTOR (make_pure_vector (size));
4920 for (i = 0; i < size; i++) 4981 for (i = 0; i < size; i++)
4921 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]); 4982 vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]);
4922 if (COMPILEDP (obj)) 4983 if (FUNVECP (obj))
4923 { 4984 {
4924 XSETPVECTYPE (vec, PVEC_COMPILED); 4985 XSETPVECTYPE (vec, PVEC_FUNVEC);
4925 XSETCOMPILED (obj, vec); 4986 XSETFUNVEC (obj, vec);
4926 } 4987 }
4927 else 4988 else
4928 XSETVECTOR (obj, vec); 4989 XSETVECTOR (obj, vec);
@@ -5512,7 +5573,7 @@ mark_object (arg)
5512 } 5573 }
5513 else if (SUBRP (obj)) 5574 else if (SUBRP (obj))
5514 break; 5575 break;
5515 else if (COMPILEDP (obj)) 5576 else if (FUNVECP (obj) && FUNVEC_COMPILED_P (obj))
5516 /* We could treat this just like a vector, but it is better to 5577 /* We could treat this just like a vector, but it is better to
5517 save the COMPILED_CONSTANTS element for last and avoid 5578 save the COMPILED_CONSTANTS element for last and avoid
5518 recursion there. */ 5579 recursion there. */
@@ -6423,6 +6484,7 @@ The time is in seconds as a floating point value. */);
6423 defsubr (&Scons); 6484 defsubr (&Scons);
6424 defsubr (&Slist); 6485 defsubr (&Slist);
6425 defsubr (&Svector); 6486 defsubr (&Svector);
6487 defsubr (&Sfunvec);
6426 defsubr (&Smake_byte_code); 6488 defsubr (&Smake_byte_code);
6427 defsubr (&Smake_list); 6489 defsubr (&Smake_list);
6428 defsubr (&Smake_vector); 6490 defsubr (&Smake_vector);