Commit d74cdbb2 by Aaron Leung

Getting ready to improve native function resolution and definition.

parent ec641613
#define SASS_CONTEXT
#ifndef SASS_ENVIRONMENT
//#ifndef SASS_ENVIRONMENT
#include "environment.hpp"
#endif
//#endif
#include <utility>
#ifndef SASS_NODE_FACTORY
#include "node_factory.hpp"
#endif
#ifndef SASS_FUNCTIONS
#include "functions.hpp"
#endif
namespace Sass {
using std::pair;
using std::map;
// struct Environment {
// map<Token, Node> current_frame;
// Environment* parent;
// Environment* global;
// Environment()
// : current_frame(map<Token, Node>()), parent(0), global(0)
// { }
// void link(Environment& env)
// {
// parent = &env;
// global = parent->global ? parent->global : parent;
// }
// bool query(const Token& key) const
// {
// if (current_frame.count(key)) return true;
// else if (parent) return parent->query(key);
// else return false;
// }
// Node& operator[](const Token& key)
// {
// if (current_frame.count(key)) return current_frame[key];
// else if (parent) return (*parent)[key];
// else return current_frame[key];
// }
// };
struct Context {
Environment global_env;
map<string, Function> function_env;
......
#define SASS_DOCUMENT
#include <map>
#ifndef SASS_PRELEXER
......
#define SASS_ERROR
namespace Sass {
struct Error {
......
#define SASS_EVAL_APPLY
#include <map>
#ifndef SASS_NODE
......
#ifndef SASS_PRELEXER
#include "prelexer.hpp"
#endif
#include "node_factory.hpp"
#include "functions.hpp"
#include "context.hpp"
#include "error.hpp"
#include <iostream>
#include <cmath>
using std::cerr; using std::endl;
namespace Sass {
Function::Function(const char* signature, Primitive ip, Node_Factory& new_Node)
{
//Document sig_doc(Document::make_from_source_chars(
}
namespace Functions {
static void throw_eval_error(string message, string path, size_t line)
......@@ -19,6 +30,11 @@ namespace Sass {
throw Error(Error::evaluation, path, line, message);
}
extern const char foo_sig[] = "foo($x, $y, $z: hey hey)";
Node foo(const Node parameters, Environment& bindings, Node_Factory& new_Node) {
return Node();
}
// RGB Functions ///////////////////////////////////////////////////////
Function_Descriptor rgb_descriptor =
......
#define SASS_FUNCTIONS
#include <cstring>
#include <map>
......@@ -26,6 +28,7 @@ namespace Sass {
Function()
{ /* TO DO: set up the generic callback here */ }
// for user-defined functions
Function(Node def)
: name(def[0].to_string()),
parameters(def[1]),
......@@ -42,6 +45,8 @@ namespace Sass {
primitive(0),
overloaded(overloaded)
{ }
Function(const char* signature, Primitive ip, Node_Factory& new_Node);
Function(Function_Descriptor d, Primitive ip, Node_Factory& new_Node)
: name(d[0]),
......
#define SASS_NODE_FACTORY
#include <vector>
#ifndef SASS_NODE
......
#define SASS_INTERFACE
#ifdef __cplusplus
extern "C" {
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment