Esempio n. 1
0
static void PrintValue(CPValue_T * value)
{
   size_t i;
   if(value != NULL)
   {
      if(value->type == e_CPVT_String)
      {
         printf("%s\n", value->data.string.token->str);
      }
      else if(value->type == e_CPVT_Array)
      {
         printf("[\n");
         for(i = 0; i < value->data.array.size; i++)
         {
            PrintValue(&value->data.array.value_list[i]);
         }
         printf("]\n");
      }
      else if(value->type == e_CPVT_Object)
      {
         printf("{\n");
         for(i = 0; i < value->data.object.size; i++)
         {

            printf("%s :\n", value->data.object.pair_list[i].key_token->str);
            PrintValue(value->data.object.pair_list[i].value);
         }
         printf("}\n");
      }
   }
   else
   {
      printf("NULL\n");
   }
}
Esempio n. 2
0
void PrintDictionary(HASH_TABLE* dictionary)
{
    unsigned int i, size;
    size = dictionary->size;

    VALUE key;
    key.type = VAL_DICTIONARY;
    key.data.dictionary = dictionary;

    // check for recursion
    if (HashGet(key, duck_print_records).type != VAL_NIL) {
        printf("...");
        return;
    } else {
        VALUE value;
        value.type = VAL_PRIMITIVE;
        value.data.primitive = 1;
        HashStore(key, value, duck_print_records);
    }

    printf("[");
    for (i = 0; i < dictionary->capacity; i++)
    {
        if (dictionary->table[i].key.type != VAL_NIL)
        {
            size--;
            PrintValue(dictionary->table[i].key);
            printf(": ");
            PrintValue(dictionary->table[i].value);
            if (size) printf(", ");
        }
    }
    printf("]");
}
Esempio n. 3
0
Expr* EvalCdr(Env* env, Expr* expr, Expr* cont){
  Expr* tmp = Eval(env, expr->next, cont);
  printf("cdr");
  PrintValue(tmp);
  PrintValue(tmp->next);
  puts("");
  return tmp->next;
}
Esempio n. 4
0
Expr* EvalCar(Env* env, Expr* expr,  Expr* cont){
  Expr* tmp = Eval(env, expr->next, cont);
  Expr* tmp_list = tmp->u.list;
  printf("car");
  PrintValue(tmp);
  PrintValue(tmp_list);
  puts("");
  return tmp_list;
}
Esempio n. 5
0
void PrintValue(rapidjson::Value &value)
{
	rapidjson::Type type = value.GetType();

	if (type == rapidjson::Type::kNumberType)
	{
		printf("%d", value.GetInt());
	}
	else if (type == rapidjson::Type::kStringType)
	{
		printf("%s", value.GetString());
	}
	else if (type == rapidjson::Type::kTrueType)
	{
		printf("가능");
	}
	else if (type == rapidjson::Type::kFalseType)
	{
		printf("불가능");
	}
	else if (type == rapidjson::Type::kArrayType)
	{
		for (int i = 0; i < value.Size(); i++)
		{
			PrintValue(value[i]);
			if (i < value.Size() - 1)
				printf(", ");
		}
		printf("\n");
	}
	else if (type == rapidjson::Type::kObjectType)
	{
		for (auto iter = value.MemberBegin(); iter != value.MemberEnd(); iter++)
		{
			rapidjson::Value &member = iter->value;
			std::string name = iter->name.GetString();

			if (member.GetType() == rapidjson::Type::kObjectType || member.GetType() == rapidjson::Type::kArrayType)
			{
				printf("\n- %s -\n", name.c_str());
				PrintValue(member);
			}
			else
			{
				printf("%s : ", name.c_str());
				PrintValue(member);
				printf("\n");
			}
		}
	}
	else
	{
		printf("Null");
	}
}
Esempio n. 6
0
static void DumpSysVar(char const *name, const SysVar *v)
{
    char buffer[VAR_NAME_LEN+10];

    if (name && !*name) name=NULL;
    if (!v && !name) return;  /* Shouldn't happen... */

    buffer[0]='$'; buffer[1] = 0;
    if (name) strcat(buffer, name); else strcat(buffer, v->name);
    fprintf(ErrFp, "%*s  ", VAR_NAME_LEN+1, buffer);
    if (v) {
	if (v->type == SPECIAL_TYPE) {
	    Value val;
	    SysVarFunc f = (SysVarFunc) v->value;
	    f(0, &val);
	    PrintValue(&val, ErrFp);
	    Putc('\n', ErrFp);
	    DestroyValue(val);
	} else if (v->type == STR_TYPE) {
	    char const *s = *((char **)v->value);
	    int y;
	    Putc('"', ErrFp);
	    for (y=0; y<MAX_PRT_LEN && *s; y++) {
		if (*s == '"') {
		    fprintf(ErrFp, "\" + char(34) + \"");
		    s++;
		} else {
		    Putc(*s++, ErrFp);
		}
	    }
	    Putc('"', ErrFp);
	    if (*s) fprintf(ErrFp, "...");
	    Putc('\n', ErrFp);
	} else if (v->type == DATE_TYPE) {
	    Value val;
	    val.type = DATE_TYPE;
	    val.v.val = * (int *) v->value;
	    PrintValue(&val, ErrFp);
	    Putc('\n', ErrFp);
	} else {
	    if (!v->modifiable) fprintf(ErrFp, "%d\n", *((int *)v->value));
	    else {
		fprintf(ErrFp, "%-10d  ", *((int *)v->value));
		if (v->min == ANY) fprintf(ErrFp, "(-Inf, ");
		else                         fprintf(ErrFp, "[%d, ", v->min);
		if (v->max == ANY) fprintf(ErrFp, "Inf)\n");
		else                         fprintf(ErrFp, "%d]\n", v->max);
	    }
	}
    } else   fprintf(ErrFp, "%s\n", UNDEF);

    return;
}
Esempio n. 7
0
void ExtractChildren(StatementList* list, int level)
{
    if (list == NULL) return;
    for (int32 i = 0; i < list->Size(); i ++) {
        Statement* statement = list->StatementAt(i);
        if (!ExtractGroup(statement, level)) {
            if (statement->GetType() == Statement::kValue) {
                PrintValue(NULL, statement->GetOption(), level);
            } else if (statement->GetType() == Statement::kDefault) {
                PrintValue("Default", statement->GetValue(), level);
            }
        }
    }
}
Esempio n. 8
0
int main ( void )
{
    int i =0 ;

    PrintValue ( i ) ;
    PrintValue ( 1 ) ;
    Forward ( 2 ) ;

/*
 * p68 the last line.
 */

    return 0 ;
}
Esempio n. 9
0
void PrintObject(CLOSURE* context)
{
    VALUE key;

    key.type = VAL_REFERENCE;
    key.data.reference = context;

    // check for recursion
    if (HashGet(key, duck_print_records).type != VAL_NIL) {
        printf("...");
        return;
    } else {
        VALUE value;
        value.type = VAL_PRIMITIVE;
        value.data.primitive = 1;
        HashStore(key, value, duck_print_records);
    }

    printf("[");
    PAIR* list = context->list;
    while (list)
    {
        PrintValue(list->value);

        if (list->next)
            printf(", ");
        list = list->next;
    }
    printf("]");
}
Esempio n. 10
0
/**
 * @brief Returns the Json representation of a Json Object.
 */
