getValue: Get the literal value associated with a GCC node

Description Usage Arguments Value Author(s) Examples

Description

This function and its methods allow us to query the value associated with a particular node in the translation unit. Often these are literals or constants.

Usage

1
getValue(node, defaultValue = NA, symbolic = FALSE)

Arguments

node

the translation unit node

defaultValue

if no value is available, return this value

symbolic

never used. The idea was (I think) to allow the value be returned symbolically as an expression if it were more than a literal, e.g. x + 1 or PI + 1

Value

An object!

Author(s)

Duncan Temple Lang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 tu = parseTU(system.file("examples", "value.cc.001t.tu", package = "RGCCTranslationUnit"))
 getValue(tu[[23]]) # 3.1415
 getValue(tu[[20]]) # pi - an identifier_node

 getValue(tu[[22]]) # y - variable declaration

 getValue(tu[[27]]) # -1

 getValue(tu[[3]]) # C routine name. foo

 getValue(tu[[39]]) # 'foo'
 getValue(tu[[67]]) # 'foo bar chicken    '

omegahat/RGCCTranslationUnit documentation built on May 24, 2019, 1:53 p.m.