本文整理汇总了C++中Expression::concrete_type方法的典型用法代码示例。如果您正苦于以下问题:C++ Expression::concrete_type方法的具体用法?C++ Expression::concrete_type怎么用?C++ Expression::concrete_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::concrete_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
Statement* Expand::operator()(For* f)
{
string variable(f->variable());
Expression* low = f->lower_bound()->perform(eval->with(env, backtrace));
if (low->concrete_type() != Expression::NUMBER) {
error("lower bound of `@for` directive must be numeric", low->path(), low->position(), backtrace);
}
Expression* high = f->upper_bound()->perform(eval->with(env, backtrace));
if (high->concrete_type() != Expression::NUMBER) {
error("upper bound of `@for` directive must be numeric", high->path(), high->position(), backtrace);
}
double lo = static_cast<Number*>(low)->value();
double hi = static_cast<Number*>(high)->value();
if (f->is_inclusive()) ++hi;
Env new_env;
new_env[variable] = new (ctx.mem) Number(low->path(), low->position(), lo);
new_env.link(env);
env = &new_env;
Block* body = f->block();
for (double i = lo;
i < hi;
(*env)[variable] = new (ctx.mem) Number(low->path(), low->position(), ++i)) {
append_block(body);
}
env = new_env.parent();
return 0;
}
示例2: operator
Statement* Expand::operator()(Assignment* a)
{
string var(a->variable());
if (env->has(var)) {
Expression* v = static_cast<Expression*>((*env)[var]);
if (!a->is_guarded() || v->concrete_type() == Expression::NULL_VAL) (*env)[var] = a->value()->perform(eval->with(env, backtrace));
}
else {
env->current_frame()[var] = a->value()->perform(eval->with(env, backtrace));
}
return 0;
}
示例3: operator
Expression* Listize::operator()(Complex_Selector* sel)
{
List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), 2);
Compound_Selector* head = sel->head();
if (head && !head->is_empty_reference())
{
Expression* hh = head->perform(this);
if (hh) *l << hh;
}
To_String to_string;
std::string reference = ! sel->reference() ? ""
: sel->reference()->perform(&to_string);
switch(sel->combinator())
{
case Complex_Selector::PARENT_OF:
*l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), ">");
break;
case Complex_Selector::ADJACENT_TO:
*l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "+");
break;
case Complex_Selector::REFERENCE:
*l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "/" + reference + "/");
break;
case Complex_Selector::PRECEDES:
*l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "~");
break;
case Complex_Selector::ANCESTOR_OF:
break;
}
Complex_Selector* tail = sel->tail();
if (tail)
{
Expression* tt = tail->perform(this);
if (tt && tt->concrete_type() == Expression::LIST)
{ *l += static_cast<List*>(tt); }
else if (tt) *l << static_cast<List*>(tt);
}
if (l->length() == 0) return 0;
return l;
}
示例4: debug_ast
//.........这里部分代码省略.........
} else if (dynamic_cast<Content*>(node)) {
Content* expression = dynamic_cast<Content*>(node);
std::cerr << ind << "Content " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [Statement]" << std::endl;
} else if (dynamic_cast<Boolean*>(node)) {
Boolean* expression = dynamic_cast<Boolean*>(node);
std::cerr << ind << "Boolean " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
std::cerr << " [" << expression->value() << "]" << std::endl;
} else if (dynamic_cast<Color*>(node)) {
Color* expression = dynamic_cast<Color*>(node);
std::cerr << ind << "Color " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
std::cerr << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << std::endl;
} else if (dynamic_cast<Number*>(node)) {
Number* expression = dynamic_cast<Number*>(node);
std::cerr << ind << "Number " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
std::cerr << " [" << expression->value() << expression->unit() << "]" <<
" [hash: " << expression->hash() << "] " <<
std::endl;
} else if (dynamic_cast<String_Quoted*>(node)) {
String_Quoted* expression = dynamic_cast<String_Quoted*>(node);
std::cerr << ind << "String_Quoted " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [" << prettyprint(expression->value()) << "]";
if (expression->is_delayed()) std::cerr << " [delayed]";
if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]";
if (expression->is_interpolant()) std::cerr << " [interpolant]";
if (expression->quote_mark()) std::cerr << " [quote_mark: " << expression->quote_mark() << "]";
std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
} else if (dynamic_cast<String_Constant*>(node)) {
String_Constant* expression = dynamic_cast<String_Constant*>(node);
std::cerr << ind << "String_Constant " << expression;
if (expression->concrete_type()) {
std::cerr << " " << expression->concrete_type();
}
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [" << prettyprint(expression->value()) << "]";
if (expression->is_delayed()) std::cerr << " [delayed]";
if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]";
if (expression->is_interpolant()) std::cerr << " [interpolant]";
std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
} else if (dynamic_cast<String_Schema*>(node)) {
String_Schema* expression = dynamic_cast<String_Schema*>(node);
std::cerr << ind << "String_Schema " << expression;
std::cerr << " " << expression->concrete_type();
if (expression->is_delayed()) std::cerr << " [delayed]";
if (expression->is_interpolant()) std::cerr << " [is interpolant]";
if (expression->has_interpolant()) std::cerr << " [has interpolant]";
if (expression->is_left_interpolant()) std::cerr << " [left interpolant] ";
if (expression->is_right_interpolant()) std::cerr << " [right interpolant] ";
std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<String*>(node)) {
String* expression = dynamic_cast<String*>(node);
std::cerr << ind << "String " << expression;
std::cerr << " " << expression->concrete_type();
std::cerr << " (" << pstate_source_position(node) << ")";
if (expression->sass_fix_1291()) std::cerr << " [sass_fix_1291]";
if (expression->is_interpolant()) std::cerr << " [interpolant]";
std::cerr << " <" << prettyprint(expression->pstate().token.ws_before()) << ">" << std::endl;
} else if (dynamic_cast<Expression*>(node)) {
Expression* expression = dynamic_cast<Expression*>(node);
std::cerr << ind << "Expression " << expression;
std::cerr << " (" << pstate_source_position(node) << ")";
switch (expression->concrete_type()) {
case Expression::Concrete_Type::NONE: std::cerr << " [NONE]"; break;
case Expression::Concrete_Type::BOOLEAN: std::cerr << " [BOOLEAN]"; break;
case Expression::Concrete_Type::NUMBER: std::cerr << " [NUMBER]"; break;
case Expression::Concrete_Type::COLOR: std::cerr << " [COLOR]"; break;
case Expression::Concrete_Type::STRING: std::cerr << " [STRING]"; break;
case Expression::Concrete_Type::LIST: std::cerr << " [LIST]"; break;
case Expression::Concrete_Type::MAP: std::cerr << " [MAP]"; break;
case Expression::Concrete_Type::SELECTOR: std::cerr << " [SELECTOR]"; break;
case Expression::Concrete_Type::NULL_VAL: std::cerr << " [NULL_VAL]"; break;
case Expression::Concrete_Type::C_WARNING: std::cerr << " [C_WARNING]"; break;
case Expression::Concrete_Type::C_ERROR: std::cerr << " [C_ERROR]"; break;
case Expression::Concrete_Type::NUM_TYPES: std::cerr << " [NUM_TYPES]"; break;
}
std::cerr << std::endl;
} else if (dynamic_cast<Has_Block*>(node)) {
Has_Block* has_block = dynamic_cast<Has_Block*>(node);
std::cerr << ind << "Has_Block " << has_block;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << has_block->tabs() << std::endl;
if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Statement*>(node)) {
Statement* statement = dynamic_cast<Statement*>(node);
std::cerr << ind << "Statement " << statement;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << statement->tabs() << std::endl;
}
if (ind == "") std::cerr << "####################################################################\n";
}
示例5: debug_ast
//.........这里部分代码省略.........
} else if (dynamic_cast<Function_Call_Schema*>(node)) {
Function_Call_Schema* expression = dynamic_cast<Function_Call_Schema*>(node);
cerr << ind << "Function_Call_Schema " << expression << "]" << endl;
debug_ast(expression->name(), ind + "name: ", env);
debug_ast(expression->arguments(), ind + " args: ", env);
} else if (dynamic_cast<Function_Call*>(node)) {
Function_Call* expression = dynamic_cast<Function_Call*>(node);
cerr << ind << "Function_Call " << expression << " [" << expression->name() << "]" << endl;
debug_ast(expression->arguments(), ind + " args: ", env);
} else if (dynamic_cast<Arguments*>(node)) {
Arguments* expression = dynamic_cast<Arguments*>(node);
cerr << ind << "Arguments " << expression << "]" << endl;
for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Argument*>(node)) {
Argument* expression = dynamic_cast<Argument*>(node);
cerr << ind << "Argument " << expression << " [" << expression->value() << "]" << endl;
debug_ast(expression->value(), ind + " value: ", env);
} else if (dynamic_cast<Unary_Expression*>(node)) {
Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node);
cerr << ind << "Unary_Expression " << expression << " [" << expression->type() << "]" << endl;
debug_ast(expression->operand(), ind + " operand: ", env);
} else if (dynamic_cast<Binary_Expression*>(node)) {
Binary_Expression* expression = dynamic_cast<Binary_Expression*>(node);
cerr << ind << "Binary_Expression " << expression << " [" << expression->type() << "]" << endl;
debug_ast(expression->left(), ind + " left: ", env);
debug_ast(expression->right(), ind + " right: ", env);
} else if (dynamic_cast<Map*>(node)) {
Map* expression = dynamic_cast<Map*>(node);
cerr << ind << "Map " << expression << " [Hashed]" << endl;
} else if (dynamic_cast<List*>(node)) {
List* expression = dynamic_cast<List*>(node);
cerr << ind << "List " << expression << " (" << expression->length() << ") " <<
(expression->separator() == Sass::List::Separator::COMMA ? "Comma " : "Space ") <<
" [delayed: " << expression->is_delayed() << "] " <<
" [interpolant: " << expression->is_interpolant() << "] " <<
endl;
for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Content*>(node)) {
Content* expression = dynamic_cast<Content*>(node);
cerr << ind << "Content " << expression << " [Statement]" << endl;
} else if (dynamic_cast<Boolean*>(node)) {
Boolean* expression = dynamic_cast<Boolean*>(node);
cerr << ind << "Boolean " << expression << " [" << expression->value() << "]" << endl;
} else if (dynamic_cast<Color*>(node)) {
Color* expression = dynamic_cast<Color*>(node);
cerr << ind << "Color " << expression << " [" << expression->r() << ":" << expression->g() << ":" << expression->b() << "@" << expression->a() << "]" << endl;
} else if (dynamic_cast<Number*>(node)) {
Number* expression = dynamic_cast<Number*>(node);
cerr << ind << "Number " << expression << " [" << expression->value() << expression->unit() << "]" << endl;
} else if (dynamic_cast<String_Quoted*>(node)) {
String_Quoted* expression = dynamic_cast<String_Quoted*>(node);
cerr << ind << "String_Quoted : " << expression << " [" << prettyprint(expression->value()) << "]" <<
(expression->is_delayed() ? " {delayed}" : "") <<
(expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
(expression->quote_mark() != 0 ? " {qm:" + string(1, expression->quote_mark()) + "}" : "") <<
" <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl;
} else if (dynamic_cast<String_Constant*>(node)) {
String_Constant* expression = dynamic_cast<String_Constant*>(node);
cerr << ind << "String_Constant : " << expression << " [" << prettyprint(expression->value()) << "]" <<
(expression->is_delayed() ? " {delayed}" : "") <<
(expression->sass_fix_1291() ? " {sass_fix_1291}" : "") <<
" <" << prettyprint(expression->pstate().token.ws_before()) << ">" << endl;
} else if (dynamic_cast<String_Schema*>(node)) {
String_Schema* expression = dynamic_cast<String_Schema*>(node);
cerr << ind << "String_Schema " << expression << " " << expression->concrete_type() <<
(expression->has_interpolants() ? " {has_interpolants}" : "") <<
endl;
for(auto i : expression->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<String*>(node)) {
String* expression = dynamic_cast<String*>(node);
cerr << ind << "String " << expression << expression->concrete_type() <<
" " << (expression->sass_fix_1291() ? "{sass_fix_1291}" : "") <<
endl;
} else if (dynamic_cast<Expression*>(node)) {
Expression* expression = dynamic_cast<Expression*>(node);
cerr << ind << "Expression " << expression;
switch (expression->concrete_type()) {
case Expression::Concrete_Type::NONE: cerr << " [NONE]"; break;
case Expression::Concrete_Type::BOOLEAN: cerr << " [BOOLEAN]"; break;
case Expression::Concrete_Type::NUMBER: cerr << " [NUMBER]"; break;
case Expression::Concrete_Type::COLOR: cerr << " [COLOR]"; break;
case Expression::Concrete_Type::STRING: cerr << " [STRING]"; break;
case Expression::Concrete_Type::LIST: cerr << " [LIST]"; break;
case Expression::Concrete_Type::MAP: cerr << " [MAP]"; break;
case Expression::Concrete_Type::SELECTOR: cerr << " [SELECTOR]"; break;
case Expression::Concrete_Type::NULL_VAL: cerr << " [NULL_VAL]"; break;
case Expression::Concrete_Type::NUM_TYPES: cerr << " [NUM_TYPES]"; break;
}
cerr << endl;
} else if (dynamic_cast<Has_Block*>(node)) {
Has_Block* has_block = dynamic_cast<Has_Block*>(node);
cerr << ind << "Has_Block " << has_block << " " << has_block->tabs() << endl;
if (has_block->block()) for(auto i : has_block->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Statement*>(node)) {
Statement* statement = dynamic_cast<Statement*>(node);
cerr << ind << "Statement " << statement << " " << statement->tabs() << endl;
}
if (ind == "") cerr << "####################################################################\n";
}