std::string JsonProcessor::PrintObject (const JsonValueObject* value, const int indent_level)
{
    int il = indent_level + 1;
    std::string in (il * indent, ' ');
    std::stringstream ss;
    ss << "{";

    bool first = true;
    for (JsonValueObject::const_iterator it = value->cbegin(); it != value->cend(); ++it) {
        JsonValueObject::ObjectPair v = *it;
        if (!first) {
            ss << ",";
        }
        ss << "\n" << in << "\"" << v.first << "\": ";
        if (v.second->IsArray()) {
            ss << PrintArray(JsonValueToArray(v.second), il);
        } else if (v.second->IsObject()) {
            ss << PrintObject(JsonValueToObject(v.second), il);
        } else {
            ss << PrintValue(v.second);
        }
        first = false;
    }

    ss << "\n" << std::string(indent_level * indent, ' ') << "}";
    return ss.str();
}
Esempio n. 11
0
//-----------------------------------------------------------------------------
// Serializes the JSON object to a String
String JSON::Stringify(bool fmt)
{
    char* text = PrintValue(0, fmt);
    String copy(text);
    OVR_FREE(text);
    return copy;
}
Esempio n. 12
0
void Data::ShowData()
{
	printf("------------------------------");
	PrintValue(document);

	Input();
}
Esempio n. 13
0
static SEXP Rserve_eval_do(void *arg) {
    rs_eval_t *e = (rs_eval_t*) arg;
    SEXP what = e->what, rho = e->rho, x;
    int i, n;

    if (TYPEOF(what) == EXPRSXP) {
        n = LENGTH(what);
        for (i = 0; i < n; i++) {
            e->exp = i;
            x = eval(VECTOR_ELT(what, i), rho);
            if (i == n - 1) {
                R_PreserveObject(x);
                e->last = x;
            }
            if (R_Visible)
                PrintValue(x);
        }
    } else {
        e->exp = -1;
        x = eval(what, rho);
        R_PreserveObject(x);
        /* intentionally we don't print if it is not an expression vector */
        e->last = x;
    }
    return R_NilValue;
}
Esempio n. 14
0
// рекурсивная ф-я
void EnumRegistry(PWCHAR RootKey/* должно быть выделено MAX_REGPATH_LEN WCHARов*/, ULONG Depth)
{
// не будем перегружать стек
	PWCHAR KeyName = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*MAX_KEYVALUENAME_LEN);
	if (!KeyName)
		return;
	PWCHAR ValueName = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*MAX_KEYVALUENAME_LEN);
	if (!ValueName)
	{
		HeapFree(GetProcessHeap(), 0, KeyName);
		return;
	}

