<commit_before>// Filename: cppExpression.cxx
// Created by:  drose (25Oct99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license.  You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// <EMAIL> .
//
////////////////////////////////////////////////////////////////////


#include "cppExpression.h"
#include "cppToken.h"
#include "cppIdentifier.h"
#include "cppType.h"
#include "cppSimpleType.h"
#include "cppPointerType.h"
#include "cppConstType.h"
#include "cppArrayType.h"
#include "cppPreprocessor.h"
#include "cppInstance.h"
#include "cppFunctionGroup.h"
#include "cppFunctionType.h"
#include "cppBison.h"

#include <assert.h>

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result() {
  _type = RT_error;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(int value) {
  _type = RT_integer;
  _u._integer = value;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(double value) {
  _type = RT_real;
  _u._real = value;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(void *value) {
  _type = RT_pointer;
  _u._pointer = value;
}


////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_integer
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
int CPPExpression::Result::
as_integer() const {
  switch (_type) {
  case RT_integer:
    return _u._integer;

  case RT_real:
    return (int)_u._real;

  case RT_pointer:
    // We don't mind if this loses precision.
    return reinterpret_cast<int>(_u._pointer);

  default:
    cerr << "Invalid type\n";
    assert(false);
    return 0;
  }
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_real
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
double CPPExpression::Result::
as_real() const {
  switch (_type) {
  case RT_integer:
    return (double)_u._integer;

  case RT_real:
    return _u._real;

  case RT_pointer:
    // We don't mind if this loses precision.
    return (double)reinterpret_cast<int>(_u._pointer);

  default:
    cerr << "Invalid type\n";
    assert(false);
    return 0.0;
  }
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_pointer
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////<commit_msg>try again to satisfy compilers<commit_after>// Filename: cppExpression.cxx
// Created by:  drose (25Oct99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license.  You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// <EMAIL> .
//
////////////////////////////////////////////////////////////////////


#include "cppExpression.h"
#include "cppToken.h"
#include "cppIdentifier.h"
#include "cppType.h"
#include "cppSimpleType.h"
#include "cppPointerType.h"
#include "cppConstType.h"
#include "cppArrayType.h"
#include "cppPreprocessor.h"
#include "cppInstance.h"
#include "cppFunctionGroup.h"
#include "cppFunctionType.h"
#include "cppBison.h"

#include <assert.h>

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result() {
  _type = RT_error;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(int value) {
  _type = RT_integer;
  _u._integer = value;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(double value) {
  _type = RT_real;
  _u._real = value;
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::Constructor
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
CPPExpression::Result::
Result(void *value) {
  _type = RT_pointer;
  _u._pointer = value;
}


////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_integer
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
int CPPExpression::Result::
as_integer() const {
  switch (_type) {
  case RT_integer:
    return _u._integer;

  case RT_real:
    return (int)_u._real;

  case RT_pointer:
    // We don't mind if this loses precision.
    return (int)reinterpret_cast<long>(_u._pointer);

  default:
    cerr << "Invalid type\n";
    assert(false);
    return 0;
  }
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_real
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
double CPPExpression::Result::
as_real() const {
  switch (_type) {
  case RT_integer:
    return (double)_u._integer;

  case RT_real:
    return _u._real;

  case RT_pointer:
    // We don't mind if this loses precision.
    return (double)reinterpret_cast<long>(_u._pointer);

  default:
    cerr << "Invalid type\n";
    assert(false);
    return 0.0;
  }
}

////////////////////////////////////////////////////////////////////
//     Function: CPPExpresion::Result::as_pointer
//       Access: Public
//  Description:
////////////////////////////////////////////////////////////////////
{'fraction_non_alphanumeric': 0.3871316572046499, 'fraction_numerical': 0.004866180048661801, 'mean_word_length': 1.171705312591723, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3295771', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1764, 'n_words': 452}