@@ -1853,18 +1853,17 @@ class TranslatedAssignOperation extends TranslatedAssignment {
18531853// }
18541854//}
18551855
1856- ///**
1857- // * The IR translation of a call to `operator new` as part of a `new` or `new[]`
1858- // * expression.
1859- // */
1856+ /**
1857+ * The IR translation of a call to `operator new` as part of a `new` expression.
1858+ */
18601859//class TranslatedAllocatorCall extends TTranslatedAllocatorCall,
1861- // TranslatedDirectCall {
1862- // override NewOrNewArrayExpr expr;
1860+ // TranslatedExpr {
1861+ // override ObjectCreation expr;
18631862//
18641863// TranslatedAllocatorCall() {
18651864// this = TTranslatedAllocatorCall(expr)
18661865// }
1867- //
1866+ //
18681867// override final string toString() {
18691868// result = "Allocator call for " + expr.toString()
18701869// }
@@ -1873,42 +1872,98 @@ class TranslatedAssignOperation extends TranslatedAssignment {
18731872// none()
18741873// }
18751874//
1876- // override Function getInstructionFunction(InstructionTag tag) {
1877- // tag = CallTargetTag() and result = expr.getAllocator()
1875+ // override final TranslatedElement getChild(int id) {
1876+ // none()
1877+ // }
1878+ //
1879+ // // TODO: Will probably need a side effect instruction
1880+ // override predicate hasInstruction(Opcode opcode, InstructionTag tag,
1881+ // Type resultType, boolean isLValue) {
1882+ // tag = NewObjTag() and
1883+ // opcode instanceof Opcode::NewObj and
1884+ // resultType = expr.getType() and
1885+ // isLValue = false
1886+ // }
1887+ //
1888+ // override final Instruction getFirstInstruction() {
1889+ // result = getInstruction(NewObjTag())
1890+ // }
1891+ //
1892+ // override final Instruction getChildSuccessor(TranslatedElement element) {
1893+ // none()
1894+ // }
1895+ //
1896+ // override final Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
1897+ // tag = NewObjTag() and
1898+ // kind instanceof GotoEdge and
1899+ // result = getParent().getChildSuccessor(this)
1900+ // }
1901+ //
1902+ // override final Instruction getResult() {
1903+ // none()
1904+ // }
1905+ //}
1906+
1907+ //TranslatedAllocatorCall getTranslatedAllocatorCall(ObjectCreation newExpr) {
1908+ // result.getAST() = newExpr
1909+ //}
1910+
1911+ //class TranslatedObjectCreation extends TranslatedNonConstantExpr,
1912+ // InitializationContext {
1913+ // override ObjectCreation expr;
1914+ //
1915+ // override final TranslatedElement getChild(int id) {
1916+ // id = 0 and result = getInitialization()
18781917// }
18791918//
1880- // override final Type getCallResultType() {
1881- // result = expr.getAllocator().getUnspecifiedType()
1919+ // override final predicate hasInstruction(Opcode opcode, InstructionTag tag,
1920+ // Type resultType, boolean isLValue) {
1921+ // tag = NewObjTag() and
1922+ // opcode instanceof Opcode::NewObj and
1923+ // resultType = expr.getType() and
1924+ // isLValue = false
18821925// }
18831926//
1884- // override final TranslatedExpr getQualifier () {
1885- // none( )
1927+ // override final Instruction getFirstInstruction () {
1928+ // result = getInstruction(NewObjTag() )
18861929// }
18871930//
1888- // override final predicate hasArguments() {
1889- // // All allocator calls have at least one argument.
1890- // any()
1931+ // override final Instruction getResult() {
1932+ // result = getInstruction(NewObjTag())
18911933// }
18921934//
1893- // override final TranslatedExpr getArgument(int index) {
1894- // // If the allocator is the default operator new(void*), there will be no
1895- // // allocator call in the AST. Otherwise, there will be an allocator call
1896- // // that includes all arguments to the allocator, including the size,
1897- // // alignment (if any), and placement args. However, the size argument is
1898- // // an error node, so we need to provide the correct size argument in any
1899- // // case.
1900- // if index = 0 then
1901- // result = getTranslatedAllocationSize(expr)
1902- // else if(index = 1 and expr.hasAlignedAllocation()) then
1903- // result = getTranslatedExpr(expr.getAlignmentArgument())
1935+ // override final Instruction getInstructionSuccessor(InstructionTag tag,
1936+ // EdgeKind kind) {
1937+ // kind instanceof GotoEdge and
1938+ // tag = NewObjTag() and
1939+ // if exists(getInitialization()) then
1940+ // result = getInitialization().getFirstInstruction()
19041941// else
1905- // result = getTranslatedExpr(expr.getAllocatorCall().getArgument(index))
1942+ // result = getParent().getChildSuccessor(this)
1943+ // }
1944+ //
1945+ // override final Instruction getChildSuccessor(TranslatedElement child) {
1946+ // child = getInitialization() and result = getParent().getChildSuccessor(this)
1947+ // }
1948+ //
1949+ // override final Instruction getInstructionOperand(InstructionTag tag,
1950+ // OperandTag operandTag) {
1951+ // none()
1952+ // }
1953+ //
1954+ // override final Instruction getTargetAddress() {
1955+ // result = getInstruction(NewObjTag())
1956+ // }
1957+ //
1958+ // override final Type getTargetType() {
1959+ // result = expr.getType()
1960+ // }
1961+ //
1962+ // final TranslatedInitialization getInitialization() {
1963+ // result = getTranslatedInitialization(expr)
19061964// }
19071965//}
19081966
1909- //TranslatedAllocatorCall getTranslatedAllocatorCall(NewOrNewArrayExpr newExpr) {
1910- // result.getAST() = newExpr
1911- //}
19121967/**
19131968 * Abstract class implemented by any `TranslatedElement` that has a child
19141969 * expression that is a call to a constructor or destructor, in order to
@@ -2454,21 +2509,22 @@ class TranslatedThrowValueExpr extends TranslatedThrowExpr,
24542509///**
24552510// * The IR translation of a `new` or `new[]` expression.
24562511// */
2457- //abstract class TranslatedNewOrNewArrayExpr extends TranslatedNonConstantExpr,
2512+ //abstract class TranslatedNewExpr extends TranslatedNonConstantExpr,
24582513// InitializationContext {
2459- // override NewOrNewArrayExpr expr;
2514+ // override ObjectCreation expr;
24602515//
24612516// override final TranslatedElement getChild(int id) {
24622517// id = 0 and result = getAllocatorCall() or
24632518// id = 1 and result = getInitialization()
24642519// }
24652520//
2521+ // final TranslatedInitialization getInitialization() {
2522+ // result = getTranslatedInitialization(expr.getInitializer())
2523+ // }
2524+ //
24662525// override final predicate hasInstruction(Opcode opcode, InstructionTag tag,
2467- // Type resultType, boolean ) {
2468- // tag = OnlyInstructionTag() and
2469- // opcode instanceof Opcode::Convert and
2470- // resultType = getResultType() and
2471- // = false
2526+ // Type resultType, boolean isLValue) {
2527+ // none()
24722528// }
24732529//
24742530// override final Instruction getFirstInstruction() {
@@ -2489,6 +2545,10 @@ class TranslatedThrowValueExpr extends TranslatedThrowExpr,
24892545// result = getParent().getChildSuccessor(this)
24902546// }
24912547//
2548+ // override final Type getTargetType() {
2549+ // result = expr.getType()
2550+ // }
2551+ //
24922552// override final Instruction getChildSuccessor(TranslatedElement child) {
24932553// child = getAllocatorCall() and result = getInstruction(OnlyInstructionTag()) or
24942554// child = getInitialization() and result = getParent().getChildSuccessor(this)
@@ -2508,41 +2568,9 @@ class TranslatedThrowValueExpr extends TranslatedThrowExpr,
25082568// private TranslatedAllocatorCall getAllocatorCall() {
25092569// result = getTranslatedAllocatorCall(expr)
25102570// }
2511- //
2512- // abstract TranslatedInitialization getInitialization();
2513- //}
2514- //
2515- ///**
2516- // * The IR translation of a `new` expression.
2517- // */
2518- //class TranslatedNewExpr extends TranslatedNewOrNewArrayExpr {
2519- // override NewExpr expr;
2520- //
2521- // override final Type getTargetType() {
2522- // result = expr.getAllocatedType().getUnspecifiedType()
2523- // }
2524- //
2525- // override final TranslatedInitialization getInitialization() {
2526- // result = getTranslatedInitialization(expr.getInitializer())
2527- // }
2528- //}
2529- //
2530- ///**
2531- // * The IR translation of a `new[]` expression.
2532- // */
2533- //class TranslatedNewArrayExpr extends TranslatedNewOrNewArrayExpr {
2534- // override NewArrayExpr expr;
2535- //
2536- // override final Type getTargetType() {
2537- // result = expr.getAllocatedType().getUnspecifiedType()
2538- // }
2539- //
2540- // override final TranslatedInitialization getInitialization() {
2541- // // REVIEW: Figure out how we want to model array initialization in the IR.
2542- // none()
2543- // }
25442571//}
25452572
2573+
25462574/**
25472575 * The IR translation of a `ConditionDeclExpr`, which represents the value of the declared variable
25482576 * after conversion to `bool` in code such as:
0 commit comments