// енумерим валушки, начиная с дефолтовой
	PrintTabs(Depth);
	printf("Values:\n");

// дефолтовая не установлена
	if (!PrintValue(RootKey, L"", Depth))
	{
		PrintTabs(Depth);
		printf("(Default):\tvalue not set\n");
	}
	for (ULONG ValueIndex = 0; EnumValues(RootKey, ValueIndex, ValueName); ValueIndex++)
	{
// пропускаем установленное дефолтовое значение
		if (ValueName[0])
			PrintValue(RootKey, ValueName, Depth);
	}

	ULONG OldLen = lstrlenW(RootKey);
	for (ULONG KeyIndex = 0; EnumKeys(RootKey, KeyIndex, KeyName); KeyIndex++)
	{
		lstrcatW(RootKey, L"\\");
		lstrcatW(RootKey, KeyName);

		PrintTabs(Depth);
		printf("%S\n", KeyName);

		EnumRegistry(RootKey, Depth+1);

		RootKey[OldLen] = 0;
	}

	HeapFree(GetProcessHeap(), 0 ,ValueName);
	HeapFree(GetProcessHeap(), 0, KeyName);
}
void AMXStackFramePrinter::PrintArgumentValue(const AMXStackFrame &frame,
                                              const AMXDebugSymbol &arg,
                                              int index) {
  std::string tag_name = debug_info_.GetTagName(arg.GetTag());
  cell value = GetArgumentValue(frame, index);

  if (arg.IsVariable()) {
    PrintValue(tag_name, value);
    return;
  }

  stream_ << "@";
  PrintAddress(value);

  if (arg.IsReference()) {
    if (cell *ptr = GetDataPtr(frame.amx(), value)) {
      stream_ << " ";
      PrintValue(tag_name, *ptr);
    }
    return;
  }

  if (arg.IsArray() || arg.IsArrayRef()) {
    std::vector<AMXDebugSymbolDim> dims = arg.GetDims();

    // Try to filter out non-printable arrays (e.g. non-strings).
    // This doesn't work 100% of the time, but it's better than nothing.
    if (dims.size() == 1
        && tag_name == "_"
        && debug_info_.GetTagName(dims[0].GetTag()) == "_")
    {
      std::string string;
      bool packed;

      GetStringContents(frame.amx(), value, dims[0].GetSize(), string, packed);
      stream_ << (packed ? " !" : " ");

      static const std::size_t kMaxString = 80;
      if (string.length() > kMaxString) {
        string.replace(kMaxString, string.length() - kMaxString, "...");
      }

      stream_ << "\"" << string << "\"";
    }
  }
}
Esempio n. 16
0
void JsonPrinter::PrintTable(Json::Value &value, Sqrat::Table table) {
	Sqrat::Table::iterator it;
	while(table.Next(it)) {
		Sqrat::Object o(it.getKey(), table.GetVM());
		std::string key = o.Cast<std::string>();
		Sqrat::Object obj(it.getValue(), table.GetVM());
		value[key] = PrintValue(obj);
	}
}
Esempio n. 17
0
int parse_eval(membuf_t *pmb, char *line, int lineno){
    membuf_t mb = *pmb;
    ParseStatus status;
    SEXP cmdSexp, cmdexpr, ans = R_NilValue;
    int i, errorOccurred;

    mb = *pmb = add_to_membuf(pmb,line);

    PROTECT(cmdSexp = allocVector(STRSXP, 1));
    SET_STRING_ELT(cmdSexp, 0, mkChar((char*)mb->buf));

    /* R_ParseVector gets a new argument in R 2.5.x */
    cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue));

    switch (status){
    case PARSE_OK:
        /* Loop is needed here as EXPSEXP might be of length > 1 */
        for(i = 0; i < length(cmdexpr); i++){
            ans = R_tryEval(VECTOR_ELT(cmdexpr, i),NULL, &errorOccurred);
            if (errorOccurred) { 
                UNPROTECT(2);
                return 1;
            }
            if (verbose) {
                PrintValue(ans);
            }
        }
        mb = *pmb = rewind_membuf(pmb);
        break;
    case PARSE_INCOMPLETE:
        fprintf(stderr, "%s: Incomplete Line! Need more code! (%d)\n", programName, status);
        UNPROTECT(2);
        return 1;
        break;
    case PARSE_NULL:
        fprintf(stderr, "%s: ParseStatus is null (%d)\n", programName, status);
        UNPROTECT(2);
        return 1;
        break;
    case PARSE_ERROR:
        fprintf(stderr,"Parse Error line %d: \"%s\"\n", lineno, line);
        UNPROTECT(2);
        return 1;
        break;
    case PARSE_EOF:
        fprintf(stderr, "%s: EOF reached (%d)\n", programName, status);
        break;
    default:
        fprintf(stderr, "%s: ParseStatus is not documented %d\n", programName, status);
        UNPROTECT(2);
        return 1;
        break;
    }
    UNPROTECT(2);
    return 0;
}
Esempio n. 18
0
/**
 * Prints the list of ccps.
 */
