Commit d74cdbb2 by Aaron Leung

Getting ready to improve native function resolution and definition.

parent ec641613
#define SASS_CONTEXT #define SASS_CONTEXT
#ifndef SASS_ENVIRONMENT //#ifndef SASS_ENVIRONMENT
#include "environment.hpp" #include "environment.hpp"
#endif //#endif
#include <utility> #include <utility>
#ifndef SASS_NODE_FACTORY
#include "node_factory.hpp" #include "node_factory.hpp"
#endif
#ifndef SASS_FUNCTIONS
#include "functions.hpp" #include "functions.hpp"
#endif
namespace Sass { namespace Sass {
using std::pair; using std::pair;
using std::map; 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 { struct Context {
Environment global_env; Environment global_env;
map<string, Function> function_env; map<string, Function> function_env;
......
#define SASS_DOCUMENT
#include <map> #include <map>
#ifndef SASS_PRELEXER #ifndef SASS_PRELEXER
......
#define SASS_ERROR
namespace Sass { namespace Sass {
struct Error { struct Error {
......
#define SASS_EVAL_APPLY
#include <map> #include <map>
#ifndef SASS_NODE #ifndef SASS_NODE
......
#ifndef SASS_PRELEXER #ifndef SASS_PRELEXER
#include "prelexer.hpp" #include "prelexer.hpp"
#endif #endif
#include "node_factory.hpp" #include "node_factory.hpp"
#include "functions.hpp" #include "functions.hpp"
#include "context.hpp"
#include "error.hpp" #include "error.hpp"
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
using std::cerr; using std::endl; using std::cerr; using std::endl;
namespace Sass { namespace Sass {
Function::Function(const char* signature, Primitive ip, Node_Factory& new_Node)
{
//Document sig_doc(Document::make_from_source_chars(
}
namespace Functions { namespace Functions {
static void throw_eval_error(string message, string path, size_t line) static void throw_eval_error(string message, string path, size_t line)
...@@ -19,6 +30,11 @@ namespace Sass { ...@@ -19,6 +30,11 @@ namespace Sass {
throw Error(Error::evaluation, path, line, message); 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 /////////////////////////////////////////////////////// // RGB Functions ///////////////////////////////////////////////////////
Function_Descriptor rgb_descriptor = Function_Descriptor rgb_descriptor =
......
#define SASS_FUNCTIONS
#include <cstring> #include <cstring>
#include <map> #include <map>
...@@ -26,6 +28,7 @@ namespace Sass { ...@@ -26,6 +28,7 @@ namespace Sass {
Function() Function()
{ /* TO DO: set up the generic callback here */ } { /* TO DO: set up the generic callback here */ }
// for user-defined functions
Function(Node def) Function(Node def)
: name(def[0].to_string()), : name(def[0].to_string()),
parameters(def[1]), parameters(def[1]),
...@@ -42,6 +45,8 @@ namespace Sass { ...@@ -42,6 +45,8 @@ namespace Sass {
primitive(0), primitive(0),
overloaded(overloaded) overloaded(overloaded)
{ } { }
Function(const char* signature, Primitive ip, Node_Factory& new_Node);
Function(Function_Descriptor d, Primitive ip, Node_Factory& new_Node) Function(Function_Descriptor d, Primitive ip, Node_Factory& new_Node)
: name(d[0]), : name(d[0]),
......
#define SASS_NODE_FACTORY
#include <vector> #include <vector>
#ifndef SASS_NODE #ifndef SASS_NODE
......
#define SASS_INTERFACE
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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