Beispiel #1
0
 Statement* Expand::operator()(Mixin_Call* c)
 {
   string full_name(c->name() + "[m]");
   if (!env->has(full_name)) {
     error("no mixin named " + c->name(), c->path(), c->position(), backtrace);
   }
   Definition* def = static_cast<Definition*>((*env)[full_name]);
   Block* body = def->block();
   Parameters* params = def->parameters();
   Arguments* args = static_cast<Arguments*>(c->arguments()
                                              ->perform(eval->with(env, backtrace)));
   Backtrace here(backtrace, c->path(), c->position(), ", in mixin `" + c->name() + "`");
   backtrace = &here;
   Env new_env;
   new_env.link(def->environment());
   if (c->block()) {
     // represent mixin content blocks as thunks/closures
     Definition* thunk = new (ctx.mem) Definition(c->path(),
                                                  c->position(),
                                                  "@content",
                                                  new (ctx.mem) Parameters(c->path(), c->position()),
                                                  c->block(),
                                                  Definition::MIXIN);
     thunk->environment(env);
     new_env.current_frame()["@content[m]"] = thunk;
   }
   bind("mixin " + c->name(), params, args, ctx, &new_env, eval);
   Env* old_env = env;
   env = &new_env;
   append_block(body);
   env = old_env;
   backtrace = here.parent;
   return 0;
 }
Beispiel #2
0
 void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
 {
   Definition* def = make_native_function(sig, f, ctx);
   stringstream ss;
   ss << def->name() << "[f]" << arity;
   def->environment(env);
   (*env)[ss.str()] = def;
 }
Beispiel #3
0
 Statement* Expand::operator()(Definition* d)
 {
   Definition* dd = new (ctx.mem) Definition(*d);
   env->current_frame()[d->name() +
                       (d->type() == Definition::MIXIN ? "[m]" : "[f]")] = dd;
   // set the static link so we can have lexical scoping
   dd->environment(env);
   return 0;
 }
Beispiel #4
0
 void register_c_function(Context& ctx, Env* env, Sass_C_Function_Callback descr)
 {
   Definition* def = make_c_function(
     sass_function_get_signature(descr),
     sass_function_get_function(descr),
     sass_function_get_cookie(descr),
     ctx
   );
   def->environment(env);
   (*env)[def->name() + "[f]"] = def;
 }
Beispiel #5
0
 void register_function(Context& ctx, Signature sig, Native_Function f, Env* env)
 {
   Definition* def = make_native_function(sig, f, ctx);
   def->environment(env);
   (*env)[def->name() + "[f]"] = def;
 }
Beispiel #6
0
 void register_c_function(Context& ctx, Env* env, Sass_C_Function_Descriptor descr)
 {
   Definition* def = make_c_function(descr.signature, descr.function, descr.cookie, ctx);
   def->environment(env);
   (*env)[def->name() + "[f]"] = def;
 }
Beispiel #7
0
 void register_c_function(Context& ctx, Env* env, Sass_Function_Entry descr)
 {
   Definition* def = make_c_function(descr, ctx);
   def->environment(env);
   (*env)[def->name() + "[f]"] = def;
 }