void  Chain::printConsecutiveCancelingPairs() const
{
	// rr debug code for ccps
//		Rprintf("\nStart\n ");
	for (unsigned i = 0; i < this->lccpMiniSteps.size(); i++)
	{
		PrintValue(getMiniStepDF(*this->lccpMiniSteps[i]));
	}
//		Rprintf("\nend\n ");
}
Esempio n. 19
0
 // Simple function for formatted output of a V8 value.
 void PrintValue(CefRefPtr<CefV8Value> value, std::stringstream &stream,
                 int indent)
 {
   std::stringstream indent_stream;
   for(int i = 0; i < indent; ++i)
     indent_stream << "  ";
   std::string indent_str = indent_stream.str();
   
   if(value->IsUndefined())
     stream << "(undefined)";
   else if(value->IsNull())
     stream << "(null)";
   else if(value->IsBool())
     stream << "(bool) " << (value->GetBoolValue() ? "true" : "false");
   else if(value->IsInt())
     stream << "(int) " << value->GetIntValue();
   else if(value->IsDouble())
     stream << "(double) " << value->GetDoubleValue();
   else if(value->IsString())
     stream << "(string) " << std::string(value->GetStringValue());
   else if(value->IsFunction())
     stream << "(function) " << std::string(value->GetFunctionName());
   else if(value->IsArray()) {
     stream << "(array) [";
     int len = value->GetArrayLength();
     for(int i = 0; i < len; ++i) {
       stream << "\n  " << indent_str.c_str() << i << " = ";
       PrintValue(value->GetValue(i), stream, indent+1);
     }
     stream << "\n" << indent_str.c_str() << "]";
   } else if(value->IsObject()) {
     stream << "(object) [";
     std::vector<CefString> keys;
     if(value->GetKeys(keys)) {
       for(size_t i = 0; i < keys.size(); ++i) {
         stream << "\n  " << indent_str.c_str() << keys[i].c_str() << " = ";
         PrintValue(value->GetValue(keys[i]), stream, indent+1);
       }
     }
     stream << "\n" << indent_str.c_str() << "]";
   }
 }
