xtc.type
Class CFactory

java.lang.Object
  extended by xtc.type.CFactory

public class CFactory
extends java.lang.Object

A factory for programmatically and concisely creating C types.

Version:
$Revision: 1.3 $
Author:
Robert Grimm

Constructor Summary
CFactory(java.lang.String prefix, SymbolTable.Scope scope)
          Create a new C factory.
 
Method Summary
 Type builtin(Type type)
          Mark the specified type as builtin.
 Type c()
          Get the canonical char type.
 Type cc()
          Get a constant char type.
 Type constant(Type type)
          Mark the specified type as constant.
 Type cv()
          Get a constant void type.
 CFactory decl(boolean nofix, java.lang.String name, Type type)
          Add the specified declaration to this factory's symbol table scope.
 void declareBuiltIns(boolean nofix)
          Declare built-in functions for C in this factory's symbol table scope.
 Type f()
          Create a new function type with no parameters and a void return type.
 Type f(Type result)
          Create a new function type with no parameters.
 Type f(Type result, Type param)
          Create a new function type.
 Type f(Type result, Type param1, Type param2)
          Create a new function type.
 Type f(Type result, Type param1, Type param2, Type param3)
          Create a new function type.
 Type f(Type result, Type param1, Type param2, Type param3, Type param4)
          Create a new function type.
 Type i()
          Get the canonical int type.
 PointerT p(Type type)
          Create a new pointer type.
 Type p2c()
          Get a pointer to char.
 Type p2cc()
          Get a pointer to constant char.
 Type p2cv()
          Get a pointer to a constant void.
 Type p2v()
          Get a pointer to void.
 Type pr(Type type)
          Create a new restricted pointer type.
 Type size()
          Get the canonical sizeof type.
 Type v()
          Get the canonical void type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CFactory

public CFactory(java.lang.String prefix,
                SymbolTable.Scope scope)
Create a new C factory.

Parameters:
prefix - The prefix for declarations.
scope - The symbol table scope.
Method Detail

v

public Type v()
Get the canonical void type.

Returns:
VoidT.TYPE.

cv

public Type cv()
Get a constant void type.

Returns:
A sealed constant void type.

c

public Type c()
Get the canonical char type.

Returns:
NumberT.CHAR.

cc

public Type cc()
Get a constant char type.

Returns:
A sealed constant char type.

i

public Type i()
Get the canonical int type.

Returns:
NumberT.INT.

size

public Type size()
Get the canonical sizeof type.

Returns:
NumberT.SIZEOF.

p

public PointerT p(Type type)
Create a new pointer type.

Parameters:
type - The pointed-to type.
Returns:
The new pointer type.

pr

public Type pr(Type type)
Create a new restricted pointer type.

Parameters:
type - The pointed-to type.
Returns:
The new restricted pointer type.

p2v

public Type p2v()
Get a pointer to void.

Returns:
A sealed pointer to void.

p2cv

public Type p2cv()
Get a pointer to a constant void.

Returns:
A sealed pointer to constant void.

p2c

public Type p2c()
Get a pointer to char.

Returns:
A sealed pointer to char.

p2cc

public Type p2cc()
Get a pointer to constant char.

Returns:
A sealed pionter to constant char.

f

public Type f()
Create a new function type with no parameters and a void return type.

Returns:
The new function type.

f

public Type f(Type result)
Create a new function type with no parameters.

Parameters:
result - The result type.
Returns:
The new function type.

f

public Type f(Type result,
              Type param)
Create a new function type.

Parameters:
result - The result type.
param - The parameter type.
Returns:
The new function type.

f

public Type f(Type result,
              Type param1,
              Type param2)
Create a new function type.

Parameters:
result - The result type.
param1 - The first parameter type.
param2 - The second parameter type.
Returns:
The new function type.

f

public Type f(Type result,
              Type param1,
              Type param2,
              Type param3)
Create a new function type.

Parameters:
result - The result type.
param1 - The first parameter type.
param2 - The second parameter type.
param3 - The third parameter type.
Returns:
The new function type.

f

public Type f(Type result,
              Type param1,
              Type param2,
              Type param3,
              Type param4)
Create a new function type.

Parameters:
result - The result type.
param1 - The first parameter type.
param2 - The second parameter type.
param3 - The third parameter type.
param4 - The fourth parameter type.
Returns:
The new function type.

constant

public Type constant(Type type)
Mark the specified type as constant. Note that this method directly modifies the specified type.

Parameters:
type - The type.
Returns:
The constant type.

builtin

public Type builtin(Type type)
Mark the specified type as builtin. Note that this method directly modifies the specified type.

Parameters:
type - The type.
Returns:
The builtin type.

decl

public CFactory decl(boolean nofix,
                     java.lang.String name,
                     Type type)
Add the specified declaration to this factory's symbol table scope. The specified name is prefixed with this factory's prefix. The specified type is marked as a built-in type. If the nofix flag is set, this method also adds a declaration without this factory's prefix.

Parameters:
nofix - The nofix flag.
name - The name.
type - The type.
Returns:
This factory.

declareBuiltIns

public void declareBuiltIns(boolean nofix)
Declare built-in functions for C in this factory's symbol table scope.

Parameters:
nofix - The flag for whether to also declare symbols without this factory's prefix.


Copyright © 2012. All Rights Reserved.