Esempio n. 20
0
void Printer::PrintArray(std::string *result, Sqrat::Array array) {
	result->append("[");
	for (int i = 0; i < array.GetSize(); i++) {
		if (i > 0) {
			result->append(",");
		}
		Sqrat::Object obj = array.GetSlot(SQInteger(i));
		PrintValue(result, obj);
	}
	result->append("]");
}
Esempio n. 21
0
int main()
{
	double x = 3.0;
	double* y;

	y = &x;

	PrintValue(y);
	
	return 0;
}
Esempio n. 22
0
TEST(StdDuck, print_value_function)
{
    CreateEnvironment();
    testing::internal::CaptureStdout();

    VALUE func = CreateFunction(TestStdDuck::DummyFunc);
    AddParameter(func, "arg0");

    PrintValue(func);
    ASSERT_STREQ("function(arg0)", testing::internal::GetCapturedStdout().c_str());

    FreeEnvironment();
}
Esempio n. 23
0
TEST(StdDuck, print_value_string)
{
    CreateEnvironment();
    testing::internal::CaptureStdout();

    VALUE val;
    val.type = VAL_STRING;
    val.data.string = "1";

    PrintValue(val);
    ASSERT_STREQ("1", testing::internal::GetCapturedStdout().c_str());

    FreeEnvironment();
}
Esempio n. 24
0
void main()
{
	int i = 10;
	printf("%d\n", i);

	int *ptr_i = &i;
	printf("%d\n", ptr_i);
	printf("%d\n", &i);
	printf("%d\n", *ptr_i);
//	PrintValue(&i);

	int j[2];
	PrintValue(&j[0]);

}
Esempio n. 25
0
Expr* EvalAppend(Env* env, Expr* expr, Expr* cont){
  puts("DEBUG");
  Expr* arg1 = Eval(env, expr->next, cont);
  Expr* arg2 = Eval(env, expr->next->next, cont);
  puts("arg1 in append");
  PrintValue(arg1);
  puts("\narg2 in append");
  PrintValue(arg2);
  puts("");
  if(arg1->type == Null_Exp && arg2->type == Null_Exp){
    return nil();
  }else if(arg1->type == Null_Exp){
    return arg2;
  }else if(arg2->type == Null_Exp){
    return arg1;
  }else if(arg1->type == Pair_Exp && arg2->type == Pair_Exp){
    printf("list append \n");
    Expr* tail_expr = ListLastBefore(arg1);
    tail_expr->next = arg2;
    return arg1;
  }else{
    fputs("list required", stderr);
  }
}
Esempio n. 26
0
static void printwhere(void)
{
  RCNTXT *cptr;
  int lct = 1;

  for (cptr = R_GlobalContext; cptr; cptr = cptr->nextcontext) {
    if ((cptr->callflag & (CTXT_FUNCTION | CTXT_BUILTIN)) &&
	(TYPEOF(cptr->call) == LANGSXP)) {
	Rprintf("where %d", lct++);
	SrcrefPrompt("", cptr->srcref);
	PrintValue(cptr->call);
    }
  }
  Rprintf("\n");
}
Esempio n. 27
0
/*
	hash table
	------------
	implement a hash table which the key is the name of the virus
	the value is the signature.

	inorder on search over the files we could use Boyer–Moore string search algorithm

	Version Alpha: 
		Anti-Virus  - Viruses and signatures save into a file
		then it loads up into a struct

	Version Beta:
		more complicated program that use hash table for searching and storing the database

	Iterate over the database stream to save them into structure.
	for example:
		"virusA" - "signature"\nVirusB" - "signature"\n\r\eof
	it will parse as:
		database info[1];

		info[0]:
			name = "virusA"
			signature = "signature"
			hash = 1
		info[1]:
			name = "virusB"
			signature = "signature"
			hash = 0

*/
void ParseDatabase(char *data)	{
	//char *token = "\"\n";
	char *token = """=\n""";
	char *ptr = strtok(data, token);
	int i = 0;
	Database *database = NULL;

	while(ptr != NULL)	{
		if(i%2 == 0)
			PrintKey(ptr, database);
		else
			PrintValue(ptr, database);
		ptr = strtok(NULL, token);
		i++;
	}
}
Esempio n. 28
0
void Fibonacci::Calculate() {
    m_mutex.lock();
    if (m_count) {
        u_int64_t tempValue;
        tempValue = m_prevValue + m_currentValue;
        m_prevValue = m_currentValue;
        m_currentValue = tempValue;
        m_mutex.unlock();
        PrintValue();
        std::chrono::milliseconds duration(250);
        std::this_thread::sleep_for(duration);
        Calculate();
    } else {
        m_mutex.unlock();
    }
}
Esempio n. 29
0
/* duck.print(output) */
int DuckPrint(int argument_count, void* data)
{
    int error = 0;
    VALUE argument = GetRecord("output", gCurrentContext);
    
    duck_print_records = CreateHashTable();

    PrintValue(argument);

    FreeHashTable(duck_print_records);
    duck_print_records = NULL;

    gLastExpression.type = VAL_NIL;
    gLastExpression.data.primitive = 0;

    return error;
}
Esempio n. 30
0
void DumpVarTable(void)
{
    register Var *v;
    register int i;

    fprintf(ErrFp, "%*s  %s\n\n", VAR_NAME_LEN, VARIABLE, VALUE);

    for (i=0; i<VAR_HASH_SIZE; i++) {
	v = VHashTbl[i];
	while(v) {
	    fprintf(ErrFp, "%*s  ", VAR_NAME_LEN, v->name);
	    PrintValue(&(v->v), ErrFp);
	    fprintf(ErrFp, "\n");
	    v = v->next;
	}
    }
}